mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Add title to engine warnings and make auto-hiding optional
Make the title of warnings adjustable, with the default title being "Warning" to preserve existing code. Make auto-hiding configurable, so the automatic closing of warning popups after 10 seconds can be toggled.
This commit is contained in:
parent
60807b5de9
commit
6951795619
|
@ -3,15 +3,21 @@
|
|||
|
||||
struct SWarning
|
||||
{
|
||||
SWarning() :
|
||||
m_WasShown(false) {}
|
||||
SWarning(const char *pMsg) :
|
||||
m_WasShown(false)
|
||||
SWarning() {}
|
||||
SWarning(const char *pMsg)
|
||||
{
|
||||
str_copy(m_aWarningMsg, pMsg, sizeof(m_aWarningMsg));
|
||||
str_copy(m_aWarningTitle, "");
|
||||
str_copy(m_aWarningMsg, pMsg);
|
||||
}
|
||||
SWarning(const char *pTitle, const char *pMsg)
|
||||
{
|
||||
str_copy(m_aWarningTitle, pTitle);
|
||||
str_copy(m_aWarningMsg, pMsg);
|
||||
}
|
||||
char m_aWarningTitle[128];
|
||||
char m_aWarningMsg[256];
|
||||
bool m_WasShown;
|
||||
bool m_WasShown = false;
|
||||
bool m_AutoHide = true;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1786,7 +1786,7 @@ int CMenus::Render()
|
|||
Part.VMargin(120.0f, &Part);
|
||||
|
||||
static CButtonContainer s_Button;
|
||||
if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER) || (time_get_nanoseconds() - m_PopupWarningLastTime >= m_PopupWarningDuration))
|
||||
if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER) || (m_PopupWarningDuration > 0s && time_get_nanoseconds() - m_PopupWarningLastTime >= m_PopupWarningDuration))
|
||||
{
|
||||
m_Popup = POPUP_NONE;
|
||||
SetActive(false);
|
||||
|
|
|
@ -673,9 +673,9 @@ void CGameClient::OnRender()
|
|||
// display gfx & client warnings
|
||||
for(SWarning *pWarning : {Graphics()->GetCurWarning(), Client()->GetCurWarning()})
|
||||
{
|
||||
if(pWarning != NULL && m_Menus.CanDisplayWarning())
|
||||
if(pWarning != nullptr && m_Menus.CanDisplayWarning())
|
||||
{
|
||||
m_Menus.PopupWarning(Localize("Warning"), pWarning->m_aWarningMsg, "Ok", 10s);
|
||||
m_Menus.PopupWarning(pWarning->m_aWarningTitle[0] == '\0' ? Localize("Warning") : pWarning->m_aWarningTitle, pWarning->m_aWarningMsg, "Ok", pWarning->m_AutoHide ? 10s : 0s);
|
||||
pWarning->m_WasShown = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue