Support pageup, pagedown, home, end buttons in menus

This commit is contained in:
def 2017-07-04 22:06:51 +02:00
parent fd73fdd942
commit 37a08e8ef0
3 changed files with 24 additions and 3 deletions

View file

@ -4,6 +4,7 @@
#include <base/tl/sorted_array.h>
#include <math.h>
#include <limits.h>
#include <game/generated/client_data.h>
@ -223,6 +224,14 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
if(m_BacklogActPage < 0)
m_BacklogActPage = 0;
}
else if(Event.m_Key == KEY_HOME)
{
m_BacklogActPage = INT_MAX;
}
else if(Event.m_Key == KEY_END)
{
m_BacklogActPage = 0;
}
else if(Event.m_Key == KEY_LSHIFT)
{
m_ReverseTAB = true;

View file

@ -189,7 +189,11 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
if(m_aInputEvents[i].m_Flags&IInput::FLAG_PRESS)
{
if(m_aInputEvents[i].m_Key == KEY_DOWN) NewIndex = m_SelectedIndex + 1;
if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = m_SelectedIndex - 1;
else if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = m_SelectedIndex - 1;
else if(m_aInputEvents[i].m_Key == KEY_PAGEUP) NewIndex = max(m_SelectedIndex - 25, 0);
else if(m_aInputEvents[i].m_Key == KEY_PAGEDOWN) NewIndex = min(m_SelectedIndex + 25, NumServers - 1);
else if(m_aInputEvents[i].m_Key == KEY_HOME) NewIndex = 0;
else if(m_aInputEvents[i].m_Key == KEY_END) NewIndex = NumServers - 1;
}
if(NewIndex > -1 && NewIndex < NumServers)
{

View file

@ -590,7 +590,11 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected,
if(m_aInputEvents[i].m_Flags&IInput::FLAG_PRESS)
{
if(m_aInputEvents[i].m_Key == KEY_DOWN) NewIndex = gs_ListBoxNewSelected + 1;
if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = gs_ListBoxNewSelected - 1;
else if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = gs_ListBoxNewSelected - 1;
else if(m_aInputEvents[i].m_Key == KEY_PAGEUP) NewIndex = max(gs_ListBoxNewSelected - 20, 0);
else if(m_aInputEvents[i].m_Key == KEY_PAGEDOWN) NewIndex = min(gs_ListBoxNewSelected + 20, gs_ListBoxNumItems - 1);
else if(m_aInputEvents[i].m_Key == KEY_HOME) NewIndex = 0;
else if(m_aInputEvents[i].m_Key == KEY_END) NewIndex = gs_ListBoxNumItems - 1;
}
if(NewIndex > -1 && NewIndex < gs_ListBoxNumItems)
{
@ -959,7 +963,11 @@ void CMenus::RenderDemoList(CUIRect MainView)
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;
else if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = m_DemolistSelectedIndex - 1;
else if(m_aInputEvents[i].m_Key == KEY_PAGEUP) NewIndex = max(m_DemolistSelectedIndex - 20, 0);
else if(m_aInputEvents[i].m_Key == KEY_PAGEDOWN) NewIndex = min(m_DemolistSelectedIndex + 20, m_lDemos.size() - 1);
else if(m_aInputEvents[i].m_Key == KEY_HOME) NewIndex = 0;
else if(m_aInputEvents[i].m_Key == KEY_END) NewIndex = m_lDemos.size() - 1;
}
if(NewIndex > -1 && NewIndex < m_lDemos.size())
{