diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index e01278da5..a8a160dd5 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -80,7 +80,7 @@ CMenus::CMenus() m_SelectedServer.m_Filter = -1; m_SelectedServer.m_Index = -1; - m_ActiveListBox = ACTLB_THEME; + m_ActiveListBox = ACTLB_NONE; } float CMenus::ButtonFade(CButtonContainer *pBC, float Seconds, int Checked) @@ -944,7 +944,7 @@ CMenus::CListboxItem CMenus::UiDoListboxNextRow(CListBoxState* pState) return Item; } -CMenus::CListboxItem CMenus::UiDoListboxNextItem(CListBoxState* pState, const void *pId, bool Selected) +CMenus::CListboxItem CMenus::UiDoListboxNextItem(CListBoxState* pState, const void *pId, bool Selected, bool* pActive) { int ThisItemIndex = pState->m_ListBoxItemIndex; if(Selected) @@ -957,12 +957,17 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(CListBoxState* pState, const vo CListboxItem Item = UiDoListboxNextRow(pState); if(Item.m_Visible && UI()->DoButtonLogic(pId, "", pState->m_ListBoxSelectedIndex == pState->m_ListBoxItemIndex, &Item.m_HitRect)) + { pState->m_ListBoxNewSelected = ThisItemIndex; + if(pActive) + *pActive = true; + } + const bool ProcessInput = !pActive || *pActive; // process input, regard selected index if(pState->m_ListBoxSelectedIndex == ThisItemIndex) { - if(!pState->m_ListBoxDoneEvents) + if(ProcessInput && !pState->m_ListBoxDoneEvents) { pState->m_ListBoxDoneEvents = 1; @@ -1008,7 +1013,7 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(CListBoxState* pState, const vo //selected_index = i; 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; diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 5e66386a2..abb183e3a 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -128,7 +128,7 @@ private: 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, int ItemsPerRow, int SelectedIndex, const CUIRect *pRect=0, bool Background=true); - CListboxItem UiDoListboxNextItem(CListBoxState* pState, const void *pID, bool Selected = false); + CListboxItem UiDoListboxNextItem(CListBoxState* pState, const void *pID, bool Selected = false, bool* pActive = NULL); CListboxItem UiDoListboxNextRow(CListBoxState* pState); int UiDoListboxEnd(CListBoxState* pState, bool *pItemActivated); @@ -176,7 +176,8 @@ private: SETTINGS_GRAPHICS, SETTINGS_SOUND, - ACTLB_LANG=0, + ACTLB_NONE=0, + ACTLB_LANG, ACTLB_THEME, }; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 658e74bf4..bd400ac52 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -713,7 +713,6 @@ void CMenus::RenderLanguageSelection(CUIRect MainView, bool Header) { static int s_LanguageList = 0; static int s_SelectedLanguage = -1; - static int s_OldSelected = -1; static sorted_array s_Languages; static CListBoxState s_ListBoxState; @@ -729,16 +728,6 @@ void CMenus::RenderLanguageSelection(CUIRect MainView, bool Header) } } - if(s_SelectedLanguage != -1 && m_ActiveListBox != ACTLB_LANG) - { - s_OldSelected = s_SelectedLanguage; - s_SelectedLanguage = -1; - } - if(s_SelectedLanguage == -1 && UI()->MouseInside(&MainView)) - { - s_SelectedLanguage = s_OldSelected; - m_ActiveListBox = ACTLB_LANG; - } int OldSelected = s_SelectedLanguage; if(Header) @@ -747,7 +736,10 @@ void CMenus::RenderLanguageSelection(CUIRect MainView, bool Header) for(sorted_array::range r = s_Languages.all(); !r.empty(); r.pop_front()) { - CListboxItem Item = UiDoListboxNextItem(&s_ListBoxState, &r.front()); + 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) { @@ -785,7 +777,6 @@ void CMenus::RenderThemeSelection(CUIRect MainView, bool Header) { static int s_ThemeList = 0; static int s_SelectedTheme = -1; - static int s_OldSelected = -1; static CListBoxState s_ListBoxState_Theme; if(m_lThemes.size() == 0) // not loaded yet @@ -803,16 +794,6 @@ void CMenus::RenderThemeSelection(CUIRect MainView, bool Header) } } - if(s_SelectedTheme != -1 && m_ActiveListBox != ACTLB_THEME) - { - s_OldSelected = s_SelectedTheme; - s_SelectedTheme = -1; - } - if(s_SelectedTheme == -1 && UI()->MouseInside(&MainView)) - { - s_SelectedTheme = s_OldSelected; - m_ActiveListBox = ACTLB_THEME; - } int OldSelected = s_SelectedTheme; if(Header) @@ -821,7 +802,10 @@ void CMenus::RenderThemeSelection(CUIRect MainView, bool Header) for(sorted_array::range r = m_lThemes.all(); !r.empty(); r.pop_front()) { - CListboxItem Item = UiDoListboxNextItem(&s_ListBoxState_Theme, &r.front()); + 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) {