diff options
| author | Léo Lam <leo@innovatetechnologi.es> | 2019-06-20 13:37:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-20 13:37:24 +0200 |
| commit | 4885130799a357eee8e279ed68dac60d6bcd78ca (patch) | |
| tree | 01260bc72811143b0153b747d0d8b860638325eb /Source/Core/Common/MsgHandler.h | |
| parent | baf02194c1bf4a55620e3aee7d9c0a1658a61168 (diff) | |
| parent | 4f1f55093fcf98aa1592b6b8b1ad0d33c4461b50 (diff) | |
Merge pull request #8194 from lioncash/common-msg
Common/MsgHandler: Tidy up interface and namespace code
Diffstat (limited to 'Source/Core/Common/MsgHandler.h')
| -rw-r--r-- | Source/Core/Common/MsgHandler.h | 85 |
1 files changed, 63 insertions, 22 deletions
diff --git a/Source/Core/Common/MsgHandler.h b/Source/Core/Common/MsgHandler.h index dcb79f4196..b5f7efbe01 100644 --- a/Source/Core/Common/MsgHandler.h +++ b/Source/Core/Common/MsgHandler.h @@ -6,6 +6,8 @@ #include <string> +namespace Common +{ // Message alerts enum class MsgType { @@ -15,8 +17,8 @@ enum class MsgType Critical }; -typedef bool (*MsgAlertHandler)(const char* caption, const char* text, bool yes_no, MsgType style); -typedef std::string (*StringTranslator)(const char* text); +using MsgAlertHandler = bool (*)(const char* caption, const char* text, bool yes_no, MsgType style); +using StringTranslator = std::string (*)(const char* text); void RegisterMsgAlertHandler(MsgAlertHandler handler); void RegisterStringTranslator(StringTranslator translator); @@ -28,30 +30,69 @@ bool MsgAlert(bool yes_no, MsgType style, const char* format, ...) #endif ; void SetEnableAlert(bool enable); +} // namespace Common #ifdef _WIN32 -#define SuccessAlert(format, ...) MsgAlert(false, MsgType::Information, format, __VA_ARGS__) -#define PanicAlert(format, ...) MsgAlert(false, MsgType::Warning, format, __VA_ARGS__) -#define PanicYesNo(format, ...) MsgAlert(true, MsgType::Warning, format, __VA_ARGS__) -#define AskYesNo(format, ...) MsgAlert(true, MsgType::Question, format, __VA_ARGS__) -#define CriticalAlert(format, ...) MsgAlert(false, MsgType::Critical, format, __VA_ARGS__) +#define SuccessAlert(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Information, format, __VA_ARGS__) + +#define PanicAlert(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Warning, format, __VA_ARGS__) + +#define PanicYesNo(format, ...) \ + Common::MsgAlert(true, Common::MsgType::Warning, format, __VA_ARGS__) + +#define AskYesNo(format, ...) Common::MsgAlert(true, Common::MsgType::Question, format, __VA_ARGS__) + +#define CriticalAlert(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Critical, format, __VA_ARGS__) + // Use these macros (that do the same thing) if the message should be translated. -#define SuccessAlertT(format, ...) MsgAlert(false, MsgType::Information, format, __VA_ARGS__) -#define PanicAlertT(format, ...) MsgAlert(false, MsgType::Warning, format, __VA_ARGS__) -#define PanicYesNoT(format, ...) MsgAlert(true, MsgType::Warning, format, __VA_ARGS__) -#define AskYesNoT(format, ...) MsgAlert(true, MsgType::Question, format, __VA_ARGS__) -#define CriticalAlertT(format, ...) MsgAlert(false, MsgType::Critical, format, __VA_ARGS__) + +#define SuccessAlertT(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Information, format, __VA_ARGS__) + +#define PanicAlertT(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Warning, format, __VA_ARGS__) + +#define PanicYesNoT(format, ...) \ + Common::MsgAlert(true, Common::MsgType::Warning, format, __VA_ARGS__) + +#define AskYesNoT(format, ...) \ + Common::MsgAlert(true, Common::MsgType::Question, format, __VA_ARGS__) + +#define CriticalAlertT(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Critical, format, __VA_ARGS__) #else -#define SuccessAlert(format, ...) MsgAlert(false, MsgType::Information, format, ##__VA_ARGS__) -#define PanicAlert(format, ...) MsgAlert(false, MsgType::Warning, format, ##__VA_ARGS__) -#define PanicYesNo(format, ...) MsgAlert(true, MsgType::Warning, format, ##__VA_ARGS__) -#define AskYesNo(format, ...) MsgAlert(true, MsgType::Question, format, ##__VA_ARGS__) -#define CriticalAlert(format, ...) MsgAlert(false, MsgType::Critical, format, ##__VA_ARGS__) +#define SuccessAlert(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Information, format, ##__VA_ARGS__) + +#define PanicAlert(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Warning, format, ##__VA_ARGS__) + +#define PanicYesNo(format, ...) \ + Common::MsgAlert(true, Common::MsgType::Warning, format, ##__VA_ARGS__) + +#define AskYesNo(format, ...) \ + Common::MsgAlert(true, Common::MsgType::Question, format, ##__VA_ARGS__) + +#define CriticalAlert(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Critical, format, ##__VA_ARGS__) + // Use these macros (that do the same thing) if the message should be translated. -#define SuccessAlertT(format, ...) MsgAlert(false, MsgType::Information, format, ##__VA_ARGS__) -#define PanicAlertT(format, ...) MsgAlert(false, MsgType::Warning, format, ##__VA_ARGS__) -#define PanicYesNoT(format, ...) MsgAlert(true, MsgType::Warning, format, ##__VA_ARGS__) -#define AskYesNoT(format, ...) MsgAlert(true, MsgType::Question, format, ##__VA_ARGS__) -#define CriticalAlertT(format, ...) MsgAlert(false, MsgType::Critical, format, ##__VA_ARGS__) +#define SuccessAlertT(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Information, format, ##__VA_ARGS__) + +#define PanicAlertT(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Warning, format, ##__VA_ARGS__) + +#define PanicYesNoT(format, ...) \ + Common::MsgAlert(true, Common::MsgType::Warning, format, ##__VA_ARGS__) + +#define AskYesNoT(format, ...) \ + Common::MsgAlert(true, Common::MsgType::Question, format, ##__VA_ARGS__) + +#define CriticalAlertT(format, ...) \ + Common::MsgAlert(false, Common::MsgType::Critical, format, ##__VA_ARGS__) #endif |
