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/misc_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/misc_gui.cpp')
-rw-r--r-- | src/misc_gui.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index b122d172d..31faae2d4 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -454,15 +454,16 @@ static const char * const _credits[] = { struct AboutWindow : public Window { int text_position; ///< The top of the scrolling text - byte counter; ///< Used to scroll the text every 5 ticks int line_height; ///< The height of a single line static const int num_visible_lines = 19; ///< The number of lines visible simultaneously + static const uint TIMER_INTERVAL = 150; ///< Scrolling interval in ms + uint timer; + AboutWindow() : Window(&_about_desc) { this->InitNested(WN_GAME_OPTIONS_ABOUT); - this->counter = 5; this->text_position = this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->current_y; } @@ -502,11 +503,11 @@ struct AboutWindow : public Window { } } - virtual void OnTick() + virtual void OnRealtimeTick(uint delta_ms) { - if (--this->counter == 0) { - this->counter = 5; - this->text_position--; + uint count = CountIntervalElapsed(this->timer, delta_ms, TIMER_INTERVAL); + if (count > 0) { + this->text_position -= count; /* If the last text has scrolled start a new from the start */ if (this->text_position < (int)(this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y - lengthof(_credits) * this->line_height)) { this->text_position = this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->current_y; |