mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
General settings listboxes now only process inputs after being clicked on
This commit is contained in:
parent
d8392baa40
commit
6139aaf42b
|
@ -944,7 +944,7 @@ CMenus::CListboxItem CMenus::UiDoListboxNextRow(CListBoxState* pState)
|
||||||
return Item;
|
return Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenus::CListboxItem CMenus::UiDoListboxNextItem(CListBoxState* pState, const void *pId, bool Selected, bool ProcessInput)
|
CMenus::CListboxItem CMenus::UiDoListboxNextItem(CListBoxState* pState, const void *pId, bool Selected, bool* pActive)
|
||||||
{
|
{
|
||||||
int ThisItemIndex = pState->m_ListBoxItemIndex;
|
int ThisItemIndex = pState->m_ListBoxItemIndex;
|
||||||
if(Selected)
|
if(Selected)
|
||||||
|
@ -957,7 +957,12 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(CListBoxState* pState, const vo
|
||||||
CListboxItem Item = UiDoListboxNextRow(pState);
|
CListboxItem Item = UiDoListboxNextRow(pState);
|
||||||
|
|
||||||
if(Item.m_Visible && UI()->DoButtonLogic(pId, "", pState->m_ListBoxSelectedIndex == pState->m_ListBoxItemIndex, &Item.m_HitRect))
|
if(Item.m_Visible && UI()->DoButtonLogic(pId, "", pState->m_ListBoxSelectedIndex == pState->m_ListBoxItemIndex, &Item.m_HitRect))
|
||||||
|
{
|
||||||
pState->m_ListBoxNewSelected = ThisItemIndex;
|
pState->m_ListBoxNewSelected = ThisItemIndex;
|
||||||
|
if(pActive)
|
||||||
|
*pActive = true;
|
||||||
|
}
|
||||||
|
const bool ProcessInput = !pActive || *pActive;
|
||||||
|
|
||||||
// process input, regard selected index
|
// process input, regard selected index
|
||||||
if(pState->m_ListBoxSelectedIndex == ThisItemIndex)
|
if(pState->m_ListBoxSelectedIndex == ThisItemIndex)
|
||||||
|
@ -1008,7 +1013,7 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(CListBoxState* pState, const vo
|
||||||
|
|
||||||
//selected_index = i;
|
//selected_index = i;
|
||||||
CUIRect r = Item.m_Rect;
|
CUIRect r = Item.m_Rect;
|
||||||
RenderTools()->DrawUIRect(&r, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 5.0f);
|
RenderTools()->DrawUIRect(&r, vec4(1,1,1,ProcessInput?0.5f:0.33f), CUI::CORNER_ALL, 5.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Item;
|
return Item;
|
||||||
|
|
|
@ -128,7 +128,7 @@ private:
|
||||||
void UiDoListboxHeader(CListBoxState* pState, const CUIRect *pRect, const char *pTitle, float HeaderHeight, float Spacing);
|
void UiDoListboxHeader(CListBoxState* pState, const CUIRect *pRect, const char *pTitle, float HeaderHeight, float Spacing);
|
||||||
void UiDoListboxStart(CListBoxState* pState, const void *pID, float RowHeight, const char *pBottomText, int NumItems,
|
void UiDoListboxStart(CListBoxState* pState, const void *pID, float RowHeight, const char *pBottomText, int NumItems,
|
||||||
int ItemsPerRow, int SelectedIndex, const CUIRect *pRect=0, bool Background=true);
|
int ItemsPerRow, int SelectedIndex, const CUIRect *pRect=0, bool Background=true);
|
||||||
CListboxItem UiDoListboxNextItem(CListBoxState* pState, const void *pID, bool Selected = false, bool ProcessInput = true);
|
CListboxItem UiDoListboxNextItem(CListBoxState* pState, const void *pID, bool Selected = false, bool* pActive = NULL);
|
||||||
CListboxItem UiDoListboxNextRow(CListBoxState* pState);
|
CListboxItem UiDoListboxNextRow(CListBoxState* pState);
|
||||||
int UiDoListboxEnd(CListBoxState* pState, bool *pItemActivated);
|
int UiDoListboxEnd(CListBoxState* pState, bool *pItemActivated);
|
||||||
|
|
||||||
|
|
|
@ -728,8 +728,6 @@ void CMenus::RenderLanguageSelection(CUIRect MainView, bool Header)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_ActiveListBox != ACTLB_LANG && UI()->MouseInside(&MainView))
|
|
||||||
m_ActiveListBox = ACTLB_LANG;
|
|
||||||
int OldSelected = s_SelectedLanguage;
|
int OldSelected = s_SelectedLanguage;
|
||||||
|
|
||||||
if(Header)
|
if(Header)
|
||||||
|
@ -738,7 +736,10 @@ void CMenus::RenderLanguageSelection(CUIRect MainView, bool Header)
|
||||||
|
|
||||||
for(sorted_array<CLanguage>::range r = s_Languages.all(); !r.empty(); r.pop_front())
|
for(sorted_array<CLanguage>::range r = s_Languages.all(); !r.empty(); r.pop_front())
|
||||||
{
|
{
|
||||||
CListboxItem Item = UiDoListboxNextItem(&s_ListBoxState, &r.front(), false, m_ActiveListBox == ACTLB_LANG);
|
bool IsActive = m_ActiveListBox == ACTLB_LANG;
|
||||||
|
CListboxItem Item = UiDoListboxNextItem(&s_ListBoxState, &r.front(), false, &IsActive);
|
||||||
|
if(IsActive)
|
||||||
|
m_ActiveListBox = ACTLB_LANG;
|
||||||
|
|
||||||
if(Item.m_Visible)
|
if(Item.m_Visible)
|
||||||
{
|
{
|
||||||
|
@ -791,8 +792,6 @@ void CMenus::RenderThemeSelection(CUIRect MainView, bool Header)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_ActiveListBox != ACTLB_THEME && UI()->MouseInside(&MainView))
|
|
||||||
m_ActiveListBox = ACTLB_THEME;
|
|
||||||
int OldSelected = s_SelectedTheme;
|
int OldSelected = s_SelectedTheme;
|
||||||
|
|
||||||
if(Header)
|
if(Header)
|
||||||
|
@ -801,7 +800,10 @@ void CMenus::RenderThemeSelection(CUIRect MainView, bool Header)
|
||||||
|
|
||||||
for(sorted_array<CTheme>::range r = m_lThemes.all(); !r.empty(); r.pop_front())
|
for(sorted_array<CTheme>::range r = m_lThemes.all(); !r.empty(); r.pop_front())
|
||||||
{
|
{
|
||||||
CListboxItem Item = UiDoListboxNextItem(&s_ListBoxState_Theme, &r.front(), false, m_ActiveListBox == ACTLB_THEME);
|
bool IsActive = m_ActiveListBox == ACTLB_THEME;
|
||||||
|
CListboxItem Item = UiDoListboxNextItem(&s_ListBoxState_Theme, &r.front(), false, &IsActive);
|
||||||
|
if(IsActive)
|
||||||
|
m_ActiveListBox = ACTLB_THEME;
|
||||||
|
|
||||||
if(Item.m_Visible)
|
if(Item.m_Visible)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue