32#include "table/strings.h"
36static constexpr NWidgetPart _nested_errmsg_widgets[] = {
50 _nested_errmsg_widgets
53static constexpr NWidgetPart _nested_errmsg_face_widgets[] = {
60 NWidget(
WWT_EMPTY, COLOUR_RED,
WID_EM_FACE),
SetPadding(2, 0, 2, 2),
SetFill(0, 1),
SetMinimalSize(92, 119),
70 _nested_errmsg_face_widgets
78 is_critical(data.is_critical), params(data.params), textref_stack_grffile(data.textref_stack_grffile), textref_stack_size(data.textref_stack_size),
79 summary_msg(data.summary_msg), detailed_msg(data.detailed_msg), extra_msg(data.extra_msg), position(data.position), face(data.face)
97 is_critical(is_critical),
98 textref_stack_grffile(textref_stack_grffile),
99 textref_stack_size(textref_stack_size),
100 summary_msg(summary_msg),
101 detailed_msg(detailed_msg),
102 extra_msg(extra_msg),
137 if (n >= this->
params.size()) this->
params.resize(n + 1);
148 if (n >= this->
params.size()) this->
params.resize(n + 1);
159 if (n >= this->
params.size()) this->
params.resize(n + 1);
188 this->display_timeout.
Reset();
386 assert(textref_stack_size == 0 || (textref_stack_grffile !=
nullptr && textref_stack !=
nullptr));
387 if (summary_msg == STR_NULL) summary_msg = STR_EMPTY;
392 if (textref_stack_size > 0)
StartTextRefStackUsage(textref_stack_grffile, textref_stack_size, textref_stack);
394 std::string message =
GetString(summary_msg);
411 if (_game_mode == GM_BOOTSTRAP)
return;
414 ErrorMessageData data(summary_msg, detailed_msg, is_critical, x, y, textref_stack_grffile, textref_stack_size, textref_stack, extra_msg);
442 if (w ==
nullptr)
return false;
Common return value for all commands.
uint GetTextRefStackSize() const
Returns the number of uint32_t values for the TextRefStack of the error message.
const uint32_t * GetTextRefStack() const
Returns a pointer to the values for the TextRefStack of the error message.
const GRFFile * GetTextRefStackGRF() const
Returns the NewGRF providing the TextRefStack of the error message.
StringID GetErrorMessage() const
Returns the error message of a command.
StringID GetExtraErrorMessage() const
Returns the extra error message of a command.
The data of the error message.
StringID extra_msg
Extra error message shown in third line. Can be INVALID_STRING_ID.
bool HasFace() const
Check whether error window shall display a company manager face.
CompanyID face
Company belonging to the face being shown. INVALID_COMPANY if no face present.
uint textref_stack_size
Number of uint32_t values to put on the TextRefStack for the error message.
void CopyOutDParams()
Copy error parameters from current DParams.
Point position
Position of the error message window.
const GRFFile * textref_stack_grffile
NewGRF that filled the TextRefStack for the error message.
void SetDParam(uint n, uint64_t v)
Set a error string parameter.
ErrorMessageData(const ErrorMessageData &data)
Copy the given data into our instance.
void SetDParamStr(uint n, const char *str)
Set a rawstring parameter.
uint32_t textref_stack[16]
Values to put on the TextRefStack for the error message.
StringID detailed_msg
Detailed error message showed in second line. Can be INVALID_STRING_ID.
std::vector< StringParameterData > params
Backup of parameters of the message strings.
StringID summary_msg
General error message showed in first line. Must be valid.
bool is_critical
Whether the error message is critical.
A timeout timer will fire once after the interval.
void Reset()
Reset the timer, so it will fire again after the timeout.
Definition of stuff that is very close to a company, like the company struct itself.
Functions related to companies.
static const int OWNED_BY_OWNER_IN_PARAMETERS_OFFSET
The index in the parameters for the owner information.
void DrawCompanyManagerFace(CompanyManagerFace cmf, Colours colour, const Rect &r)
Draws the face of a company manager's face.
Functionality related to the company manager's face.
Owner
Enum for all companies/owners.
@ INVALID_COMPANY
An invalid company.
@ MAX_COMPANIES
Maximum number of companies.
void IConsolePrint(TextColour colour_code, const std::string &string)
Handle the printing of text entered into the console or redirected there by any other means.
Console functions used outside of the console code.
static const TextColour CC_WARNING
Colour for warning lines.
static const TextColour CC_ERROR
Colour for error lines.
Functions related to errors.
std::list< ErrorMessageData > ErrorList
Define a queue with errors.
WarningLevel
Message severity/type.
@ WL_WARNING
Other information.
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
static ErrorList _error_list
The actual queue with errors.
void UnshowCriticalError()
Unshow the critical error.
void ClearErrorMessages()
Clear all errors from the queue.
void ScheduleErrorMessage(ErrorList &datas)
Schedule a list of errors.
bool _window_system_initialized
Whether the window system is initialized or not.
bool HideActiveErrorMessage()
Close active error message window.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
void ShowFirstError()
Show the first error of the queue.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
bool _right_button_down
Is right mouse button pressed?
Functions related to the gfx engine.
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
@ SA_CENTER
Center both horizontally and vertically.
Functions related to OTTD's landscape.
Functions related to memory operations.
void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
void StartTextRefStackUsage(const GRFFile *grffile, uint8_t numEntries, const uint32_t *values)
Start using the TTDP compatible string code parsing.
void StopTextRefStackUsage()
Stop using the TTDP compatible string code parsing.
Header of Action 04 "universal holder" structure and functions.
A number of safeguards to prevent using unsafe methods.
ClientSettings _settings_client
The current settings for this game.
Definition of base types and functions in a cross-platform compatible way.
Functions related to low-level strings.
void AppendStringInPlace(std::string &result, StringID string)
Resolve the given StringID and append in place into an existing std::string with all the associated D...
uint64_t GetDParam(size_t n)
Get the current string parameter at index n from 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 CopyOutDParam(std::vector< StringParameterData > &backup, size_t num)
Copy num string parameters from the global string parameter array to the backup.
void CopyInDParam(const std::span< const StringParameterData > backup)
Copy the parameters from the backup into the global string parameter array.
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
GUISettings gui
settings related to the GUI
Colours colour
Company colour.
CompanyManagerFace face
Face description of the president.
Point pos
logical mouse position
Dimensions (a width and height) of a rectangle in 2D.
Window class for displaying an error message window.
bool IsCritical()
Check whether the currently shown error message was critical or not.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
uint height_extra
Height of the extra_msg string in pixels in the WID_EM_MESSAGE widget.
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
Compute the initial position of the window.
uint height_detailed
Height of the detailed_msg string in pixels in the WID_EM_MESSAGE widget.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
uint height_summary
Height of the summary_msg string in pixels in the WID_EM_MESSAGE widget.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
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.
Dynamic data of a loaded NewGRF.
uint8_t errmsg_duration
duration of error message
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 Titem * Get(size_t index)
Returns Titem with given index.
Specification of a rectangle with absolute coordinates of all edges.
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
int Height() const
Get height of Rect.
High level window description.
Data structure for an opened window.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
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.
WindowNumber window_number
Window number within the window class.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition of Interval and OneShot timers.
Definition of the Window system.
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Functions related to (drawing on) viewports.
int GetMainViewTop()
Return the top of the main view available for general use.
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.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
@ WC_ERRMSG
Error message; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Functions related to zooming.