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)) {
101 Point pt = { 0, _screen.height - sm_height };
120 int64 max_money = UINT32_MAX;
122 FOR_ALL_COMPANIES(c) max_money = max<int64>(c->
money, max_money);
132 d.width += padding.width;
133 d.height += padding.height;
182 if (this->reminder_timeout > 0) {
197 if (!gui_scope)
return;
199 default: NOT_REACHED();
224 if (this->ticker_scroll < TICKER_STOP) {
229 if (this->reminder_timeout > REMINDER_STOP) {
231 }
else if (this->reminder_timeout < REMINDER_STOP) {
238 static const NWidgetPart _nested_main_status_widgets[] = {
250 _nested_main_status_widgets,
lengthof(_nested_main_status_widgets)
Functions related to OTTD's strings.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
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
initial value of the reminder counter (right dot on the right)
High level window description.
WindowFlags flags
Window flags.
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.
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.
#define lastof(x)
Get the last element of an fixed size array.
The client is spectating.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
#define CLRBITS(x, y)
Clears several bits in a variable.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
virtual void OnTick()
Called once per (game) tick.
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.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
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.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
Functions related to low-level strings.
Functions/types related to saving and loading games.
StringID string_id
Message text.
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
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)
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.
PauseModeByte _pause_mode
The current pause mode.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
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.
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.
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-NULL) 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.
virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
Compute the initial position of the window.
Date _date
Current date in days (day counter)
uint32 WChar
Type for wide characters, i.e.
Window white border counter bit mask.
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.
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-...
News window; Window numbers:
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.