|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
34 #include "table/strings.h"
39 static bool DrawScrollingStatusText(
const NewsItem *ni,
int scroll_pos,
int left,
int right,
int top,
int bottom)
75 Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]]
int window_number)
override
77 Point pt = { 0, _screen.height - sm_height };
81 void FindWindowPlacementAndResize([[maybe_unused]]
int def_width, [[maybe_unused]]
int def_height)
override
96 int64_t max_money = UINT32_MAX;
107 d.width += padding.width;
108 d.height += padding.height;
112 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
148 }
else if (this->ticker_scroll < TICKER_STOP && _statusbar_news_item != nullptr && _statusbar_news_item->string_id != 0) {
150 if (!DrawScrollingStatusText(_statusbar_news_item,
ScaleGUITrad(this->ticker_scroll), tr.left, tr.right, tr.top, tr.bottom)) {
166 if (!this->reminder_timeout.
HasFired()) {
168 DrawSprite(SPR_UNREAD_NEWS, PAL_NONE, tr.right - icon_size.width,
CenterBounds(r.top, r.bottom, icon_size.height));
179 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
181 if (!gui_scope)
return;
183 default: NOT_REACHED();
190 this->reminder_timeout.
Abort();
195 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
209 this->ticker_scroll += count;
223 static constexpr
NWidgetPart _nested_main_status_widgets[] = {
231 static WindowDesc _main_status_desc(__FILE__, __LINE__,
235 std::begin(_nested_main_status_widgets), std::end(_nested_main_status_widgets)
static constexpr auto REMINDER_START
time in ms for reminder notification (red dot on the right) to stay
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 CopyInDParam(const std::span< const StringParameterBackup > backup)
Copy the parameters from the backup into the global string parameter array.
Dimensions (a width and height) of a rectangle in 2D.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Information about a single item of news.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
std::vector< StringParameterBackup > params
Parameters for string resolving.
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.
DifficultySettings difficulty
settings related to the difficulty
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.
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.
@ SA_VERT_CENTER
Vertically center the text.
bool IsNewsTickerShown()
Checks whether the news ticker is currently being used.
bool HasFired() const
Check whether the timeout occurred.
@ PM_UNPAUSED
A normal unpaused game.
High level window description.
void Reset()
Reset the timer, so it will fire again after the timeout.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
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.
@ SBI_SAVELOAD_FINISH
finished saving
@ FS_NORMAL
Index of the normal font in the font tables.
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.
@ SBI_NEWS_DELETED
abort current news display (active news were deleted)
Money money
Money owned by the company.
PauseMode _pause_mode
The current pause mode.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ 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 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.
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,...
@ WDF_NO_CLOSE
This window can't be interactively closed.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
@ 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.
IntervalTimer< TimerWindow > ticker_scroll_interval
Move information on the ticker slowly from one side to the other.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static constexpr Date DateAtStartOfYear(Year year)
Calculate the date of the first day of a given year.
bool infinite_money
whether spending money despite negative balance is allowed
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 OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
@ COMPANY_SPECTATOR
The client is spectating.
void ShowLastNewsMessage()
Show previous news item.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
@ PM_PAUSED_LINK_GRAPH
A game paused due to the link graph schedule lagging.
@ SA_LEFT
Left align the text.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
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.
static Date date
Current date in days (day counter).
Data structure for an opened window.
@ SVS_REPLACE_TAB_CR_NL_WITH_SPACE
Replace tabs ('\t'), carriage returns ('\r') and newlines (' ') with spaces.
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
Specification of a rectangle with absolute coordinates of all edges.
#define CLRBITS(x, y)
Clears several bits in a variable.
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.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
@ SBI_SHOW_TICKER
start scrolling news
Data about how and where to blit pixels.
void Abort()
Abort the timer so it doesn't fire if it hasn't yet.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.