diff options
author | rubidium <rubidium@openttd.org> | 2011-12-10 15:16:58 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-12-10 15:16:58 +0000 |
commit | 2bf0fc3c5c4be7fa497db0924296ef43d2f3b95e (patch) | |
tree | 693ef021b01bb1997dedae1760426f25d21dadc6 /src/error_gui.cpp | |
parent | 420d358fef4d88942a5df168ab5c78d68060fe35 (diff) | |
download | openttd-2bf0fc3c5c4be7fa497db0924296ef43d2f3b95e.tar.xz |
(svn r23476) -Codechange: use the error queue to replace switch mode error strings, again making it possible to return multiple errors
Diffstat (limited to 'src/error_gui.cpp')
-rw-r--r-- | src/error_gui.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/error_gui.cpp b/src/error_gui.cpp index ee2d5325a..72e051281 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -127,6 +127,8 @@ public: typedef std::list<ErrorMessageData> ErrorList; /** The actual queue with errors. */ ErrorList _errors; +/** Whether the window system is initialized or not. */ +bool _window_system_initialized = false; /** Window class for displaying an error message window. */ struct ErrmsgWindow : public Window, ErrorMessageData { @@ -261,11 +263,7 @@ public: ~ErrmsgWindow() { SetRedErrorSquare(INVALID_TILE); - - if (!_errors.empty()) { - new ErrmsgWindow(_errors.front()); - _errors.pop_front(); - } + if (_window_system_initialized) ShowFirstError(); } virtual EventState OnKeyPress(uint16 key, uint16 keycode) @@ -293,6 +291,30 @@ void ClearErrorMessages() _errors.clear(); } +/** Show the first error of the queue. */ +void ShowFirstError() +{ + _window_system_initialized = true; + if (!_errors.empty()) { + new ErrmsgWindow(_errors.front()); + _errors.pop_front(); + } +} + +/** + * 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. + */ +void UnshowCriticalError() +{ + ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0); + if (w != NULL) { + if (w->IsCritical()) _errors.push_front(*w); + _window_system_initialized = false; + } +} + /** * Display an error message in a window. * @param summary_msg General error message showed in first line. Must be valid. |