mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Common/MsgHandler: Make default message handler and translator's internally linked
Previously these functions were declared without the static specifier, giving them external linkage, which isn't really ideal. Instead, we can place these functions up by the relevant file-scope variables and place them inside an anonymous namespace with said variables, giving them internal linkage.
This commit is contained in:
parent
d1475f6d59
commit
76b675e9f0
@ -19,12 +19,38 @@
|
|||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, MsgType style);
|
namespace
|
||||||
static MsgAlertHandler msg_handler = DefaultMsgHandler;
|
{
|
||||||
static bool AlertEnabled = true;
|
// Default non library dependent panic alert
|
||||||
|
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, MsgType style)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
int window_style = MB_ICONINFORMATION;
|
||||||
|
if (style == MsgType::Question)
|
||||||
|
window_style = MB_ICONQUESTION;
|
||||||
|
if (style == MsgType::Warning)
|
||||||
|
window_style = MB_ICONWARNING;
|
||||||
|
|
||||||
std::string DefaultStringTranslator(const char* text);
|
return IDYES == MessageBox(0, UTF8ToTStr(text).c_str(), UTF8ToTStr(caption).c_str(),
|
||||||
static StringTranslator str_translator = DefaultStringTranslator;
|
window_style | (yes_no ? MB_YESNO : MB_OK));
|
||||||
|
#else
|
||||||
|
fmt::print(stderr, "{}\n", text);
|
||||||
|
|
||||||
|
// Return no to any question (which will in general crash the emulator)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default (non) translator
|
||||||
|
std::string DefaultStringTranslator(const char* text)
|
||||||
|
{
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
MsgAlertHandler msg_handler = DefaultMsgHandler;
|
||||||
|
StringTranslator str_translator = DefaultStringTranslator;
|
||||||
|
bool AlertEnabled = true;
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
// Select which of these functions that are used for message boxes. If
|
// Select which of these functions that are used for message boxes. If
|
||||||
// Qt is enabled we will use QtMsgAlertHandler() that is defined in Main.cpp
|
// Qt is enabled we will use QtMsgAlertHandler() that is defined in Main.cpp
|
||||||
@ -100,29 +126,3 @@ bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default non library dependent panic alert
|
|
||||||
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, MsgType style)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
int window_style = MB_ICONINFORMATION;
|
|
||||||
if (style == MsgType::Question)
|
|
||||||
window_style = MB_ICONQUESTION;
|
|
||||||
if (style == MsgType::Warning)
|
|
||||||
window_style = MB_ICONWARNING;
|
|
||||||
|
|
||||||
return IDYES == MessageBox(0, UTF8ToTStr(text).c_str(), UTF8ToTStr(caption).c_str(),
|
|
||||||
window_style | (yes_no ? MB_YESNO : MB_OK));
|
|
||||||
#else
|
|
||||||
fmt::print(stderr, "{}\n", text);
|
|
||||||
|
|
||||||
// Return no to any question (which will in general crash the emulator)
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default (non) translator
|
|
||||||
std::string DefaultStringTranslator(const char* text)
|
|
||||||
{
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user