34#include "table/strings.h"
39static bool DrawScrollingStatusText(
const NewsItem *ni,
int scroll_pos,
int left,
int right,
int top,
int bottom)
107 d.width += padding.width;
108 d.height += padding.height;
166 if (!this->reminder_timeout.
HasFired()) {
183 default: NOT_REACHED();
190 this->reminder_timeout.
Abort();
209 this->ticker_scroll += count;
223static constexpr NWidgetPart _nested_main_status_widgets[] = {
235 _nested_main_status_widgets
Class for backupping variables and making sure they are restored later.
#define CLRBITS(x, y)
Clears several bits in a variable.
An interval timer will fire every interval, and will continue to fire until it is deleted.
A timeout timer will fire once after the interval.
void Reset()
Reset the timer, so it will fire again after the timeout.
bool HasFired() const
Check whether the timeout occurred.
void Abort()
Abort the timer so it doesn't fire if it hasn't yet.
static Date date
Current date in days (day counter).
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
static constexpr Date DateAtStartOfYear(Year year)
Calculate the date of the first day of a given year.
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
GUI Functions related to companies.
@ COMPANY_SPECTATOR
The client is spectating.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
PauseMode _pause_mode
The current pause mode.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Functions related to the gfx engine.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
@ SA_LEFT
Left align the text.
@ SA_HOR_CENTER
Horizontally center the text.
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
@ SA_VERT_CENTER
Vertically center the text.
@ FS_NORMAL
Index of the normal font in the font tables.
Functions related to news.
const NewsItem * GetStatusbarNews()
Get pointer to the current status bar news item.
void ShowLastNewsMessage()
Show previous news item.
GUI functions related to the news.
@ PM_UNPAUSED
A normal unpaused game.
@ PM_PAUSED_LINK_GRAPH
A game paused due to the link graph schedule lagging.
A number of safeguards to prevent using unsafe methods.
bool _do_autosave
are we doing an autosave at the moment?
Functions/types related to saving and loading games.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
This file contains all sprite-related enums and defines.
void ShowStatusBar()
Show our status bar.
bool IsNewsTickerShown()
Checks whether the news ticker is currently being used.
Functions, definitions and such used only by the GUI.
@ SBI_SHOW_REMINDER
show a reminder (dot on the right side of the statusbar)
@ SBI_SAVELOAD_FINISH
finished saving
@ SBI_SHOW_TICKER
start scrolling news
@ SBI_SAVELOAD_START
started saving
@ SBI_NEWS_DELETED
abort current news display (active news were deleted)
Definition of base types and functions in a cross-platform compatible way.
static void StrMakeValid(T &dst, const char *str, const char *last, StringValidationSettings settings)
Copies the valid (UTF-8) characters from str up to last to the dst.
Functions related to low-level strings.
@ SVS_REPLACE_TAB_CR_NL_WITH_SPACE
Replace tabs ('\t'), carriage returns ('\r') and newlines (' ') with spaces.
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
void CopyInDParam(const std::span< const StringParameterData > backup)
Copy the parameters from the backup into the global string parameter array.
TextDirection _current_text_dir
Text direction of the currently selected language.
Functions related to OTTD's strings.
@ TD_RTL
Text is written right-to-left by default.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Money money
Money owned by the company.
bool infinite_money
whether spending money despite negative balance is allowed
Dimensions (a width and height) of a rectangle in 2D.
Data about how and where to blit pixels.
DifficultySettings difficulty
settings related to the difficulty
Information about a single item of news.
std::vector< StringParameterData > params
Parameters for string resolving.
StringID string_id
Message text.
Coordinates of a point in 2D.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Specification of a rectangle with absolute coordinates of all edges.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
IntervalTimer< TimerWindow > ticker_scroll_interval
Move information on the ticker slowly from one side to the other.
static const int TICKER_STOP
scrolling is finished when counter reaches this value
Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
Compute the initial position of the window.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static const int COUNTER_STEP
this is subtracted from active counters every tick
static constexpr auto REMINDER_START
time in ms for reminder notification (red dot on the right) to stay
High level window description.
Data structure for an opened window.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
ResizeInfo resize
Resize information.
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
WindowFlags flags
Window flags.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
WindowNumber window_number
Window number within the window class.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
Definition of the Window system.
int PositionStatusbar(Window *w)
(Re)position statusbar window at the screen.
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-...
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ WF_WHITE_BORDER
Window white border counter bit mask.
@ WDF_NO_CLOSE
This window can't be interactively closed.
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Functions related to zooming.