OpenTTD Source  13.2.1
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),
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),
56  NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_FACE), SetPadding(2, 0, 2, 2), SetFill(0, 1), SetMinimalSize(92, 119),
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  this->height_summary = GetStringHeight(this->summary_msg, size->width);
204  this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, size->width);
205 
206  if (this->textref_stack_size > 0) StopTextRefStackUsage();
207 
208  uint panel_height = this->height_summary;
209  if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WidgetDimensions::scaled.vsep_wide;
210 
211  size->height = std::max(size->height, panel_height);
212  break;
213  }
214  case WID_EM_FACE: {
215  Dimension face_size = GetSpriteSize(SPR_GRADIENT);
216  size->width = std::max(size->width, face_size.width);
217  size->height = std::max(size->height, face_size.height);
218  break;
219  }
220  }
221  }
222 
223  Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
224  {
225  /* Position (0, 0) given, center the window. */
226  if (this->position.x == 0 && this->position.y == 0) {
227  Point pt = {(_screen.width - sm_width) >> 1, (_screen.height - sm_height) >> 1};
228  return pt;
229  }
230 
231  /* Find the free screen space between the main toolbar at the top, and the statusbar at the bottom.
232  * Add a fixed distance 20 to make it less cluttered.
233  */
234  int scr_top = GetMainViewTop() + 20;
235  int scr_bot = GetMainViewBottom() - 20;
236 
237  Point pt = RemapCoords(this->position.x, this->position.y, GetSlopePixelZOutsideMap(this->position.x, this->position.y));
239  if (this->face == INVALID_COMPANY) {
240  /* move x pos to opposite corner */
241  pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left;
242  pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - sm_width - 20 : 20; // Stay 20 pixels away from the edge of the screen.
243 
244  /* move y pos to opposite corner */
245  pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top;
246  pt.y = (pt.y < (_screen.height >> 1)) ? scr_bot - sm_height : scr_top;
247  } else {
248  pt.x = std::min(std::max(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (sm_width / 2), 0), _screen.width - sm_width);
249  pt.y = std::min(std::max(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (sm_height / 2), scr_top), scr_bot - sm_height);
250  }
251  return pt;
252  }
253 
259  void OnInvalidateData(int data = 0, bool gui_scope = true) override
260  {
261  /* If company gets shut down, while displaying an error about it, remove the error message. */
262  if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) this->Close();
263  }
264 
265  void SetStringParameters(int widget) const override
266  {
267  if (widget == WID_EM_CAPTION) CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
268  }
269 
270  void DrawWidget(const Rect &r, int widget) const override
271  {
272  switch (widget) {
273  case WID_EM_FACE: {
274  const Company *c = Company::Get(this->face);
275  DrawCompanyManagerFace(c->face, c->colour, r.left, r.top);
276  break;
277  }
278 
279  case WID_EM_MESSAGE:
282 
283  if (this->detailed_msg == INVALID_STRING_ID) {
284  DrawStringMultiLine(r, this->summary_msg, TC_FROMSTRING, SA_CENTER);
285  } else {
286  /* Extra space when message is shorter than company face window */
287  int extra = (r.Height() - this->height_summary - this->height_detailed - WidgetDimensions::scaled.vsep_wide) / 2;
288 
289  /* Note: NewGRF supplied error message often do not start with a colour code, so default to white. */
290  DrawStringMultiLine(r.WithHeight(this->height_summary + extra, false), this->summary_msg, TC_WHITE, SA_CENTER);
291  DrawStringMultiLine(r.WithHeight(this->height_detailed + extra, true), this->detailed_msg, TC_WHITE, SA_CENTER);
292  }
293 
294  if (this->textref_stack_size > 0) StopTextRefStackUsage();
295  break;
296 
297  default:
298  break;
299  }
300  }
301 
302  void OnMouseLoop() override
303  {
304  /* Disallow closing the window too easily, if timeout is disabled */
305  if (_right_button_down && !this->display_timer.HasElapsed()) this->Close();
306  }
307 
308  void OnRealtimeTick(uint delta_ms) override
309  {
310  if (this->display_timer.CountElapsed(delta_ms) == 0) return;
311 
312  this->Close();
313  }
314 
315  void Close() override
316  {
318  if (_window_system_initialized) ShowFirstError();
319  this->Window::Close();
320  }
321 
326  bool IsCritical()
327  {
328  return this->display_timer.HasElapsed();
329  }
330 };
331 
336 {
338  _error_list.clear();
339 }
340 
343 {
345  if (!_error_list.empty()) {
346  new ErrmsgWindow(_error_list.front());
347  _error_list.pop_front();
348  }
349 }
350 
357 {
359  if (_window_system_initialized && w != nullptr) {
360  if (w->IsCritical()) _error_list.push_front(*w);
362  w->Close();
363  }
364 }
365 
377 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)
378 {
379  assert(textref_stack_size == 0 || (textref_stack_grffile != nullptr && textref_stack != nullptr));
380  if (summary_msg == STR_NULL) summary_msg = STR_EMPTY;
381 
382  if (wl != WL_INFO) {
383  /* Print message to console */
384  char buf[DRAW_STRING_BUFFER];
385 
386  if (textref_stack_size > 0) StartTextRefStackUsage(textref_stack_grffile, textref_stack_size, textref_stack);
387 
388  char *b = GetString(buf, summary_msg, lastof(buf));
389  if (detailed_msg != INVALID_STRING_ID) {
390  b += seprintf(b, lastof(buf), " ");
391  GetString(b, detailed_msg, lastof(buf));
392  }
393 
394  if (textref_stack_size > 0) StopTextRefStackUsage();
395 
397  }
398 
399  bool no_timeout = wl == WL_CRITICAL;
400 
401  if (_game_mode == GM_BOOTSTRAP) return;
402  if (_settings_client.gui.errmsg_duration == 0 && !no_timeout) return;
403 
404  ErrorMessageData data(summary_msg, detailed_msg, no_timeout ? 0 : _settings_client.gui.errmsg_duration, x, y, textref_stack_grffile, textref_stack_size, textref_stack);
405  data.CopyOutDParams();
406 
408  if (w != nullptr) {
409  if (w->IsCritical()) {
410  /* A critical error is currently shown. */
411  if (wl == WL_CRITICAL) {
412  /* Push another critical error in the queue of errors,
413  * but do not put other errors in the queue. */
414  _error_list.push_back(data);
415  }
416  return;
417  }
418  /* A non-critical error was shown. */
419  w->Close();
420  }
421  new ErrmsgWindow(data);
422 }
423 
424 
431  if (w == nullptr) return false;
432  w->Close();
433  return true;
434 }
435 
442 {
443  _error_list.splice(_error_list.end(), datas);
444 }
445 
452 {
453  _error_list.push_back(data);
454 }
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
ErrmsgWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: error_gui.cpp:259
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:85
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:140
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:1143
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
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
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:255
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2465
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:218
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:1161
INVALID_TILE
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:108
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:53
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:65
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:270
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
UnshowCriticalError
void UnshowCriticalError()
Unshow the critical error.
Definition: error_gui.cpp:356
Rect::WithHeight
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Definition: geometry_type.hpp:205
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:975
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
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:789
ErrmsgWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: error_gui.cpp:265
gfx_func.h
WindowDesc
High level window description.
Definition: window_gui.h:102
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:71
DRAW_STRING_BUFFER
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
Definition: gfx_func.h:86
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
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:1804
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
GetMainViewTop
int GetMainViewTop()
Return the top of the main view available for general use.
Definition: window.cpp:2124
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:377
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:223
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
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:241
landscape.h
ErrmsgWindow::IsCritical
bool IsCritical()
Check whether the currently shown error message was critical or not.
Definition: error_gui.cpp:326
viewport_func.h
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
_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:715
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:993
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:1096
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:315
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:1229
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
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:302
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:1179
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:554
WC_MAIN_WINDOW
@ WC_MAIN_WINDOW
Main window; Window numbers:
Definition: window_type.h:44
ClearErrorMessages
void ClearErrorMessages()
Clear all errors from the queue.
Definition: error_gui.cpp:335
CC_ERROR
static const TextColour CC_ERROR
Colour for error lines.
Definition: console_type.h:24
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:138
window_func.h
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:344
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
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:89
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:361
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
HideActiveErrorMessage
bool HideActiveErrorMessage()
Close active error message window.
Definition: error_gui.cpp:429
ShowFirstError
void ShowFirstError()
Show the first error of the queue.
Definition: error_gui.cpp:342
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
Window
Data structure for an opened window.
Definition: window_gui.h:213
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
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
WC_ERRMSG
@ WC_ERRMSG
Error message; Window numbers:
Definition: window_type.h:103
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:470
GetMainViewBottom
int GetMainViewBottom()
Return the bottom of the main view available for general use.
Definition: window.cpp:2135
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
Company
Definition: company_base.h:117
GUISettings::errmsg_duration
byte errmsg_duration
duration of error message
Definition: settings_type.h:117
WidgetDimensions::vsep_wide
int vsep_wide
Wide vertical spacing.
Definition: window_gui.h:62
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:402
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:308
ScheduleErrorMessage
void ScheduleErrorMessage(ErrorList &datas)
Schedule a list of errors.
Definition: error_gui.cpp:441
_right_button_down
bool _right_button_down
Is right mouse button pressed?
Definition: gfx.cpp:43
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:129
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:106
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:604
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:1107
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