diff options
Diffstat (limited to 'src/common/msg_handler.h')
| -rw-r--r-- | src/common/msg_handler.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/common/msg_handler.h b/src/common/msg_handler.h new file mode 100644 index 000000000..bde2808fa --- /dev/null +++ b/src/common/msg_handler.h | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | // Copyright 2013 Dolphin Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #ifndef _MSGHANDLER_H_ | ||
| 6 | #define _MSGHANDLER_H_ | ||
| 7 | |||
| 8 | #include <string> | ||
| 9 | |||
| 10 | // Message alerts | ||
| 11 | enum MSG_TYPE | ||
| 12 | { | ||
| 13 | INFORMATION, | ||
| 14 | QUESTION, | ||
| 15 | WARNING, | ||
| 16 | CRITICAL | ||
| 17 | }; | ||
| 18 | |||
| 19 | typedef bool (*MsgAlertHandler)(const char* caption, const char* text, | ||
| 20 | bool yes_no, int Style); | ||
| 21 | typedef std::string (*StringTranslator)(const char* text); | ||
| 22 | |||
| 23 | void RegisterMsgAlertHandler(MsgAlertHandler handler); | ||
| 24 | void RegisterStringTranslator(StringTranslator translator); | ||
| 25 | |||
| 26 | extern bool MsgAlert(bool yes_no, int Style, const char* format, ...) | ||
| 27 | #ifdef __GNUC__ | ||
| 28 | __attribute__((format(printf, 3, 4))) | ||
| 29 | #endif | ||
| 30 | ; | ||
| 31 | void SetEnableAlert(bool enable); | ||
| 32 | |||
| 33 | #ifndef GEKKO | ||
| 34 | #ifdef _WIN32 | ||
| 35 | #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__) | ||
| 36 | #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__) | ||
| 37 | #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__) | ||
| 38 | #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__) | ||
| 39 | #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__) | ||
| 40 | // Use these macros (that do the same thing) if the message should be translated. | ||
| 41 | #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__) | ||
| 42 | #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__) | ||
| 43 | #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__) | ||
| 44 | #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__) | ||
| 45 | #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__) | ||
| 46 | #else | ||
| 47 | #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__) | ||
| 48 | #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__) | ||
| 49 | #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__) | ||
| 50 | #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__) | ||
| 51 | #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__) | ||
| 52 | // Use these macros (that do the same thing) if the message should be translated. | ||
| 53 | #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__) | ||
| 54 | #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__) | ||
| 55 | #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__) | ||
| 56 | #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__) | ||
| 57 | #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__) | ||
| 58 | #endif | ||
| 59 | #else | ||
| 60 | // GEKKO | ||
| 61 | #define SuccessAlert(format, ...) ; | ||
| 62 | #define PanicAlert(format, ...) ; | ||
| 63 | #define PanicYesNo(format, ...) ; | ||
| 64 | #define AskYesNo(format, ...) ; | ||
| 65 | #define CriticalAlert(format, ...) ; | ||
| 66 | #define SuccessAlertT(format, ...) ; | ||
| 67 | #define PanicAlertT(format, ...) ; | ||
| 68 | #define PanicYesNoT(format, ...) ; | ||
| 69 | #define AskYesNoT(format, ...) ; | ||
| 70 | #define CriticalAlertT(format, ...) ; | ||
| 71 | #endif | ||
| 72 | |||
| 73 | #endif // _MSGHANDLER_H_ | ||