mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix scroll bar (fixes #3347)
This commit is contained in:
parent
1883546939
commit
bb43660cd4
|
@ -2650,7 +2650,7 @@ bool CMenus::HandleListInputs(const CUIRect &View, float &ScrollValue, const flo
|
|||
{
|
||||
int NewIndex = -1;
|
||||
int Num = (int)(View.h / ElemHeight) + 1;
|
||||
int ScrollNum = NumElems - Num + 1;
|
||||
int ScrollNum = maximum(NumElems - Num + 1, 0);
|
||||
if(ScrollNum > 0)
|
||||
{
|
||||
if(pScrollOffset && *pScrollOffset >= 0)
|
||||
|
@ -2663,18 +2663,9 @@ bool CMenus::HandleListInputs(const CUIRect &View, float &ScrollValue, const flo
|
|||
if(Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN) && UI()->MouseInside(&View))
|
||||
ScrollValue += 3.0f / ScrollNum;
|
||||
}
|
||||
else
|
||||
ScrollNum = 0;
|
||||
|
||||
if(ScrollValue < 0)
|
||||
ScrollValue = 0;
|
||||
if(ScrollValue > 1)
|
||||
ScrollValue = 1;
|
||||
|
||||
if(SelectedIndex < 0)
|
||||
SelectedIndex = 0;
|
||||
if(SelectedIndex >= NumElems)
|
||||
SelectedIndex = NumElems;
|
||||
ScrollValue = clamp(ScrollValue, 0.0f, 1.0f);
|
||||
SelectedIndex = clamp(SelectedIndex, 0, NumElems);
|
||||
|
||||
for(int i = 0; i < m_NumInputEvents; i++)
|
||||
{
|
||||
|
|
|
@ -190,7 +190,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
|
||||
CUIRect OriginalView = View;
|
||||
int Num = (int)(View.h / s_aCols[0].m_Rect.h) + 1;
|
||||
int ScrollNum = NumServers - Num + 1;
|
||||
int ScrollNum = maximum(NumServers - Num + 1, 0);
|
||||
View.y -= s_ScrollValue * ScrollNum * s_aCols[0].m_Rect.h;
|
||||
|
||||
int NewSelected = -1;
|
||||
|
|
|
@ -569,13 +569,8 @@ void CMenus::UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHe
|
|||
gs_ListBoxScrollValue += Num == 1 ? 0.1f : 3.0f / Num;
|
||||
}
|
||||
|
||||
if(gs_ListBoxScrollValue < 0.0f)
|
||||
gs_ListBoxScrollValue = 0.0f;
|
||||
if(gs_ListBoxScrollValue > 1.0f)
|
||||
gs_ListBoxScrollValue = 1.0f;
|
||||
|
||||
Scroll.HMargin(5.0f, &Scroll);
|
||||
gs_ListBoxScrollValue = DoScrollbarV(pID, &Scroll, gs_ListBoxScrollValue);
|
||||
gs_ListBoxScrollValue = clamp(DoScrollbarV(pID, &Scroll, gs_ListBoxScrollValue), 0.0f, 1.0f);
|
||||
|
||||
// the list
|
||||
gs_ListBoxView = gs_ListBoxOriginalView;
|
||||
|
@ -1078,7 +1073,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
|||
|
||||
CUIRect OriginalView = ListBox;
|
||||
int Num = (int)(ListBox.h / s_aCols[0].m_Rect.h) + 1;
|
||||
int ScrollNum = m_lDemos.size() - Num + 1;
|
||||
int ScrollNum = maximum(m_lDemos.size() - Num + 1, 0);
|
||||
ListBox.y -= s_ScrollValue * ScrollNum * s_aCols[0].m_Rect.h;
|
||||
|
||||
int NewSelected = -1;
|
||||
|
|
|
@ -1029,7 +1029,7 @@ void CMenus::RenderGhost(CUIRect MainView)
|
|||
|
||||
CUIRect OriginalView = View;
|
||||
int Num = (int)(View.h / s_aCols[0].m_Rect.h) + 1;
|
||||
int ScrollNum = NumGhosts - Num + 1;
|
||||
int ScrollNum = maximum(NumGhosts - Num + 1, 0);
|
||||
View.y -= s_ScrollValue * ScrollNum * s_aCols[0].m_Rect.h;
|
||||
|
||||
int NewSelected = -1;
|
||||
|
|
Loading…
Reference in a new issue