mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 22:18:19 +00:00
Merge pull request #8188 from Robyt3/UI-DoScrollbarOption-Bool-Result
Let `CUi::DoScrollbarOption` return `true` if value changed
This commit is contained in:
commit
e63c9481e0
|
@ -2620,18 +2620,14 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
|
|||
GameClient()->m_Chat.RebuildChat();
|
||||
|
||||
LeftView.HSplitTop(2 * LineSize, &Button, &LeftView);
|
||||
int PrevFontSize = g_Config.m_ClChatFontSize;
|
||||
Ui()->DoScrollbarOption(&g_Config.m_ClChatFontSize, &g_Config.m_ClChatFontSize, &Button, Localize("Chat font size"), 10, 100, &CUi::ms_LinearScrollbarScale, CUi::SCROLLBAR_OPTION_MULTILINE);
|
||||
if(PrevFontSize != g_Config.m_ClChatFontSize)
|
||||
if(Ui()->DoScrollbarOption(&g_Config.m_ClChatFontSize, &g_Config.m_ClChatFontSize, &Button, Localize("Chat font size"), 10, 100, &CUi::ms_LinearScrollbarScale, CUi::SCROLLBAR_OPTION_MULTILINE))
|
||||
{
|
||||
Chat.EnsureCoherentWidth();
|
||||
Chat.RebuildChat();
|
||||
}
|
||||
|
||||
LeftView.HSplitTop(2 * LineSize, &Button, &LeftView);
|
||||
int PrevWidth = g_Config.m_ClChatWidth;
|
||||
Ui()->DoScrollbarOption(&g_Config.m_ClChatWidth, &g_Config.m_ClChatWidth, &Button, Localize("Chat width"), 120, 400, &CUi::ms_LinearScrollbarScale, CUi::SCROLLBAR_OPTION_MULTILINE);
|
||||
if(PrevWidth != g_Config.m_ClChatWidth)
|
||||
if(Ui()->DoScrollbarOption(&g_Config.m_ClChatWidth, &g_Config.m_ClChatWidth, &Button, Localize("Chat width"), 120, 400, &CUi::ms_LinearScrollbarScale, CUi::SCROLLBAR_OPTION_MULTILINE))
|
||||
{
|
||||
Chat.EnsureCoherentFontSize();
|
||||
Chat.RebuildChat();
|
||||
|
@ -3258,10 +3254,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
|
|||
|
||||
if(g_Config.m_ClTextEntities)
|
||||
{
|
||||
int PreviousSize = g_Config.m_ClTextEntitiesSize;
|
||||
Ui()->DoScrollbarOption(&g_Config.m_ClTextEntitiesSize, &g_Config.m_ClTextEntitiesSize, &Button, Localize("Size"), 0, 100);
|
||||
|
||||
if(PreviousSize != g_Config.m_ClTextEntitiesSize)
|
||||
if(Ui()->DoScrollbarOption(&g_Config.m_ClTextEntitiesSize, &g_Config.m_ClTextEntitiesSize, &Button, Localize("Size"), 0, 100))
|
||||
m_pClient->m_MapImages.SetTextureScale(g_Config.m_ClTextEntitiesSize);
|
||||
}
|
||||
|
||||
|
@ -3290,9 +3283,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
|
|||
GameClient()->m_Tooltips.DoToolTip(&g_Config.m_ClShowQuads, &Button, Localize("Quads are used for background decoration"));
|
||||
|
||||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
int PreviousZoom = g_Config.m_ClDefaultZoom;
|
||||
Ui()->DoScrollbarOption(&g_Config.m_ClDefaultZoom, &g_Config.m_ClDefaultZoom, &Button, Localize("Default zoom"), 0, 20);
|
||||
if(PreviousZoom != g_Config.m_ClDefaultZoom)
|
||||
if(Ui()->DoScrollbarOption(&g_Config.m_ClDefaultZoom, &g_Config.m_ClDefaultZoom, &Button, Localize("Default zoom"), 0, 20))
|
||||
m_pClient->m_Camera.SetZoom(std::pow(CCamera::ZOOM_STEP, g_Config.m_ClDefaultZoom - 10), g_Config.m_ClSmoothZoomTime);
|
||||
|
||||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
|
|
|
@ -1286,7 +1286,7 @@ float CUi::DoScrollbarH(const void *pId, const CUIRect *pRect, float Current, co
|
|||
return ReturnValue;
|
||||
}
|
||||
|
||||
void CUi::DoScrollbarOption(const void *pId, int *pOption, const CUIRect *pRect, const char *pStr, int Min, int Max, const IScrollbarScale *pScale, unsigned Flags, const char *pSuffix)
|
||||
bool CUi::DoScrollbarOption(const void *pId, int *pOption, const CUIRect *pRect, const char *pStr, int Min, int Max, const IScrollbarScale *pScale, unsigned Flags, const char *pSuffix)
|
||||
{
|
||||
const bool Infinite = Flags & CUi::SCROLLBAR_OPTION_INFINITE;
|
||||
const bool NoClampValue = Flags & CUi::SCROLLBAR_OPTION_NOCLAMPVALUE;
|
||||
|
@ -1332,7 +1332,12 @@ void CUi::DoScrollbarOption(const void *pId, int *pOption, const CUIRect *pRect,
|
|||
Value = 0;
|
||||
}
|
||||
|
||||
*pOption = Value;
|
||||
if(*pOption != Value)
|
||||
{
|
||||
*pOption = Value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CUi::RenderProgressSpinner(vec2 Center, float OuterRadius, const SProgressSpinnerProperties &Props) const
|
||||
|
|
|
@ -574,7 +574,7 @@ public:
|
|||
};
|
||||
float DoScrollbarV(const void *pId, const CUIRect *pRect, float Current);
|
||||
float DoScrollbarH(const void *pId, const CUIRect *pRect, float Current, const ColorRGBA *pColorInner = nullptr);
|
||||
void DoScrollbarOption(const void *pId, int *pOption, const CUIRect *pRect, const char *pStr, int Min, int Max, const IScrollbarScale *pScale = &ms_LinearScrollbarScale, unsigned Flags = 0u, const char *pSuffix = "");
|
||||
bool DoScrollbarOption(const void *pId, int *pOption, const CUIRect *pRect, const char *pStr, int Min, int Max, const IScrollbarScale *pScale = &ms_LinearScrollbarScale, unsigned Flags = 0u, const char *pSuffix = "");
|
||||
|
||||
// progress spinner
|
||||
void RenderProgressSpinner(vec2 Center, float OuterRadius, const SProgressSpinnerProperties &Props = {}) const;
|
||||
|
|
Loading…
Reference in a new issue