diff options
author | Peter Nelson <peter1138@openttd.org> | 2021-04-10 12:40:56 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-04-10 22:36:30 +0200 |
commit | 59b6e46bcee466532e7dae3a272079ecdafa0ae1 (patch) | |
tree | 9d53c9f93e7836462123846741ef6ba045dbcdc3 | |
parent | 39b7ef31f8754a7e9d535d3b061a2e167ccd1338 (diff) | |
download | openttd-59b6e46bcee466532e7dae3a272079ecdafa0ae1.tar.xz |
Fix: Adjust scrolling interval of credits to account for text line height
-rw-r--r-- | src/misc_gui.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 2f538f2af..8ca94b2c3 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -497,7 +497,7 @@ struct AboutWindow : public Window { 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 + static const uint TIMER_INTERVAL = 2100; ///< Scrolling interval, scaled by line text line height. This value chosen to maintain parity: 2100 / FONT_HEIGHT_NORMAL = 150ms GUITimer timer; AboutWindow() : Window(&_about_desc) @@ -505,7 +505,6 @@ struct AboutWindow : public Window { this->InitNested(WN_GAME_OPTIONS_ABOUT); this->text_position = this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->current_y; - this->timer.SetInterval(TIMER_INTERVAL); } void SetStringParameters(int widget) const override @@ -528,6 +527,10 @@ struct AboutWindow : public Window { d.width = std::max(d.width, GetStringBoundingBox(_credits[i]).width); } *size = maxdim(*size, d); + + /* Set scroll interval based on required speed. To keep scrolling smooth, + * the interval is adjusted rather than the distance moved. */ + this->timer.SetInterval(TIMER_INTERVAL / FONT_HEIGHT_NORMAL); } void DrawWidget(const Rect &r, int widget) const override |