OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
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);
103 Point pt = { 0, _screen.height - sm_height };
122 int64 max_money = UINT32_MAX;
133 d.width += padding.width;
134 d.height += padding.height;
140 int text_offset = std::max(0, ((
int)(r.bottom - r.top + 1) -
FONT_HEIGHT_NORMAL) / 2);
141 int text_top = r.top + text_offset;
172 }
else if (this->ticker_scroll < TICKER_STOP && _statusbar_news_item != nullptr && _statusbar_news_item->string_id != 0) {
190 if (!this->reminder_timeout.HasElapsed()) {
192 DrawSprite(SPR_UNREAD_NEWS, PAL_NONE, r.right -
WD_FRAMERECT_RIGHT - icon_size.width, r.top + std::max(0, ((
int)(r.bottom - r.top + 1) - (
int)icon_size.height) / 2));
205 if (!gui_scope)
return;
207 default: NOT_REACHED();
235 this->ticker_scroll += count;
241 if (this->reminder_timeout.
Elapsed(delta_ms)) {
247 static const NWidgetPart _nested_main_status_widgets[] = {
259 _nested_main_status_widgets,
lengthof(_nested_main_status_widgets)
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
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-...
void OnRealtimeTick(uint delta_ms) override
Called periodically.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
char32_t WChar
Type for wide characters, i.e.
Dimensions (a width and height) of a rectangle in 2D.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Information about a single item of news.
static int8 Utf8CharLen(WChar c)
Return the length of a UTF-8 encoded character.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
bool _do_autosave
are we doing an autosave at the moment?
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
size_t Utf8Encode(T buf, WChar c)
Encode a unicode character and place it in the buffer.
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.
Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
Compute the initial position of the window.
@ SA_VERT_CENTER
Vertically center the text.
bool IsNewsTickerShown()
Checks whether the news ticker is currently being used.
static const int REMINDER_STOP
reminder disappears 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.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
@ PM_UNPAUSED
A normal unpaused game.
High level window description.
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.
int PositionStatusbar(Window *w)
(Re)position statusbar window at the screen.
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
ResizeInfo resize
Resize information.
Date _date
Current date in days (day counter)
@ SBI_SAVELOAD_FINISH
finished saving
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
@ WF_WHITE_BORDER
Window white border counter bit mask.
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
@ SBI_NEWS_DELETED
abort current news display (active news were deleted)
Money money
Money owned by the company.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
PauseMode _pause_mode
The current pause mode.
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
WindowFlags flags
Window flags.
static const int REMINDER_START
time in ms for reminder notification (red dot on the right) to stay
static const int TICKER_STOP
scrolling is finished when counter reaches this value
StringID string_id
Message text.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Coordinates of a point in 2D.
@ SBI_SAVELOAD_START
started saving
WindowNumber window_number
Window number within the window class.
@ SBI_SHOW_REMINDER
show a reminder (dot on the right side of the statusbar)
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ SA_HOR_CENTER
Horizontally center the text.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
@ COMPANY_SPECTATOR
The client is spectating.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
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.
void ShowLastNewsMessage()
Show previous news item.
static const int DAYS_IN_YEAR
days per year
uint CountElapsed(uint delta)
Count how many times the interval has elapsed.
@ PM_PAUSED_LINK_GRAPH
A game paused due to the link graph schedule lagging.
bool Elapsed(uint delta)
Test if a timer has elapsed.
@ SA_LEFT
Left align the text.
#define lengthof(x)
Return the length of an fixed size array.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
uint64 params[10]
Parameters for string resolving.
Data structure for an opened window.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
static const int COUNTER_STEP
this is subtracted from active counters every tick
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Specification of a rectangle with absolute coordinates of all edges.
#define CLRBITS(x, y)
Clears several bits in a variable.
#define lastof(x)
Get the last element of an fixed size array.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void ShowStatusBar()
Show our status bar.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
@ SBI_SHOW_TICKER
start scrolling news
void CopyInDParam(int offs, const uint64 *src, int num)
Copy num string parameters from array src into the global string parameter array.
Data about how and where to blit pixels.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
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,...