From b18d72db1fc59a8ad733b134bf2ee6c9c92bc7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Mon, 26 Oct 2020 17:47:26 +0300 Subject: [PATCH] using time_get_mircoseconds and storing it as int64 val --- src/game/client/components/menus.cpp | 16 ++++++---------- src/game/client/ui.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 7b87b576c..3c21bc2d6 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -218,15 +218,14 @@ void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked, int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, int AlignVertically) { - int Time = 0; bool MouseInside = UI()->MouseInside(pRect); CUIRect Rect = *pRect; if(pAnimator != NULL) { - Time = time(); + int64 Time = time_get_microseconds(); - if(pAnimator->m_Time + 1000000.f < Time) + if(pAnimator->m_Time + 100000 < Time) { pAnimator->m_Value = pAnimator->m_Active ? 1 : 0; pAnimator->m_Time = Time; @@ -235,9 +234,9 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co pAnimator->m_Active = Checked || MouseInside; if(pAnimator->m_Active) - pAnimator->m_Value = clamp(pAnimator->m_Value + (Time - pAnimator->m_Time) / 1000000.f, 0, 1); + pAnimator->m_Value = clamp(pAnimator->m_Value + (Time - pAnimator->m_Time) / 100000.f, 0, 1); else - pAnimator->m_Value = clamp(pAnimator->m_Value - (Time - pAnimator->m_Time) / 1000000.f, 0, 1); + pAnimator->m_Value = clamp(pAnimator->m_Value - (Time - pAnimator->m_Time) / 100000.f, 0, 1); Rect.w += pAnimator->m_Value * pAnimator->m_WOffset; Rect.h += pAnimator->m_Value * pAnimator->m_HOffset; @@ -290,12 +289,9 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co Rect.w = pRect->w; Rect.h = pRect->h; } - - Rect.HMargin(2.0f, &Temp); } - else - pRect->HMargin(2.0f, &Temp); - + + Rect.HMargin(2.0f, &Temp); UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0, -1, AlignVertically); return UI()->DoButtonLogic(pID, pText, Checked, pRect); diff --git a/src/game/client/ui.h b/src/game/client/ui.h index 6dc159b26..7b8887272 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -103,7 +103,7 @@ struct SUIAnimator bool m_ScaleLabel; bool m_RepositionLabel; - float m_Time; + long long m_Time; float m_Value; float m_XOffset;