Settings: Remove second source of truth for OSD notifications
And split it into warnings/messages. Warnings are always displayed regardless of the "Show OSD Messages" setting, because they're critical and users forget they disable messages.
This commit is contained in:
@@ -543,7 +543,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
|
||||
}
|
||||
else if (settings.gpu_pgxp_enable && settings.gpu_pgxp_vertex_cache)
|
||||
{
|
||||
Host::AddIconOSDMessage(
|
||||
Host::AddIconOSDWarning(
|
||||
"gamedb_force_pgxp_vertex_cache", ICON_EMOJI_WARNING,
|
||||
TRANSLATE_STR(
|
||||
"GameDatabase",
|
||||
@@ -558,7 +558,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
|
||||
#ifndef __ANDROID__
|
||||
APPEND_MESSAGE(TRANSLATE_SV("GameDatabase", "PGXP CPU mode enabled."));
|
||||
#else
|
||||
Host::AddIconOSDMessage("gamedb_force_pgxp_cpu", ICON_EMOJI_WARNING,
|
||||
Host::AddIconOSDWarning("gamedb_force_pgxp_cpu", ICON_EMOJI_WARNING,
|
||||
"This game requires PGXP CPU mode, which increases system requirements.\n"
|
||||
" If the game runs too slow, disable PGXP for this game.",
|
||||
Host::OSD_WARNING_DURATION);
|
||||
@@ -569,7 +569,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
|
||||
}
|
||||
else if (settings.UsingPGXPCPUMode())
|
||||
{
|
||||
Host::AddIconOSDMessage(
|
||||
Host::AddIconOSDWarning(
|
||||
"gamedb_force_pgxp_cpu", ICON_EMOJI_WARNING,
|
||||
TRANSLATE_STR("GameDatabase",
|
||||
"PGXP CPU mode is enabled, but it is not required for this game. This may cause rendering errors."),
|
||||
|
||||
@@ -315,8 +315,7 @@ bool Host::CreateGPUDevice(RenderAPI api, Error* error)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ImGuiManager::Initialize(g_settings.display_osd_scale / 100.0f, g_settings.display_show_osd_messages,
|
||||
&create_error))
|
||||
if (!ImGuiManager::Initialize(g_settings.display_osd_scale / 100.0f, &create_error))
|
||||
{
|
||||
ERROR_LOG("Failed to initialize ImGuiManager: {}", create_error.GetDescription());
|
||||
Error::SetStringFmt(error, "Failed to initialize ImGuiManager: {}", create_error.GetDescription());
|
||||
|
||||
@@ -304,7 +304,7 @@ void Settings::Load(SettingsInterface& si, SettingsInterface& controller_si)
|
||||
display_active_end_offset = static_cast<s16>(si.GetIntValue("Display", "ActiveEndOffset", 0));
|
||||
display_line_start_offset = static_cast<s8>(si.GetIntValue("Display", "LineStartOffset", 0));
|
||||
display_line_end_offset = static_cast<s8>(si.GetIntValue("Display", "LineEndOffset", 0));
|
||||
display_show_osd_messages = si.GetBoolValue("Display", "ShowOSDMessages", true);
|
||||
ImGuiManager::SetShowOSDMessages(si.GetBoolValue("Display", "ShowOSDMessages", true));
|
||||
display_show_fps = si.GetBoolValue("Display", "ShowFPS", false);
|
||||
display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false);
|
||||
display_show_gpu_stats = si.GetBoolValue("Display", "ShowGPUStatistics", false);
|
||||
@@ -573,7 +573,7 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const
|
||||
si.GetIntValue("Display", "CustomAspectRatioDenominator", display_aspect_ratio_custom_denominator);
|
||||
if (!ignore_base)
|
||||
{
|
||||
si.SetBoolValue("Display", "ShowOSDMessages", display_show_osd_messages);
|
||||
si.SetBoolValue("Display", "ShowOSDMessages", ImGuiManager::IsShowingOSDMessages());
|
||||
si.SetBoolValue("Display", "ShowFPS", display_show_fps);
|
||||
si.SetBoolValue("Display", "ShowSpeed", display_show_speed);
|
||||
si.SetBoolValue("Display", "ShowResolution", display_show_resolution);
|
||||
|
||||
@@ -159,7 +159,6 @@ struct Settings
|
||||
bool display_disable_mailbox_presentation : 1 = true;
|
||||
bool display_force_4_3_for_24bit : 1 = false;
|
||||
bool display_24bit_chroma_smoothing : 1 = false;
|
||||
bool display_show_osd_messages : 1 = true;
|
||||
bool display_show_fps : 1 = false;
|
||||
bool display_show_speed : 1 = false;
|
||||
bool display_show_gpu_stats : 1 = false;
|
||||
|
||||
@@ -1236,7 +1236,7 @@ void System::HandleHostGPUDeviceLost()
|
||||
std::memcpy(g_vram, vram_backup.data(), VRAM_SIZE);
|
||||
|
||||
// First frame after reopening is definitely going to be trash, so skip it.
|
||||
Host::AddIconOSDMessage(
|
||||
Host::AddIconOSDWarning(
|
||||
"HostGPUDeviceLost", ICON_EMOJI_WARNING,
|
||||
TRANSLATE_STR("System", "Host GPU device encountered an error and has recovered. This may cause broken rendering."),
|
||||
Host::OSD_CRITICAL_ERROR_DURATION);
|
||||
@@ -1301,7 +1301,7 @@ LayeredSettingsInterface System::GetControllerSettingsLayers(std::unique_lock<st
|
||||
// Select input profile _or_ game settings, not both.
|
||||
if (SettingsInterface* isi = Host::Internal::GetInputSettingsLayer())
|
||||
{
|
||||
ret.SetLayer(LayeredSettingsInterface::Layer::LAYER_INPUT, Host::Internal::GetInputSettingsLayer());
|
||||
ret.SetLayer(LayeredSettingsInterface::Layer::LAYER_INPUT, isi);
|
||||
}
|
||||
else if (SettingsInterface* gsi = Host::Internal::GetGameSettingsLayer();
|
||||
gsi && gsi->GetBoolValue("ControllerPorts", "UseGameSettingsForController", false))
|
||||
@@ -1332,7 +1332,6 @@ void System::SetDefaultSettings(SettingsInterface& si)
|
||||
Settings temp;
|
||||
|
||||
// we don't want to reset some things (e.g. OSD)
|
||||
temp.display_show_osd_messages = g_settings.display_show_osd_messages;
|
||||
temp.display_show_fps = g_settings.display_show_fps;
|
||||
temp.display_show_speed = g_settings.display_show_speed;
|
||||
temp.display_show_gpu_stats = g_settings.display_show_gpu_stats;
|
||||
@@ -1940,7 +1939,8 @@ void System::DestroySystem()
|
||||
GDBServer::Shutdown();
|
||||
#endif
|
||||
|
||||
Host::ClearOSDMessages();
|
||||
// TODO-GPU-THREAD: Needs to be called on GPU thread.
|
||||
Host::ClearOSDMessages(true);
|
||||
|
||||
PostProcessing::Shutdown();
|
||||
|
||||
@@ -2398,7 +2398,7 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
|
||||
{
|
||||
WARNING_LOG("BIOS hash mismatch: System: {} | State: {}", BIOS::ImageInfo::GetHashString(s_bios_hash),
|
||||
BIOS::ImageInfo::GetHashString(bios_hash));
|
||||
Host::AddIconOSDMessage(
|
||||
Host::AddIconOSDWarning(
|
||||
"StateBIOSMismatch", ICON_FA_EXCLAMATION_TRIANGLE,
|
||||
TRANSLATE_STR("System", "This save state was created with a different BIOS. This may cause stability issues."),
|
||||
Host::OSD_WARNING_DURATION);
|
||||
@@ -3934,7 +3934,7 @@ bool System::InsertMedia(const char* path)
|
||||
std::unique_ptr<CDImage> image = CDImage::Open(path, g_settings.cdrom_load_image_patches, &error);
|
||||
if (!image)
|
||||
{
|
||||
Host::AddIconOSDMessage(
|
||||
Host::AddIconOSDWarning(
|
||||
"DiscInserted", ICON_FA_COMPACT_DISC,
|
||||
fmt::format(TRANSLATE_FS("OSDMessage", "Failed to open disc image '{}': {}."), path, error.GetDescription()),
|
||||
Host::OSD_ERROR_DURATION);
|
||||
@@ -4473,8 +4473,6 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
|
||||
{
|
||||
if (g_settings.display_osd_scale != old_settings.display_osd_scale)
|
||||
ImGuiManager::SetGlobalScale(g_settings.display_osd_scale / 100.0f);
|
||||
if (g_settings.display_show_osd_messages != old_settings.display_show_osd_messages)
|
||||
ImGuiManager::SetShowOSDMessages(g_settings.display_show_osd_messages);
|
||||
}
|
||||
|
||||
bool controllers_updated = false;
|
||||
@@ -4600,6 +4598,8 @@ void System::WarnAboutUnsafeSettings()
|
||||
{
|
||||
append(ICON_EMOJI_WARNING, TRANSLATE_SV("System", "All enhancements are currently disabled."));
|
||||
|
||||
if (ImGuiManager::IsShowingOSDMessages())
|
||||
{
|
||||
#define APPEND_SUBMESSAGE(msg) \
|
||||
do \
|
||||
{ \
|
||||
@@ -4608,47 +4608,48 @@ void System::WarnAboutUnsafeSettings()
|
||||
messages.append('\n'); \
|
||||
} while (0)
|
||||
|
||||
if (g_settings.cpu_overclock_active)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Overclock disabled."));
|
||||
if (g_settings.enable_8mb_ram)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "8MB RAM disabled."));
|
||||
if (g_settings.enable_cheats)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Cheats disabled."));
|
||||
if (g_settings.gpu_resolution_scale != 1)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Resolution scale set to 1x."));
|
||||
if (g_settings.gpu_multisamples != 1)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Multisample anti-aliasing disabled."));
|
||||
if (g_settings.gpu_true_color)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "True color disabled."));
|
||||
if (g_settings.gpu_texture_filter != GPUTextureFilter::Nearest ||
|
||||
g_settings.gpu_sprite_texture_filter != GPUTextureFilter::Nearest)
|
||||
{
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Texture filtering disabled."));
|
||||
}
|
||||
if (g_settings.display_deinterlacing_mode == DisplayDeinterlacingMode::Progressive)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Interlaced rendering enabled."));
|
||||
if (g_settings.gpu_force_video_timing != ForceVideoTimingMode::Disabled)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Video timings set to default."));
|
||||
if (g_settings.gpu_widescreen_hack)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Widescreen rendering disabled."));
|
||||
if (g_settings.display_24bit_chroma_smoothing)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "FMV chroma smoothing disabled."));
|
||||
if (g_settings.cdrom_read_speedup != 1)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "CD-ROM read speedup disabled."));
|
||||
if (g_settings.cdrom_seek_speedup != 1)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "CD-ROM seek speedup disabled."));
|
||||
if (g_settings.cdrom_mute_cd_audio)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Mute CD-ROM audio disabled."));
|
||||
if (g_settings.texture_replacements.enable_vram_write_replacements)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "VRAM write texture replacements disabled."));
|
||||
if (g_settings.use_old_mdec_routines)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Use old MDEC routines disabled."));
|
||||
if (g_settings.pcdrv_enable)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "PCDrv disabled."));
|
||||
if (g_settings.bios_patch_fast_boot)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Fast boot disabled."));
|
||||
if (g_settings.cpu_overclock_active)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Overclock disabled."));
|
||||
if (g_settings.enable_8mb_ram)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "8MB RAM disabled."));
|
||||
if (g_settings.enable_cheats)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Cheats disabled."));
|
||||
if (g_settings.gpu_resolution_scale != 1)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Resolution scale set to 1x."));
|
||||
if (g_settings.gpu_multisamples != 1)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Multisample anti-aliasing disabled."));
|
||||
if (g_settings.gpu_true_color)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "True color disabled."));
|
||||
if (g_settings.gpu_texture_filter != GPUTextureFilter::Nearest ||
|
||||
g_settings.gpu_sprite_texture_filter != GPUTextureFilter::Nearest)
|
||||
{
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Texture filtering disabled."));
|
||||
}
|
||||
if (g_settings.display_deinterlacing_mode == DisplayDeinterlacingMode::Progressive)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Interlaced rendering enabled."));
|
||||
if (g_settings.gpu_force_video_timing != ForceVideoTimingMode::Disabled)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Video timings set to default."));
|
||||
if (g_settings.gpu_widescreen_hack)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Widescreen rendering disabled."));
|
||||
if (g_settings.display_24bit_chroma_smoothing)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "FMV chroma smoothing disabled."));
|
||||
if (g_settings.cdrom_read_speedup != 1)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "CD-ROM read speedup disabled."));
|
||||
if (g_settings.cdrom_seek_speedup != 1)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "CD-ROM seek speedup disabled."));
|
||||
if (g_settings.cdrom_mute_cd_audio)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Mute CD-ROM audio disabled."));
|
||||
if (g_settings.texture_replacements.enable_vram_write_replacements)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "VRAM write texture replacements disabled."));
|
||||
if (g_settings.use_old_mdec_routines)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Use old MDEC routines disabled."));
|
||||
if (g_settings.pcdrv_enable)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "PCDrv disabled."));
|
||||
if (g_settings.bios_patch_fast_boot)
|
||||
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Fast boot disabled."));
|
||||
|
||||
#undef APPEND_SUBMESSAGE
|
||||
}
|
||||
}
|
||||
|
||||
if (!g_settings.apply_compatibility_settings)
|
||||
@@ -4663,11 +4664,11 @@ void System::WarnAboutUnsafeSettings()
|
||||
messages.pop_back();
|
||||
|
||||
LogUnsafeSettingsToConsole(messages);
|
||||
Host::AddKeyedOSDMessage("performance_settings_warning", std::string(messages.view()), Host::OSD_WARNING_DURATION);
|
||||
Host::AddKeyedOSDWarning("performance_settings_warning", std::string(messages.view()), Host::OSD_WARNING_DURATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
Host::RemoveKeyedOSDMessage("performance_settings_warning");
|
||||
Host::RemoveKeyedOSDWarning("performance_settings_warning");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5214,7 +5215,7 @@ bool System::StartMediaCapture(std::string path, bool capture_video, bool captur
|
||||
std::string(),
|
||||
&error))
|
||||
{
|
||||
Host::AddIconOSDMessage(
|
||||
Host::AddIconOSDWarning(
|
||||
"MediaCapture", ICON_FA_EXCLAMATION_TRIANGLE,
|
||||
fmt::format(TRANSLATE_FS("System", "Failed to create media capture: {0}"), error.GetDescription()),
|
||||
Host::OSD_ERROR_DURATION);
|
||||
@@ -5253,7 +5254,7 @@ void System::StopMediaCapture()
|
||||
}
|
||||
else
|
||||
{
|
||||
Host::AddIconOSDMessage(
|
||||
Host::AddIconOSDWarning(
|
||||
"MediaCapture", ICON_FA_EXCLAMATION_TRIANGLE,
|
||||
fmt::format(TRANSLATE_FS("System", "Stopped {0}: {1}."),
|
||||
GetCaptureTypeForMessage(s_media_capture->IsCapturingVideo(), s_media_capture->IsCapturingAudio()),
|
||||
|
||||
@@ -381,7 +381,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
|
||||
dialog->registerWidgetHelp(
|
||||
m_ui.stretchDisplayVertically, tr("Stretch Vertically"), tr("Unchecked"),
|
||||
tr("Prefers stretching the display vertically instead of horizontally, when applying the display aspect ratio."));
|
||||
dialog->registerWidgetHelp(m_ui.stretchDisplayVertically, tr("Automatically Resize Window"), tr("Unchecked"),
|
||||
dialog->registerWidgetHelp(m_ui.automaticallyResizeWindow, tr("Automatically Resize Window"), tr("Unchecked"),
|
||||
tr("Automatically resizes the window to match the internal resolution. <strong>For high "
|
||||
"internal resolutions, this will create very large windows.</strong>"));
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -56,6 +56,7 @@ struct OSDMessage
|
||||
float duration;
|
||||
float target_y;
|
||||
float last_y;
|
||||
bool is_warning;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -71,6 +72,9 @@ static bool AddImGuiFonts(bool fullscreen_fonts);
|
||||
static ImFont* AddTextFont(float size, bool full_glyph_range);
|
||||
static ImFont* AddFixedFont(float size);
|
||||
static bool AddIconFonts(float size);
|
||||
static void AddOSDMessage(std::string key, std::string message, float duration, bool is_warning);
|
||||
static void RemoveKeyedOSDMessage(std::string key, bool is_warning);
|
||||
static void ClearOSDMessages(bool clear_warnings);
|
||||
static void AcquirePendingOSDMessages(Common::Timer::Value current_time);
|
||||
static void DrawOSDMessages(Common::Timer::Value current_time);
|
||||
static void CreateSoftwareCursorTextures();
|
||||
@@ -203,6 +207,11 @@ void ImGuiManager::SetGlobalScale(float global_scale)
|
||||
s_scale_changed = true;
|
||||
}
|
||||
|
||||
bool ImGuiManager::IsShowingOSDMessages()
|
||||
{
|
||||
return s_show_osd_messages;
|
||||
}
|
||||
|
||||
void ImGuiManager::SetShowOSDMessages(bool enable)
|
||||
{
|
||||
if (s_show_osd_messages == enable)
|
||||
@@ -210,10 +219,10 @@ void ImGuiManager::SetShowOSDMessages(bool enable)
|
||||
|
||||
s_show_osd_messages = enable;
|
||||
if (!enable)
|
||||
Host::ClearOSDMessages();
|
||||
Host::ClearOSDMessages(false);
|
||||
}
|
||||
|
||||
bool ImGuiManager::Initialize(float global_scale, bool show_osd_messages, Error* error)
|
||||
bool ImGuiManager::Initialize(float global_scale, Error* error)
|
||||
{
|
||||
if (!LoadFontData())
|
||||
{
|
||||
@@ -224,7 +233,6 @@ bool ImGuiManager::Initialize(float global_scale, bool show_osd_messages, Error*
|
||||
s_global_prescale = global_scale;
|
||||
s_global_scale = std::max(g_gpu_device->GetWindowScale() * global_scale, 1.0f);
|
||||
s_scale_changed = false;
|
||||
s_show_osd_messages = show_osd_messages;
|
||||
|
||||
ImGui::CreateContext();
|
||||
|
||||
@@ -743,24 +751,19 @@ bool ImGuiManager::HasFullscreenFonts()
|
||||
return (s_medium_font && s_large_font);
|
||||
}
|
||||
|
||||
void Host::AddOSDMessage(std::string message, float duration /*= 2.0f*/)
|
||||
{
|
||||
AddKeyedOSDMessage(std::string(), std::move(message), duration);
|
||||
}
|
||||
|
||||
void Host::AddKeyedOSDMessage(std::string key, std::string message, float duration /* = 2.0f */)
|
||||
void ImGuiManager::AddOSDMessage(std::string key, std::string message, float duration, bool is_warning)
|
||||
{
|
||||
if (!key.empty())
|
||||
INFO_LOG("OSD [{}]: {}", key, message);
|
||||
else
|
||||
INFO_LOG("OSD: {}", message);
|
||||
|
||||
if (!ImGuiManager::s_show_osd_messages)
|
||||
if (!s_show_osd_messages && !is_warning)
|
||||
return;
|
||||
|
||||
const Common::Timer::Value current_time = Common::Timer::GetCurrentValue();
|
||||
|
||||
ImGuiManager::OSDMessage msg;
|
||||
OSDMessage msg;
|
||||
msg.key = std::move(key);
|
||||
msg.text = std::move(message);
|
||||
msg.duration = duration;
|
||||
@@ -768,37 +771,60 @@ void Host::AddKeyedOSDMessage(std::string key, std::string message, float durati
|
||||
msg.move_time = current_time;
|
||||
msg.target_y = -1.0f;
|
||||
msg.last_y = -1.0f;
|
||||
msg.is_warning = is_warning;
|
||||
|
||||
std::unique_lock<std::mutex> lock(ImGuiManager::s_osd_messages_lock);
|
||||
ImGuiManager::s_osd_posted_messages.push_back(std::move(msg));
|
||||
std::unique_lock<std::mutex> lock(s_osd_messages_lock);
|
||||
s_osd_posted_messages.push_back(std::move(msg));
|
||||
}
|
||||
|
||||
void Host::AddIconOSDMessage(std::string key, const char* icon, std::string message, float duration /* = 2.0f */)
|
||||
void ImGuiManager::RemoveKeyedOSDMessage(std::string key, bool is_warning)
|
||||
{
|
||||
return AddKeyedOSDMessage(std::move(key), fmt::format("{} {}", icon, message), duration);
|
||||
}
|
||||
|
||||
void Host::RemoveKeyedOSDMessage(std::string key)
|
||||
{
|
||||
if (!ImGuiManager::s_show_osd_messages)
|
||||
if (!s_show_osd_messages && !is_warning)
|
||||
return;
|
||||
|
||||
ImGuiManager::OSDMessage msg = {};
|
||||
msg.key = std::move(key);
|
||||
msg.duration = 0.0f;
|
||||
msg.is_warning = is_warning;
|
||||
|
||||
std::unique_lock<std::mutex> lock(ImGuiManager::s_osd_messages_lock);
|
||||
ImGuiManager::s_osd_posted_messages.push_back(std::move(msg));
|
||||
std::unique_lock<std::mutex> lock(s_osd_messages_lock);
|
||||
s_osd_posted_messages.push_back(std::move(msg));
|
||||
}
|
||||
|
||||
void Host::ClearOSDMessages()
|
||||
void ImGuiManager::ClearOSDMessages(bool clear_warnings)
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(ImGuiManager::s_osd_messages_lock);
|
||||
ImGuiManager::s_osd_posted_messages.clear();
|
||||
std::unique_lock<std::mutex> lock(s_osd_messages_lock);
|
||||
if (clear_warnings)
|
||||
{
|
||||
s_osd_posted_messages.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto iter = s_osd_posted_messages.begin(); iter != s_osd_posted_messages.end();)
|
||||
{
|
||||
if (!iter->is_warning)
|
||||
iter = s_osd_posted_messages.erase(iter);
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiManager::s_osd_active_messages.clear();
|
||||
if (clear_warnings)
|
||||
{
|
||||
s_osd_active_messages.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto iter = s_osd_active_messages.begin(); iter != s_osd_active_messages.end();)
|
||||
{
|
||||
if (!iter->is_warning)
|
||||
s_osd_active_messages.erase(iter);
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiManager::AcquirePendingOSDMessages(Common::Timer::Value current_time)
|
||||
@@ -940,6 +966,46 @@ void ImGuiManager::RenderOSDMessages()
|
||||
DrawOSDMessages(current_time);
|
||||
}
|
||||
|
||||
void Host::AddOSDMessage(std::string message, float duration /*= 2.0f*/)
|
||||
{
|
||||
ImGuiManager::AddOSDMessage(std::string(), std::move(message), duration, false);
|
||||
}
|
||||
|
||||
void Host::AddKeyedOSDMessage(std::string key, std::string message, float duration /* = 2.0f */)
|
||||
{
|
||||
ImGuiManager::AddOSDMessage(std::move(key), std::move(message), duration, false);
|
||||
}
|
||||
|
||||
void Host::AddIconOSDMessage(std::string key, const char* icon, std::string message, float duration /* = 2.0f */)
|
||||
{
|
||||
ImGuiManager::AddOSDMessage(std::move(key), fmt::format("{} {}", icon, message), duration, false);
|
||||
}
|
||||
|
||||
void Host::AddKeyedOSDWarning(std::string key, std::string message, float duration /* = 2.0f */)
|
||||
{
|
||||
ImGuiManager::AddOSDMessage(std::move(key), std::move(message), duration, true);
|
||||
}
|
||||
|
||||
void Host::AddIconOSDWarning(std::string key, const char* icon, std::string message, float duration /* = 2.0f */)
|
||||
{
|
||||
ImGuiManager::AddOSDMessage(std::move(key), fmt::format("{} {}", icon, message), duration, true);
|
||||
}
|
||||
|
||||
void Host::RemoveKeyedOSDMessage(std::string key)
|
||||
{
|
||||
ImGuiManager::RemoveKeyedOSDMessage(std::move(key), false);
|
||||
}
|
||||
|
||||
void Host::RemoveKeyedOSDWarning(std::string key)
|
||||
{
|
||||
ImGuiManager::RemoveKeyedOSDMessage(std::move(key), true);
|
||||
}
|
||||
|
||||
void Host::ClearOSDMessages(bool clear_warnings)
|
||||
{
|
||||
ImGuiManager::ClearOSDMessages(clear_warnings);
|
||||
}
|
||||
|
||||
float ImGuiManager::GetGlobalScale()
|
||||
{
|
||||
return s_global_scale;
|
||||
|
||||
@@ -33,10 +33,11 @@ std::vector<WCharType> CompactFontRange(std::span<const WCharType> range);
|
||||
void SetGlobalScale(float global_scale);
|
||||
|
||||
/// Changes whether OSD messages are silently dropped.
|
||||
bool IsShowingOSDMessages();
|
||||
void SetShowOSDMessages(bool enable);
|
||||
|
||||
/// Initializes ImGui, creates fonts, etc.
|
||||
bool Initialize(float global_scale, bool show_osd_messages, Error* error);
|
||||
bool Initialize(float global_scale, Error* error);
|
||||
|
||||
/// Frees all ImGui resources.
|
||||
void Shutdown();
|
||||
@@ -137,6 +138,9 @@ static constexpr float OSD_QUICK_DURATION = 2.5f;
|
||||
void AddOSDMessage(std::string message, float duration = 2.0f);
|
||||
void AddKeyedOSDMessage(std::string key, std::string message, float duration = 2.0f);
|
||||
void AddIconOSDMessage(std::string key, const char* icon, std::string message, float duration = 2.0f);
|
||||
void AddKeyedOSDWarning(std::string key, std::string message, float duration = 2.0f);
|
||||
void AddIconOSDWarning(std::string key, const char* icon, std::string message, float duration = 2.0f);
|
||||
void RemoveKeyedOSDMessage(std::string key);
|
||||
void ClearOSDMessages();
|
||||
void RemoveKeyedOSDWarning(std::string key);
|
||||
void ClearOSDMessages(bool clear_warnings);
|
||||
} // namespace Host
|
||||
|
||||
Reference in New Issue
Block a user