Skip to content

Commit 82ab3e8

Browse files
committed
Host: Add ReportStatusMessage()
1 parent 8f94a56 commit 82ab3e8

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

src/core/host.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ std::optional<std::time_t> GetResourceFileTimestamp(std::string_view filename, b
3737
/// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller.
3838
void ReportErrorAsync(std::string_view title, std::string_view message);
3939

40+
/// Displays a message in either the on-screen display or status bar, depending on host capabilities.
41+
void ReportStatusMessage(std::string_view message);
42+
4043
/// Displays an asynchronous confirmation on the UI thread, but does not block the caller.
4144
/// The callback may be executed on a different thread. Use RunOnCoreThread() in the callback to ensure safety.
4245
using ConfirmMessageAsyncCallback = std::function<void(bool)>;

src/duckstation-mini/mini_host.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,11 @@ void Host::ReportErrorAsync(std::string_view title, std::string_view message)
13291329
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, TinyString(title).c_str(), SmallString(message).c_str(), nullptr);
13301330
}
13311331

1332+
void Host::ReportStatusMessage(std::string_view message)
1333+
{
1334+
Host::AddOSDMessage(OSDMessageType::Info, std::string(message));
1335+
}
1336+
13321337
void Host::RequestResizeHostDisplay(s32 width, s32 height)
13331338
{
13341339
using namespace MiniHost;

src/duckstation-qt/qthost.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,6 +2081,14 @@ void Host::ReportErrorAsync(std::string_view title, std::string_view message)
20812081
message.empty() ? QString() : QString::fromUtf8(message.data(), message.size()));
20822082
}
20832083

2084+
void Host::ReportStatusMessage(std::string_view message)
2085+
{
2086+
if (message.empty())
2087+
return;
2088+
2089+
emit g_core_thread->statusMessage(QtUtils::StringViewToQString(message));
2090+
}
2091+
20842092
void Host::ConfirmMessageAsync(std::string_view title, std::string_view message, ConfirmMessageAsyncCallback callback,
20852093
std::string_view yes_text, std::string_view no_text)
20862094
{

src/duckstation-regtest/regtest_host.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ void Host::ReportErrorAsync(std::string_view title, std::string_view message)
166166
ERROR_LOG("ReportErrorAsync: {}", message);
167167
}
168168

169+
void Host::ReportStatusMessage(std::string_view message)
170+
{
171+
INFO_LOG("ReportStatusMessage: {}", message);
172+
}
173+
169174
void Host::ConfirmMessageAsync(std::string_view title, std::string_view message, ConfirmMessageAsyncCallback callback,
170175
std::string_view yes_text, std::string_view no_text)
171176
{

0 commit comments

Comments
 (0)