32 #include "table/strings.h" 37 static bool DrawScrollingStatusText(
const NewsItem *ni,
int scroll_pos,
int left,
int right,
int top,
int bottom)
43 GetString(buf, str,
lastof(buf));
48 const char *last =
lastof(buffer);
51 WChar c = Utf8Consume(&s);
54 }
else if (c ==
'\n') {
55 if (d + 4 >= last)
break;
56 d[0] = d[1] = d[2] = d[3] =
' ';
58 }
else if (IsPrintable(c)) {
93 this->ticker_timer.SetInterval(15);
94 this->reminder_timeout.SetInterval(REMINDER_STOP);
103 Point pt = { 0, _screen.height - sm_height };
122 int64 max_money = UINT32_MAX;
133 d.width += padding.width;
134 d.height += padding.height;
165 }
else if (this->ticker_scroll < TICKER_STOP && _statusbar_news_item != nullptr && _statusbar_news_item->string_id != 0) {
183 if (!this->reminder_timeout.HasElapsed()) {
198 if (!gui_scope)
return;
200 default: NOT_REACHED();
204 case SBI_SHOW_REMINDER: this->reminder_timeout.SetInterval(REMINDER_START);
break;
207 this->reminder_timeout.SetInterval(REMINDER_STOP);
225 if (this->ticker_scroll < TICKER_STOP) {
228 this->ticker_scroll += count;
234 if (this->reminder_timeout.
Elapsed(delta_ms)) {
240 static const NWidgetPart _nested_main_status_widgets[] = {
252 _nested_main_status_widgets,
lengthof(_nested_main_status_widgets)
Functions related to OTTD's strings.
Definition of stuff that is very close to a company, like the company struct itself.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static const int DAYS_IN_YEAR
days per year
Data about how and where to blit pixels.
Horizontally center the text.
ResizeInfo resize
Resize information.
static const int REMINDER_START
time in ms for reminder notification (red dot on the right) to stay
High level window description.
uint CountElapsed(uint delta)
Count how many times the interval has elapsed.
WindowFlags flags
Window flags.
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
Functions related to dates.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Offset at top to draw the frame rectangular area.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
bool Elapsed(uint delta)
Test if a timer has elapsed.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
void CopyInDParam(int offs, const uint64 *src, int num)
Copy num string parameters from array src into the global string parameter array. ...
uint64 params[10]
Parameters for string resolving.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
#define lastof(x)
Get the last element of an fixed size array.
#define CLRBITS(x, y)
Clears several bits in a variable.
Functions, definitions and such used only by the GUI.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Force the alignment, i.e. don't swap for RTL languages.
Data structure for an opened window.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
int PositionStatusbar(Window *w)
(Re)position statusbar window at the screen.
Functions related to low-level strings.
Functions/types related to saving and loading games.
StringID string_id
Message text.
The client is spectating.
GUI functions related to the news.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Functions related to the gfx engine.
abort current news display (active news were deleted)
static const int COUNTER_STEP
this is subtracted from active counters every tick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
show a reminder (dot on the right side of the statusbar)
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
GUI Functions related to companies.
static int8 Utf8CharLen(WChar c)
Return the length of a UTF-8 encoded character.
void ShowLastNewsMessage()
Show previous news item.
Money money
Money owned by the company.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
#define lengthof(x)
Return the length of an fixed size array.
PauseMode _pause_mode
The current pause mode.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
Functions related to companies.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
Compute the initial position of the window.
TextDirection _current_text_dir
Text direction of the currently selected language.
This window won't get focus/make any other window lose focus when click.
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Functions related to zooming.
Statusbar (at the bottom of your screen); Window numbers:
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
bool IsNewsTickerShown()
Checks whether the news ticker is currently being used.
static const int REMINDER_STOP
reminder disappears when counter reaches this value
size_t Utf8Encode(char *buf, WChar c)
Encode a unicode character and place it in the buffer.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
Offset at right to draw the frame rectangular area.
void ShowStatusBar()
Show our status bar.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Specification of a rectangle with absolute coordinates of all edges.
Text is written right-to-left by default.
WindowNumber window_number
Window number within the window class.
Functions related to tile highlights.
Window functions not directly related to making/drawing windows.
Manually align the window (so no automatic location finding)
Functions related to news.
Functions, definitions and such used only by the GUI.
Date _date
Current date in days (day counter)
uint32 WChar
Type for wide characters, i.e.
Window white border counter bit mask.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date...
bool _do_autosave
are we doing an autosave at the moment?
This file contains all sprite-related enums and defines.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Information about a single item of news.
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
static const int TICKER_STOP
scrolling is finished when counter reaches this value
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.