aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts/presence
diff options
context:
space:
mode:
authorRoyalBlue1 <malte.hoermeyer@web.de>2022-07-15 00:41:36 +0200
committerRoyalBlue1 <malte.hoermeyer@web.de>2022-07-15 00:41:36 +0200
commit1d9b24faf5280db4b57eea42904f24ff4fdd16ba (patch)
tree558c8c8aa6b3d044f5fd9e17284177f96ba354f3 /Northstar.Client/mod/scripts/vscripts/presence
parent88d765b41f4ff94c59fa535d53e708274fa22d26 (diff)
parent85eb27362bd295a9e1560982a3369a688e13ded0 (diff)
downloadNorthstarMods-1d9b24faf5280db4b57eea42904f24ff4fdd16ba.tar.gz
NorthstarMods-1d9b24faf5280db4b57eea42904f24ff4fdd16ba.zip
Merge remote-tracking branch 'upsteam/main' into gamemode_fd
Diffstat (limited to 'Northstar.Client/mod/scripts/vscripts/presence')
-rw-r--r--Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut60
-rw-r--r--Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut38
2 files changed, 98 insertions, 0 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut b/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut
new file mode 100644
index 00000000..755396e3
--- /dev/null
+++ b/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut
@@ -0,0 +1,60 @@
+untyped
+globalize_all_functions
+
+struct {
+ int highestScore = 0
+ int secondHighestScore = 0
+} file
+
+void function OnPrematchStart()
+{
+ if ( GetServerVar( "roundBased" ) )
+ NSUpdateTimeInfo( level.nv.roundEndTime - Time() )
+ else
+ NSUpdateTimeInfo( level.nv.gameEndTime - Time() )
+}
+
+void function NSUpdateGameStateClientStart()
+{
+ #if MP
+ AddCallback_GameStateEnter( eGameState.Prematch, OnPrematchStart )
+ #endif
+
+ thread NSUpdateGameStateLoopClient()
+ OnPrematchStart()
+}
+
+void function NSUpdateGameStateLoopClient()
+{
+ while ( true )
+ {
+ if ( IsSingleplayer() )
+ {
+ NSUpdateGameStateClient( GetPlayerArray().len(), GetCurrentPlaylistVarInt( "max_players", 65535 ), 1, 1, 1, GetServerVar( "roundBased" ), 1 )
+ wait 1.0
+ }
+ else
+ {
+ foreach ( player in GetPlayerArray() )
+ {
+ if ( GameRules_GetTeamScore( player.GetTeam() ) >= file.highestScore )
+ {
+ file.highestScore = GameRules_GetTeamScore( player.GetTeam() )
+ }
+ else if ( GameRules_GetTeamScore( player.GetTeam() ) > file.secondHighestScore )
+ {
+ file.secondHighestScore = GameRules_GetTeamScore( player.GetTeam() )
+ }
+ }
+
+ int ourScore = 0
+ if ( IsValid( GetLocalClientPlayer() ) )
+ ourScore = GameRules_GetTeamScore( GetLocalClientPlayer().GetTeam() )
+
+ int limit = IsRoundBased() ? GetCurrentPlaylistVarInt( "roundscorelimit", 0 ) : GetCurrentPlaylistVarInt( "scorelimit", 0 )
+ NSUpdateGameStateClient( GetPlayerArray().len(), GetCurrentPlaylistVarInt( "max_players", 65535 ), ourScore, file.secondHighestScore, file.highestScore, GetServerVar( "roundBased" ), limit )
+ OnPrematchStart()
+ wait 1.0
+ }
+ }
+}
diff --git a/Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut b/Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut
new file mode 100644
index 00000000..1e381989
--- /dev/null
+++ b/Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut
@@ -0,0 +1,38 @@
+untyped
+globalize_all_functions
+
+void function NSUpdateGameStateUIStart()
+{
+ thread NSUpdateGameStateLoopUI()
+}
+
+void function NSUpdateGameStateLoopUI()
+{
+ while ( true )
+ {
+ wait 1.0
+
+ if ( uiGlobal.loadedLevel == "" )
+ {
+ if ( uiGlobal.isLoading )
+ NSSetLoading( true )
+ else
+ {
+ NSSetLoading( false )
+ NSUpdateGameStateUI( "", "", "", "", true, false )
+ }
+
+ continue
+ }
+
+ NSSetLoading( false )
+ if( GetConVarString( "mp_gamemode" ) == "solo" )
+ {
+ NSUpdateGameStateUI( GetActiveLevel(), Localize( GetMapDisplayName( GetActiveLevel() + "_CAMPAIGN_NAME" ) ), "Campaign", "Campaign", IsFullyConnected(), false )
+ }
+ else
+ {
+ NSUpdateGameStateUI( GetActiveLevel(), Localize( GetMapDisplayName( GetActiveLevel() ) ), GetConVarString( "mp_gamemode" ), Localize( GetPlaylistDisplayName( GetConVarString( "mp_gamemode" ) ) ), IsFullyConnected(), false )
+ }
+ }
+}