From 0f76c89d8a36c6118cadff28baa6c2c94c8964c5 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sun, 17 Nov 2019 18:11:33 +0100 Subject: [PATCH] Save selected UI settings page Inspired by @SushiTee's teeworlds commit: https://github.com/teeworlds/teeworlds/commit/65cc8f7fd93d6136f4d4ec570a4d22aa3490928e --- src/game/client/components/menus.h | 12 +++++++++- src/game/client/components/menus_settings.cpp | 24 +++++++++---------- src/game/variables.h | 1 + 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 089943c9b..05b285f50 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -344,7 +344,17 @@ public: PAGE_SETTINGS, PAGE_SYSTEM, PAGE_NETWORK, - PAGE_GHOST + PAGE_GHOST, + + SETTINGS_LANGUAGE=0, + SETTINGS_GENERAL, + SETTINGS_PLAYER, + SETTINGS_TEE, + SETTINGS_HUD, + SETTINGS_CONTROLS, + SETTINGS_GRAPHICS, + SETTINGS_SOUND, + SETTINGS_DDNET, }; // DDRace diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 1d159475f..00b5e58ce 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1364,8 +1364,6 @@ void CMenus::RenderLanguageSelection(CUIRect MainView) void CMenus::RenderSettings(CUIRect MainView) { - static int s_SettingsPage = 0; - // render background CUIRect Temp, TabBar, RestartWarning; MainView.VSplitRight(120.0f, &MainView, &TabBar); @@ -1397,29 +1395,29 @@ void CMenus::RenderSettings(CUIRect MainView) { TabBar.HSplitTop(10, &Button, &TabBar); TabBar.HSplitTop(26, &Button, &TabBar); - if(DoButton_MenuTab(aTabs[i], aTabs[i], s_SettingsPage == i, &Button, CUI::CORNER_R)) - s_SettingsPage = i; + if(DoButton_MenuTab(aTabs[i], aTabs[i], g_Config.m_UiSettingsPage == i, &Button, CUI::CORNER_R)) + g_Config.m_UiSettingsPage = i; } MainView.Margin(10.0f, &MainView); - if(s_SettingsPage == 0) + if(g_Config.m_UiSettingsPage == SETTINGS_LANGUAGE) RenderLanguageSelection(MainView); - else if(s_SettingsPage == 1) + else if(g_Config.m_UiSettingsPage == SETTINGS_GENERAL) RenderSettingsGeneral(MainView); - else if(s_SettingsPage == 2) + else if(g_Config.m_UiSettingsPage == SETTINGS_PLAYER) RenderSettingsPlayer(MainView); - else if(s_SettingsPage == 3) + else if(g_Config.m_UiSettingsPage == SETTINGS_TEE) RenderSettingsTee(MainView); - else if(s_SettingsPage == 4) + else if(g_Config.m_UiSettingsPage == SETTINGS_HUD) RenderSettingsHUD(MainView); - else if(s_SettingsPage == 5) + else if(g_Config.m_UiSettingsPage == SETTINGS_CONTROLS) RenderSettingsControls(MainView); - else if(s_SettingsPage == 6) + else if(g_Config.m_UiSettingsPage == SETTINGS_GRAPHICS) RenderSettingsGraphics(MainView); - else if(s_SettingsPage == 7) + else if(g_Config.m_UiSettingsPage == SETTINGS_SOUND) RenderSettingsSound(MainView); - else if(s_SettingsPage == 8) + else if(g_Config.m_UiSettingsPage == SETTINGS_DDNET) RenderSettingsDDNet(MainView); if(m_NeedRestartUpdate) diff --git a/src/game/variables.h b/src/game/variables.h index 8911e83be..d4e2b6fc0 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -89,6 +89,7 @@ MACRO_CONFIG_STR(ClSkinPrefix, cl_skin_prefix, 100, "", CFGFLAG_CLIENT|CFGFLAG_S MACRO_CONFIG_INT(ClFatSkins, cl_fat_skins, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable fat skins") MACRO_CONFIG_INT(UiPage, ui_page, 9, 0, 12, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface page") +MACRO_CONFIG_INT(UiSettingsPage, ui_settings_page, 0, 0, 8, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface settings page") MACRO_CONFIG_INT(UiToolboxPage, ui_toolbox_page, 0, 0, 2, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Toolbox page") MACRO_CONFIG_STR(UiServerAddress, ui_server_address, 64, "localhost:8303", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface server address") MACRO_CONFIG_INT(UiScale, ui_scale, 100, 50, 150, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface scale")