From 05f2b193915fc754d738ef8b6bf47db0f20ea816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 18 May 2023 12:17:15 +0200 Subject: [PATCH 1/5] Remove unused `SLabelProperties Props` variable --- src/game/client/components/menus.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 495349085..436f672ca 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -910,14 +910,10 @@ void CMenus::RenderLoading(const char *pCaption, const char *pContent, int Incre Box.HSplitTop(20.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box); Part.VMargin(20.f, &Part); - SLabelProperties Props; - Props.m_MaxWidth = (int)Part.w; UI()->DoLabel(&Part, pCaption, 24.f, TEXTALIGN_MC); Box.HSplitTop(20.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box); Part.VMargin(20.f, &Part); - - Props.m_MaxWidth = (int)Part.w; UI()->DoLabel(&Part, pContent, 20.0f, TEXTALIGN_MC); if(RenderLoadingBar) From af67130dbdf6360c07364953f493fa11459b1158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 18 May 2023 12:18:22 +0200 Subject: [PATCH 2/5] Use `nullptr` for unused UI rect splitting parameters --- src/game/client/components/menus.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 436f672ca..6f97e91a2 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -906,12 +906,12 @@ void CMenus::RenderLoading(const char *pCaption, const char *pContent, int Incre Box.Draw(ColorRGBA{0, 0, 0, 0.50f}, IGraphics::CORNER_ALL, 15.0f); CUIRect Part; - - Box.HSplitTop(20.f, &Part, &Box); + Box.HSplitTop(20.f, nullptr, &Box); Box.HSplitTop(24.f, &Part, &Box); Part.VMargin(20.f, &Part); UI()->DoLabel(&Part, pCaption, 24.f, TEXTALIGN_MC); - Box.HSplitTop(20.f, &Part, &Box); + + Box.HSplitTop(20.f, nullptr, &Box); Box.HSplitTop(24.f, &Part, &Box); Part.VMargin(20.f, &Part); UI()->DoLabel(&Part, pContent, 20.0f, TEXTALIGN_MC); From f60dd0d3c26b8aceebdb3016f55fc83317d21302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 18 May 2023 12:19:10 +0200 Subject: [PATCH 3/5] Fix name of static variable `s_LastLoadRender` --- src/game/client/components/menus.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 6f97e91a2..2cae5e2fc 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -872,17 +872,17 @@ void CMenus::RenderLoading(const char *pCaption, const char *pContent, int Incre { // TODO: not supported right now due to separate render thread - static std::chrono::nanoseconds LastLoadRender{0}; + static std::chrono::nanoseconds s_LastLoadRender{0}; auto CurLoadRenderCount = m_LoadCurrent; m_LoadCurrent += IncreaseCounter; float Percent = CurLoadRenderCount / (float)m_LoadTotal; // make sure that we don't render for each little thing we load // because that will slow down loading if we have vsync - if(time_get_nanoseconds() - LastLoadRender < std::chrono::nanoseconds(1s) / 60l) + if(time_get_nanoseconds() - s_LastLoadRender < std::chrono::nanoseconds(1s) / 60l) return; - LastLoadRender = time_get_nanoseconds(); + s_LastLoadRender = time_get_nanoseconds(); // need up date this here to get correct ms_GuiColor = color_cast(ColorHSLA(g_Config.m_UiColor, true)); From fe359e290937aab4e3b53b87f96b3f9cf261cd56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 18 May 2023 12:20:53 +0200 Subject: [PATCH 4/5] Combine `Margin` function calls Both calls put a margin around the same rect but the intermediate result is never used, so both margins can be combined. The variable `Screen` is also not necessary. --- src/game/client/components/menus.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 2cae5e2fc..2ce21c7f7 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -887,9 +887,6 @@ void CMenus::RenderLoading(const char *pCaption, const char *pContent, int Incre // need up date this here to get correct ms_GuiColor = color_cast(ColorHSLA(g_Config.m_UiColor, true)); - CUIRect Screen = *UI()->Screen(); - // some margin around the screen - Screen.Margin(10.0f, &Screen); UI()->MapScreen(); if(!RenderMenuBackgroundMap || !m_pBackground->Render()) @@ -897,8 +894,8 @@ void CMenus::RenderLoading(const char *pCaption, const char *pContent, int Incre RenderBackground(); } - CUIRect Box = Screen; - Box.Margin(150.0f, &Box); + CUIRect Box = *UI()->Screen(); + Box.Margin(160.0f, &Box); Graphics()->BlendNormal(); From 13ed0e386a67181512c704c5a08f680b84be330f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 18 May 2023 12:21:34 +0200 Subject: [PATCH 5/5] Use `const` when possible --- src/game/client/components/menus.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 2ce21c7f7..9c43eae3d 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -873,9 +873,9 @@ void CMenus::RenderLoading(const char *pCaption, const char *pContent, int Incre // TODO: not supported right now due to separate render thread static std::chrono::nanoseconds s_LastLoadRender{0}; - auto CurLoadRenderCount = m_LoadCurrent; + const int CurLoadRenderCount = m_LoadCurrent; m_LoadCurrent += IncreaseCounter; - float Percent = CurLoadRenderCount / (float)m_LoadTotal; + const float Percent = CurLoadRenderCount / (float)m_LoadTotal; // make sure that we don't render for each little thing we load // because that will slow down loading if we have vsync