OpenTTD

Data Structures | Typedefs | Functions | Variables
error_gui.cpp File Reference

GUI related to errors. More...

`#include "stdafx.h"`
`#include "landscape.h"`
`#include "newgrf_text.h"`
`#include "error.h"`
`#include "viewport_func.h"`
`#include "gfx_func.h"`
`#include "string_func.h"`
`#include "company_base.h"`
`#include "company_manager_face.h"`
`#include "strings_func.h"`
`#include "zoom_func.h"`
`#include "window_func.h"`
`#include "console_func.h"`
`#include "window_gui.h"`
`#include "widgets/error_widget.h"`
`#include "table/strings.h"`
`#include <list>`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | ErrmsgWindow
| Window class for displaying an error message window. More...

## Typedefs
typedef std::list< ErrorMessageData > | ErrorList
| Define a queue with errors. More...

## Functions
void | ClearErrorMessages ()
| Clear all errors from the queue.
void | ShowFirstError ()
| Show the first error of the queue. More...
void | UnshowCriticalError ()
| Unshow the critical error. More...
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. More...
void | ScheduleErrorMessage (ErrorList &datas)
| Schedule a list of errors. More...
void | ScheduleErrorMessage (const ErrorMessageData &data)
| Schedule an error. More...

## Variables
static const NWidgetPart | _nested_errmsg_widgets []
static WindowDesc | _errmsg_desc (WDP_MANUAL, "error", 0, 0, WC_ERRMSG, WC_NONE, 0, _nested_errmsg_widgets, lengthof(_nested_errmsg_widgets))
static const NWidgetPart | _nested_errmsg_face_widgets []
static WindowDesc | _errmsg_face_desc (WDP_MANUAL, "error_face", 0, 0, WC_ERRMSG, WC_NONE, 0, _nested_errmsg_face_widgets, lengthof(_nested_errmsg_face_widgets))
ErrorList | _error_list
| The actual queue with errors. More...
bool | _window_system_initialized = false
| Whether the window system is initialized or not. More...

## Detailed Description

GUI related to errors.

Definition in file error_gui.cpp.

## Typedef Documentation

## ◆ ErrorList

typedef std::list<ErrorMessageData> ErrorList

Define a queue with errors.

Definition at line 165 of file error_gui.cpp.

## Function Documentation

## ◆ ScheduleErrorMessage() [1/2]

void ScheduleErrorMessage | ( | ErrorList & | datas | ) |

Schedule a list of errors.

Note: This does not try to display the error now. This is useful if the window system is not yet running.

Parameters

  data | Error message datas; cleared afterwards

Definition at line 430 of file error_gui.cpp.

## ◆ ScheduleErrorMessage() [2/2]

void ScheduleErrorMessage | ( | const ErrorMessageData & | data | ) |

Schedule an error.

Note: This does not try to display the error now. This is useful if the window system is not yet running.

Parameters

  data | Error message data; cleared afterwards

Definition at line 440 of file error_gui.cpp.

Referenced by ErrorMessageData::HasFace().

## ◆ 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.

Parameters

  summary_msg | General error message showed in first line. Must be valid.
  detailed_msg | Detailed error message showed in second line. Can be INVALID_STRING_ID.
  wl | Message severity.
  x | World X position (TileVirtX) of the error location. Set both x and y to 0 to just center the message when there is no related error tile.
  y | World Y position (TileVirtY) of the error location. Set both x and y to 0 to just center the message when there is no related error tile.
  textref_stack_grffile | NewGRF providing the TextRefStack for the error message.
  textref_stack_size | Number of uint32 values to put on the TextRefStack for the error message; 0 if the TextRefStack shall not be used.
  textref_stack | Values to put on the TextRefStack.

Definition at line 378 of file error_gui.cpp.

Referenced by NewGRFWindow::AddGRFToActive(), CcBuildIndustry(), ClientNetworkGameSocketHandler::CheckConnection(), CheckIndustries(), ClickChangeMaxHlCheat(), NetworkGameSocketHandler::CloseConnection(), GameInstance::Died(), AIInstance::Died(), ErrorUnknownCallbackResult(), GetSavegameFormat(), GRFLoadConfig(), ErrorMessageData::HasFace(), SelectGameWindow::OnClick(), SelectCompanyManagerFaceWindow::OnClick(), NetworkContentListWindow::OnConnect(), SelectCompanyManagerFaceWindow::OnQueryTextFinished(), SaveLoadWindow::OnTimeout(), ClientNetworkGameSocketHandler::Receive_SERVER_BANNED(), ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(), ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT(), ClientNetworkGameSocketHandler::Receive_SERVER_FULL(), ClientNetworkGameSocketHandler::Receive_SERVER_NEWGAME(), ClientNetworkGameSocketHandler::Receive_SERVER_SHUTDOWN(), SaveFileError(), SaveOrLoad(), ShowAIDebugWindow(), ShowNewGrfVehicleError(), and WarnCorruptSprite().

## ◆ ShowFirstError()

void ShowFirstError | ( |  | ) |

Show the first error of the queue.

Definition at line 343 of file error_gui.cpp.

Referenced by InitWindowSystem(), and ErrmsgWindow::OnHundredthTick().

## ◆ UnshowCriticalError()

void UnshowCriticalError | ( |  | ) |

Unshow the critical error.

This has to happen when a critical error is shown and we uninitialise the window system, i.e. remove all the windows.

Definition at line 357 of file error_gui.cpp.

References FindWindowById(), ErrmsgWindow::IsCritical(), and WC_ERRMSG.

Referenced by ClearErrorMessages(), and UnInitWindowSystem().

## Variable Documentation

## ◆ _error_list

ErrorList _error_list

The actual queue with errors.

Definition at line 167 of file error_gui.cpp.

## ◆ _nested_errmsg_face_widgets

const NWidgetPart _nested_errmsg_face_widgets[]
| static

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_RED),
NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION_OTHER_COMPANY, STR_NULL),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_RED),
NWidget(NWID_HORIZONTAL), SetPIP(2, 1, 2),
NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_FACE), SetMinimalSize(92, 119), SetFill(0, 1), SetPadding(2, 0, 1, 0),
NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetFill(0, 1), SetMinimalSize(238, 123),
EndContainer(),
EndContainer(),
}
WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:48
NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
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:1046
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
NWidget
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:1114
WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
WID_EM_MESSAGE
Error message.
Definition: error_widget.h:19
EndContainer
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:999
WID_EM_FACE
Error title.
Definition: error_widget.h:18
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
WID_EM_CAPTION
Caption of the window.
Definition: error_widget.h:17
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1076

Definition at line 51 of file error_gui.cpp.

## ◆ _nested_errmsg_widgets

const NWidgetPart _nested_errmsg_widgets[]
| static

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_RED),
NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION, STR_NULL),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_RED),
NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetPadding(0, 2, 0, 2), SetMinimalSize(236, 32),
EndContainer(),
}
WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:48
NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
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:1046
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
NWidget
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:1114
WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
WID_EM_MESSAGE
Error message.
Definition: error_widget.h:19
EndContainer
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:999
WID_EM_CAPTION
Caption of the window.
Definition: error_widget.h:17

Definition at line 34 of file error_gui.cpp.

## ◆ _window_system_initialized

bool _window_system_initialized = false

Whether the window system is initialized or not.

Definition at line 169 of file error_gui.cpp.