Rearrange storage of reserved tracks for railway tiles
[openttd/fttd.git] / src / error.h
blob4a78a07aabadfd77a2a96f86f546934ddb70c958
1 /* $Id$ */
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 */
10 /** @file error.h Functions related to errors. */
12 #ifndef ERROR_H
13 #define ERROR_H
15 #include "strings_type.h"
16 #include "company_type.h"
17 #include "core/geometry_type.hpp"
19 /** Message severity/type */
20 enum WarningLevel {
21 WL_INFO, ///< Used for DoCommand-like (and some non-fatal AI GUI) errors/information
22 WL_WARNING, ///< Other information
23 WL_ERROR, ///< Errors (eg. saving/loading failed)
24 WL_CRITICAL, ///< Critical errors, the MessageBox is shown in all cases
27 /** The data of the error message. */
28 class ErrorMessageData {
29 protected:
30 uint duration; ///< Length of display of the message. 0 means forever,
31 uint64 decode_params[20]; ///< Parameters of the message strings.
32 const char *strings[20]; ///< Copies of raw strings that were used.
33 uint textref_stack_size; ///< Number of uint32 values to put on the #TextRefStack for the error message.
34 uint32 textref_stack[16]; ///< Values to put on the #TextRefStack for the error message.
35 StringID summary_msg; ///< General error message showed in first line. Must be valid.
36 StringID detailed_msg; ///< Detailed error message showed in second line. Can be #INVALID_STRING_ID.
37 Point position; ///< Position of the error message window.
38 CompanyID face; ///< Company belonging to the face being shown. #INVALID_COMPANY if no face present.
40 public:
41 ErrorMessageData(const ErrorMessageData &data);
42 ~ErrorMessageData();
43 ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration = 0, int x = 0, int y = 0, uint textref_stack_size = 0, const uint32 *textref_stack = NULL);
45 /** Check whether error window shall display a company manager face */
46 bool HasFace() const { return face != INVALID_COMPANY; }
48 void SetDParam(uint n, uint64 v);
49 void SetDParamStr(uint n, const char *str);
51 void CopyOutDParams();
54 void ScheduleErrorMessage(const ErrorMessageData &data);
56 void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, uint textref_stack_size = 0, const uint32 *textref_stack = NULL);
57 void ClearErrorMessages();
58 void ShowFirstError();
59 void UnshowCriticalError();
61 #endif /* ERROR_H */