diff options
author | Peter Nelson <peter1138@openttd.org> | 2018-05-04 21:29:22 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-01-11 11:56:21 +0000 |
commit | 2a8fa5fef9021bff67a13899832bf6f0a18e6ea1 (patch) | |
tree | c712f1973d6c74938e968f752a069b499dde7266 /src/toolbar_gui.cpp | |
parent | 916e911806083a2fe06a79f6f10e275015079149 (diff) | |
download | openttd-2a8fa5fef9021bff67a13899832bf6f0a18e6ea1.tar.xz |
Change: Split up Window::OnTick into OnGameTick and OnRealtimeTick. Adjust timers to work with milliseconds instead of ticks.
Diffstat (limited to 'src/toolbar_gui.cpp')
-rw-r--r-- | src/toolbar_gui.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 40ac3634f..4f0f14011 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1978,6 +1978,8 @@ enum MainToolbarHotkeys { /** Main toolbar. */ struct MainToolbarWindow : Window { + int timer; + MainToolbarWindow(WindowDesc *desc) : Window(desc) { this->InitNested(0); @@ -1988,6 +1990,8 @@ struct MainToolbarWindow : Window { this->SetWidgetDisabledState(WID_TN_FAST_FORWARD, _networking); // if networking, disable fast-forward button PositionMainToolbar(this); DoZoomInOutWindow(ZOOM_NONE, this); + + this->timer = MILLISECONDS_PER_TICK; } virtual void FindWindowPlacementAndResize(int def_width, int def_height) @@ -2092,8 +2096,11 @@ struct MainToolbarWindow : Window { _last_started_action = CBF_NONE; } - virtual void OnTick() + virtual void OnRealtimeTick(uint delta_ms) { + if (!TimerElapsed(this->timer, delta_ms)) return; + this->timer = MILLISECONDS_PER_TICK; + if (this->IsWidgetLowered(WID_TN_PAUSE) != !!_pause_mode) { this->ToggleWidgetLoweredState(WID_TN_PAUSE); this->SetWidgetDirty(WID_TN_PAUSE); @@ -2310,6 +2317,8 @@ enum MainToolbarEditorHotkeys { }; struct ScenarioEditorToolbarWindow : Window { + int timer; + ScenarioEditorToolbarWindow(WindowDesc *desc) : Window(desc) { this->InitNested(0); @@ -2318,6 +2327,8 @@ struct ScenarioEditorToolbarWindow : Window { CLRBITS(this->flags, WF_WHITE_BORDER); PositionMainToolbar(this); DoZoomInOutWindow(ZOOM_NONE, this); + + this->timer = MILLISECONDS_PER_TICK; } virtual void FindWindowPlacementAndResize(int def_width, int def_height) @@ -2445,8 +2456,11 @@ struct ScenarioEditorToolbarWindow : Window { this->SetWidgetDirty(WID_TE_DATE_FORWARD); } - virtual void OnTick() + virtual void OnRealtimeTick(uint delta_ms) { + if (!TimerElapsed(this->timer, delta_ms)) return; + this->timer = MILLISECONDS_PER_TICK; + if (this->IsWidgetLowered(WID_TE_PAUSE) != !!_pause_mode) { this->ToggleWidgetLoweredState(WID_TE_PAUSE); this->SetDirty(); |