OpenTTD

error.h
Go to the documentation of this file.
1 /* $Id: error.h 26241 2014-01-12 18:00:39Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef ERROR_H
13 #define ERROR_H
14
15 #include "strings_type.h"
16 #include "company_type.h"
17 #include "core/geometry_type.hpp"
18
19 struct GRFFile;
20
22 enum WarningLevel {
23 WL_INFO,
24 WL_WARNING,
25 WL_ERROR,
26 WL_CRITICAL,
27 };
28
30 class ErrorMessageData {
31 protected:
32 uint duration;
33 uint64 decode_params[20];
34 const char *strings[20];
35 const GRFFile *textref_stack_grffile;
36 uint textref_stack_size;
37 uint32 textref_stack[16];
38 StringID summary_msg;
39 StringID detailed_msg;
40 Point position;
41 CompanyID face;
42
43 public:
44 ErrorMessageData(const ErrorMessageData &data);
45 ~ErrorMessageData();
46 ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration = 0, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = NULL, uint textref_stack_size = 0, const uint32 *textref_stack = NULL);
47
49 bool HasFace() const { return face != INVALID_COMPANY; }
50
51 void SetDParam(uint n, uint64 v);
52 void SetDParamStr(uint n, const char *str);
53
54 void CopyOutDParams();
55 };
56
57 void ScheduleErrorMessage(const ErrorMessageData &data);
58
59 void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = NULL, uint textref_stack_size = 0, const uint32 *textref_stack = NULL);
60 void ClearErrorMessages();
61 void ShowFirstError();
62 void UnshowCriticalError();
63
64 #endif /* ERROR_H */
ErrorMessageData::textref_stack_size
uint textref_stack_size
Number of uint32 values to put on the TextRefStack for the error message.
Definition: error.h:36
ErrorMessageData::SetDParamStr
void SetDParamStr(uint n, const char *str)
Set a rawstring parameter.
Definition: error_gui.cpp:158
ErrorMessageData::ErrorMessageData
ErrorMessageData(const ErrorMessageData &data)
Copy the given data into our instance.
Definition: error_gui.cpp:75
ErrorMessageData::SetDParam
void SetDParam(uint n, uint64 v)
Set a error string parameter.
Definition: error_gui.cpp:148
ErrorMessageData::face
CompanyID face
Company belonging to the face being shown. INVALID_COMPANY if no face present.
Definition: error.h:41
ErrorMessageData::CopyOutDParams
void CopyOutDParams()
Copy error parameters from current DParams.
Definition: error_gui.cpp:125
ErrorMessageData::~ErrorMessageData
~ErrorMessageData()
Free all the strings.
Definition: error_gui.cpp:87
ErrorMessageData::textref_stack
uint32 textref_stack[16]
Values to put on the TextRefStack for the error message.
Definition: error.h:37
WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
Definition: error.h:26
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
Definition: error_gui.cpp:378
WL_WARNING
Other information.
Definition: error.h:24
ErrorMessageData::detailed_msg
StringID detailed_msg
Detailed error message showed in second line. Can be INVALID_STRING_ID.
Definition: error.h:39
ScheduleErrorMessage
void ScheduleErrorMessage(const ErrorMessageData &data)
Schedule an error.
Definition: error_gui.cpp:440
ErrorMessageData::summary_msg
StringID summary_msg
General error message showed in first line. Must be valid.
Definition: error.h:38
ErrorMessageData::strings
const char * strings[20]
Copies of raw strings that were used.
Definition: error.h:34
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
ErrorMessageData::HasFace
bool HasFace() const
Check whether error window shall display a company manager face.
Definition: error.h:49
UnshowCriticalError
void UnshowCriticalError()
Unshow the critical error.
Definition: error_gui.cpp:357
ErrorMessageData
The data of the error message.
Definition: error.h:30
ClearErrorMessages
void ClearErrorMessages()
Clear all errors from the queue.
Definition: error_gui.cpp:336
ErrorMessageData::duration
uint duration
Length of display of the message. 0 means forever,.
Definition: error.h:32
ErrorMessageData::textref_stack_grffile
const GRFFile * textref_stack_grffile
NewGRF that filled the TextRefStack for the error message.
Definition: error.h:35
geometry_type.hpp
All geometry types in OpenTTD.
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:28
company_type.h
Types related to companies.
strings_type.h
Types related to strings.
WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition: error.h:23
ErrorMessageData::decode_params
uint64 decode_params[20]
Parameters of the message strings.
Definition: error.h:33
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:25
INVALID_COMPANY
An invalid company.
Definition: company_type.h:32
ErrorMessageData::position
Point position
Position of the error message window.
Definition: error.h:40
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:104
WarningLevel
WarningLevel
Message severity/type.
Definition: error.h:22
ShowFirstError
void ShowFirstError()
Show the first error of the queue.
Definition: error_gui.cpp:343