System: OSD message corrections

This commit is contained in:
Stenzek 2024-05-24 21:57:51 +10:00
parent 49e3663dfe
commit 98520978a8
No known key found for this signature in database
6 changed files with 163 additions and 192 deletions

View file

@ -298,17 +298,19 @@ DEFINE_HOTKEY("ToggleOverclocking", TRANSLATE_NOOP("Hotkeys", "System"),
const u32 percent = g_settings.GetCPUOverclockPercent(); const u32 percent = g_settings.GetCPUOverclockPercent();
const double clock_speed = const double clock_speed =
((static_cast<double>(System::MASTER_CLOCK) * static_cast<double>(percent)) / 100.0) / 1000000.0; ((static_cast<double>(System::MASTER_CLOCK) * static_cast<double>(percent)) / 100.0) / 1000000.0;
Host::AddKeyedFormattedOSDMessage( Host::AddIconOSDMessage(
"ToggleOverclocking", 5.0f, "ToggleOverclocking", ICON_FA_TACHOMETER_ALT,
TRANSLATE("OSDMessage", "CPU clock speed control enabled (%u%% / %.3f MHz)."), percent, fmt::format(TRANSLATE_FS("OSDMessage", "CPU clock speed control enabled ({:.3f} MHz)."),
clock_speed); clock_speed),
Host::OSD_QUICK_DURATION);
} }
else else
{ {
Host::AddKeyedFormattedOSDMessage( Host::AddIconOSDMessage(
"ToggleOverclocking", 5.0f, "ToggleOverclocking", ICON_FA_TACHOMETER_ALT,
TRANSLATE("OSDMessage", "CPU clock speed control disabled (%.3f MHz)."), fmt::format(TRANSLATE_FS("OSDMessage", "CPU clock speed control disabled ({:.3f} MHz)."),
static_cast<double>(System::MASTER_CLOCK) / 1000000.0); static_cast<double>(System::MASTER_CLOCK) / 1000000.0),
Host::OSD_QUICK_DURATION);
} }
} }
}) })
@ -319,9 +321,11 @@ DEFINE_HOTKEY("IncreaseEmulationSpeed", TRANSLATE_NOOP("Hotkeys", "System"),
{ {
g_settings.emulation_speed += 0.1f; g_settings.emulation_speed += 0.1f;
System::UpdateSpeedLimiterState(); System::UpdateSpeedLimiterState();
Host::AddKeyedFormattedOSDMessage("EmulationSpeedChange", 5.0f, Host::AddIconOSDMessage(
TRANSLATE("OSDMessage", "Emulation speed set to %u%%."), "EmulationSpeedChange", ICON_FA_TACHOMETER_ALT,
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f))); fmt::format(TRANSLATE_FS("OSDMessage", "Emulation speed set to {}%."),
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f))),
Host::OSD_QUICK_DURATION);
} }
}) })
@ -331,9 +335,11 @@ DEFINE_HOTKEY("DecreaseEmulationSpeed", TRANSLATE_NOOP("Hotkeys", "System"),
{ {
g_settings.emulation_speed = std::max(g_settings.emulation_speed - 0.1f, 0.1f); g_settings.emulation_speed = std::max(g_settings.emulation_speed - 0.1f, 0.1f);
System::UpdateSpeedLimiterState(); System::UpdateSpeedLimiterState();
Host::AddKeyedFormattedOSDMessage("EmulationSpeedChange", 5.0f, Host::AddIconOSDMessage(
TRANSLATE("OSDMessage", "Emulation speed set to %u%%."), "EmulationSpeedChange", ICON_FA_TACHOMETER_ALT,
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f))); fmt::format(TRANSLATE_FS("OSDMessage", "Emulation speed set to {}%."),
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f))),
Host::OSD_QUICK_DURATION);
} }
}) })
@ -343,9 +349,11 @@ DEFINE_HOTKEY("ResetEmulationSpeed", TRANSLATE_NOOP("Hotkeys", "System"),
{ {
g_settings.emulation_speed = Host::GetFloatSettingValue("Main", "EmulationSpeed", 1.0f); g_settings.emulation_speed = Host::GetFloatSettingValue("Main", "EmulationSpeed", 1.0f);
System::UpdateSpeedLimiterState(); System::UpdateSpeedLimiterState();
Host::AddKeyedFormattedOSDMessage("EmulationSpeedChange", 5.0f, Host::AddIconOSDMessage(
TRANSLATE("OSDMessage", "Emulation speed set to %u%%."), "EmulationSpeedChange", ICON_FA_TACHOMETER_ALT,
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f))); fmt::format(TRANSLATE_FS("OSDMessage", "Emulation speed set to {}%."),
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f))),
Host::OSD_QUICK_DURATION);
} }
}) })
@ -547,24 +555,22 @@ DEFINE_HOTKEY("LoadSelectedSaveState", TRANSLATE_NOOP("Hotkeys", "Save States"),
Host::RunOnCPUThread(SaveStateSelectorUI::LoadCurrentSlot); Host::RunOnCPUThread(SaveStateSelectorUI::LoadCurrentSlot);
}) })
DEFINE_HOTKEY("SaveSelectedSaveState", TRANSLATE_NOOP("Hotkeys", "Save States"), DEFINE_HOTKEY("SaveSelectedSaveState", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Save To Selected Slot"), TRANSLATE_NOOP("Hotkeys", "Save To Selected Slot"), [](s32 pressed) {
[](s32 pressed) {
if (!pressed) if (!pressed)
Host::RunOnCPUThread(SaveStateSelectorUI::SaveCurrentSlot); Host::RunOnCPUThread(SaveStateSelectorUI::SaveCurrentSlot);
}) })
DEFINE_HOTKEY("SelectPreviousSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save States"), DEFINE_HOTKEY("SelectPreviousSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Select Previous Save Slot"), TRANSLATE_NOOP("Hotkeys", "Select Previous Save Slot"), [](s32 pressed) {
[](s32 pressed) {
if (!pressed) if (!pressed)
Host::RunOnCPUThread([]() { SaveStateSelectorUI::SelectPreviousSlot(true); }); Host::RunOnCPUThread([]() { SaveStateSelectorUI::SelectPreviousSlot(true); });
}) DEFINE_HOTKEY("SelectNextSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save States"), })
TRANSLATE_NOOP("Hotkeys", "Select Next Save Slot"), DEFINE_HOTKEY("SelectNextSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
[](s32 pressed) { TRANSLATE_NOOP("Hotkeys", "Select Next Save Slot"), [](s32 pressed) {
if (!pressed) if (!pressed)
Host::RunOnCPUThread([]() { SaveStateSelectorUI::SelectNextSlot(true); }); Host::RunOnCPUThread([]() { SaveStateSelectorUI::SelectNextSlot(true); });
}) DEFINE_HOTKEY("SaveStateAndSelectNextSlot", TRANSLATE_NOOP("Hotkeys", "Save States"), })
TRANSLATE_NOOP("Hotkeys", "Save State and Select Next Slot"), DEFINE_HOTKEY("SaveStateAndSelectNextSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
[](s32 pressed) { TRANSLATE_NOOP("Hotkeys", "Save State and Select Next Slot"), [](s32 pressed) {
if (!pressed && System::IsValid()) if (!pressed && System::IsValid())
{ {
SaveStateSelectorUI::SaveCurrentSlot(); SaveStateSelectorUI::SaveCurrentSlot();
@ -591,18 +597,19 @@ DEFINE_HOTKEY("SelectPreviousSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save Sta
Host::RunOnCPUThread([]() { HotkeySaveStateSlot(global, slot); }); \ Host::RunOnCPUThread([]() { HotkeySaveStateSlot(global, slot); }); \
}) })
// clang-format off
MAKE_LOAD_STATE_HOTKEY(false, 1, TRANSLATE_NOOP("Hotkeys", "Load Game State 1")) MAKE_LOAD_STATE_HOTKEY(false, 1, TRANSLATE_NOOP("Hotkeys", "Load Game State 1"))
MAKE_SAVE_STATE_HOTKEY(false, 1, TRANSLATE_NOOP("Hotkeys", "Save Game State 1")) MAKE_SAVE_STATE_HOTKEY(false, 1, TRANSLATE_NOOP("Hotkeys", "Save Game State 1"))
MAKE_LOAD_STATE_HOTKEY(false, 2, TRANSLATE_NOOP("Hotkeys", "Load Game State 2")) MAKE_SAVE_STATE_HOTKEY( MAKE_LOAD_STATE_HOTKEY(false, 2, TRANSLATE_NOOP("Hotkeys", "Load Game State 2"))
false, 2, TRANSLATE_NOOP("Hotkeys", "Save Game State 2")) MAKE_SAVE_STATE_HOTKEY(false, 2, TRANSLATE_NOOP("Hotkeys", "Save Game State 2"))
MAKE_LOAD_STATE_HOTKEY(false, 3, TRANSLATE_NOOP("Hotkeys", "Load Game State 3")) MAKE_SAVE_STATE_HOTKEY( MAKE_LOAD_STATE_HOTKEY(false, 3, TRANSLATE_NOOP("Hotkeys", "Load Game State 3"))
false, 3, TRANSLATE_NOOP("Hotkeys", "Save Game State 3")) MAKE_SAVE_STATE_HOTKEY(false, 3, TRANSLATE_NOOP("Hotkeys", "Save Game State 3"))
MAKE_LOAD_STATE_HOTKEY(false, 4, TRANSLATE_NOOP("Hotkeys", "Load Game State 4")) MAKE_SAVE_STATE_HOTKEY( MAKE_LOAD_STATE_HOTKEY(false, 4, TRANSLATE_NOOP("Hotkeys", "Load Game State 4"))
false, 4, TRANSLATE_NOOP("Hotkeys", "Save Game State 4")) MAKE_SAVE_STATE_HOTKEY(false, 4, TRANSLATE_NOOP("Hotkeys", "Save Game State 4"))
MAKE_LOAD_STATE_HOTKEY(false, 5, TRANSLATE_NOOP("Hotkeys", "Load Game State 5")) MAKE_SAVE_STATE_HOTKEY( MAKE_LOAD_STATE_HOTKEY(false, 5, TRANSLATE_NOOP("Hotkeys", "Load Game State 5"))
false, 5, TRANSLATE_NOOP("Hotkeys", "Save Game State 5")) MAKE_SAVE_STATE_HOTKEY(false, 5, TRANSLATE_NOOP("Hotkeys", "Save Game State 5"))
MAKE_LOAD_STATE_HOTKEY(false, 6, TRANSLATE_NOOP("Hotkeys", "Load Game State 6")) MAKE_SAVE_STATE_HOTKEY( MAKE_LOAD_STATE_HOTKEY(false, 6, TRANSLATE_NOOP("Hotkeys", "Load Game State 6"))
false, 6, TRANSLATE_NOOP("Hotkeys", "Save Game State 6")) MAKE_SAVE_STATE_HOTKEY(false, 6, TRANSLATE_NOOP("Hotkeys", "Save Game State 6"))
MAKE_LOAD_STATE_HOTKEY(false, 7, TRANSLATE_NOOP("Hotkeys", "Load Game State 7")) MAKE_LOAD_STATE_HOTKEY(false, 7, TRANSLATE_NOOP("Hotkeys", "Load Game State 7"))
MAKE_SAVE_STATE_HOTKEY(false, 7, TRANSLATE_NOOP("Hotkeys", "Save Game State 7")) MAKE_SAVE_STATE_HOTKEY(false, 7, TRANSLATE_NOOP("Hotkeys", "Save Game State 7"))
MAKE_LOAD_STATE_HOTKEY(false, 8, TRANSLATE_NOOP("Hotkeys", "Load Game State 8")) MAKE_LOAD_STATE_HOTKEY(false, 8, TRANSLATE_NOOP("Hotkeys", "Load Game State 8"))
@ -615,53 +622,24 @@ DEFINE_HOTKEY("SelectPreviousSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save Sta
MAKE_LOAD_STATE_HOTKEY(true, 1, TRANSLATE_NOOP("Hotkeys", "Load Global State 1")) MAKE_LOAD_STATE_HOTKEY(true, 1, TRANSLATE_NOOP("Hotkeys", "Load Global State 1"))
MAKE_SAVE_STATE_HOTKEY(true, 1, TRANSLATE_NOOP("Hotkeys", "Save Global State 1")) MAKE_SAVE_STATE_HOTKEY(true, 1, TRANSLATE_NOOP("Hotkeys", "Save Global State 1"))
MAKE_LOAD_STATE_HOTKEY(true, 2, TRANSLATE_NOOP("Hotkeys", "Load Global State 2")) MAKE_LOAD_STATE_HOTKEY(true, 2, TRANSLATE_NOOP("Hotkeys", "Load Global State 2"))
MAKE_SAVE_STATE_HOTKEY(true, 2, MAKE_SAVE_STATE_HOTKEY(true, 2, TRANSLATE_NOOP("Hotkeys", "Save Global State 2"))
TRANSLATE_NOOP("Hotkeys", "Save Global State 2")) MAKE_LOAD_STATE_HOTKEY(true, 3, TRANSLATE_NOOP("Hotkeys", "Load Global State 3"))
MAKE_LOAD_STATE_HOTKEY(true, MAKE_SAVE_STATE_HOTKEY(true, 3, TRANSLATE_NOOP("Hotkeys", "Save Global State 3"))
3, TRANSLATE_NOOP("Hotkeys", "Load Global State 3")) MAKE_LOAD_STATE_HOTKEY(true, 4, TRANSLATE_NOOP("Hotkeys", "Load Global State 4"))
MAKE_SAVE_STATE_HOTKEY(true, 3, MAKE_SAVE_STATE_HOTKEY(true, 4, TRANSLATE_NOOP("Hotkeys", "Save Global State 4"))
TRANSLATE_NOOP("Hotkeys", "Save Global State 3")) MAKE_LOAD_STATE_HOTKEY(true, 5, TRANSLATE_NOOP("Hotkeys", "Load Global State 5"))
MAKE_LOAD_STATE_HOTKEY(true, 4, MAKE_SAVE_STATE_HOTKEY(true, 5, TRANSLATE_NOOP("Hotkeys", "Save Global State 5"))
TRANSLATE_NOOP("Hotkeys", "Load Global State 4")) MAKE_LOAD_STATE_HOTKEY(true, 6, TRANSLATE_NOOP("Hotkeys", "Load Global State 6"))
MAKE_SAVE_STATE_HOTKEY(true, 4, MAKE_SAVE_STATE_HOTKEY(true, 6, TRANSLATE_NOOP("Hotkeys", "Save Global State 6"))
TRANSLATE_NOOP("Hotkeys", "Save Global State 4")) MAKE_LOAD_STATE_HOTKEY(true, 7, TRANSLATE_NOOP("Hotkeys", "Load Global State 7"))
MAKE_LOAD_STATE_HOTKEY(true, 5, MAKE_SAVE_STATE_HOTKEY(true, 7, TRANSLATE_NOOP("Hotkeys", "Save Global State 7"))
TRANSLATE_NOOP("Hotkeys", MAKE_LOAD_STATE_HOTKEY(true, 8, TRANSLATE_NOOP("Hotkeys", "Load Global State 8"))
"Load Global State 5")) MAKE_SAVE_STATE_HOTKEY(true, 8, TRANSLATE_NOOP("Hotkeys", "Save Global State 8"))
MAKE_SAVE_STATE_HOTKEY(true, 5, MAKE_LOAD_STATE_HOTKEY(true, 9, TRANSLATE_NOOP("Hotkeys", "Load Global State 9"))
TRANSLATE_NOOP("Hotkeys", MAKE_SAVE_STATE_HOTKEY(true, 9, TRANSLATE_NOOP("Hotkeys", "Save Global State 9"))
"Save Global State 5")) MAKE_LOAD_STATE_HOTKEY(true, 10, TRANSLATE_NOOP("Hotkeys", "Load Global State 10"))
MAKE_LOAD_STATE_HOTKEY(true, 6, MAKE_SAVE_STATE_HOTKEY(true, 10, TRANSLATE_NOOP("Hotkeys", "Save Global State 10"))
TRANSLATE_NOOP("Hotkeys", // clang-format on
"Load Global State 6"))
MAKE_SAVE_STATE_HOTKEY(true, 6,
TRANSLATE_NOOP("Hotkeys",
"Save Global State 6"))
MAKE_LOAD_STATE_HOTKEY(true, 7,
TRANSLATE_NOOP("Hotkeys",
"Load Global State 7"))
MAKE_SAVE_STATE_HOTKEY(
true, 7, TRANSLATE_NOOP("Hotkeys", "Save Global State 7"))
MAKE_LOAD_STATE_HOTKEY(
true, 8,
TRANSLATE_NOOP("Hotkeys", "Load Global State 8"))
MAKE_SAVE_STATE_HOTKEY(
true, 8,
TRANSLATE_NOOP("Hotkeys", "Save Global State 8"))
MAKE_LOAD_STATE_HOTKEY(
true, 9,
TRANSLATE_NOOP("Hotkeys", "Load Global State 9"))
MAKE_SAVE_STATE_HOTKEY(
true, 9,
TRANSLATE_NOOP("Hotkeys", "Save Global State 9"))
MAKE_LOAD_STATE_HOTKEY(
true, 10,
TRANSLATE_NOOP("Hotkeys",
"Load Global State 10"))
MAKE_SAVE_STATE_HOTKEY(
true, 10,
TRANSLATE_NOOP("Hotkeys",
"Save Global State 10"))
#undef MAKE_SAVE_STATE_HOTKEY #undef MAKE_SAVE_STATE_HOTKEY
#undef MAKE_LOAD_STATE_HOTKEY #undef MAKE_LOAD_STATE_HOTKEY

View file

@ -203,15 +203,18 @@ bool Pad::DoStateController(StateWrapper& sw, u32 i)
// UI notification portion is separated from emulation portion (intentional condition check redundancy) // UI notification portion is separated from emulation portion (intentional condition check redundancy)
if (g_settings.load_devices_from_save_states) if (g_settings.load_devices_from_save_states)
{ {
Host::AddFormattedOSDMessage( Host::AddOSDMessage(
10.0f, TRANSLATE("OSDMessage", "Save state contains controller type %s in port %u, but %s is used. Switching."), fmt::format(TRANSLATE_FS("OSDMessage",
"Save state contains controller type {0} in port {1}, but {2} is used. Switching."),
state_cinfo ? state_cinfo->GetDisplayName() : "", i + 1u, state_cinfo ? state_cinfo->GetDisplayName() : "", i + 1u,
Controller::GetControllerInfo(controller_type)->GetDisplayName()); Controller::GetControllerInfo(controller_type)->GetDisplayName()),
Host::OSD_WARNING_DURATION);
} }
else else
{ {
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Ignoring mismatched controller type %s in port %u."), Host::AddOSDMessage(
state_cinfo ? state_cinfo->GetDisplayName() : "", i + 1u); fmt::format(TRANSLATE_FS("OSDMessage", "Ignoring mismatched controller type {0} in port {1}."),
state_cinfo ? state_cinfo->GetDisplayName() : "", i + 1u, Host::OSD_WARNING_DURATION));
} }
DEV_LOG("Controller type mismatch in slot {}: state={}({}) ui={}({}) load_from_state={}", i + 1u, DEV_LOG("Controller type mismatch in slot {}: state={}({}) ui={}({}) load_from_state={}", i + 1u,

View file

@ -1161,17 +1161,17 @@ bool System::UpdateGameSettingsLayer()
std::string filename(GetGameSettingsPath(s_running_game_serial)); std::string filename(GetGameSettingsPath(s_running_game_serial));
if (FileSystem::FileExists(filename.c_str())) if (FileSystem::FileExists(filename.c_str()))
{ {
INFO_LOG("Loading game settings from '%s'...", Path::GetFileName(filename)); INFO_LOG("Loading game settings from '{}'...", Path::GetFileName(filename));
new_interface = std::make_unique<INISettingsInterface>(std::move(filename)); new_interface = std::make_unique<INISettingsInterface>(std::move(filename));
if (!new_interface->Load()) if (!new_interface->Load())
{ {
ERROR_LOG("Failed to parse game settings ini '%s'", new_interface->GetFileName()); ERROR_LOG("Failed to parse game settings ini '{}'", new_interface->GetFileName());
new_interface.reset(); new_interface.reset();
} }
} }
else else
{ {
INFO_LOG("No game settings found (tried '%s')", Path::GetFileName(filename)); INFO_LOG("No game settings found (tried '{}')", Path::GetFileName(filename));
} }
} }
@ -2200,9 +2200,10 @@ bool System::CreateGPU(GPURenderer renderer, bool is_switching, Error* error)
{ {
ERROR_LOG("Failed to initialize {} renderer, falling back to software renderer", ERROR_LOG("Failed to initialize {} renderer, falling back to software renderer",
Settings::GetRendererName(renderer)); Settings::GetRendererName(renderer));
Host::AddFormattedOSDMessage( Host::AddOSDMessage(
30.0f, TRANSLATE("OSDMessage", "Failed to initialize %s renderer, falling back to software renderer."), fmt::format(TRANSLATE_FS("System", "Failed to initialize {} renderer, falling back to software renderer."),
Settings::GetRendererName(renderer)); Settings::GetRendererName(renderer)),
Host::OSD_CRITICAL_ERROR_DURATION);
g_gpu.reset(); g_gpu.reset();
g_gpu = GPU::CreateSoftwareRenderer(); g_gpu = GPU::CreateSoftwareRenderer();
if (!g_gpu) if (!g_gpu)
@ -2238,11 +2239,10 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
if (bios_hash != s_bios_hash) if (bios_hash != s_bios_hash)
{ {
WARNING_LOG("BIOS hash mismatch: System: {} | State: {}", s_bios_hash.ToString(), bios_hash.ToString()); WARNING_LOG("BIOS hash mismatch: System: {} | State: {}", s_bios_hash.ToString(), bios_hash.ToString());
Host::AddKeyedOSDMessage("StateBIOSMismatch", Host::AddIconOSDMessage(
TRANSLATE_STR("OSDMessage", "StateBIOSMismatch", ICON_FA_EXCLAMATION_TRIANGLE,
"This save state was created with a different BIOS version or patch " TRANSLATE_STR("System", "This save state was created with a different BIOS. This may cause stability issues."),
"options. This may cause stability issues."), Host::OSD_WARNING_DURATION);
10.0f);
} }
} }
@ -2310,12 +2310,14 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
(cpu_overclock_active && (g_settings.cpu_overclock_numerator != cpu_overclock_numerator || (cpu_overclock_active && (g_settings.cpu_overclock_numerator != cpu_overclock_numerator ||
g_settings.cpu_overclock_denominator != cpu_overclock_denominator)))) g_settings.cpu_overclock_denominator != cpu_overclock_denominator))))
{ {
Host::AddFormattedOSDMessage( Host::AddIconOSDMessage(
10.0f, TRANSLATE("OSDMessage", "WARNING: CPU overclock (%u%%) was different in save state (%u%%)."), "state_overclock_difference", ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("System", "WARNING: CPU overclock ({}%) was different in save state ({}%)."),
g_settings.cpu_overclock_enable ? g_settings.GetCPUOverclockPercent() : 100u, g_settings.cpu_overclock_enable ? g_settings.GetCPUOverclockPercent() : 100u,
cpu_overclock_active ? cpu_overclock_active ?
Settings::CPUOverclockFractionToPercent(cpu_overclock_numerator, cpu_overclock_denominator) : Settings::CPUOverclockFractionToPercent(cpu_overclock_numerator, cpu_overclock_denominator) :
100u); 100u),
Host::OSD_WARNING_DURATION);
UpdateOverclock(); UpdateOverclock();
} }
@ -2617,7 +2619,7 @@ bool System::SaveStateToStream(ByteStream* state, Error* error, u32 screenshot_s
{ {
if (screenshot_stride != (screenshot_width * sizeof(u32))) if (screenshot_stride != (screenshot_width * sizeof(u32)))
{ {
WARNING_LOG("Failed to save {}x{} screenshot for save state due to incorrect stride(%u)", screenshot_width, WARNING_LOG("Failed to save {}x{} screenshot for save state due to incorrect stride({})", screenshot_width,
screenshot_height, screenshot_stride); screenshot_height, screenshot_stride);
} }
else else
@ -3177,7 +3179,7 @@ bool SetExpansionROM(const char* filename)
std::FILE* fp = FileSystem::OpenCFile(filename, "rb"); std::FILE* fp = FileSystem::OpenCFile(filename, "rb");
if (!fp) if (!fp)
{ {
Log_ErrorPrintf("Failed to open '%s'", filename); ERROR_LOG("Failed to open '{}'", Path::GetFileName(filename));
return false; return false;
} }
@ -3188,14 +3190,14 @@ bool SetExpansionROM(const char* filename)
std::vector<u8> data(size); std::vector<u8> data(size);
if (std::fread(data.data(), size, 1, fp) != 1) if (std::fread(data.data(), size, 1, fp) != 1)
{ {
Log_ErrorPrintf("Failed to read ROM data from '%s'", filename); ERROR_LOG("Failed to read ROM data from '{}'", Path::GetFileName(filename))
std::fclose(fp); std::fclose(fp);
return false; return false;
} }
std::fclose(fp); std::fclose(fp);
Log_InfoPrintf("Loaded expansion ROM from '%s': %u bytes", filename, size); INFO_LOG("Loaded expansion ROM from '{}': {} bytes", Path::GetFileName(filename), size);
Bus::SetExpansionROM(std::move(data)); Bus::SetExpansionROM(std::move(data));
return true; return true;
} }
@ -3752,17 +3754,21 @@ bool System::SwitchMediaSubImage(u32 index)
Error error; Error error;
if (!image->SwitchSubImage(index, &error)) if (!image->SwitchSubImage(index, &error))
{ {
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Failed to switch to subimage %u in '%s': %s."), Host::AddIconOSDMessage("media_switch_subimage", ICON_FA_COMPACT_DISC,
index + 1u, image->GetFileName().c_str(), error.GetDescription().c_str()); fmt::format(TRANSLATE_FS("System", "Failed to switch to subimage {} in '{}': {}."),
index + 1u, Path::GetFileName(image->GetFileName()), error.GetDescription()),
Host::OSD_INFO_DURATION);
const DiscRegion region = GetRegionForImage(image.get()); const DiscRegion region = GetRegionForImage(image.get());
CDROM::InsertMedia(std::move(image), region); CDROM::InsertMedia(std::move(image), region);
return false; return false;
} }
Host::AddFormattedOSDMessage(20.0f, TRANSLATE("OSDMessage", "Switched to sub-image %s (%u) in '%s'."), Host::AddIconOSDMessage("media_switch_subimage", ICON_FA_COMPACT_DISC,
image->GetSubImageMetadata(index, "title").c_str(), index + 1u, fmt::format(TRANSLATE_FS("System", "Switched to sub-image {} ({}) in '{}'."),
image->GetMetadata("title").c_str()); image->GetSubImageMetadata(index, "title"), index + 1u,
image->GetMetadata("title")),
Host::OSD_INFO_DURATION);
const DiscRegion region = GetRegionForImage(image.get()); const DiscRegion region = GetRegionForImage(image.get());
CDROM::InsertMedia(std::move(image), region); CDROM::InsertMedia(std::move(image), region);
@ -4594,12 +4600,18 @@ bool System::StartDumpingAudio(const char* filename)
if (SPU::StartDumpingAudio(filename)) if (SPU::StartDumpingAudio(filename))
{ {
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Started dumping audio to '%s'."), filename); Host::AddIconOSDMessage(
"audio_dumping", ICON_FA_VOLUME_UP,
fmt::format(TRANSLATE_FS("OSDMessage", "Started dumping audio to '{}'."), Path::GetFileName(filename)),
Host::OSD_INFO_DURATION);
return true; return true;
} }
else else
{ {
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Failed to start dumping audio to '%s'."), filename); Host::AddIconOSDMessage(
"audio_dumping", ICON_FA_VOLUME_UP,
fmt::format(TRANSLATE_FS("OSDMessage", "Failed to start dumping audio to '{}'."), Path::GetFileName(filename)),
Host::OSD_ERROR_DURATION);
return false; return false;
} }
} }
@ -4609,7 +4621,8 @@ void System::StopDumpingAudio()
if (System::IsShutdown() || !SPU::StopDumpingAudio()) if (System::IsShutdown() || !SPU::StopDumpingAudio())
return; return;
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Stopped dumping audio."), 5.0f); Host::AddIconOSDMessage("audio_dumping", ICON_FA_VOLUME_MUTE, TRANSLATE_STR("OSDMessage", "Stopped dumping audio."),
Host::OSD_INFO_DURATION);
} }
bool System::SaveScreenshot(const char* filename, DisplayScreenshotMode mode, DisplayScreenshotFormat format, bool System::SaveScreenshot(const char* filename, DisplayScreenshotMode mode, DisplayScreenshotFormat format,
@ -4922,8 +4935,9 @@ bool System::LoadCheatList()
std::unique_ptr<CheatList> cl = std::make_unique<CheatList>(); std::unique_ptr<CheatList> cl = std::make_unique<CheatList>();
if (!cl->LoadFromFile(filename.c_str(), CheatList::Format::Autodetect)) if (!cl->LoadFromFile(filename.c_str(), CheatList::Format::Autodetect))
{ {
Host::AddIconOSDMessage("cheats_loaded", ICON_FA_EXCLAMATION_TRIANGLE, Host::AddIconOSDMessage(
fmt::format(TRANSLATE_FS("OSDMessage", "Failed to load cheats from '{}'."), filename)); "cheats_loaded", ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("System", "Failed to load cheats from '{}'."), Path::GetFileName(filename)));
return false; return false;
} }
@ -4956,26 +4970,15 @@ bool System::SaveCheatList()
if (!System::GetCheatList()->SaveToPCSXRFile(filename.c_str())) if (!System::GetCheatList()->SaveToPCSXRFile(filename.c_str()))
{ {
Host::AddFormattedOSDMessage(15.0f, TRANSLATE("OSDMessage", "Failed to save cheat list to '%s'"), filename.c_str()); Host::AddIconOSDMessage(
"cheat_save_error", ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("System", "Failed to save cheat list to '{}'."), Path::GetFileName(filename)),
Host::OSD_ERROR_DURATION);
} }
return true; return true;
} }
bool System::SaveCheatList(const char* filename)
{
if (!System::IsValid() || !System::HasCheatList())
return false;
if (!System::GetCheatList()->SaveToPCSXRFile(filename))
return false;
// This shouldn't be needed, but lupdate doesn't gather this string otherwise...
const u32 code_count = System::GetCheatList()->GetCodeCount();
Host::AddOSDMessage(fmt::format(TRANSLATE_FS("OSDMessage", "Saved {} cheats to '{}'."), code_count, filename), 5.0f);
return true;
}
bool System::DeleteCheatList() bool System::DeleteCheatList()
{ {
if (!System::IsValid()) if (!System::IsValid())
@ -4987,7 +4990,10 @@ bool System::DeleteCheatList()
if (!FileSystem::DeleteFile(filename.c_str())) if (!FileSystem::DeleteFile(filename.c_str()))
return false; return false;
Host::AddOSDMessage(fmt::format(TRANSLATE_FS("OSDMessage", "Deleted cheat list '{}'."), filename), 5.0f); Host::AddIconOSDMessage(
"cheat_delete", ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("System", "Deleted cheat list '{}'."), Path::GetFileName(filename)),
Host::OSD_INFO_DURATION);
} }
System::SetCheatList(nullptr); System::SetCheatList(nullptr);
@ -5029,11 +5035,15 @@ void System::SetCheatCodeState(u32 index, bool enabled)
if (enabled) if (enabled)
{ {
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Cheat '%s' enabled."), cc.description.c_str()); Host::AddIconOSDMessage(fmt::format("cheat_{}_state", index), ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("System", "Cheat '{}' enabled."), cc.description),
Host::OSD_INFO_DURATION);
} }
else else
{ {
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Cheat '%s' disabled."), cc.description.c_str()); Host::AddIconOSDMessage(fmt::format("cheat_{}_state", index), ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("System", "Cheat '{}' disabled."), cc.description),
Host::OSD_INFO_DURATION);
} }
SaveCheatList(); SaveCheatList();
@ -5048,12 +5058,15 @@ void System::ApplyCheatCode(u32 index)
if (!cc.enabled) if (!cc.enabled)
{ {
cc.Apply(); cc.Apply();
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Applied cheat '%s'."), cc.description.c_str()); Host::AddIconOSDMessage(fmt::format("cheat_{}_state", index), ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("System", "Applied cheat '{}'."), cc.description),
Host::OSD_INFO_DURATION);
} }
else else
{ {
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Cheat '%s' is already enabled."), Host::AddIconOSDMessage(fmt::format("cheat_{}_state", index), ICON_FA_EXCLAMATION_TRIANGLE,
cc.description.c_str()); fmt::format(TRANSLATE_FS("System", "Cheat '{}' is already enabled."), cc.description),
Host::OSD_INFO_DURATION);
} }
} }

