From 9a2778eabc7ba968968e41dda9f03525d6c5383d Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Thu, 14 Oct 2021 21:01:40 +0100 Subject: oh fuck i forgot to commit for a while --- .../mod/scripts/vscripts/lobby/_private_lobby.gnut | 15 ++++++++++++++ .../mod/scripts/vscripts/lobby/sh_lobby.gnut | 23 +++++++++++++++++++++- .../lobby/sh_private_lobby_modes_init.gnut | 2 ++ 3 files changed, 39 insertions(+), 1 deletion(-) (limited to 'Northstar.CustomServers/mod/scripts/vscripts/lobby') diff --git a/Northstar.CustomServers/mod/scripts/vscripts/lobby/_private_lobby.gnut b/Northstar.CustomServers/mod/scripts/vscripts/lobby/_private_lobby.gnut index 60daa452..63b2c81a 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/lobby/_private_lobby.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/lobby/_private_lobby.gnut @@ -13,6 +13,11 @@ void function PrivateLobby_Init() print( "PrivateLobby_Init()" ) //ClearPlaylistVarOverrides() + file.map = GetConVarString( "ns_private_match_last_map" ) + file.mode = GetConVarString( "ns_private_match_last_mode" ) + + thread SetupPrivateMatchUIVarsWhenReady() + AddClientCommandCallback( "PrivateMatchLaunch", ClientCommandCallback_PrivateMatchLaunch ) AddClientCommandCallback( "PrivateMatchSetMode", ClientCommandCallback_PrivateMatchSetMode ) AddClientCommandCallback( "SetCustomMap", ClientCommandCallback_SetCustomMap ) @@ -22,6 +27,14 @@ void function PrivateLobby_Init() AddClientCommandCallback( "ResetMatchSettingsToDefault", ClientCommandCallback_ResetMatchSettingsToDefault ) } +void function SetupPrivateMatchUIVarsWhenReady() +{ + // have to wait until end of first frame for SetUIVar to work + WaitEndFrame() + SetUIVar( level, "privatematch_map", GetPrivateMatchMapIndex( file.map ) ) + SetUIVar( level, "privatematch_mode", GetPrivateMatchModeIndex( file.mode ) ) +} + bool function ClientCommandCallback_PrivateMatchLaunch( entity player, array args ) { if ( file.startState == ePrivateMatchStartState.STARTING ) @@ -127,6 +140,8 @@ void function StartMatch() RefreshPlayerTeams() + SetConVarString( "ns_private_match_last_map", file.map ) + SetConVarString( "ns_private_match_last_mode", file.mode ) SetConVarBool( "ns_should_return_to_lobby", true ) // potentially temp? // TEMP for now: start game diff --git a/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_lobby.gnut b/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_lobby.gnut index 2c02ebdc..605b23fd 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_lobby.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_lobby.gnut @@ -189,11 +189,32 @@ void function AddPrivateMatchModeSettingEnumEx( string category, string playlist #endif } -array< string > function GetPrivateMatchSettingCategories() +array< string > function GetPrivateMatchSettingCategories( bool uiAllowAllModeCategories = false ) { array< string > categories foreach ( string k, v in file.customMatchSettingsByCategory ) + { + // can only do this in ui because it relies on GetUIVar + #if UI + bool gamemode = k.find( "#GAMEMODE_" ) == 0 + if ( !uiAllowAllModeCategories && ( gamemode || k.find( "#PL_" ) == 0 ) ) + { + if ( gamemode ) + { + if ( k.slice( 10 ) != PrivateMatch_GetSelectedMode() ) + { + continue + } + } + else if ( k.slice( 4 ) != PrivateMatch_GetSelectedMode() ) + { + continue + } + } + #endif + categories.append( k ) + } return categories } diff --git a/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut b/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut index 8991ebb0..5cd4de50 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut @@ -4,6 +4,8 @@ void function PrivateMatchModesInit() { // match settings // super temp: do localisation strings later + AddPrivateMatchModeSettingEnum( "#MODE_SETTING_CATEGORY_MATCH", "classic_mp", [ "Disabled", "Enabled" ], "1" ) + AddPrivateMatchModeSettingEnum( "#MODE_SETTING_CATEGORY_MATCH", "run_epilogue", [ "Disabled", "Enabled" ], "1" ) AddPrivateMatchModeSettingArbitrary( "#MODE_SETTING_CATEGORY_MATCH", "scorelimit", "5" ) //, "Score Limit" ) AddPrivateMatchModeSettingArbitrary( "#MODE_SETTING_CATEGORY_MATCH", "roundscorelimit", "0" ) //, "Score Limit (round-based modes)" ) AddPrivateMatchModeSettingArbitrary( "#MODE_SETTING_CATEGORY_MATCH", "timelimit", "12" ) //, "Time Limit" ) -- cgit v1.2.3