Merge branch 'master' into jgrpp

This commit is contained in:
Jonathan G Rennison
2022-09-09 17:36:01 +01:00
3 changed files with 60 additions and 44 deletions

View File

@@ -266,6 +266,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)
@@ -277,8 +278,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] */
@@ -322,6 +321,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);
@@ -519,6 +523,18 @@ struct NewsWindow : Window {
}
}
void OnResize() override
{
if (this->viewport != nullptr) {
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_N_VIEWPORT);
nvp->UpdateViewportCoordinates(this);
if (ni->reftype1 != NR_VEHICLE) {
ScrollWindowToTile(GetReferenceTile(ni->reftype1, ni->ref1), this, true); // Re-center viewport.
}
}
}
/**
* Some data on this window has become invalid.
* @param data Information about the changed data.