View file

@ -443,9 +443,6 @@ bool LoadCheatListFromDatabase();
/// Saves the current cheat list to the game title's file. /// Saves the current cheat list to the game title's file.
bool SaveCheatList(); bool SaveCheatList();
/// Saves the current cheat list to the specified file.
bool SaveCheatList(const char* filename);
/// Deletes the cheat list, if present. /// Deletes the cheat list, if present.
bool DeleteCheatList(); bool DeleteCheatList();

View file

@ -708,29 +708,11 @@ void Host::AddKeyedOSDMessage(std::string key, std::string message, float durati
ImGuiManager::s_osd_posted_messages.push_back(std::move(msg)); ImGuiManager::s_osd_posted_messages.push_back(std::move(msg));
} }
void Host::AddFormattedOSDMessage(float duration, const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
std::string ret = StringUtil::StdStringFromFormatV(format, ap);
va_end(ap);
return AddKeyedOSDMessage(std::string(), std::move(ret), duration);
}
void Host::AddIconOSDMessage(std::string key, const char* icon, std::string message, float duration /* = 2.0f */) void Host::AddIconOSDMessage(std::string key, const char* icon, std::string message, float duration /* = 2.0f */)
{ {
return AddKeyedOSDMessage(std::move(key), fmt::format("{} {}", icon, message), duration); return AddKeyedOSDMessage(std::move(key), fmt::format("{} {}", icon, message), duration);
} }
void Host::AddKeyedFormattedOSDMessage(std::string key, float duration, const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
std::string ret = StringUtil::StdStringFromFormatV(format, ap);
va_end(ap);
return AddKeyedOSDMessage(std::move(key), std::move(ret), duration);
}
void Host::RemoveKeyedOSDMessage(std::string key) void Host::RemoveKeyedOSDMessage(std::string key)
{ {
if (!ImGuiManager::s_show_osd_messages) if (!ImGuiManager::s_show_osd_messages)

View file

@ -126,8 +126,6 @@ float GetOSDScale();
void AddOSDMessage(std::string message, float duration = 2.0f); void AddOSDMessage(std::string message, float duration = 2.0f);
void AddKeyedOSDMessage(std::string key, 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 AddIconOSDMessage(std::string key, const char* icon, std::string message, float duration = 2.0f);
void AddFormattedOSDMessage(float duration, const char* format, ...);
void AddKeyedFormattedOSDMessage(std::string key, float duration, const char* format, ...);
void RemoveKeyedOSDMessage(std::string key); void RemoveKeyedOSDMessage(std::string key);
void ClearOSDMessages(); void ClearOSDMessages();
} // namespace Host } // namespace Host