mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix #1031
This commit is contained in:
parent
c0fa444f3a
commit
8cfebaa0b2
|
@ -87,7 +87,7 @@ class CMenus : public CComponent
|
|||
int ItemsPerRow, int SelectedIndex, float ScrollValue);
|
||||
CListboxItem UiDoListboxNextItem(const void *pID, bool Selected = false, bool KeyEvents = true);
|
||||
CListboxItem UiDoListboxNextRow();
|
||||
int UiDoListboxEnd(float *pScrollValue, bool *pItemActivated);
|
||||
int UiDoListboxEnd(float *pScrollValue, bool *pItemActivated, bool *pListBoxActive = 0);
|
||||
|
||||
//static void demolist_listdir_callback(const char *name, int is_dir, void *user);
|
||||
//static void demolist_list_callback(const CUIRect *rect, int index, void *user);
|
||||
|
|
|
@ -457,6 +457,7 @@ static int gs_ListBoxNumItems;
|
|||
static int gs_ListBoxItemsPerRow;
|
||||
static float gs_ListBoxScrollValue;
|
||||
static bool gs_ListBoxItemActivated;
|
||||
static bool gs_ListBoxClicked;
|
||||
|
||||
void CMenus::UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHeight, const char *pTitle, const char *pBottomText, int NumItems,
|
||||
int ItemsPerRow, int SelectedIndex, float ScrollValue)
|
||||
|
@ -497,6 +498,7 @@ void CMenus::UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHe
|
|||
gs_ListBoxDoneEvents = 0;
|
||||
gs_ListBoxScrollValue = ScrollValue;
|
||||
gs_ListBoxItemActivated = false;
|
||||
gs_ListBoxClicked = false;
|
||||
|
||||
// do the scrollbar
|
||||
View.HSplitTop(gs_ListBoxRowHeight, &Row, 0);
|
||||
|
@ -591,8 +593,10 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected,
|
|||
|
||||
CListboxItem Item = UiDoListboxNextRow();
|
||||
|
||||
if(Item.m_Visible && UI()->DoButtonLogic(pId, "", gs_ListBoxSelectedIndex == gs_ListBoxItemIndex, &Item.m_HitRect))
|
||||
if(Item.m_Visible && UI()->DoButtonLogic(pId, "", gs_ListBoxSelectedIndex == gs_ListBoxItemIndex, &Item.m_HitRect)){
|
||||
gs_ListBoxClicked = true;
|
||||
gs_ListBoxNewSelected = ThisItemIndex;
|
||||
}
|
||||
|
||||
// process input, regard selected index
|
||||
if(gs_ListBoxSelectedIndex == ThisItemIndex)
|
||||
|
@ -601,7 +605,6 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected,
|
|||
{
|
||||
gs_ListBoxDoneEvents = 1;
|
||||
|
||||
|
||||
if(m_EnterPressed || (UI()->ActiveItem() == pId && Input()->MouseDoubleClick()))
|
||||
{
|
||||
gs_ListBoxItemActivated = true;
|
||||
|
@ -661,13 +664,15 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected,
|
|||
return Item;
|
||||
}
|
||||
|
||||
int CMenus::UiDoListboxEnd(float *pScrollValue, bool *pItemActivated)
|
||||
int CMenus::UiDoListboxEnd(float *pScrollValue, bool *pItemActivated, bool *pListBoxActive)
|
||||
{
|
||||
UI()->ClipDisable();
|
||||
if(pScrollValue)
|
||||
*pScrollValue = gs_ListBoxScrollValue;
|
||||
if(pItemActivated)
|
||||
*pItemActivated = gs_ListBoxItemActivated;
|
||||
if(pListBoxActive)
|
||||
*pListBoxActive = gs_ListBoxClicked;
|
||||
return gs_ListBoxNewSelected;
|
||||
}
|
||||
|
||||
|
|
|
@ -330,6 +330,10 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
m_NeedSendinfo = true;
|
||||
}
|
||||
|
||||
static bool s_ListBoxUsed = false;
|
||||
if(UI()->ActiveItem() == Clan || UI()->ActiveItem() == Name)
|
||||
s_ListBoxUsed = false;
|
||||
|
||||
// country flag selector
|
||||
MainView.HSplitTop(20.0f, 0, &MainView);
|
||||
static float s_ScrollValue = 0.0f;
|
||||
|
@ -342,7 +346,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
if(pEntry->m_CountryCode == *Country)
|
||||
OldSelected = i;
|
||||
|
||||
CListboxItem Item = UiDoListboxNextItem(&pEntry->m_CountryCode, OldSelected == i);
|
||||
CListboxItem Item = UiDoListboxNextItem(&pEntry->m_CountryCode, OldSelected == i, s_ListBoxUsed);
|
||||
if(Item.m_Visible)
|
||||
{
|
||||
CUIRect Label;
|
||||
|
@ -358,7 +362,11 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
}
|
||||
}
|
||||
|
||||
const int NewSelected = UiDoListboxEnd(&s_ScrollValue, 0);
|
||||
bool Clicked = false;
|
||||
const int NewSelected = UiDoListboxEnd(&s_ScrollValue, 0, &Clicked);
|
||||
if(Clicked)
|
||||
s_ListBoxUsed = true;
|
||||
|
||||
if(OldSelected != NewSelected)
|
||||
{
|
||||
*Country = m_pClient->m_pCountryFlags->GetByIndex(NewSelected)->m_CountryCode;
|
||||
|
|
Loading…
Reference in a new issue