diff options
Diffstat (limited to 'Northstar.Client/mod/scripts/vscripts/presence')
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut | 95 | ||||
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut | 42 |
2 files changed, 48 insertions, 89 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut b/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut index 755396e3..c8a8274a 100644 --- a/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut +++ b/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut @@ -1,60 +1,45 @@ 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 ) +void function NorthstarCodeCallback_GenerateGameState() { + + GameStateStruct gs + + int highestScore = 0 + int secondHighest = 0 + + foreach ( player in GetPlayerArray() ) { - 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 - } + if ( GameRules_GetTeamScore( player.GetTeam() ) >= highestScore ) + { + highestScore = GameRules_GetTeamScore( player.GetTeam() ) + } + else if ( GameRules_GetTeamScore( player.GetTeam() ) > secondHighest ) + { + secondHighest = GameRules_GetTeamScore( player.GetTeam() ) + } } -} + + gs.map = GetMapName() + gs.mapDisplayname = Localize(GetMapDisplayName(GetMapName())) + + gs.playlist = GetCurrentPlaylistName() + gs.playlistDisplayname = Localize(GetCurrentPlaylistVarString("name", GetCurrentPlaylistName())) + + gs.currentPlayers = GetPlayerArray().len() + gs.maxPlayers = GetCurrentPlaylistVarInt( "maxPlayers", -1 ) + + if ( IsValid( GetLocalClientPlayer() ) ) + gs.ownScore = GameRules_GetTeamScore( GetLocalClientPlayer().GetTeam() ) + + gs.otherHighestScore = gs.ownScore == highestScore ? secondHighest : highestScore + + gs.maxScore = IsRoundBased() ? GetCurrentPlaylistVarInt( "roundscorelimit", 0 ) : GetCurrentPlaylistVarInt( "scorelimit", 0 ) + + if ( GetServerVar( "roundBased" ) ) + gs.timeEnd = expect float(level.nv.roundEndTime - Time()) + else + gs.timeEnd = expect float(level.nv.gameEndTime - Time()) + + NSPushGameStateData(gs) +}
\ No newline at end of file diff --git a/Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut b/Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut index 1e381989..cdf1c981 100644 --- a/Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut +++ b/Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut @@ -1,38 +1,12 @@ untyped globalize_all_functions -void function NSUpdateGameStateUIStart() -{ - thread NSUpdateGameStateLoopUI() -} +void function NorthstarCodeCallback_GenerateUIPresence() { + UIPresenceStruct uis -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 ) - } - } -} + uis.isLoading = uiGlobal.isLoading + uis.isLobby = IsLobby() + uis.loadingLevel = uiGlobal.loadingLevel + uis.loadedLevel = uiGlobal.loadedLevel + NSPushUIPresence(uis) +}
\ No newline at end of file |