Update to OpenTTD 1.9.0-beta2

--HG--
branch : openttd
This commit is contained in:
Pavel Stupnikov
2019-02-13 15:17:23 +03:00
parent 42ec3bd611
commit 2bda8d4f34
1362 changed files with 22145 additions and 10644 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: statusbar_gui.cpp 27146 2015-02-13 21:13:45Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
@@ -26,6 +26,7 @@
#include "statusbar_gui.h"
#include "toolbar_gui.h"
#include "core/geometry_func.hpp"
#include "guitimer_func.h"
#include "widgets/statusbar_widget.h"
@@ -79,17 +80,19 @@ static bool DrawScrollingStatusText(const NewsItem *ni, int scroll_pos, int left
struct StatusBarWindow : Window {
bool saving;
int ticker_scroll;
int reminder_timeout;
GUITimer ticker_timer;
GUITimer reminder_timeout;
static const int TICKER_STOP = 1640; ///< scrolling is finished when counter reaches this value
static const int REMINDER_START = 91; ///< initial value of the reminder counter (right dot on the right)
static const int REMINDER_START = 1350; ///< time in ms for reminder notification (red dot on the right) to stay
static const int REMINDER_STOP = 0; ///< reminder disappears when counter reaches this value
static const int COUNTER_STEP = 2; ///< this is subtracted from active counters every tick
StatusBarWindow(WindowDesc *desc) : Window(desc)
{
this->ticker_scroll = TICKER_STOP;
this->reminder_timeout = REMINDER_STOP;
this->ticker_scroll = TICKER_STOP;
this->ticker_timer.SetInterval(15);
this->reminder_timeout.SetInterval(REMINDER_STOP);
this->InitNested();
CLRBITS(this->flags, WF_WHITE_BORDER);
@@ -179,7 +182,7 @@ struct StatusBarWindow : Window {
}
}
if (this->reminder_timeout > 0) {
if (!this->reminder_timeout.HasElapsed()) {
Dimension icon_size = GetSpriteSize(SPR_UNREAD_NEWS);
DrawSprite(SPR_UNREAD_NEWS, PAL_NONE, r.right - WD_FRAMERECT_RIGHT - icon_size.width, r.top + WD_FRAMERECT_TOP + (int)(FONT_HEIGHT_NORMAL - icon_size.height) / 2);
}
@@ -200,10 +203,10 @@ struct StatusBarWindow : Window {
case SBI_SAVELOAD_START: this->saving = true; break;
case SBI_SAVELOAD_FINISH: this->saving = false; break;
case SBI_SHOW_TICKER: this->ticker_scroll = 0; break;
case SBI_SHOW_REMINDER: this->reminder_timeout = REMINDER_START; break;
case SBI_SHOW_REMINDER: this->reminder_timeout.SetInterval(REMINDER_START); break;
case SBI_NEWS_DELETED:
this->ticker_scroll = TICKER_STOP; // reset ticker ...
this->reminder_timeout = REMINDER_STOP; // ... and reminder
this->reminder_timeout.SetInterval(REMINDER_STOP); // ... and reminder
break;
}
}
@@ -217,19 +220,20 @@ struct StatusBarWindow : Window {
}
}
virtual void OnTick()
virtual void OnRealtimeTick(uint delta_ms)
{
if (_pause_mode != PM_UNPAUSED) return;
if (this->ticker_scroll < TICKER_STOP) { // Scrolling text
this->ticker_scroll += COUNTER_STEP;
this->SetWidgetDirty(WID_S_MIDDLE);
uint count = this->ticker_timer.CountElapsed(delta_ms);
if (count > 0) {
this->ticker_scroll += count;
this->SetWidgetDirty(WID_S_MIDDLE);
}
}
if (this->reminder_timeout > REMINDER_STOP) { // Red blot to show there are new unread newsmessages
this->reminder_timeout -= COUNTER_STEP;
} else if (this->reminder_timeout < REMINDER_STOP) {
this->reminder_timeout = REMINDER_STOP;
// Red blot to show there are new unread newsmessages
if (this->reminder_timeout.Elapsed(delta_ms)) {
this->SetWidgetDirty(WID_S_MIDDLE);
}
}