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, INVALID_COLOUR,
WID_EM_FACE),
SetPadding(2, 0, 2, 2),
SetFill(0, 1),
SetMinimalSize(92, 119),
70 _nested_errmsg_face_widgets
83 is_critical(is_critical),
84 summary_msg(std::move(summary_msg)),
85 detailed_msg(std::move(detailed_msg)),
86 extra_msg(std::move(extra_msg)),
118 this->display_timeout.
Reset();
313 std::string message = summary_msg.GetDecodedString();
314 if (!detailed_msg.empty()) {
316 message += detailed_msg.GetDecodedString();
318 if (!extra_msg.empty()) {
320 message += extra_msg.GetDecodedString();
328 if (_game_mode == GM_BOOTSTRAP)
return;
331 ErrorMessageData data(std::move(summary_msg), std::move(detailed_msg), is_critical, x, y, std::move(extra_msg), company);
358 if (w ==
nullptr)
return false;
Common return value for all commands.
static EncodedString & GetEncodedMessage()
Get the last encoded error message.
StringID GetErrorMessage() const
Returns the error message of a command.
CompanyID GetErrorOwner() const
Get the originator owner for this error.
StringID GetExtraErrorMessage() const
Returns the extra error message of a command.
Container for an encoded string, created by GetEncodedString.
std::string GetDecodedString() const
Decode the encoded string.
The data of the error message.
ErrorMessageData(EncodedString &&summary_msg, EncodedString &&detailed_msg, bool is_critical=false, int x=0, int y=0, EncodedString &&extra_msg={}, CompanyID company=CompanyID::Invalid())
Display an error message in a window.
bool HasFace() const
Check whether error window shall display a company manager face.
CompanyID company
Company belonging to the face being shown. CompanyID::Invalid() if no face present.
Point position
Position of the error message window.
EncodedString detailed_msg
Detailed error message showed in second line. Can be INVALID_STRING_ID.
EncodedString extra_msg
Extra error message shown in third line. Can be INVALID_STRING_ID.
EncodedString 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.
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.
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 ShowFirstError()
Show the first error of the queue.
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, const CommandCost &cc)
Display an error message in a window.
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.
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.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Functions related to OTTD's strings.
static EncodedString GetEncodedStringIfValid(StringID str)
Encode a string with no parameters into an encoded string, if the string id is valid.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
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.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
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 UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
uint8_t errmsg_duration
duration of error message
Coordinates of a point in 2D.
static Titem * Get(auto index)
Returns Titem with given index.
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
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.
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
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.