Change: Split up Window::OnTick into OnGameTick and OnRealtimeTick. Adjust timers to work with milliseconds instead of ticks.

This commit is contained in:
Peter Nelson
2018-05-04 21:29:22 +01:00
committed by PeterN
parent 916e911806
commit 2a8fa5fef9
21 changed files with 144 additions and 64 deletions

View File

@@ -3074,14 +3074,33 @@ void InputLoop()
HandleAutoscroll();
}
/**
* Dispatch OnRealtimeTick event over all windows
*/
void CallWindowRealtimeTickEvent(uint delta_ms)
{
Window *w;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
w->OnRealtimeTick(delta_ms);
}
}
/**
* Update the continuously changing contents of the windows, such as the viewports
*/
void UpdateWindows()
{
static uint32 last_realtime_tick = _realtime_tick;
uint delta_ms = _realtime_tick - last_realtime_tick;
last_realtime_tick = _realtime_tick;
if (delta_ms == 0) return;
PerformanceMeasurer framerate(PFE_DRAWING);
PerformanceAccumulator::Reset(PFE_DRAWWORLD);
CallWindowRealtimeTickEvent(delta_ms);
Window *w;
static int highlight_timer = 1;
@@ -3263,13 +3282,13 @@ void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
}
/**
* Dispatch WE_TICK event over all windows
* Dispatch OnTick event over all windows
*/
void CallWindowTickEvent()
void CallWindowGameTickEvent()
{
Window *w;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
w->OnTick();
w->OnGameTick();
}
}