mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Add cancel button to country popup, confirm with list item activation
Add "Cancel" button to country/region picker popup. It's already possible to cancel with the Escape key, so there should also be a button, which keeps the current selection. Delegate the listbox activation (enter / double click on item) to the popup to confirm it. Enter was previously working but then broken by the logic that ensures that every hotkey is only consumed once. Now both enter and double click confirm the popup. From teeworlds/teeworlds#2961.
This commit is contained in:
parent
5994812a1c
commit
5903c25799
|
@ -1885,23 +1885,27 @@ int CMenus::Render()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const int NewSelected = UiDoListboxEnd(&s_ScrollValue, 0);
|
bool Activated = false;
|
||||||
|
const int NewSelected = UiDoListboxEnd(&s_ScrollValue, &Activated);
|
||||||
if(OldSelected != NewSelected)
|
if(OldSelected != NewSelected)
|
||||||
s_CurSelection = m_pClient->m_CountryFlags.GetByIndex(NewSelected)->m_CountryCode;
|
s_CurSelection = m_pClient->m_CountryFlags.GetByIndex(NewSelected)->m_CountryCode;
|
||||||
|
|
||||||
Part.VMargin(120.0f, &Part);
|
CUIRect CancelButton, OkButton;
|
||||||
|
Part.VMargin(100.0f, &Part);
|
||||||
|
Part.VSplitMid(&CancelButton, &OkButton, 40.0f);
|
||||||
|
|
||||||
static CButtonContainer s_Button;
|
static CButtonContainer s_CancelButton;
|
||||||
if(DoButton_Menu(&s_Button, Localize("Ok"), 0, &Part) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER))
|
if(DoButton_Menu(&s_CancelButton, Localize("Cancel"), 0, &CancelButton) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE))
|
||||||
{
|
{
|
||||||
g_Config.m_BrFilterCountryIndex = s_CurSelection;
|
s_CurSelection = g_Config.m_BrFilterCountryIndex;
|
||||||
Client()->ServerBrowserUpdate();
|
|
||||||
m_Popup = POPUP_NONE;
|
m_Popup = POPUP_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE))
|
static CButtonContainer s_OkButton;
|
||||||
|
if(DoButton_Menu(&s_OkButton, Localize("Ok"), 0, &OkButton) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER) || Activated)
|
||||||
{
|
{
|
||||||
s_CurSelection = g_Config.m_BrFilterCountryIndex;
|
g_Config.m_BrFilterCountryIndex = s_CurSelection;
|
||||||
|
Client()->ServerBrowserUpdate();
|
||||||
m_Popup = POPUP_NONE;
|
m_Popup = POPUP_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue