Skip to content

Commit

Permalink
Scroll to selected skin when entering name and switching tabs
Browse files Browse the repository at this point in the history
Scroll to reveal the selected skin when entering a skin name and when switching between the player and dummy tabs.
  • Loading branch information
Robyt3 committed Oct 19, 2024
1 parent 1bd0f43 commit 9e7ba82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/game/client/components/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class CMenus : public CComponent
void DoJoystickBar(const CUIRect *pRect, float Current, float Tolerance, bool Active);

bool m_SkinListNeedsUpdate = false;
bool m_SkinListScrollToSelected = false;

int m_DirectionQuadContainerIndex;

Expand Down
10 changes: 10 additions & 0 deletions src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,14 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
if(DoButton_MenuTab(&s_PlayerTabButton, Localize("Player"), !m_Dummy, &PlayerTab, IGraphics::CORNER_L, nullptr, nullptr, nullptr, nullptr, 4.0f))
{
m_Dummy = false;
m_SkinListScrollToSelected = true;
}

static CButtonContainer s_DummyTabButton;
if(DoButton_MenuTab(&s_DummyTabButton, Localize("Dummy"), m_Dummy, &DummyTab, IGraphics::CORNER_R, nullptr, nullptr, nullptr, nullptr, 4.0f))
{
m_Dummy = true;
m_SkinListScrollToSelected = true;
}

if(Client()->State() == IClient::STATE_ONLINE && m_pClient->m_NextChangeInfo && m_pClient->m_NextChangeInfo > Client()->GameTick(g_Config.m_ClDummy))
Expand Down Expand Up @@ -611,6 +613,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
if(Ui()->DoClearableEditBox(&s_SkinInput, &Button, 14.0f))
{
SetNeedSendInfo();
m_SkinListScrollToSelected = true;
}

// Random skin button
Expand Down Expand Up @@ -762,7 +765,14 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
{
const CSkin *pSkinToBeDraw = s_vSkinList[i].m_pSkin;
if(str_comp(pSkinToBeDraw->GetName(), pSkinName) == 0)
{
OldSelected = i;
if(m_SkinListScrollToSelected)
{
s_ListBox.ScrollToSelected();
m_SkinListScrollToSelected = false;
}
}

const CListboxItem Item = s_ListBox.DoNextItem(pSkinToBeDraw, OldSelected >= 0 && (size_t)OldSelected == i);
if(!Item.m_Visible)
Expand Down

0 comments on commit 9e7ba82

Please sign in to comment.