From ff09eff5261975a3f33aeae61f726b9864e65d09 Mon Sep 17 00:00:00 2001 From: east Date: Thu, 27 Aug 2015 16:59:25 +0200 Subject: [PATCH] arrow up/down in demo browser --- src/game/client/components/menus_demo.cpp | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 71451b6df..852c4a5bb 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -953,6 +953,43 @@ void CMenus::RenderDemoList(CUIRect MainView) else ScrollNum = 0; + if(m_DemolistSelectedIndex > -1) + { + for(int i = 0; i < m_NumInputEvents; i++) + { + int NewIndex = -1; + if(m_aInputEvents[i].m_Flags&IInput::FLAG_PRESS) + { + if(m_aInputEvents[i].m_Key == KEY_DOWN) NewIndex = m_DemolistSelectedIndex + 1; + if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = m_DemolistSelectedIndex - 1; + } + if(NewIndex > -1 && NewIndex < m_lDemos.size()) + { + //scroll + float IndexY = ListBox.y - s_ScrollValue*ScrollNum*s_aCols[0].m_Rect.h + NewIndex*s_aCols[0].m_Rect.h; + int Scroll = ListBox.y > IndexY ? -1 : ListBox.y+ListBox.h < IndexY+s_aCols[0].m_Rect.h ? 1 : 0; + if(Scroll) + { + if(Scroll < 0) + { + int NumScrolls = (ListBox.y-IndexY+s_aCols[0].m_Rect.h-1.0f)/s_aCols[0].m_Rect.h; + s_ScrollValue -= (1.0f/ScrollNum)*NumScrolls; + } + else + { + int NumScrolls = (IndexY+s_aCols[0].m_Rect.h-(ListBox.y+ListBox.h)+s_aCols[0].m_Rect.h-1.0f)/s_aCols[0].m_Rect.h; + s_ScrollValue += (1.0f/ScrollNum)*NumScrolls; + } + } + + m_DemolistSelectedIndex = NewIndex; + + str_copy(g_Config.m_UiDemoSelected, m_lDemos[NewIndex].m_aName, sizeof(g_Config.m_UiDemoSelected)); + DemolistOnUpdate(false); + } + } + } + if(s_ScrollValue < 0) s_ScrollValue = 0; if(s_ScrollValue > 1) s_ScrollValue = 1;