From 2d2a5dd9661f842b0399d367883e6bbf1f19cdca Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 6 Sep 2022 17:46:01 +0100 Subject: [PATCH] Fix: Change duration of news window scroll depending on GUI zoom. --- src/news_gui.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 03811a9abe..a4c4c14082 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -267,6 +267,7 @@ struct NewsWindow : Window { const NewsItem *ni; ///< News item to display. static int duration; ///< Remaining time for showing the current news message (may only be access while a news item is displayed). + static const uint TIMER_INTERVAL = 210; ///< Scrolling interval, scaled by line text line height. This value chosen to maintain the 15ms at normal zoom. GUITimer timer; NewsWindow(WindowDesc *desc, const NewsItem *ni) : Window(desc), ni(ni) @@ -278,8 +279,6 @@ struct NewsWindow : Window { this->flags |= WF_DISABLE_VP_SCROLL; - this->timer.SetInterval(15); - this->CreateNestedTree(); /* For company news with a face we have a separate headline in param[0] */ @@ -323,6 +322,11 @@ struct NewsWindow : Window { PositionNewsMessage(this); } + void OnInit() override + { + this->timer.SetInterval(TIMER_INTERVAL / FONT_HEIGHT_NORMAL); + } + void DrawNewsBorder(const Rect &r) const { GfxFillRect(r.left, r.top, r.right, r.bottom, PC_WHITE);