msg_handler.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  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. extern 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. #ifdef _MSC_VER
  26. #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__)
  27. #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__)
  28. #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__)
  29. #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__)
  30. #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__)
  31. // Use these macros (that do the same thing) if the message should be translated.
  32. #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__)
  33. #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__)
  34. #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__)
  35. #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__)
  36. #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__)
  37. #else
  38. #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__)
  39. #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__)
  40. #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__)
  41. #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__)
  42. #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__)
  43. // Use these macros (that do the same thing) if the message should be translated.
  44. #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__)
  45. #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__)
  46. #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__)
  47. #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__)
  48. #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__)
  49. #endif