Add confirmation popup for resetting controls to defaults

To avoid accidentally losing all binds.
This commit is contained in:
Robert Müller 2022-11-30 22:56:17 +01:00
parent a45f833afa
commit 9b719ef61c
2 changed files with 20 additions and 13 deletions

View file

@ -570,6 +570,7 @@ protected:
void RenderSettingsDummyPlayer(CUIRect MainView); void RenderSettingsDummyPlayer(CUIRect MainView);
void RenderSettingsTee(CUIRect MainView); void RenderSettingsTee(CUIRect MainView);
void RenderSettingsControls(CUIRect MainView); void RenderSettingsControls(CUIRect MainView);
void ResetSettingsControls();
void RenderSettingsGraphics(CUIRect MainView); void RenderSettingsGraphics(CUIRect MainView);
void RenderSettingsSound(CUIRect MainView); void RenderSettingsSound(CUIRect MainView);
void RenderSettings(CUIRect MainView); void RenderSettings(CUIRect MainView);

View file

@ -1337,19 +1337,8 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
static CButtonContainer s_DefaultButton; static CButtonContainer s_DefaultButton;
if(DoButton_Menu(&s_DefaultButton, Localize("Reset to defaults"), 0, &ResetButton)) if(DoButton_Menu(&s_DefaultButton, Localize("Reset to defaults"), 0, &ResetButton))
{ {
m_pClient->m_Binds.SetDefaults(); PopupConfirm(Localize("Reset controls"), Localize("Are you sure that you want to reset the controls to their defaults?"),
Localize("Reset"), Localize("Cancel"), &CMenus::ResetSettingsControls);
g_Config.m_InpMousesens = 200;
g_Config.m_UiMousesens = 200;
g_Config.m_InpControllerEnable = 0;
g_Config.m_InpControllerGUID[0] = '\0';
g_Config.m_InpControllerAbsolute = 0;
g_Config.m_InpControllerSens = 100;
g_Config.m_InpControllerX = 0;
g_Config.m_InpControllerY = 1;
g_Config.m_InpControllerTolerance = 5;
g_Config.m_UiControllerSens = 100;
} }
} }
} }
@ -1421,6 +1410,23 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
s_ScrollRegion.End(); s_ScrollRegion.End();
} }
void CMenus::ResetSettingsControls()
{
m_pClient->m_Binds.SetDefaults();
g_Config.m_InpMousesens = 200;
g_Config.m_UiMousesens = 200;
g_Config.m_InpControllerEnable = 0;
g_Config.m_InpControllerGUID[0] = '\0';
g_Config.m_InpControllerAbsolute = 0;
g_Config.m_InpControllerSens = 100;
g_Config.m_InpControllerX = 0;
g_Config.m_InpControllerY = 1;
g_Config.m_InpControllerTolerance = 5;
g_Config.m_UiControllerSens = 100;
}
int CMenus::RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelection, const void **pIDs, const char **pStr, int PickNum, CButtonContainer *pButtonContainer, float &ScrollVal) int CMenus::RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelection, const void **pIDs, const char **pStr, int PickNum, CButtonContainer *pButtonContainer, float &ScrollVal)
{ {
if(CurDropDownState != 0) if(CurDropDownState != 0)