mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
add restart button for restart warning label
This commit is contained in:
parent
3820abaefb
commit
429b0c6fdb
|
@ -1196,6 +1196,11 @@ int CMenus::Render()
|
|||
pTitle = Localize("Password incorrect");
|
||||
pButtonText = Localize("Try again");
|
||||
}
|
||||
else if(m_Popup == POPUP_RESTART)
|
||||
{
|
||||
pTitle = Localize("Restart");
|
||||
pExtraText = Localize("Are you sure that you want to restart?");
|
||||
}
|
||||
else if(m_Popup == POPUP_QUIT)
|
||||
{
|
||||
pTitle = Localize("Quit");
|
||||
|
@ -1319,7 +1324,7 @@ int CMenus::Render()
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(m_Popup == POPUP_QUIT)
|
||||
else if(m_Popup == POPUP_QUIT || m_Popup == POPUP_RESTART)
|
||||
{
|
||||
CUIRect Yes, No;
|
||||
Box.HSplitBottom(20.f, &Box, &Part);
|
||||
|
@ -1329,7 +1334,7 @@ int CMenus::Render()
|
|||
Box.VMargin(20.f, &Box);
|
||||
if(m_pClient->Editor()->HasUnsavedData())
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%s\n%s", Localize("There's an unsaved map in the editor, you might want to save it before you quit the game."), Localize("Quit anyway?"));
|
||||
str_format(aBuf, sizeof(aBuf), "%s\n\n%s", Localize("There's an unsaved map in the editor, you might want to save it."), Localize("Continue anyway?"));
|
||||
Props.m_MaxWidth = Part.w - 20.0f;
|
||||
UI()->DoLabel(&Box, aBuf, 20.f, TEXTALIGN_ML, Props);
|
||||
}
|
||||
|
@ -1346,11 +1351,19 @@ int CMenus::Render()
|
|||
|
||||
static CButtonContainer s_ButtonTryAgain;
|
||||
if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER))
|
||||
{
|
||||
if(m_Popup == POPUP_RESTART)
|
||||
{
|
||||
m_Popup = POPUP_NONE;
|
||||
Client()->Restart();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Popup = POPUP_NONE;
|
||||
Client()->Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(m_Popup == POPUP_PASSWORD)
|
||||
{
|
||||
CUIRect Label, TextBox, TryAgain, Abort;
|
||||
|
|
|
@ -219,12 +219,9 @@ protected:
|
|||
static float ms_ListitemAdditionalHeight;
|
||||
|
||||
// for settings
|
||||
bool m_NeedRestartGeneral;
|
||||
bool m_NeedRestartSkins;
|
||||
bool m_NeedRestartGraphics;
|
||||
bool m_NeedRestartSound;
|
||||
bool m_NeedRestartUpdate;
|
||||
bool m_NeedRestartDDNet;
|
||||
bool m_NeedSendinfo;
|
||||
bool m_NeedSendDummyinfo;
|
||||
int m_SettingPlayerPage;
|
||||
|
@ -745,6 +742,7 @@ public:
|
|||
POPUP_RENDER_DONE,
|
||||
POPUP_PASSWORD,
|
||||
POPUP_QUIT,
|
||||
POPUP_RESTART,
|
||||
POPUP_WARNING,
|
||||
|
||||
// demo player states
|
||||
|
|
|
@ -1988,11 +1988,12 @@ bool CMenus::RenderLanguageSelection(CUIRect MainView)
|
|||
void CMenus::RenderSettings(CUIRect MainView)
|
||||
{
|
||||
// render background
|
||||
CUIRect Button, TabBar, RestartWarning;
|
||||
CUIRect Button, TabBar, RestartBar, RestartWarning, RestartButton;
|
||||
MainView.VSplitRight(120.0f, &MainView, &TabBar);
|
||||
MainView.Draw(ms_ColorTabbarActive, IGraphics::CORNER_B, 10.0f);
|
||||
MainView.Margin(10.0f, &MainView);
|
||||
MainView.HSplitBottom(15.0f, &MainView, &RestartWarning);
|
||||
MainView.HSplitBottom(15.0f, &MainView, &RestartBar);
|
||||
RestartBar.VSplitRight(125.0f, &RestartWarning, &RestartButton);
|
||||
TabBar.HSplitTop(50.0f, &Button, &TabBar);
|
||||
Button.Draw(ms_ColorTabbarActive, IGraphics::CORNER_BR, 10.0f);
|
||||
|
||||
|
@ -2020,7 +2021,7 @@ void CMenus::RenderSettings(CUIRect MainView)
|
|||
}
|
||||
|
||||
MainView.Margin(10.0f, &MainView);
|
||||
RestartWarning.VMargin(10.0f, &RestartWarning);
|
||||
RestartBar.VMargin(10.0f, &RestartBar);
|
||||
|
||||
if(g_Config.m_UiSettingsPage == SETTINGS_LANGUAGE)
|
||||
{
|
||||
|
@ -2073,16 +2074,34 @@ void CMenus::RenderSettings(CUIRect MainView)
|
|||
RenderSettingsCustom(MainView);
|
||||
}
|
||||
|
||||
if(m_NeedRestartGraphics || m_NeedRestartSound || m_NeedRestartUpdate)
|
||||
{
|
||||
if(m_NeedRestartUpdate)
|
||||
{
|
||||
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
|
||||
UI()->DoLabel(&RestartWarning, Localize("DDNet Client needs to be restarted to complete update!"), 14.0f, TEXTALIGN_ML);
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
else if(m_NeedRestartGeneral || m_NeedRestartSkins || m_NeedRestartGraphics || m_NeedRestartSound || m_NeedRestartDDNet)
|
||||
else
|
||||
{
|
||||
UI()->DoLabel(&RestartWarning, Localize("You must restart the game for all settings to take effect."), 14.0f, TEXTALIGN_ML);
|
||||
}
|
||||
|
||||
static CButtonContainer s_RestartButton;
|
||||
if(DoButton_Menu(&s_RestartButton, Localize("Restart"), 0, &RestartButton))
|
||||
{
|
||||
if(Client()->State() == IClient::STATE_ONLINE || m_pClient->Editor()->HasUnsavedData())
|
||||
{
|
||||
m_Popup = POPUP_RESTART;
|
||||
}
|
||||
else
|
||||
{
|
||||
Client()->Restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool Alpha, bool ClampedLight)
|
||||
{
|
||||
ColorHSLA Color(*pColor, Alpha);
|
||||
|
|
Loading…
Reference in a new issue