aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-04-15 16:08:16 +0100
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-04-19 23:07:48 +0200
commit6e8f81a9a9127654112c5b1cec227c764b4ca8fd (patch)
treec4df30c6b67fa292d946e35316c436afe73b3926 /Northstar.Client/mod/scripts/vscripts
parentffdf44de4aed8e34cdc1d749193271ac80facaf3 (diff)
downloadNorthstarMods-6e8f81a9a9127654112c5b1cec227c764b4ca8fd.tar.gz
NorthstarMods-6e8f81a9a9127654112c5b1cec227c764b4ca8fd.zip
cleanup file structure and code for presence and chat (#292)
* refactor presence and chat * improve spacing in cl_chat
Diffstat (limited to 'Northstar.Client/mod/scripts/vscripts')
-rw-r--r--Northstar.Client/mod/scripts/vscripts/chat.gnut22
-rw-r--r--Northstar.Client/mod/scripts/vscripts/client/cl_chat.gnut22
-rw-r--r--Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut60
-rw-r--r--Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut (renamed from Northstar.Client/mod/scripts/vscripts/state_ui.nut)20
-rw-r--r--Northstar.Client/mod/scripts/vscripts/state_client.nut59
5 files changed, 93 insertions, 90 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/chat.gnut b/Northstar.Client/mod/scripts/vscripts/chat.gnut
deleted file mode 100644
index f5988bb7..00000000
--- a/Northstar.Client/mod/scripts/vscripts/chat.gnut
+++ /dev/null
@@ -1,22 +0,0 @@
-untyped
-globalize_all_functions
-
-void function Chat_NetworkWriteLine(string text)
-{
- NSChatWriteLine(0, text)
-}
-
-void function Chat_GameWriteLine(string text)
-{
- NSChatWriteLine(1, text)
-}
-
-void function Chat_NetworkWrite(string text)
-{
- NSChatWrite(0, text)
-}
-
-void function Chat_GameWrite(string text)
-{
- NSChatWrite(1, text)
-}
diff --git a/Northstar.Client/mod/scripts/vscripts/client/cl_chat.gnut b/Northstar.Client/mod/scripts/vscripts/client/cl_chat.gnut
new file mode 100644
index 00000000..3a43f312
--- /dev/null
+++ b/Northstar.Client/mod/scripts/vscripts/client/cl_chat.gnut
@@ -0,0 +1,22 @@
+untyped
+globalize_all_functions
+
+void function Chat_NetworkWriteLine( string text )
+{
+ NSChatWriteLine( 0, text)
+}
+
+void function Chat_GameWriteLine( string text )
+{
+ NSChatWriteLine( 1, text)
+}
+
+void function Chat_NetworkWrite( string text )
+{
+ NSChatWrite( 0, text)
+}
+
+void function Chat_GameWrite( string text )
+{
+ NSChatWrite( 1, text )
+}
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/state_ui.nut b/Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut
index 51e4856f..5f42cc7d 100644
--- a/Northstar.Client/mod/scripts/vscripts/state_ui.nut
+++ b/Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut
@@ -1,5 +1,4 @@
untyped
-
globalize_all_functions
void function NSUpdateGameStateUIStart()
@@ -12,6 +11,7 @@ void function NSUpdateGameStateLoopUI()
while ( true )
{
wait 1.0
+
if ( uiGlobal.loadedLevel == "" )
{
if ( uiGlobal.isLoading )
@@ -21,16 +21,18 @@ void function NSUpdateGameStateLoopUI()
NSSetLoading( false )
NSUpdateGameStateUI( "", "", "", "", true, false )
}
+
continue
}
- NSSetLoading( false )
- if(GetConVarString( "mp_gamemode" ) == "solo")
- {
- NSUpdateGameStateUI( "northstar", Localize( GetMapDisplayName( GetActiveLevel()+"_CAMPAIGN_NAME" ) ) , "Campaign", "Campaign", IsFullyConnected(), false )
+ NSSetLoading( false )
+ if( GetConVarString( "mp_gamemode" ) == "solo" )
+ {
+ NSUpdateGameStateUI( "northstar", 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 )
+ }
}
- else{
- NSUpdateGameStateUI( GetActiveLevel(), Localize( GetMapDisplayName( GetActiveLevel() ) ), GetConVarString( "mp_gamemode" ), Localize( GetPlaylistDisplayName( GetConVarString("mp_gamemode") ) ), IsFullyConnected(), false )
- }
-}
}
diff --git a/Northstar.Client/mod/scripts/vscripts/state_client.nut b/Northstar.Client/mod/scripts/vscripts/state_client.nut
deleted file mode 100644
index 2a380e35..00000000
--- a/Northstar.Client/mod/scripts/vscripts/state_client.nut
+++ /dev/null
@@ -1,59 +0,0 @@
-untyped
-
-int highestScore = 0
-int secondHighestScore = 0
-int ourScore = 0
-
-globalize_all_functions
-
-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(GetConVarString( "mp_gamemode" ) == "solo")
- {
-
- 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() ) >= highestScore )
- {
- highestScore = GameRules_GetTeamScore( player.GetTeam() )
- }
- else if ( GameRules_GetTeamScore( player.GetTeam() ) > secondHighestScore )
- {
- secondHighestScore = GameRules_GetTeamScore( player.GetTeam() )
- }
- }
- if ( GetLocalClientPlayer() != null )
- {
- ourScore = GameRules_GetTeamScore( GetLocalClientPlayer().GetTeam() )
- }
- int limit = GetServerVar( "roundBased" ) ? GetCurrentPlaylistVarInt( "roundscorelimit", 0 ) : GetCurrentPlaylistVarInt( "scorelimit", 0 )
- NSUpdateGameStateClient( GetPlayerArray().len(), GetCurrentPlaylistVarInt( "max_players", 65535 ), ourScore, secondHighestScore, highestScore, GetServerVar( "roundBased" ), limit )
- OnPrematchStart()
- wait 1.0
- }
- }
-}