From 544f34caca405614e1ede544c3b3466e9d5566bd Mon Sep 17 00:00:00 2001 From: Neoministein <57015772+Neoministein@users.noreply.github.com> Date: Sun, 6 Mar 2022 23:49:22 +0100 Subject: Add ability to have custom private match settings menus (#226) --- .../menu_ns_custom_match_settings_categories.nut | 35 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_custom_match_settings_categories.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_custom_match_settings_categories.nut index be2a1048..7d5953b5 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_custom_match_settings_categories.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_custom_match_settings_categories.nut @@ -1,4 +1,11 @@ global function AddNorthstarCustomMatchSettingsCategoryMenu +global function AddCustomPrivateMatchSettingsCategory + +struct { + int count = 0 + array< string > customCategoryMenus + array< string > customCategoryLocalization +} file void function AddNorthstarCustomMatchSettingsCategoryMenu() { @@ -30,8 +37,15 @@ void function OnNorthstarCustomMatchSettingsCategoryMenuOpened() Hud_SetEnabled( button, false ) Hud_SetVisible( button, false ) } + + for ( int i = 0; i < file.count && i < buttons.len(); i++ ) + { + Hud_SetText( buttons[ i ], Localize( file.customCategoryLocalization[ i ] ) + " ->" ) + Hud_SetEnabled( buttons[ i ], true ) + Hud_SetVisible( buttons[ i ], true ) + } - for ( int i = 0, j = 0; j < categories.len() && i < buttons.len(); i++, j++ ) + for ( int i = file.count, j = 0; j < categories.len() && i < buttons.len(); i++, j++ ) { Hud_SetText( buttons[ i ], Localize( categories[ j ] ) + " ->" ) Hud_SetEnabled( buttons[ i ], true ) @@ -41,11 +55,26 @@ void function OnNorthstarCustomMatchSettingsCategoryMenuOpened() void function SelectPrivateMatchSettingsCategory( var button ) { - SetNextMatchSettingsCategory( GetPrivateMatchSettingCategories()[ int( Hud_GetScriptID( button ) ) ] ) - AdvanceMenu( GetMenu( "CustomMatchSettingsMenu" ) ) + int buttonId = int( Hud_GetScriptID( button ) ) + if (file.count <= buttonId) + { + SetNextMatchSettingsCategory( GetPrivateMatchSettingCategories()[ int( Hud_GetScriptID( button ) ) - file.count ] ) + AdvanceMenu( GetMenu( "CustomMatchSettingsMenu" ) ) + } + else + { + AdvanceMenu( GetMenu( file.customCategoryMenus[buttonId] ) ) + } } void function ResetMatchSettingsToDefault( var button ) { ClientCommand( "ResetMatchSettingsToDefault" ) +} + +void function AddCustomPrivateMatchSettingsCategory(string menuLocalization, string menuName) +{ + file.count++ + file.customCategoryMenus.append(menuName) + file.customCategoryLocalization.append(menuLocalization) } \ No newline at end of file -- cgit v1.2.3