NoGUI: Add ConfirmMessage() to platform

This commit is contained in:
Connor McLaughlin 2022-08-27 19:00:31 +10:00
parent d2d2e3ae6e
commit c90e2f19fc
10 changed files with 35 additions and 11 deletions

View file

@ -293,7 +293,6 @@ void Host::ReportErrorAsync(const std::string_view& title, const std::string_vie
bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message)
{
// TODO: Post to window
if (!title.empty() && !message.empty())
{
Log_ErrorPrintf("ConfirmMessage: %.*s: %.*s", static_cast<int>(title.size()), title.data(),
@ -304,7 +303,7 @@ bool Host::ConfirmMessage(const std::string_view& title, const std::string_view&
Log_ErrorPrintf("ConfirmMessage: %.*s", static_cast<int>(message.size()), message.data());
}
return true;
return g_nogui_window->ConfirmMessage(title, message);
}
void Host::ReportDebuggerMessage(const std::string_view& message)

View file

@ -16,6 +16,7 @@ public:
virtual ~NoGUIPlatform() = default;
virtual void ReportError(const std::string_view& title, const std::string_view& message) = 0;
virtual bool ConfirmMessage(const std::string_view& title, const std::string_view& message) = 0;
virtual void SetDefaultConfig(SettingsInterface& si) = 0;

View file

@ -43,9 +43,13 @@ bool VTYNoGUIPlatform::Initialize()
void VTYNoGUIPlatform::ReportError(const std::string_view& title, const std::string_view& message)
{
const std::string title_copy(title);
const std::string message_copy(message);
Log_ErrorPrintf("%s: %s", title_copy.c_str(), message_copy.c_str());
// not implemented
}
bool VTYNoGUIPlatform::ConfirmMessage(const std::string_view& title, const std::string_view& message)
{
// not implemented
return true;
}
void VTYNoGUIPlatform::SetDefaultConfig(SettingsInterface& si)

View file

@ -16,6 +16,7 @@ public:
bool Initialize();
void ReportError(const std::string_view& title, const std::string_view& message) override;
bool ConfirmMessage(const std::string_view& title, const std::string_view& message) override;
void SetDefaultConfig(SettingsInterface& si) override;

View file

@ -78,9 +78,13 @@ bool WaylandNoGUIPlatform::Initialize()
void WaylandNoGUIPlatform::ReportError(const std::string_view& title, const std::string_view& message)
{
const std::string title_copy(title);
const std::string message_copy(message);
Log_ErrorPrintf("%s: %s", title_copy.c_str(), message_copy.c_str());
// not implemented
}
bool WaylandNoGUIPlatform::ConfirmMessage(const std::string_view& title, const std::string_view& message)
{
// not implemented
return true;
}
void WaylandNoGUIPlatform::SetDefaultConfig(SettingsInterface& si) {}

View file

@ -21,6 +21,7 @@ public:
bool Initialize();
void ReportError(const std::string_view& title, const std::string_view& message) override;
bool ConfirmMessage(const std::string_view& title, const std::string_view& message) override;
void SetDefaultConfig(SettingsInterface& si) override;

View file

@ -79,6 +79,14 @@ void Win32NoGUIPlatform::ReportError(const std::string_view& title, const std::s
MessageBoxW(m_hwnd, message_copy.c_str(), title_copy.c_str(), MB_ICONERROR | MB_OK);
}
bool Win32NoGUIPlatform::ConfirmMessage(const std::string_view& title, const std::string_view& message)
{
const std::wstring title_copy(StringUtil::UTF8StringToWideString(title));
const std::wstring message_copy(StringUtil::UTF8StringToWideString(message));
return (MessageBoxW(m_hwnd, message_copy.c_str(), title_copy.c_str(), MB_ICONQUESTION | MB_YESNO) == IDYES);
}
void Win32NoGUIPlatform::SetDefaultConfig(SettingsInterface& si)
{
// noop

View file

@ -15,6 +15,7 @@ public:
bool Initialize();
void ReportError(const std::string_view& title, const std::string_view& message) override;
bool ConfirmMessage(const std::string_view& title, const std::string_view& message) override;
void SetDefaultConfig(SettingsInterface& si) override;

View file

@ -36,9 +36,13 @@ bool X11NoGUIPlatform::Initialize()
void X11NoGUIPlatform::ReportError(const std::string_view& title, const std::string_view& message)
{
const std::string title_copy(title);
const std::string message_copy(message);
Log_ErrorPrintf("%s: %s", title_copy.c_str(), message_copy.c_str());
// not implemented
}
bool X11NoGUIPlatform::ConfirmMessage(const std::string_view& title, const std::string_view& message)
{
// not implemented
return true;
}
void X11NoGUIPlatform::SetDefaultConfig(SettingsInterface& si) {}

View file

@ -40,6 +40,7 @@ public:
bool Initialize();
void ReportError(const std::string_view& title, const std::string_view& message) override;
bool ConfirmMessage(const std::string_view& title, const std::string_view& message) override;
void SetDefaultConfig(SettingsInterface& si) override;