1
0
Fork 0

(svn r24248) -Codechange: Move ErrorMessageData class definition to header file.

release/1.3
frosch 2012-05-14 20:58:59 +00:00
parent c11d80148f
commit fd6f92a4e8
2 changed files with 66 additions and 60 deletions

View File

@ -13,6 +13,8 @@
#define ERROR_H #define ERROR_H
#include "strings_type.h" #include "strings_type.h"
#include "company_type.h"
#include "core/geometry_type.hpp"
/** Message severity/type */ /** Message severity/type */
enum WarningLevel { enum WarningLevel {
@ -22,6 +24,25 @@ enum WarningLevel {
WL_CRITICAL, ///< Critical errors, the MessageBox is shown in all cases WL_CRITICAL, ///< Critical errors, the MessageBox is shown in all cases
}; };
/** The data of the error message. */
class ErrorMessageData {
protected:
uint duration; ///< Length of display of the message. 0 means forever,
uint64 decode_params[20]; ///< Parameters of the message strings.
const char *strings[20]; ///< Copies of raw strings that were used.
uint textref_stack_size; ///< Number of uint32 values to put on the #TextRefStack for the error message.
uint32 textref_stack[16]; ///< Values to put on the #TextRefStack for the error message.
StringID summary_msg; ///< General error message showed in first line. Must be valid.
StringID detailed_msg; ///< Detailed error message showed in second line. Can be #INVALID_STRING_ID.
Point position; ///< Position of the error message window.
CompanyID face; ///< Company belonging to the face being shown. #INVALID_COMPANY if no face present.
public:
ErrorMessageData(const ErrorMessageData &data);
~ErrorMessageData();
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);
};
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); 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);
void ClearErrorMessages(); void ClearErrorMessages();
void ShowFirstError(); void ShowFirstError();

View File

@ -66,25 +66,11 @@ static const WindowDesc _errmsg_face_desc(
_nested_errmsg_face_widgets, lengthof(_nested_errmsg_face_widgets) _nested_errmsg_face_widgets, lengthof(_nested_errmsg_face_widgets)
); );
/** The data of the error message. */
class ErrorMessageData {
protected:
uint duration; ///< Length of display of the message. 0 means forever,
uint64 decode_params[20]; ///< Parameters of the message strings.
const char *strings[20]; ///< Copies of raw strings that were used.
uint textref_stack_size; ///< Number of uint32 values to put on the #TextRefStack for the error message.
uint32 textref_stack[16]; ///< Values to put on the #TextRefStack for the error message.
StringID summary_msg; ///< General error message showed in first line. Must be valid.
StringID detailed_msg; ///< Detailed error message showed in second line. Can be #INVALID_STRING_ID.
Point position; ///< Position of the error message window.
CompanyID face; ///< Company belonging to the face being shown. #INVALID_COMPANY if no face present.
public:
/** /**
* Copy the given data into our instace. * Copy the given data into our instace.
* @param data The data to copy. * @param data The data to copy.
*/ */
ErrorMessageData(const ErrorMessageData &data) ErrorMessageData::ErrorMessageData(const ErrorMessageData &data)
{ {
*this = data; *this = data;
for (size_t i = 0; i < lengthof(this->strings); i++) { for (size_t i = 0; i < lengthof(this->strings); i++) {
@ -96,7 +82,7 @@ public:
} }
/** Free all the strings. */ /** Free all the strings. */
~ErrorMessageData() ErrorMessageData::~ErrorMessageData()
{ {
for (size_t i = 0; i < lengthof(this->strings); i++) free(this->strings[i]); for (size_t i = 0; i < lengthof(this->strings); i++) free(this->strings[i]);
} }
@ -111,7 +97,7 @@ public:
* @param textref_stack_size Number of uint32 values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used. * @param textref_stack_size Number of uint32 values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used.
* @param textref_stack Values to put on the #TextRefStack. * @param textref_stack Values to put on the #TextRefStack.
*/ */
ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration, int x, int y, uint textref_stack_size, const uint32 *textref_stack) : ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration, int x, int y, uint textref_stack_size, const uint32 *textref_stack) :
duration(duration), duration(duration),
textref_stack_size(textref_stack_size), textref_stack_size(textref_stack_size),
summary_msg(summary_msg), summary_msg(summary_msg),
@ -131,7 +117,6 @@ public:
assert(summary_msg != INVALID_STRING_ID); assert(summary_msg != INVALID_STRING_ID);
} }
};
/** Define a queue with errors. */ /** Define a queue with errors. */
typedef std::list<ErrorMessageData> ErrorList; typedef std::list<ErrorMessageData> ErrorList;