MsgHandler.h 2.9 KB

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