From 35483177e818d3915601327a004a6c59a0112790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Fri, 8 Jul 2022 18:12:50 +0200 Subject: [PATCH 1/3] Use else-if instead of duplicating condition --- src/game/client/components/menus_browser.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index f89685c37..7d4a25894 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -285,8 +285,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) r.Margin(0.5f, &r); RenderTools()->DrawUIElRect(*pItem->m_pUIElement->Get(0), &r, ColorRGBA(1, 1, 1, 0.5f), CUI::CORNER_ALL, 4.0f); } - - if(!Selected && UI()->MouseHovered(&Row)) + else if(UI()->MouseHovered(&Row)) { CUIRect r = Row; r.Margin(0.5f, &r); From fb1919b9be02d0556f99bfd572889561d0f6eb93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Fri, 8 Jul 2022 18:33:33 +0200 Subject: [PATCH 2/3] Fix spaces around documentation comments in `tooltip.h` --- src/game/client/components/tooltips.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/game/client/components/tooltips.h b/src/game/client/components/tooltips.h index f789262d2..15b00b6c4 100644 --- a/src/game/client/components/tooltips.h +++ b/src/game/client/components/tooltips.h @@ -18,7 +18,7 @@ struct CTooltip /** * A component that manages and renders UI tooltips. - * + * * Should be among the last components to render. */ class CTooltips : public CComponent @@ -28,10 +28,10 @@ class CTooltips : public CComponent int64_t HoverTime; /** - * The passed tooltip is only actually set if there is no currently active tooltip. - * - * @param Tooltip A reference to the tooltip that should be active. - */ + * The passed tooltip is only actually set if there is no currently active tooltip. + * + * @param Tooltip A reference to the tooltip that should be active. + */ void SetActiveTooltip(CTooltip &Tooltip); inline void ClearActiveTooltip(); @@ -42,9 +42,9 @@ public: /** * Adds the tooltip to a cache and renders it when active. - * - * On the first call to this function, the data passed is cached, afterwards the calls are used to detect if the tooltip should be activated. - * + * + * On the first call to this function, the data passed is cached, afterwards the calls are used to detect if the tooltip should be activated. + * * For now only works correctly with single line tooltips, since Text width calculation gets broken when there are multiple lines. * * @param pID The ID of the tooltip. Usually a reference to some g_Config value. From 0d29e6fe3f765526b7c4f0893338355b86d39d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 10 Jul 2022 15:33:23 +0200 Subject: [PATCH 3/3] Rename variable `HoverTime` -> `m_HoverTime` --- src/game/client/components/tooltips.cpp | 6 +++--- src/game/client/components/tooltips.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/client/components/tooltips.cpp b/src/game/client/components/tooltips.cpp index ababd2dcf..b33af1714 100644 --- a/src/game/client/components/tooltips.cpp +++ b/src/game/client/components/tooltips.cpp @@ -9,7 +9,7 @@ CTooltips::CTooltips() void CTooltips::OnReset() { - HoverTime = -1; + m_HoverTime = -1; m_Tooltips.clear(); } @@ -19,7 +19,7 @@ void CTooltips::SetActiveTooltip(CTooltip &Tooltip) return; m_ActiveTooltip.emplace(Tooltip); - HoverTime = time_get(); + m_HoverTime = time_get(); } inline void CTooltips::ClearActiveTooltip() @@ -68,7 +68,7 @@ void CTooltips::OnRender() return; // Delay tooltip until 1 second passed. - if(HoverTime > time_get() - time_freq()) + if(m_HoverTime > time_get() - time_freq()) return; const float MARGIN = 5.0f; diff --git a/src/game/client/components/tooltips.h b/src/game/client/components/tooltips.h index 15b00b6c4..400eb5f5c 100644 --- a/src/game/client/components/tooltips.h +++ b/src/game/client/components/tooltips.h @@ -25,7 +25,7 @@ class CTooltips : public CComponent { std::unordered_map m_Tooltips; std::optional> m_ActiveTooltip; - int64_t HoverTime; + int64_t m_HoverTime; /** * The passed tooltip is only actually set if there is no currently active tooltip.