Merge branch 'save_ext' into jgrpp
# Conflicts: # config.lib # src/misc_gui.cpp # src/network/network_gui.cpp # src/settings_type.h # src/smallmap_gui.cpp # src/smallmap_gui.h # src/station_cmd.cpp # src/toolbar_gui.cpp # src/vehicle_gui.cpp # src/window.cpp
This commit is contained in:
@@ -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);
|
||||
@@ -180,7 +183,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);
|
||||
}
|
||||
@@ -201,10 +204,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;
|
||||
}
|
||||
}
|
||||
@@ -218,7 +221,7 @@ struct StatusBarWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnTick()
|
||||
virtual void OnRealtimeTick(uint delta_ms)
|
||||
{
|
||||
if (_pause_mode != PM_UNPAUSED) return;
|
||||
|
||||
@@ -227,14 +230,15 @@ struct StatusBarWindow : Window {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user