@@ -12,97 +12,97 @@
#include "string_func.h"
#include "strings_func.h"
#include "company_base.h"
#include "tilehighlight_func.h"
#include "news_gui.h"
#include "company_gui.h"
#include "window_gui.h"
#include "variables.h"
#include "window_func.h"
#include "statusbar_gui.h"
#include "table/strings.h"
#include "table/sprites.h"
static bool DrawScrollingStatusText(const NewsItem *ni, int pos, int width)
{
CopyInDParam(0, ni->params, lengthof(ni->params));
StringID str = ni->string_id;
char buf[512];
GetString(buf, str, lastof(buf));
const char *s = buf;
char buffer[256];
char *d = buffer;
const char *last = lastof(buffer);
for (;;) {
WChar c = Utf8Consume(&s);
if (c == 0) {
break;
} else if (c == '\n') {
if (d + 4 >= last) break;
d[0] = d[1] = d[2] = d[3] = ' ';
d += 4;
} else if (IsPrintable(c)) {
if (d + Utf8CharLen(c) >= last) break;
d += Utf8Encode(d, c);
}
*d = '\0';
DrawPixelInfo tmp_dpi;
if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, width, 11)) return true;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
int x = DrawString(pos, pos + width, 0, buffer, TC_LIGHT_BLUE);
int x = DrawString(pos, INT16_MAX, 0, buffer, TC_LIGHT_BLUE);
_cur_dpi = old_dpi;
return x > 0;
enum StatusbarWidget {
SBW_LEFT, ///< left part of the statusbar; date is shown there
SBW_MIDDLE, ///< middle part; current news or company name or *** SAVING *** or *** PAUSED ***
SBW_RIGHT, ///< right part; bank balance
};
struct StatusBarWindow : Window {
bool saving;
int ticker_scroll;
int reminder_timeout;
enum {
TICKER_START = 360, ///< initial value of the ticker counter (scrolling news)
TICKER_STOP = -1280, ///< scrolling is finished when counter reaches this value
REMINDER_START = 91, ///< initial value of the reminder counter (right dot on the right)
REMINDER_STOP = 0, ///< reminder disappears when counter reaches this value
COUNTER_STEP = 2, ///< this is subtracted from active counters every tick
StatusBarWindow(const WindowDesc *desc) : Window(desc)
CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
this->ticker_scroll = TICKER_STOP;
this->reminder_timeout = REMINDER_STOP;
this->FindWindowPlacementAndResize(desc);
virtual void OnPaint()
const Company *c = (_local_company == COMPANY_SPECTATOR) ? NULL : GetCompany(_local_company);
this->DrawWidgets();
SetDParam(0, _date);
DrawString(this->widget[SBW_LEFT].left + 1, this->widget[SBW_LEFT].right - 1, 1, (_pause_mode || _settings_client.gui.status_long_date) ? STR_DATE_LONG_WHITE : STR_DATE_SHORT_WHITE, TC_FROMSTRING, SA_CENTER);
if (c != NULL) {
/* Draw company money */
SetDParam(0, c->money);
DrawString(this->widget[SBW_RIGHT].left + 1, this->widget[SBW_RIGHT].right - 1, 1, STR_COMPANY_MONEY, TC_FROMSTRING, SA_CENTER);
/* Draw status bar */
Status change: