diff --git a/ui/UISystem.cpp b/ui/UISystem.cpp index 2c18e5a3..0520b238 100644 --- a/ui/UISystem.cpp +++ b/ui/UISystem.cpp @@ -175,7 +175,7 @@ #define UI_MOUSE_HOTX 2 #define UI_MOUSE_HOTY 2 -#define UI_FRAMETIME 0.05 +constexpr int ui_FrameTimeMS = 50; ////////////////////////////////////////////////////////////////////////////// // VARIABLES struct tUIWindowNode { @@ -502,9 +502,9 @@ int ui_DoFrame(bool input) { ui_DoWindowFocus(); // determine window with current input focus. res = ui_ProcessFocusedWindow(); // process focused window - // int64_t cur_time = timer_GetMSTime(); - while ((timer_GetTime() - UI_input.cur_time) < UI_FRAMETIME) { - }; + const float elapsedTimeS = timer_GetTime() - UI_input.cur_time; + const int waitTimeMS = ui_FrameTimeMS - static_cast(elapsedTimeS * 1000.0f); + D3::ChronoTimer::SleepMS(waitTimeMS); float temp_time = timer_GetTime(); UIFrameTime = temp_time - UI_input.cur_time;