OpenTTD Source: src/error_gui.cpp Source File

OpenTTD Source 15.0-RC2

error_gui.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "stdafx.h"
11#include "core/geometry_func.hpp"
12#include "landscape.h"
13#include "newgrf_text.h"
14#include "error.h"
15#include "viewport_func.h"
16#include "gfx_func.h"
17#include "string_func.h"
18#include "company_base.h"
19#include "company_func.h"
20#include "company_manager_face.h"
21#include "strings_func.h"
22#include "zoom_func.h"
23#include "window_func.h"
24#include "console_func.h"
25#include "window_gui.h"
26#include "timer/timer.h"
27#include "timer/timer_window.h"
28
29#include "widgets/error_widget.h"
30
31#include "table/sprites.h"
32#include "table/strings.h"
33
34#include "safeguards.h"
35
36static constexpr std::initializer_list<NWidgetPart> _nested_errmsg_widgets = {
37 NWidget(NWID_HORIZONTAL),
38 NWidget(WWT_CLOSEBOX, COLOUR_RED),
39 NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetStringTip(STR_ERROR_MESSAGE_CAPTION),
40 EndContainer(),
41 NWidget(WWT_PANEL, COLOUR_RED),
42 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_EM_MESSAGE), SetPadding(WidgetDimensions::unscaled.modalpopup), SetFill(1, 0), SetMinimalSize(236, 0),
43 EndContainer(),
44};
45
46static WindowDesc _errmsg_desc(
47 WDP_MANUAL, {}, 0, 0,
48 WC_ERRMSG, WC_NONE,
49 {},
50 _nested_errmsg_widgets
51);
52
53static constexpr std::initializer_list<NWidgetPart> _nested_errmsg_face_widgets = {
54 NWidget(NWID_HORIZONTAL),
55 NWidget(WWT_CLOSEBOX, COLOUR_RED),
56 NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION),
57 EndContainer(),
58 NWidget(WWT_PANEL, COLOUR_RED),
59 NWidget(NWID_HORIZONTAL),
60 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_EM_FACE), SetPadding(2, 0, 2, 2), SetFill(0, 1), SetMinimalSize(92, 119),
61 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_EM_MESSAGE), SetPadding(WidgetDimensions::unscaled.modalpopup), SetFill(1, 1), SetMinimalSize(236, 0),
62 EndContainer(),
63 EndContainer(),
64};
65
66static WindowDesc _errmsg_face_desc(
67 WDP_MANUAL, {}, 0, 0,
68 WC_ERRMSG, WC_NONE,
69 {},
70 _nested_errmsg_face_widgets
71);
72
82ErrorMessageData::ErrorMessageData(EncodedString &&summary_msg, EncodedString &&detailed_msg, bool is_critical, int x, int y, EncodedString &&extra_msg, CompanyID company) :
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)),
87 position(x, y),
88 company(company)
89{
90 assert(!this->summary_msg.empty());
91}
92
94 static ErrorList _error_list;
96 bool _window_system_initialized = false;
97
99 struct ErrmsgWindow : public Window, ErrorMessageData {
100private:
101 uint height_summary = 0;
102 uint height_detailed = 0;
103 uint height_extra = 0;
104 TimeoutTimer<TimerWindow> display_timeout;
105
106public:
107 ErrmsgWindow(const ErrorMessageData &data) :
108 Window(data.HasFace() ? _errmsg_face_desc : _errmsg_desc),
109 ErrorMessageData(data),
110 display_timeout(std::chrono::seconds(_settings_client.gui.errmsg_duration), [this]() {
111 this->Close();
112 })
113 {
114 this->InitNested();
115
116 /* Only start the timeout if the message is not critical. */
117 if (!this->is_critical) {
118 this->display_timeout.Reset();
119 }
120 }
121
122 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
123 {
124 switch (widget) {
125 case WID_EM_MESSAGE: {
126 this->height_summary = GetStringHeight(this->summary_msg.GetDecodedString(), size.width);
127 this->height_detailed = (this->detailed_msg.empty()) ? 0 : GetStringHeight(this->detailed_msg.GetDecodedString(), size.width);
128 this->height_extra = (this->extra_msg.empty()) ? 0 : GetStringHeight(this->extra_msg.GetDecodedString(), size.width);
129
130 uint panel_height = this->height_summary;
131 if (!this->detailed_msg.empty()) panel_height += this->height_detailed + WidgetDimensions::scaled.vsep_wide;
132 if (!this->extra_msg.empty()) panel_height += this->height_extra + WidgetDimensions::scaled.vsep_wide;
133
134 size.height = std::max(size.height, panel_height);
135 break;
136 }
137 case WID_EM_FACE:
138 size = maxdim(size, GetScaledSpriteSize(SPR_GRADIENT));
139 break;
140 }
141 }
142
143 Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
144 {
145 /* Position (0, 0) given, center the window. */
146 if (this->position.x == 0 && this->position.y == 0) {
147 Point pt = {(_screen.width - sm_width) >> 1, (_screen.height - sm_height) >> 1};
148 return pt;
149 }
150
151 constexpr int distance_to_cursor = 200;
152
153 /* Position the error window just above the cursor. This makes the
154 * error window clearly visible, without being in the way of what
155 * the user is doing. */
156 Point pt;
157 pt.x = _cursor.pos.x - sm_width / 2;
158 pt.y = _cursor.pos.y - (distance_to_cursor + sm_height);
159
160 if (pt.y < GetMainViewTop()) {
161 /* Window didn't fit above cursor, so place it below. */
162 pt.y = _cursor.pos.y + distance_to_cursor;
163 }
164
165 return pt;
166 }
167
173 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
174 {
175 /* If company gets shut down, while displaying an error about it, remove the error message. */
176 if (this->company != CompanyID::Invalid() && !Company::IsValidID(this->company)) this->Close();
177 }
178
179 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
180 {
181 if (widget == WID_EM_CAPTION && this->company != CompanyID::Invalid()) return GetString(STR_ERROR_MESSAGE_CAPTION_OTHER_COMPANY, this->company);
182
183 return this->Window::GetWidgetString(widget, stringid);
184 }
185
186 void DrawWidget(const Rect &r, WidgetID widget) const override
187 {
188 switch (widget) {
189 case WID_EM_FACE: {
190 const Company *c = Company::Get(this->company);
191 DrawCompanyManagerFace(c->face, c->colour, r);
192 break;
193 }
194
195 case WID_EM_MESSAGE:
196 if (this->detailed_msg.empty()) {
197 DrawStringMultiLineWithClipping(r, this->summary_msg.GetDecodedString(), TC_FROMSTRING, SA_CENTER);
198 } else if (this->extra_msg.empty()) {
199 /* Extra space when message is shorter than company face window */
200 int extra = (r.Height() - this->height_summary - this->height_detailed - WidgetDimensions::scaled.vsep_wide) / 2;
201
202 /* Note: NewGRF supplied error message often do not start with a colour code, so default to white. */
203 DrawStringMultiLineWithClipping(r.WithHeight(this->height_summary + extra, false), this->summary_msg.GetDecodedString(), TC_WHITE, SA_CENTER);
204 DrawStringMultiLineWithClipping(r.WithHeight(this->height_detailed + extra, true), this->detailed_msg.GetDecodedString(), TC_WHITE, SA_CENTER);
205 } else {
206 /* Extra space when message is shorter than company face window */
207 int extra = (r.Height() - this->height_summary - this->height_detailed - this->height_extra - (WidgetDimensions::scaled.vsep_wide * 2)) / 3;
208
209 /* Note: NewGRF supplied error message often do not start with a colour code, so default to white. */
210 Rect top_section = r.WithHeight(this->height_summary + extra, false);
211 Rect bottom_section = r.WithHeight(this->height_extra + extra, true);
212 Rect middle_section = top_section.WithY(top_section.bottom, bottom_section.top);
213 DrawStringMultiLineWithClipping(top_section, this->summary_msg.GetDecodedString(), TC_WHITE, SA_CENTER);
214 DrawStringMultiLineWithClipping(middle_section, this->detailed_msg.GetDecodedString(), TC_WHITE, SA_CENTER);
215 DrawStringMultiLineWithClipping(bottom_section, this->extra_msg.GetDecodedString(), TC_WHITE, SA_CENTER);
216 }
217
218 break;
219
220 default:
221 break;
222 }
223 }
224
225 void OnMouseLoop() override
226 {
227 /* Disallow closing the window too easily, if timeout is disabled */
228 if (_right_button_down && !this->is_critical) this->Close();
229 }
230
231 void Close([[maybe_unused]] int data = 0) override
232 {
233 SetRedErrorSquare(INVALID_TILE);
234 if (_window_system_initialized) ShowFirstError();
235 this->Window::Close();
236 }
237
242 bool IsCritical()
243 {
244 return this->is_critical;
245 }
246};
247
251 void ClearErrorMessages()
252{
253 UnshowCriticalError();
254 _error_list.clear();
255}
256
258 void ShowFirstError()
259{
260 _window_system_initialized = true;
261 if (!_error_list.empty()) {
262 new ErrmsgWindow(_error_list.front());
263 _error_list.pop_front();
264 }
265}
266
272 void UnshowCriticalError()
273{
274 ErrmsgWindow *w = dynamic_cast<ErrmsgWindow *>(FindWindowById(WC_ERRMSG, 0));
275 if (_window_system_initialized && w != nullptr) {
276 if (w->IsCritical()) _error_list.push_front(*w);
277 _window_system_initialized = false;
278 w->Close();
279 }
280}
281
290 void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
291{
292 EncodedString error = std::move(cc.GetEncodedMessage());
293 if (error.empty()) error = GetEncodedStringIfValid(cc.GetErrorMessage());
294
295 ShowErrorMessage(std::move(summary_msg), std::move(error), WL_INFO, x, y,
296 GetEncodedStringIfValid(cc.GetExtraErrorMessage()), cc.GetErrorOwner());
297}
298
308 void ShowErrorMessage(EncodedString &&summary_msg, EncodedString &&detailed_msg, WarningLevel wl, int x, int y, EncodedString &&extra_msg, CompanyID company)
309{
310 if (wl != WL_INFO) {
311 /* Print message to console */
312
313 std::string message = summary_msg.GetDecodedString();
314 if (!detailed_msg.empty()) {
315 message += " ";
316 message += detailed_msg.GetDecodedString();
317 }
318 if (!extra_msg.empty()) {
319 message += " ";
320 message += extra_msg.GetDecodedString();
321 }
322
323 IConsolePrint(wl == WL_WARNING ? CC_WARNING : CC_ERROR, message);
324 }
325
326 bool is_critical = wl == WL_CRITICAL;
327
328 if (_game_mode == GM_BOOTSTRAP) return;
329 if (_settings_client.gui.errmsg_duration == 0 && !is_critical) return;
330
331 ErrorMessageData data(std::move(summary_msg), std::move(detailed_msg), is_critical, x, y, std::move(extra_msg), company);
332
333 ErrmsgWindow *w = dynamic_cast<ErrmsgWindow *>(FindWindowById(WC_ERRMSG, 0));
334 if (w != nullptr) {
335 if (w->IsCritical()) {
336 /* A critical error is currently shown. */
337 if (wl == WL_CRITICAL) {
338 /* Push another critical error in the queue of errors,
339 * but do not put other errors in the queue. */
340 _error_list.push_back(std::move(data));
341 }
342 return;
343 }
344 /* A non-critical error was shown. */
345 w->Close();
346 }
347 new ErrmsgWindow(data);
348}
349
350
355 bool HideActiveErrorMessage()
356{
357 ErrmsgWindow *w = dynamic_cast<ErrmsgWindow *>(FindWindowById(WC_ERRMSG, 0));
358 if (w == nullptr) return false;
359 w->Close();
360 return true;
361}
362
368 void ScheduleErrorMessage(ErrorList &datas)
369{
370 _error_list.splice(_error_list.end(), datas);
371}
372
378 void ScheduleErrorMessage(const ErrorMessageData &data)
379{
380 _error_list.push_back(data);
381}
CommandCost
Common return value for all commands.
Definition command_type.h:24
CommandCost::GetEncodedMessage
EncodedString & GetEncodedMessage()
Get the last encoded error message.
Definition command_type.h:81
CommandCost::GetErrorMessage
StringID GetErrorMessage() const
Returns the error message of a command.
Definition command_type.h:148
CommandCost::GetErrorOwner
CompanyID GetErrorOwner() const
Get the originator owner for this error.
Definition command_type.h:89
CommandCost::GetExtraErrorMessage
StringID GetExtraErrorMessage() const
Returns the extra error message of a command.
Definition command_type.h:158
EncodedString
Container for an encoded string, created by GetEncodedString.
Definition strings_type.h:98
EncodedString::GetDecodedString
std::string GetDecodedString() const
Decode the encoded string.
Definition strings.cpp:207
ErrorMessageData
The data of the error message.
Definition error.h:31
ErrorMessageData::ErrorMessageData
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.
Definition error_gui.cpp:82
ErrorMessageData::HasFace
bool HasFace() const
Check whether error window shall display a company manager face.
Definition error.h:44
ErrorMessageData::company
CompanyID company
Company belonging to the face being shown. CompanyID::Invalid() if no face present.
Definition error.h:38
ErrorMessageData::position
Point position
Position of the error message window.
Definition error.h:37
ErrorMessageData::detailed_msg
EncodedString detailed_msg
Detailed error message showed in second line. Can be INVALID_STRING_ID.
Definition error.h:35
ErrorMessageData::extra_msg
EncodedString extra_msg
Extra error message shown in third line. Can be INVALID_STRING_ID.
Definition error.h:36
ErrorMessageData::summary_msg
EncodedString summary_msg
General error message showed in first line. Must be valid.
Definition error.h:34
ErrorMessageData::is_critical
bool is_critical
Whether the error message is critical.
Definition error.h:33
TimeoutTimer
A timeout timer will fire once after the interval.
Definition timer.h:116
TimeoutTimer::Reset
void Reset()
Reset the timer, so it will fire again after the timeout.
Definition timer.h:140
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
WidgetDimensions::vsep_wide
int vsep_wide
Wide vertical spacing.
Definition window_gui.h:60
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
company_func.h
Functions related to companies.
DrawCompanyManagerFace
void DrawCompanyManagerFace(const CompanyManagerFace &cmf, Colours colour, const Rect &r)
Draws the face of a company manager's face.
Definition company_gui.cpp:1120
company_manager_face.h
Functionality related to the company manager's face.
IConsolePrint
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.
Definition console.cpp:90
console_func.h
Console functions used outside of the console code.
CC_WARNING
static const TextColour CC_WARNING
Colour for warning lines.
Definition console_type.h:25
CC_ERROR
static const TextColour CC_ERROR
Colour for error lines.
Definition console_type.h:24
error.h
Functions related to errors.
ErrorList
std::list< ErrorMessageData > ErrorList
Define a queue with errors.
Definition error.h:48
WarningLevel
WarningLevel
Message severity/type.
Definition error.h:23
WL_WARNING
@ WL_WARNING
Other information.
Definition error.h:25
WL_CRITICAL
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
Definition error.h:27
WL_INFO
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition error.h:24
_error_list
static ErrorList _error_list
The actual queue with errors.
Definition error_gui.cpp:94
UnshowCriticalError
void UnshowCriticalError()
Unshow the critical error.
Definition error_gui.cpp:272
ClearErrorMessages
void ClearErrorMessages()
Clear all errors from the queue.
Definition error_gui.cpp:251
ScheduleErrorMessage
void ScheduleErrorMessage(ErrorList &datas)
Schedule a list of errors.
Definition error_gui.cpp:368
_window_system_initialized
bool _window_system_initialized
Whether the window system is initialized or not.
Definition error_gui.cpp:96
HideActiveErrorMessage
bool HideActiveErrorMessage()
Close active error message window.
Definition error_gui.cpp:355
ShowErrorMessage
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
Definition error_gui.cpp:290
ShowFirstError
void ShowFirstError()
Show the first error of the queue.
Definition error_gui.cpp:258
error_widget.h
Types related to the error widgets.
WID_EM_CAPTION
@ WID_EM_CAPTION
Caption of the window.
Definition error_widget.h:15
WID_EM_MESSAGE
@ WID_EM_MESSAGE
Error message.
Definition error_widget.h:17
WID_EM_FACE
@ WID_EM_FACE
Error title.
Definition error_widget.h:16
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition geometry_func.cpp:22
geometry_func.hpp
Geometry functions.
GetStringHeight
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition gfx.cpp:712
DrawStringMultiLineWithClipping
bool DrawStringMultiLineWithClipping(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw a multiline string, possibly over multiple lines, if the region is within the current display cl...
Definition gfx.cpp:867
_right_button_down
bool _right_button_down
Is right mouse button pressed?
Definition gfx.cpp:43
gfx_func.h
Functions related to the gfx engine.
GetScaledSpriteSize
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
Definition widget.cpp:68
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition gfx_type.h:398
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition widget_type.h:1219
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1332
SetStringTip
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
Definition widget_type.h:1240
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition widget_type.h:1156
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1229
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1424
landscape.h
Functions related to OTTD's landscape.
newgrf_text.h
Header of Action 04 "universal holder" structure and functions.
safeguards.h
A number of safeguards to prevent using unsafe methods.
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
sprites.h
This file contains all sprite-related enums and defines.
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
string_func.h
Functions related to low-level strings.
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
strings_func.h
Functions related to OTTD's strings.
GetEncodedStringIfValid
static EncodedString GetEncodedStringIfValid(StringID str)
Encode a string with no parameters into an encoded string, if the string id is valid.
Definition strings_func.h:134
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition settings_type.h:650
CompanyProperties::colour
Colours colour
Company colour.
Definition company_base.h:89
CompanyProperties::face
CompanyManagerFace face
Face description of the president.
Definition company_base.h:82
Company
Definition company_base.h:127
Coord2D< int >
Coord2D::y
T y
Y coordinate.
Definition geometry_type.hpp:35
Coord2D::x
T x
X coordinate.
Definition geometry_type.hpp:34
CursorVars::pos
Point pos
logical mouse position
Definition gfx_type.h:125
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition geometry_type.hpp:56
ErrmsgWindow
Window class for displaying an error message window.
Definition error_gui.cpp:99
ErrmsgWindow::GetWidgetString
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
Definition error_gui.cpp:179
ErrmsgWindow::IsCritical
bool IsCritical()
Check whether the currently shown error message was critical or not.
Definition error_gui.cpp:242
ErrmsgWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition error_gui.cpp:173
ErrmsgWindow::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition error_gui.cpp:231
ErrmsgWindow::height_extra
uint height_extra
Height of the extra_msg string in pixels in the WID_EM_MESSAGE widget.
Definition error_gui.cpp:103
ErrmsgWindow::OnMouseLoop
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
Definition error_gui.cpp:225
ErrmsgWindow::OnInitialPosition
Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
Compute the initial position of the window.
Definition error_gui.cpp:143
ErrmsgWindow::height_detailed
uint height_detailed
Height of the detailed_msg string in pixels in the WID_EM_MESSAGE widget.
Definition error_gui.cpp:102
ErrmsgWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition error_gui.cpp:186
ErrmsgWindow::height_summary
uint height_summary
Height of the summary_msg string in pixels in the WID_EM_MESSAGE widget.
Definition error_gui.cpp:101
ErrmsgWindow::UpdateWidgetSize
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.
Definition error_gui.cpp:122
GUISettings::errmsg_duration
uint8_t errmsg_duration
duration of error message
Definition settings_type.h:174
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(auto index)
Returns Titem with given index.
Definition pool_type.hpp:387
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition pool_type.hpp:376
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:101
Rect::WithHeight
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Definition geometry_type.hpp:237
Rect::Height
int Height() const
Get height of Rect.
Definition geometry_type.hpp:117
Rect::WithY
Rect WithY(int new_top, int new_bottom) const
Create a new Rect, replacing the top and bottom coordiates.
Definition geometry_type.hpp:280
WindowDesc
High level window description.
Definition window_gui.h:168
Window
Data structure for an opened window.
Definition window_gui.h:274
Window::Close
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:1102
Window::GetWidgetString
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:504
Window::resize
ResizeInfo resize
Resize information.
Definition window_gui.h:315
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1820
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:303
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
timer.h
Definition of Interval and OneShot timers.
timer_window.h
Definition of the Window system.
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition viewport.cpp:2601
viewport_func.h
Functions related to (drawing on) viewports.
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
GetMainViewTop
int GetMainViewTop()
Return the top of the main view available for general use.
Definition window.cpp:2136
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition window.cpp:1151
window_func.h
Window functions not directly related to making/drawing windows.
window_gui.h
Functions, definitions and such used only by the GUI.
WDP_MANUAL
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition window_gui.h:143
WidgetID
int WidgetID
Widget ID.
Definition window_type.h:20
WC_ERRMSG
@ WC_ERRMSG
Error message; Window numbers:
Definition window_type.h:115
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:50
zoom_func.h
Functions related to zooming.