|
@@ -70,28 +70,29 @@ static bool DrawScrollingStatusText(cons
|
|
|
|
|
|
DrawPixelInfo *old_dpi = _cur_dpi;
|
|
|
_cur_dpi = &tmp_dpi;
|
|
|
DrawString(pos, INT16_MAX, 0, buffer, TC_LIGHT_BLUE, SA_LEFT | SA_FORCE);
|
|
|
_cur_dpi = old_dpi;
|
|
|
|
|
|
return (_current_text_dir == TD_RTL) ? (pos < right - left) : (pos + width > 0);
|
|
|
}
|
|
|
|
|
|
struct StatusBarWindow : Window {
|
|
|
bool saving;
|
|
|
int ticker_scroll;
|
|
|
uint ticker_timer;
|
|
|
int 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->InitNested();
|
|
|
CLRBITS(this->flags, WF_WHITE_BORDER);
|
|
|
PositionStatusbar(this);
|
|
|
}
|
|
@@ -194,51 +195,53 @@ struct StatusBarWindow : Window {
|
|
|
*/
|
|
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
|
|
{
|
|
|
if (!gui_scope) return;
|
|
|
switch (data) {
|
|
|
default: NOT_REACHED();
|
|
|
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_NEWS_DELETED:
|
|
|
this->ticker_scroll = TICKER_STOP; // reset ticker ...
|
|
|
this->ticker_timer = 0;
|
|
|
this->reminder_timeout = REMINDER_STOP; // ... and reminder
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case WID_S_MIDDLE: ShowLastNewsMessage(); break;
|
|
|
case WID_S_RIGHT: if (_local_company != COMPANY_SPECTATOR) ShowCompanyFinances(_local_company); break;
|
|
|
default: ResetObjectToPlace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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 = CountIntervalElapsed(this->ticker_timer, delta_ms, 15);
|
|
|
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 (TimerElapsed(this->reminder_timeout, delta_ms)) {
|
|
|
this->SetWidgetDirty(WID_S_MIDDLE);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
static const NWidgetPart _nested_main_status_widgets[] = {
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_S_LEFT), SetMinimalSize(140, 12), EndContainer(),
|
|
|
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_MIDDLE), SetMinimalSize(40, 12), SetDataTip(0x0, STR_STATUSBAR_TOOLTIP_SHOW_LAST_NEWS), SetResize(1, 0),
|
|
|
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_RIGHT), SetMinimalSize(140, 12),
|
|
|
EndContainer(),
|
|
|
};
|