mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
automatically adjust the scrollbar based on the according text length. closes #1956
This commit is contained in:
parent
d1657320a9
commit
f634f8a76b
|
@ -595,21 +595,24 @@ void CMenus::DoEditBoxOption(void *pID, char *pOption, int OptionLength, const C
|
|||
DoEditBox(pID, &EditBox, pOption, OptionLength, pRect->h*ms_FontmodHeight*0.8f, pOffset, Hidden);
|
||||
}
|
||||
|
||||
void CMenus::DoScrollbarOption(void *pID, int *pOption, const CUIRect *pRect, const char *pStr, float VSplitVal, int Min, int Max, bool infinite)
|
||||
void CMenus::DoScrollbarOption(void *pID, int *pOption, const CUIRect *pRect, const char *pStr, int Min, int Max, bool infinite)
|
||||
{
|
||||
RenderTools()->DrawUIRect(pRect, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
|
||||
CUIRect Label, ScrollBar;
|
||||
pRect->VSplitLeft(VSplitVal, &Label, &ScrollBar);
|
||||
|
||||
char aBuf[32];
|
||||
char aBuf[128];
|
||||
if(*pOption || !infinite)
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i", pStr, *pOption);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%s: \xe2\x88\x9e", pStr);
|
||||
float FontSize = pRect->h*ms_FontmodHeight*0.8f;
|
||||
float VSplitVal = TextRender()->TextWidth(0, FontSize, aBuf, -1);
|
||||
|
||||
pRect->VSplitLeft(pRect->h+10.0f+VSplitVal, &Label, &ScrollBar);
|
||||
Label.VSplitLeft(Label.h+5.0f, 0, &Label);
|
||||
Label.y += 2.0f;
|
||||
UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT);
|
||||
UI()->DoLabel(&Label, aBuf, FontSize, CUI::ALIGN_LEFT);
|
||||
|
||||
ScrollBar.VMargin(4.0f, &ScrollBar);
|
||||
*pOption = round_to_int(DoScrollbarH(pOption, &ScrollBar, (float)(*pOption-Min)/(float)(Max-Min))*(float)(Max-Min)+(float)Min+0.1f);
|
||||
|
|
|
@ -84,7 +84,7 @@ private:
|
|||
*/
|
||||
int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden=false, int Corners=CUI::CORNER_ALL);
|
||||
void DoEditBoxOption(void *pID, char *pOption, int OptionLength, const CUIRect *pRect, const char *pStr, float VSplitVal, float *pOffset, bool Hidden=false);
|
||||
void DoScrollbarOption(void *pID, int *pOption, const CUIRect *pRect, const char *pStr, float VSplitVal, int Min, int Max, bool infinite=false);
|
||||
void DoScrollbarOption(void *pID, int *pOption, const CUIRect *pRect, const char *pStr, int Min, int Max, bool infinite=false);
|
||||
float DoDropdownMenu(void *pID, const CUIRect *pRect, const char *pStr, float HeaderHeight, FDropdownCallback pfnCallback);
|
||||
float DoIndependentDropdownMenu(void *pID, const CUIRect *pRect, const char *pStr, float HeaderHeight, FDropdownCallback pfnCallback, bool* pActive);
|
||||
void DoInfoBox(const CUIRect *pRect, const char *pLable, const char *pValue);
|
||||
|
|
|
@ -127,7 +127,7 @@ float CMenus::RenderSettingsControlsMovement(CUIRect View, void *pUser)
|
|||
CUIRect Button;
|
||||
View.HSplitTop(Spaceing, 0, &View);
|
||||
View.HSplitTop(ButtonHeight, &Button, &View);
|
||||
pSelf->DoScrollbarOption(&g_Config.m_InpMousesens, &g_Config.m_InpMousesens, &Button, Localize("Mouse sens."), 200.0f, 5, 500);
|
||||
pSelf->DoScrollbarOption(&g_Config.m_InpMousesens, &g_Config.m_InpMousesens, &Button, Localize("Mouse sens."), 5, 500);
|
||||
|
||||
pSelf->UiDoGetButtons(0, 5, View, ButtonHeight, Spaceing);
|
||||
|
||||
|
|
|
@ -958,7 +958,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
GameLeft.HSplitTop(Spacing, 0, &GameLeft);
|
||||
GameLeft.HSplitTop(ButtonHeight, &Button, &GameLeft);
|
||||
Button.VSplitLeft(ButtonHeight, 0, &Button);
|
||||
DoScrollbarOption(&g_Config.m_ClNameplatesSize, &g_Config.m_ClNameplatesSize, &Button, Localize("Size"), 100.0f, 0, 100);
|
||||
DoScrollbarOption(&g_Config.m_ClNameplatesSize, &g_Config.m_ClNameplatesSize, &Button, Localize("Size"), 0, 100);
|
||||
|
||||
GameLeft.HSplitTop(Spacing, 0, &GameLeft);
|
||||
GameLeft.HSplitTop(ButtonHeight, &Button, &GameLeft);
|
||||
|
@ -1044,7 +1044,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
Client.HSplitTop(Spacing, 0, &Client);
|
||||
Client.HSplitTop(ButtonHeight, &Button, &Client);
|
||||
Button.VSplitLeft(ButtonHeight, 0, &Button);
|
||||
DoScrollbarOption(&g_Config.m_ClAutoDemoMax, &g_Config.m_ClAutoDemoMax, &Button, Localize("Max"), 100.0f, 0, 1000, true);
|
||||
DoScrollbarOption(&g_Config.m_ClAutoDemoMax, &g_Config.m_ClAutoDemoMax, &Button, Localize("Max"), 0, 1000, true);
|
||||
}
|
||||
|
||||
Client.HSplitTop(Spacing, 0, &Client);
|
||||
|
@ -1058,7 +1058,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
Client.HSplitTop(Spacing, 0, &Client);
|
||||
Client.HSplitTop(ButtonHeight, &Button, &Client);
|
||||
Button.VSplitLeft(ButtonHeight, 0, &Button);
|
||||
DoScrollbarOption(&g_Config.m_ClAutoScreenshotMax, &g_Config.m_ClAutoScreenshotMax, &Button, Localize("Max"), 100.0f, 0, 1000, true);
|
||||
DoScrollbarOption(&g_Config.m_ClAutoScreenshotMax, &g_Config.m_ClAutoScreenshotMax, &Button, Localize("Max"), 0, 1000, true);
|
||||
}
|
||||
|
||||
MainView.HSplitTop(10.0f, 0, &MainView);
|
||||
|
@ -1681,7 +1681,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
|||
ScreenRight.HSplitTop(Spacing, 0, &ScreenRight);
|
||||
ScreenRight.HSplitTop(ButtonHeight, &Button, &ScreenRight);
|
||||
DoScrollbarOption(&g_Config.m_GfxMaxFps, &g_Config.m_GfxMaxFps,
|
||||
&Button, Localize("Max fps"), 144.0f, 30, 300);
|
||||
&Button, Localize("Max fps"), 30, 300);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1690,7 +1690,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
|||
ScreenRight.HSplitTop(Spacing, 0, &ScreenRight);
|
||||
ScreenRight.HSplitTop(ButtonHeight, &Button, &ScreenRight);
|
||||
int Index = g_Config.m_GfxScreen;
|
||||
DoScrollbarOption(&g_Config.m_GfxScreen, &Index, &Button, Localize("Screen"), 110.0f, 0, Graphics()->GetNumScreens()-1);
|
||||
DoScrollbarOption(&g_Config.m_GfxScreen, &Index, &Button, Localize("Screen"), 0, Graphics()->GetNumScreens()-1);
|
||||
if(Index != g_Config.m_GfxScreen)
|
||||
Client()->SwitchWindowScreen(Index);
|
||||
}
|
||||
|
@ -1939,7 +1939,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
}
|
||||
|
||||
Right.HSplitTop(ButtonHeight, &Button, &Right);
|
||||
DoScrollbarOption(&g_Config.m_SndVolume, &g_Config.m_SndVolume, &Button, Localize("Volume"), 130.0f, 0, 100);
|
||||
DoScrollbarOption(&g_Config.m_SndVolume, &g_Config.m_SndVolume, &Button, Localize("Volume"), 0, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue