OpenTTD
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 <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "landscape.h"
12 #include "newgrf_text.h"
13 #include "error.h"
14 #include "viewport_func.h"
15 #include "gfx_func.h"
16 #include "string_func.h"
17 #include "company_base.h"
18 #include "company_manager_face.h"
19 #include "strings_func.h"
20 #include "zoom_func.h"
21 #include "window_func.h"
22 #include "console_func.h"
23 #include "window_gui.h"
24 
25 #include "widgets/error_widget.h"
26 
27 #include "table/strings.h"
28 #include <list>
29 
30 #include "safeguards.h"
31 
32 static const NWidgetPart _nested_errmsg_widgets[] = {
34  NWidget(WWT_CLOSEBOX, COLOUR_RED),
35  NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION, STR_NULL),
36  EndContainer(),
37  NWidget(WWT_PANEL, COLOUR_RED),
38  NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetPadding(0, 2, 0, 2), SetMinimalSize(236, 32),
39  EndContainer(),
40 };
41 
42 static WindowDesc _errmsg_desc(
43  WDP_MANUAL, "error", 0, 0,
45  0,
46  _nested_errmsg_widgets, lengthof(_nested_errmsg_widgets)
47 );
48 
49 static const NWidgetPart _nested_errmsg_face_widgets[] = {
51  NWidget(WWT_CLOSEBOX, COLOUR_RED),
52  NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION_OTHER_COMPANY, STR_NULL),
53  EndContainer(),
54  NWidget(WWT_PANEL, COLOUR_RED),
55  NWidget(NWID_HORIZONTAL), SetPIP(2, 1, 2),
56  NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_FACE), SetMinimalSize(92, 119), SetFill(0, 1), SetPadding(2, 0, 1, 0),
57  NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetFill(0, 1), SetMinimalSize(238, 123),
58  EndContainer(),
59  EndContainer(),
60 };
61 
62 static WindowDesc _errmsg_face_desc(
63  WDP_MANUAL, "error_face", 0, 0,
65  0,
66  _nested_errmsg_face_widgets, lengthof(_nested_errmsg_face_widgets)
67 );
68 
74  duration(data.duration), textref_stack_grffile(data.textref_stack_grffile), textref_stack_size(data.textref_stack_size),
75  summary_msg(data.summary_msg), detailed_msg(data.detailed_msg), position(data.position), face(data.face)
76 {
77  memcpy(this->textref_stack, data.textref_stack, sizeof(this->textref_stack));
78  memcpy(this->decode_params, data.decode_params, sizeof(this->decode_params));
79  memcpy(this->strings, data.strings, sizeof(this->strings));
80  for (size_t i = 0; i < lengthof(this->strings); i++) {
81  if (this->strings[i] != nullptr) {
82  this->strings[i] = stredup(this->strings[i]);
83  this->decode_params[i] = (size_t)this->strings[i];
84  }
85  }
86 }
87 
90 {
91  for (size_t i = 0; i < lengthof(this->strings); i++) free(this->strings[i]);
92 }
93 
106  duration(duration),
107  textref_stack_grffile(textref_stack_grffile),
108  textref_stack_size(textref_stack_size),
109  summary_msg(summary_msg),
110  detailed_msg(detailed_msg),
112 {
113  this->position.x = x;
114  this->position.y = y;
115 
116  memset(this->decode_params, 0, sizeof(this->decode_params));
117  memset(this->strings, 0, sizeof(this->strings));
118 
119  if (textref_stack_size > 0) MemCpyT(this->textref_stack, textref_stack, textref_stack_size);
120 
121  assert(summary_msg != INVALID_STRING_ID);
122 }
123 
128 {
129  /* Reset parameters */
130  for (size_t i = 0; i < lengthof(this->strings); i++) free(this->strings[i]);
131  memset(this->decode_params, 0, sizeof(this->decode_params));
132  memset(this->strings, 0, sizeof(this->strings));
133 
134  /* Get parameters using type information */
137  if (this->textref_stack_size > 0) StopTextRefStackUsage();
138 
139  if (this->detailed_msg == STR_ERROR_OWNED_BY) {
140  CompanyID company = (CompanyID)GetDParamX(this->decode_params, 2);
141  if (company < MAX_COMPANIES) face = company;
142  }
143 }
144 
150 void ErrorMessageData::SetDParam(uint n, uint64 v)
151 {
152  this->decode_params[n] = v;
153 }
154 
160 void ErrorMessageData::SetDParamStr(uint n, const char *str)
161 {
162  free(this->strings[n]);
163  this->strings[n] = stredup(str);
164 }
165 
167 typedef std::list<ErrorMessageData> ErrorList;
169 ErrorList _error_list;
172 
175 private:
178 
179 public:
180  ErrmsgWindow(const ErrorMessageData &data) : Window(data.HasFace() ? &_errmsg_face_desc : &_errmsg_desc), ErrorMessageData(data)
181  {
182  this->InitNested();
183  }
184 
185  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
186  {
187  switch (widget) {
188  case WID_EM_MESSAGE: {
191 
192  int text_width = max(0, (int)size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT);
193  this->height_summary = GetStringHeight(this->summary_msg, text_width);
194  this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, text_width);
195 
196  if (this->textref_stack_size > 0) StopTextRefStackUsage();
197 
198  uint panel_height = WD_FRAMERECT_TOP + this->height_summary + WD_FRAMERECT_BOTTOM;
199  if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WD_PAR_VSEP_WIDE;
200 
201  size->height = max(size->height, panel_height);
202  break;
203  }
204  case WID_EM_FACE: {
205  Dimension face_size = GetSpriteSize(SPR_GRADIENT);
206  size->width = max(size->width, face_size.width);
207  size->height = max(size->height, face_size.height);
208  break;
209  }
210  }
211  }
212 
213  Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
214  {
215  /* Position (0, 0) given, center the window. */
216  if (this->position.x == 0 && this->position.y == 0) {
217  Point pt = {(_screen.width - sm_width) >> 1, (_screen.height - sm_height) >> 1};
218  return pt;
219  }
220 
221  /* Find the free screen space between the main toolbar at the top, and the statusbar at the bottom.
222  * Add a fixed distance 20 to make it less cluttered.
223  */
224  int scr_top = GetMainViewTop() + 20;
225  int scr_bot = GetMainViewBottom() - 20;
226 
227  Point pt = RemapCoords(this->position.x, this->position.y, GetSlopePixelZOutsideMap(this->position.x, this->position.y));
229  if (this->face == INVALID_COMPANY) {
230  /* move x pos to opposite corner */
231  pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left;
232  pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - sm_width - 20 : 20; // Stay 20 pixels away from the edge of the screen.
233 
234  /* move y pos to opposite corner */
235  pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top;
236  pt.y = (pt.y < (_screen.height >> 1)) ? scr_bot - sm_height : scr_top;
237  } else {
238  pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (sm_width / 2), 0, _screen.width - sm_width);
239  pt.y = Clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (sm_height / 2), scr_top, scr_bot - sm_height);
240  }
241  return pt;
242  }
243 
249  void OnInvalidateData(int data = 0, bool gui_scope = true) override
250  {
251  /* If company gets shut down, while displaying an error about it, remove the error message. */
252  if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) delete this;
253  }
254 
255  void SetStringParameters(int widget) const override
256  {
257  if (widget == WID_EM_CAPTION) CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
258  }
259 
260  void DrawWidget(const Rect &r, int widget) const override
261  {
262  switch (widget) {
263  case WID_EM_FACE: {
264  const Company *c = Company::Get(this->face);
265  DrawCompanyManagerFace(c->face, c->colour, r.left, r.top);
266  break;
267  }
268 
269  case WID_EM_MESSAGE:
272 
273  if (this->detailed_msg == INVALID_STRING_ID) {
275  this->summary_msg, TC_FROMSTRING, SA_CENTER);
276  } else {
277  int extra = (r.bottom - r.top + 1 - this->height_summary - this->height_detailed - WD_PAR_VSEP_WIDE) / 2;
278 
279  /* Note: NewGRF supplied error message often do not start with a colour code, so default to white. */
280  int top = r.top + WD_FRAMERECT_TOP;
281  int bottom = top + this->height_summary + extra;
282  DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, top, bottom, this->summary_msg, TC_WHITE, SA_CENTER);
283 
284  bottom = r.bottom - WD_FRAMERECT_BOTTOM;
285  top = bottom - this->height_detailed - extra;
286  DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, top, bottom, this->detailed_msg, TC_WHITE, SA_CENTER);
287  }
288 
289  if (this->textref_stack_size > 0) StopTextRefStackUsage();
290  break;
291 
292  default:
293  break;
294  }
295  }
296 
297  void OnMouseLoop() override
298  {
299  /* Disallow closing the window too easily, if timeout is disabled */
300  if (_right_button_down && this->duration != 0) delete this;
301  }
302 
303  void OnHundredthTick() override
304  {
305  /* Timeout enabled? */
306  if (this->duration != 0) {
307  this->duration--;
308  if (this->duration == 0) delete this;
309  }
310  }
311 
312  ~ErrmsgWindow()
313  {
315  if (_window_system_initialized) ShowFirstError();
316  }
317 
318  EventState OnKeyPress(WChar key, uint16 keycode) override
319  {
320  if (keycode != WKC_SPACE) return ES_NOT_HANDLED;
321  delete this;
322  return ES_HANDLED;
323  }
324 
329  bool IsCritical()
330  {
331  return this->duration == 0;
332  }
333 };
334 
339 {
341  _error_list.clear();
342 }
343 
346 {
347  _window_system_initialized = true;
348  if (!_error_list.empty()) {
349  new ErrmsgWindow(_error_list.front());
350  _error_list.pop_front();
351  }
352 }
353 
360 {
362  if (_window_system_initialized && w != nullptr) {
363  if (w->IsCritical()) _error_list.push_front(*w);
364  _window_system_initialized = false;
365  delete w;
366  }
367 }
368 
381 {
382  assert(textref_stack_size == 0 || (textref_stack_grffile != nullptr && textref_stack != nullptr));
383  if (summary_msg == STR_NULL) summary_msg = STR_EMPTY;
384 
385  if (wl != WL_INFO) {
386  /* Print message to console */
387  char buf[DRAW_STRING_BUFFER];
388 
389  if (textref_stack_size > 0) StartTextRefStackUsage(textref_stack_grffile, textref_stack_size, textref_stack);
390 
391  char *b = GetString(buf, summary_msg, lastof(buf));
392  if (detailed_msg != INVALID_STRING_ID) {
393  b += seprintf(b, lastof(buf), " ");
394  GetString(b, detailed_msg, lastof(buf));
395  }
396 
397  if (textref_stack_size > 0) StopTextRefStackUsage();
398 
399  switch (wl) {
400  case WL_WARNING: IConsolePrint(CC_WARNING, buf); break;
401  default: IConsoleError(buf); break;
402  }
403  }
404 
405  bool no_timeout = wl == WL_CRITICAL;
406 
407  if (_settings_client.gui.errmsg_duration == 0 && !no_timeout) return;
408 
409  ErrorMessageData data(summary_msg, detailed_msg, no_timeout ? 0 : _settings_client.gui.errmsg_duration, x, y, textref_stack_grffile, textref_stack_size, textref_stack);
410  data.CopyOutDParams();
411 
413  if (w != nullptr && w->IsCritical()) {
414  /* A critical error is currently shown. */
415  if (wl == WL_CRITICAL) {
416  /* Push another critical error in the queue of errors,
417  * but do not put other errors in the queue. */
418  _error_list.push_back(data);
419  }
420  } else {
421  /* Nothing or a non-critical error was shown. */
422  delete w;
423  new ErrmsgWindow(data);
424  }
425 }
426 
432 void ScheduleErrorMessage(ErrorList &datas)
433 {
434  _error_list.splice(_error_list.end(), datas);
435 }
436 
443 {
444  _error_list.push_back(data);
445 }
EventState
State of handling an event.
Definition: window_type.h:711
Functions related to OTTD&#39;s strings.
Owner
Enum for all companies/owners.
Definition: company_type.h:18
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
void ShowFirstError()
Show the first error of the queue.
Definition: error_gui.cpp:345
Definition of stuff that is very close to a company, like the company struct itself.
int virtual_left
Virtual left coordinate.
Definition: viewport_type.h:28
uint textref_stack_size
Number of uint32 values to put on the TextRefStack for the error message.
Definition: error.h:34
void SetDParamStr(uint n, const char *str)
Set a rawstring parameter.
Definition: error_gui.cpp:160
High level window description.
Definition: window_gui.h:166
static uint64 GetDParamX(const uint64 *s, uint n)
Get the current string parameter at index n from parameter array s.
Definition: strings_func.h:219
Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
Compute the initial position of the window.
Definition: error_gui.cpp:213
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:291
static Point RemapCoords(int x, int y, int z)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap...
Definition: landscape.h:82
void OnHundredthTick() override
Called once every 100 (game) ticks.
Definition: error_gui.cpp:303
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:407
bool _right_button_down
Is right mouse button pressed?
Definition: gfx.cpp:40
ErrorMessageData(const ErrorMessageData &data)
Copy the given data into our instance.
Definition: error_gui.cpp:73
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:62
int GetSlopePixelZOutsideMap(int x, int y)
Return world z coordinate of a given point of a tile, also for tiles outside the map (virtual "black"...
Definition: landscape.cpp:357
Horizontal container.
Definition: widget_type.h:73
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1130
The passed event is not handled.
Definition: window_type.h:713
static int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL) When shifting right...
Definition: zoom_func.h:34
void SetDParam(uint n, uint64 v)
Set a error string parameter.
Definition: error_gui.cpp:150
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
Definition: error_gui.cpp:297
void CopyInDParam(int offs, const uint64 *src, int num)
Copy num string parameters from array src into the global string parameter array. ...
Definition: strings.cpp:138
CompanyID face
Company belonging to the face being shown. INVALID_COMPANY if no face present.
Definition: error.h:39
void DrawCompanyManagerFace(CompanyManagerFace cmf, int colour, int x, int y)
Draws the face of a company manager&#39;s face.
bool IsCritical()
Check whether the currently shown error message was critical or not.
Definition: error_gui.cpp:329
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:547
Close box (at top-left of a window)
Definition: widget_type.h:67
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
Definition: gfx_func.h:83
byte errmsg_duration
duration of error message
Definition: settings_type.h:92
#define lastof(x)
Get the last element of an fixed size array.
Definition: depend.cpp:48
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:24
void UpdateWidgetSize(int 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:185
Large amount of vertical space between two paragraphs of text.
Definition: window_gui.h:138
void CopyOutDParams()
Copy error parameters from current DParams.
Definition: error_gui.cpp:127
Functions, definitions and such used only by the GUI.
~ErrorMessageData()
Free all the strings.
Definition: error_gui.cpp:89
int GetMainViewBottom()
Return the bottom of the main view available for general use.
Definition: window.cpp:2189
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:908
Functions related to (drawing on) viewports.
uint32 textref_stack[16]
Values to put on the TextRefStack for the error message.
Definition: error.h:35
Data structure for an opened window.
Definition: window_gui.h:276
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1044
Critical errors, the MessageBox is shown in all cases.
Definition: error.h:24
Types related to the error widgets.
Header of Action 04 "universal holder" structure and functions.
Main window; Window numbers:
Definition: window_type.h:44
Functions related to low-level strings.
Other information.
Definition: error.h:22
Functions related to errors.
Error message; Window numbers:
Definition: window_type.h:103
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2405
void UnshowCriticalError()
Unshow the critical error.
Definition: error_gui.cpp:359
void IConsolePrint(TextColour colour_code, const char *string)
Handle the printing of text entered into the console or redirected there by any other means...
Definition: console.cpp:84
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1012
Functions related to the gfx engine.
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:78
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:945
Definition of base types and functions in a cross-platform compatible way.
ErrorList _error_list
The actual queue with errors.
Definition: error_gui.cpp:169
Center both horizontally and vertically.
Definition: gfx_func.h:104
int GetMainViewTop()
Return the top of the main view available for general use.
Definition: window.cpp:2178
A number of safeguards to prevent using unsafe methods.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: error_gui.cpp:255
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: error_gui.cpp:249
void CopyOutDParam(uint64 *dst, int offs, int num)
Copy num string parameters from the global string parameter array to the dst array.
Definition: strings.cpp:149
Simple depressed panel.
Definition: widget_type.h:48
StringID detailed_msg
Detailed error message showed in second line. Can be INVALID_STRING_ID.
Definition: error.h:37
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Definition: string.cpp:136
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: error_gui.cpp:260
Console functions used outside of the console code.
bool _window_system_initialized
Whether the window system is initialized or not.
Definition: error_gui.cpp:171
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1112
StringID summary_msg
General error message showed in first line. Must be valid.
Definition: error.h:36
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:63
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32 *textref_stack)
Display an error message in a window.
Definition: error_gui.cpp:380
uint height_summary
Height of the summary_msg string in pixels in the WID_EM_MESSAGE widget.
Definition: error_gui.cpp:176
Right offset of the text of the frame.
Definition: window_gui.h:71
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:40
const char * strings[20]
Copies of raw strings that were used.
Definition: error.h:32
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
Definition: error_gui.cpp:318
Left offset of the text of the frame.
Definition: window_gui.h:70
void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint32 *values)
Start using the TTDP compatible string code parsing.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
CompanyManagerFace face
Face description of the president.
Definition: company_base.h:63
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:137
static void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
Definition: mem_func.hpp:23
bool HasFace() const
Check whether error window shall display a company manager face.
Definition: error.h:47
int left
Screen coordinate left edge of the viewport.
Definition: viewport_type.h:23
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
An invalid company.
Definition: company_type.h:30
The data of the error message.
Definition: error.h:28
Functionality related to the company manager&#39;s face.
GUISettings gui
settings related to the GUI
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:22
uint duration
Length of display of the message. 0 means forever,.
Definition: error.h:30
void ClearErrorMessages()
Clear all errors from the queue.
Definition: error_gui.cpp:338
Window class for displaying an error message window.
Definition: error_gui.cpp:174
Error message.
Definition: error_widget.h:17
byte colour
Company colour.
Definition: company_base.h:69
void IConsoleError(const char *string)
It is possible to print error information to the console.
Definition: console.cpp:167
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:997
Functions related to zooming.
Maximum number of companies.
Definition: company_type.h:23
const GRFFile * textref_stack_grffile
NewGRF that filled the TextRefStack for the error message.
Definition: error.h:33
Functions related to OTTD&#39;s landscape.
Error title.
Definition: error_widget.h:16
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:770
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:280
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: depend.cpp:129
ZoomLevel zoom
The zoom level of the viewport.
Definition: viewport_type.h:33
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition: error.h:21
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:981
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:83
int virtual_top
Virtual top coordinate.
Definition: viewport_type.h:29
Specification of a rectangle with absolute coordinates of all edges.
The passed event is handled.
Definition: window_type.h:712
uint64 decode_params[20]
Parameters of the message strings.
Definition: error.h:31
Window functions not directly related to making/drawing windows.
void ScheduleErrorMessage(ErrorList &datas)
Schedule a list of errors.
Definition: error_gui.cpp:432
int top
Screen coordinate top edge of the viewport.
Definition: viewport_type.h:24
Manually align the window (so no automatic location finding)
Definition: window_gui.h:153
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:326
Caption of the window.
Definition: error_widget.h:15
uint32 WChar
Type for wide characters, i.e.
Definition: string_type.h:35
std::list< ErrorMessageData > ErrorList
Define a queue with errors.
Definition: error_gui.cpp:167
static const TextColour CC_WARNING
Colour for warning lines.
Definition: console_type.h:25
Dimensions (a width and height) of a rectangle in 2D.
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1074
Point position
Position of the error message window.
Definition: error.h:38
uint height_detailed
Height of the detailed_msg string in pixels in the WID_EM_MESSAGE widget.
Definition: error_gui.cpp:177
void StopTextRefStackUsage()
Stop using the TTDP compatible string code parsing.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:621
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:105
WarningLevel
Message severity/type.
Definition: error.h:20