msg_handler.h 3.0 KB

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