mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Support pageup, pagedown, home, end buttons in menus
This commit is contained in:
parent
fd73fdd942
commit
37a08e8ef0
|
@ -4,6 +4,7 @@
|
||||||
#include <base/tl/sorted_array.h>
|
#include <base/tl/sorted_array.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <game/generated/client_data.h>
|
#include <game/generated/client_data.h>
|
||||||
|
|
||||||
|
@ -223,6 +224,14 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
|
||||||
if(m_BacklogActPage < 0)
|
if(m_BacklogActPage < 0)
|
||||||
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)
|
else if(Event.m_Key == KEY_LSHIFT)
|
||||||
{
|
{
|
||||||
m_ReverseTAB = true;
|
m_ReverseTAB = true;
|
||||||
|
|
|
@ -189,7 +189,11 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
||||||
if(m_aInputEvents[i].m_Flags&IInput::FLAG_PRESS)
|
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_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)
|
if(NewIndex > -1 && NewIndex < NumServers)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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_Flags&IInput::FLAG_PRESS)
|
||||||
{
|
{
|
||||||
if(m_aInputEvents[i].m_Key == KEY_DOWN) NewIndex = gs_ListBoxNewSelected + 1;
|
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)
|
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_Flags&IInput::FLAG_PRESS)
|
||||||
{
|
{
|
||||||
if(m_aInputEvents[i].m_Key == KEY_DOWN) NewIndex = m_DemolistSelectedIndex + 1;
|
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())
|
if(NewIndex > -1 && NewIndex < m_lDemos.size())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue