OpenTTD Source  12.0-beta2
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  display_timer(data.display_timer), 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 
105 ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32 *textref_stack) :
106  textref_stack_grffile(textref_stack_grffile),
107  textref_stack_size(textref_stack_size),
108  summary_msg(summary_msg),
109  detailed_msg(detailed_msg),
110  face(INVALID_COMPANY)
111 {
112  this->position.x = x;
113  this->position.y = y;
114 
115  memset(this->decode_params, 0, sizeof(this->decode_params));
116  memset(this->strings, 0, sizeof(this->strings));
117 
118  if (textref_stack_size > 0) MemCpyT(this->textref_stack, textref_stack, textref_stack_size);
119 
120  assert(summary_msg != INVALID_STRING_ID);
121 
122  this->display_timer.SetInterval(duration * 3000);
123 }
124 
129 {
130  /* Reset parameters */
131  for (size_t i = 0; i < lengthof(this->strings); i++) free(this->strings[i]);
132  memset(this->decode_params, 0, sizeof(this->decode_params));
133  memset(this->strings, 0, sizeof(this->strings));
134 
135  /* Get parameters using type information */
138  if (this->textref_stack_size > 0) StopTextRefStackUsage();
139 
140  if (this->detailed_msg == STR_ERROR_OWNED_BY) {
141  CompanyID company = (CompanyID)GetDParamX(this->decode_params, 2);
142  if (company < MAX_COMPANIES) face = company;
143  }
144 }
145 
151 void ErrorMessageData::SetDParam(uint n, uint64 v)
152 {
153  this->decode_params[n] = v;
154 }
155 
161 void ErrorMessageData::SetDParamStr(uint n, const char *str)
162 {
163  free(this->strings[n]);
164  this->strings[n] = stredup(str);
165 }
166 
172 void ErrorMessageData::SetDParamStr(uint n, const std::string &str)
173 {
174  this->SetDParamStr(n, str.c_str());
175 }
176 
178 typedef std::list<ErrorMessageData> ErrorList;
183 
186 private:
189 
190 public:
191  ErrmsgWindow(const ErrorMessageData &data) : Window(data.HasFace() ? &_errmsg_face_desc : &_errmsg_desc), ErrorMessageData(data)
192  {
193  this->InitNested();
194  }
195 
196  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
197  {
198  switch (widget) {
199  case WID_EM_MESSAGE: {
202 
203  int text_width = std::max(0, (int)size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT);
204  this->height_summary = GetStringHeight(this->summary_msg, text_width);
205  this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, text_width);
206 
207  if (this->textref_stack_size > 0) StopTextRefStackUsage();
208 
209  uint panel_height = WD_FRAMERECT_TOP + this->height_summary + WD_FRAMERECT_BOTTOM;
210  if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WD_PAR_VSEP_WIDE;
211 
212  size->height = std::max(size->height, panel_height);
213  break;
214  }
215  case WID_EM_FACE: {
216  Dimension face_size = GetSpriteSize(SPR_GRADIENT);
217  size->width = std::max(size->width, face_size.width);
218  size->height = std::max(size->height, face_size.height);
219  break;
220  }
221  }
222  }
223 
224  Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
225  {
226  /* Position (0, 0) given, center the window. */
227  if (this->position.x == 0 && this->position.y == 0) {
228  Point pt = {(_screen.width - sm_width) >> 1, (_screen.height - sm_height) >> 1};
229  return pt;
230  }
231 
232  /* Find the free screen space between the main toolbar at the top, and the statusbar at the bottom.
233  * Add a fixed distance 20 to make it less cluttered.
234  */
235  int scr_top = GetMainViewTop() + 20;
236  int scr_bot = GetMainViewBottom() - 20;
237 
238  Point pt = RemapCoords(this->position.x, this->position.y, GetSlopePixelZOutsideMap(this->position.x, this->position.y));
240  if (this->face == INVALID_COMPANY) {
241  /* move x pos to opposite corner */
242  pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left;
243  pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - sm_width - 20 : 20; // Stay 20 pixels away from the edge of the screen.
244 
245  /* move y pos to opposite corner */
246  pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top;
247  pt.y = (pt.y < (_screen.height >> 1)) ? scr_bot - sm_height : scr_top;
248  } else {
249  pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (sm_width / 2), 0, _screen.width - sm_width);
250  pt.y = Clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (sm_height / 2), scr_top, scr_bot - sm_height);
251  }
252  return pt;
253  }
254 
260  void OnInvalidateData(int data = 0, bool gui_scope = true) override
261  {
262  /* If company gets shut down, while displaying an error about it, remove the error message. */
263  if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) this->Close();
264  }
265 
266  void SetStringParameters(int widget) const override
267  {
268  if (widget == WID_EM_CAPTION) CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
269  }
270 
271  void DrawWidget(const Rect &r, int widget) const override
272  {
273  switch (widget) {
274  case WID_EM_FACE: {
275  const Company *c = Company::Get(this->face);
276  DrawCompanyManagerFace(c->face, c->colour, r.left, r.top);
277  break;
278  }
279 
280  case WID_EM_MESSAGE:
283 
284  if (this->detailed_msg == INVALID_STRING_ID) {
286  this->summary_msg, TC_FROMSTRING, SA_CENTER);
287  } else {
288  int extra = (r.bottom - r.top + 1 - this->height_summary - this->height_detailed - WD_PAR_VSEP_WIDE) / 2;
289 
290  /* Note: NewGRF supplied error message often do not start with a colour code, so default to white. */
291  int top = r.top + WD_FRAMERECT_TOP;
292  int bottom = top + this->height_summary + extra;
293  DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, top, bottom, this->summary_msg, TC_WHITE, SA_CENTER);
294 
295  bottom = r.bottom - WD_FRAMERECT_BOTTOM;
296  top = bottom - this->height_detailed - extra;
297  DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, top, bottom, this->detailed_msg, TC_WHITE, SA_CENTER);
298  }
299 
300  if (this->textref_stack_size > 0) StopTextRefStackUsage();
301  break;
302 
303  default:
304  break;
305  }
306  }
307 
308  void OnMouseLoop() override
309  {
310  /* Disallow closing the window too easily, if timeout is disabled */
311  if (_right_button_down && !this->display_timer.HasElapsed()) this->Close();
312  }
313 
314  void OnRealtimeTick(uint delta_ms) override
315  {
316  if (this->display_timer.CountElapsed(delta_ms) == 0) return;
317 
318  this->Close();
319  }
320 
321  void Close() override
322  {
324  if (_window_system_initialized) ShowFirstError();
325  this->Window::Close();
326  }
327 
332  bool IsCritical()
333  {
334  return this->display_timer.HasElapsed();
335  }
336 };
337 
342 {
344  _error_list.clear();
345 }
346 
349 {
351  if (!_error_list.empty()) {
352  new ErrmsgWindow(_error_list.front());
353  _error_list.pop_front();
354  }
355 }
356 
363 {
365  if (_window_system_initialized && w != nullptr) {
366  if (w->IsCritical()) _error_list.push_front(*w);
368  w->Close();
369  }
370 }
371 
383 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)
384 {
385  assert(textref_stack_size == 0 || (textref_stack_grffile != nullptr && textref_stack != nullptr));
386  if (summary_msg == STR_NULL) summary_msg = STR_EMPTY;
387 
388  if (wl != WL_INFO) {
389  /* Print message to console */
390  char buf[DRAW_STRING_BUFFER];
391 
392  if (textref_stack_size > 0) StartTextRefStackUsage(textref_stack_grffile, textref_stack_size, textref_stack);
393 
394  char *b = GetString(buf, summary_msg, lastof(buf));
395  if (detailed_msg != INVALID_STRING_ID) {
396  b += seprintf(b, lastof(buf), " ");
397  GetString(b, detailed_msg, lastof(buf));
398  }
399 
400  if (textref_stack_size > 0) StopTextRefStackUsage();
401 
403  }
404 
405  bool no_timeout = wl == WL_CRITICAL;
406 
407  if (_game_mode == GM_BOOTSTRAP) return;
408  if (_settings_client.gui.errmsg_duration == 0 && !no_timeout) return;
409 
410  ErrorMessageData data(summary_msg, detailed_msg, no_timeout ? 0 : _settings_client.gui.errmsg_duration, x, y, textref_stack_grffile, textref_stack_size, textref_stack);
411  data.CopyOutDParams();
412 
414  if (w != nullptr) {
415  if (w->IsCritical()) {
416  /* A critical error is currently shown. */
417  if (wl == WL_CRITICAL) {
418  /* Push another critical error in the queue of errors,
419  * but do not put other errors in the queue. */
420  _error_list.push_back(data);
421  }
422  return;
423  }
424  /* A non-critical error was shown. */
425  w->Close();
426  }
427  new ErrmsgWindow(data);
428 }
429 
430 
437  if (w == nullptr) return false;
438  w->Close();
439  return true;
440 }
441 
448 {
449  _error_list.splice(_error_list.end(), datas);
450 }
451 
458 {
459  _error_list.push_back(data);
460 }
ErrorMessageData::position
Point position
Position of the error message window.
Definition: error.h:39
ErrorList
std::list< ErrorMessageData > ErrorList
Define a queue with errors.
Definition: error_gui.cpp:178
WD_FRAMERECT_TOP
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:64
ErrmsgWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: error_gui.cpp:260
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
ErrorMessageData::textref_stack_grffile
const GRFFile * textref_stack_grffile
NewGRF that filled the TextRefStack for the error message.
Definition: error.h:34
CopyOutDParam
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:139
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
ErrorMessageData::textref_stack_size
uint textref_stack_size
Number of uint32 values to put on the TextRefStack for the error message.
Definition: error.h:35
SetPadding
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:1139
ErrorMessageData::SetDParamStr
void SetDParamStr(uint n, const char *str)
Set a rawstring parameter.
Definition: error_gui.cpp:161
WarningLevel
WarningLevel
Message severity/type.
Definition: error.h:21
WL_WARNING
@ WL_WARNING
Other information.
Definition: error.h:23
ErrorMessageData::decode_params
uint64 decode_params[20]
Parameters of the message strings.
Definition: error.h:32
company_base.h
ErrmsgWindow::UpdateWidgetSize
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:196
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
RemapCoords
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
Window::viewport
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:321
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2454
company_manager_face.h
GetDParamX
static uint64 GetDParamX(const uint64 *s, uint n)
Get the current string parameter at index n from parameter array s.
Definition: strings_func.h:217
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
Viewport::top
int top
Screen coordinate top edge of the viewport.
Definition: viewport_type.h:24
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1146
ErrmsgWindow::height_summary
uint height_summary
Height of the summary_msg string in pixels in the WID_EM_MESSAGE widget.
Definition: error_gui.cpp:187
zoom_func.h
StartTextRefStackUsage
void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint32 *values)
Start using the TTDP compatible string code parsing.
Definition: newgrf_text.cpp:821
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:52
ErrorMessageData::~ErrorMessageData
~ErrorMessageData()
Free all the strings.
Definition: error_gui.cpp:89
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
CompanyProperties::face
CompanyManagerFace face
Face description of the president.
Definition: company_base.h:64
StopTextRefStackUsage
void StopTextRefStackUsage()
Stop using the TTDP compatible string code parsing.
Definition: newgrf_text.cpp:838
ErrmsgWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: error_gui.cpp:271
ErrorMessageData::CopyOutDParams
void CopyOutDParams()
Copy error parameters from current DParams.
Definition: error_gui.cpp:128
Viewport::virtual_top
int virtual_top
Virtual top coordinate.
Definition: viewport_type.h:29
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
MemCpyT
static void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
Definition: mem_func.hpp:23
WD_FRAMETEXT_LEFT
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
Definition: window_gui.h:72
UnshowCriticalError
void UnshowCriticalError()
Unshow the critical error.
Definition: error_gui.cpp:362
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:971
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1107
DrawStringMultiLine
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:787
ErrmsgWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: error_gui.cpp:266
gfx_func.h
WindowDesc
High level window description.
Definition: window_gui.h:168
window_gui.h
ErrmsgWindow::height_detailed
uint height_detailed
Height of the detailed_msg string in pixels in the WID_EM_MESSAGE widget.
Definition: error_gui.cpp:188
Viewport
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:22
CompanyProperties::colour
byte colour
Company colour.
Definition: company_base.h:70
DRAW_STRING_BUFFER
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
Definition: gfx_func.h:85
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:317
ErrorMessageData::textref_stack
uint32 textref_stack[16]
Values to put on the TextRefStack for the error message.
Definition: error.h:36
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1789
ErrorMessageData::SetDParam
void SetDParam(uint n, uint64 v)
Set a error string parameter.
Definition: error_gui.cpp:151
Viewport::virtual_left
int virtual_left
Virtual left coordinate.
Definition: viewport_type.h:28
Viewport::left
int left
Screen coordinate left edge of the viewport.
Definition: viewport_type.h:23
WD_FRAMERECT_BOTTOM
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
GetMainViewTop
int GetMainViewTop()
Return the top of the main view available for general use.
Definition: window.cpp:2105
WL_INFO
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition: error.h:22
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
ShowErrorMessage
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:383
safeguards.h
_error_list
ErrorList _error_list
The actual queue with errors.
Definition: error_gui.cpp:180
newgrf_text.h
ErrorMessageData
The data of the error message.
Definition: error.h:29
ErrmsgWindow::OnInitialPosition
Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
Compute the initial position of the window.
Definition: error_gui.cpp:224
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
error.h
UnScaleByZoom
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
WD_FRAMETEXT_RIGHT
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
Definition: window_gui.h:73
ErrorMessageData::face
CompanyID face
Company belonging to the face being shown. INVALID_COMPANY if no face present.
Definition: error.h:40
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:307
landscape.h
ErrmsgWindow::IsCritical
bool IsCritical()
Check whether the currently shown error message was critical or not.
Definition: error_gui.cpp:332
viewport_func.h
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:37
_window_system_initialized
bool _window_system_initialized
Whether the window system is initialized or not.
Definition: error_gui.cpp:182
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:713
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:976
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
ErrorMessageData::display_timer
GUITimer display_timer
Timer before closing the message.
Definition: error.h:31
string_func.h
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1092
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
strings_func.h
ErrorMessageData::HasFace
bool HasFace() const
Check whether error window shall display a company manager face.
Definition: error.h:51
ErrmsgWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: error_gui.cpp:321
ErrorMessageData::detailed_msg
StringID detailed_msg
Detailed error message showed in second line. Can be INVALID_STRING_ID.
Definition: error.h:38
WID_EM_MESSAGE
@ WID_EM_MESSAGE
Error message.
Definition: error_widget.h:17
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1207
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1010
error_widget.h
ErrmsgWindow::OnMouseLoop
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
Definition: error_gui.cpp:308
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
DrawCompanyManagerFace
void DrawCompanyManagerFace(CompanyManagerFace cmf, int colour, int x, int y)
Draws the face of a company manager's face.
Definition: company_gui.cpp:1110
GUITimer::CountElapsed
uint CountElapsed(uint delta)
Count how many times the interval has elapsed.
Definition: guitimer_func.h:40
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:535
WC_MAIN_WINDOW
@ WC_MAIN_WINDOW
Main window; Window numbers:
Definition: window_type.h:43
ClearErrorMessages
void ClearErrorMessages()
Clear all errors from the queue.
Definition: error_gui.cpp:341
CC_ERROR
static const TextColour CC_ERROR
Colour for error lines.
Definition: console_type.h:24
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:313
ErrorMessageData::strings
const char * strings[20]
Copies of raw strings that were used.
Definition: error.h:33
stredup
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Definition: string.cpp:137
window_func.h
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:338
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:378
Viewport::zoom
ZoomLevel zoom
The zoom level of the viewport.
Definition: viewport_type.h:33
WDP_MANUAL
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition: window_gui.h:155
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1169
GetSlopePixelZOutsideMap
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:358
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:88
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
HideActiveErrorMessage
bool HideActiveErrorMessage()
Close active error message window.
Definition: error_gui.cpp:435
ShowFirstError
void ShowFirstError()
Show the first error of the queue.
Definition: error_gui.cpp:348
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1076
Window
Data structure for an opened window.
Definition: window_gui.h:279
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
ErrmsgWindow
Window class for displaying an error message window.
Definition: error_gui.cpp:185
WID_EM_CAPTION
@ WID_EM_CAPTION
Caption of the window.
Definition: error_widget.h:15
console_func.h
WC_ERRMSG
@ WC_ERRMSG
Error message; Window numbers:
Definition: window_type.h:102
CC_WARNING
static const TextColour CC_WARNING
Colour for warning lines.
Definition: console_type.h:25
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: stdafx.h:460
GetMainViewBottom
int GetMainViewBottom()
Return the bottom of the main view available for general use.
Definition: window.cpp:2116
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
Company
Definition: company_base.h:115
GUISettings::errmsg_duration
byte errmsg_duration
duration of error message
Definition: settings_type.h:113
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:394
WD_PAR_VSEP_WIDE
@ WD_PAR_VSEP_WIDE
Large amount of vertical space between two paragraphs of text.
Definition: window_gui.h:140
WID_EM_FACE
@ WID_EM_FACE
Error title.
Definition: error_widget.h:16
ErrmsgWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: error_gui.cpp:314
ScheduleErrorMessage
void ScheduleErrorMessage(ErrorList &datas)
Schedule a list of errors.
Definition: error_gui.cpp:447
_right_button_down
bool _right_button_down
Is right mouse button pressed?
Definition: gfx.cpp:40
CopyInDParam
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:128
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:105
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:593
WL_CRITICAL
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
Definition: error.h:25
Window::Close
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1092
ErrorMessageData::summary_msg
StringID summary_msg
General error message showed in first line. Must be valid.
Definition: error.h:37
ErrorMessageData::ErrorMessageData
ErrorMessageData(const ErrorMessageData &data)
Copy the given data into our instance.
Definition: error_gui.cpp:73
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:94