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 double clock_speed =
((static_cast<double>(System::MASTER_CLOCK) * static_cast<double>(percent)) / 100.0) / 1000000.0;
Host::AddKeyedFormattedOSDMessage(
"ToggleOverclocking", 5.0f,
TRANSLATE("OSDMessage", "CPU clock speed control enabled (%u%% / %.3f MHz)."), percent,
clock_speed);
Host::AddIconOSDMessage(
"ToggleOverclocking", ICON_FA_TACHOMETER_ALT,
fmt::format(TRANSLATE_FS("OSDMessage", "CPU clock speed control enabled ({:.3f} MHz)."),
clock_speed),
Host::OSD_QUICK_DURATION);
}
else
{
Host::AddKeyedFormattedOSDMessage(
"ToggleOverclocking", 5.0f,
TRANSLATE("OSDMessage", "CPU clock speed control disabled (%.3f MHz)."),
static_cast<double>(System::MASTER_CLOCK) / 1000000.0);
Host::AddIconOSDMessage(
"ToggleOverclocking", ICON_FA_TACHOMETER_ALT,
fmt::format(TRANSLATE_FS("OSDMessage", "CPU clock speed control disabled ({:.3f} MHz)."),
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;
System::UpdateSpeedLimiterState();
Host::AddKeyedFormattedOSDMessage("EmulationSpeedChange", 5.0f,
TRANSLATE("OSDMessage", "Emulation speed set to %u%%."),
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f)));
Host::AddIconOSDMessage(
"EmulationSpeedChange", ICON_FA_TACHOMETER_ALT,
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);
System::UpdateSpeedLimiterState();
Host::AddKeyedFormattedOSDMessage("EmulationSpeedChange", 5.0f,
TRANSLATE("OSDMessage", "Emulation speed set to %u%%."),
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f)));
Host::AddIconOSDMessage(
"EmulationSpeedChange", ICON_FA_TACHOMETER_ALT,
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);
System::UpdateSpeedLimiterState();
Host::AddKeyedFormattedOSDMessage("EmulationSpeedChange", 5.0f,
TRANSLATE("OSDMessage", "Emulation speed set to %u%%."),
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f)));
Host::AddIconOSDMessage(
"EmulationSpeedChange", ICON_FA_TACHOMETER_ALT,
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,36 +555,34 @@ DEFINE_HOTKEY("LoadSelectedSaveState", TRANSLATE_NOOP("Hotkeys", "Save States"),
Host::RunOnCPUThread(SaveStateSelectorUI::LoadCurrentSlot);
})
DEFINE_HOTKEY("SaveSelectedSaveState", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Save To Selected Slot"),
[](s32 pressed) {
TRANSLATE_NOOP("Hotkeys", "Save To Selected Slot"), [](s32 pressed) {
if (!pressed)
Host::RunOnCPUThread(SaveStateSelectorUI::SaveCurrentSlot);
})
DEFINE_HOTKEY("SelectPreviousSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Select Previous Save Slot"),
[](s32 pressed) {
TRANSLATE_NOOP("Hotkeys", "Select Previous Save Slot"), [](s32 pressed) {
if (!pressed)
Host::RunOnCPUThread([]() { SaveStateSelectorUI::SelectPreviousSlot(true); });
}) DEFINE_HOTKEY("SelectNextSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Select Next Save Slot"),
[](s32 pressed) {
if (!pressed)
Host::RunOnCPUThread([]() { SaveStateSelectorUI::SelectNextSlot(true); });
}) DEFINE_HOTKEY("SaveStateAndSelectNextSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Save State and Select Next Slot"),
[](s32 pressed) {
if (!pressed && System::IsValid())
{
SaveStateSelectorUI::SaveCurrentSlot();
SaveStateSelectorUI::SelectNextSlot(false);
}
})
})
DEFINE_HOTKEY("SelectNextSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Select Next Save Slot"), [](s32 pressed) {
if (!pressed)
Host::RunOnCPUThread([]() { SaveStateSelectorUI::SelectNextSlot(true); });
})
DEFINE_HOTKEY("SaveStateAndSelectNextSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Save State and Select Next Slot"), [](s32 pressed) {
if (!pressed && System::IsValid())
{
SaveStateSelectorUI::SaveCurrentSlot();
SaveStateSelectorUI::SelectNextSlot(false);
}
})
DEFINE_HOTKEY("UndoLoadState", TRANSLATE_NOOP("Hotkeys", "Save States"), TRANSLATE_NOOP("Hotkeys", "Undo Load State"),
[](s32 pressed) {
if (!pressed)
Host::RunOnCPUThread(System::UndoLoadState);
})
DEFINE_HOTKEY("UndoLoadState", TRANSLATE_NOOP("Hotkeys", "Save States"), TRANSLATE_NOOP("Hotkeys", "Undo Load State"),
[](s32 pressed) {
if (!pressed)
Host::RunOnCPUThread(System::UndoLoadState);
})
#define MAKE_LOAD_STATE_HOTKEY(global, slot, name) \
DEFINE_HOTKEY(global ? "LoadGameState" #slot : "LoadGlobalState" #slot, TRANSLATE_NOOP("Hotkeys", "Save States"), \
@ -591,79 +597,51 @@ DEFINE_HOTKEY("SelectPreviousSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save Sta
Host::RunOnCPUThread([]() { HotkeySaveStateSlot(global, slot); }); \
})
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_LOAD_STATE_HOTKEY(false, 2, TRANSLATE_NOOP("Hotkeys", "Load 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(
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(
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(
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(
false, 6, TRANSLATE_NOOP("Hotkeys", "Save Game State 6"))
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_LOAD_STATE_HOTKEY(false, 8, TRANSLATE_NOOP("Hotkeys", "Load Game State 8"))
MAKE_SAVE_STATE_HOTKEY(false, 8, TRANSLATE_NOOP("Hotkeys", "Save Game State 8"))
MAKE_LOAD_STATE_HOTKEY(false, 9, TRANSLATE_NOOP("Hotkeys", "Load Game State 9"))
MAKE_SAVE_STATE_HOTKEY(false, 9, TRANSLATE_NOOP("Hotkeys", "Save Game State 9"))
MAKE_LOAD_STATE_HOTKEY(false, 10, TRANSLATE_NOOP("Hotkeys", "Load Game State 10"))
MAKE_SAVE_STATE_HOTKEY(false, 10, TRANSLATE_NOOP("Hotkeys", "Save Game State 10"))
// clang-format off
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_LOAD_STATE_HOTKEY(false, 2, TRANSLATE_NOOP("Hotkeys", "Load 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(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(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(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(false, 6, TRANSLATE_NOOP("Hotkeys", "Save Game State 6"))
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_LOAD_STATE_HOTKEY(false, 8, TRANSLATE_NOOP("Hotkeys", "Load Game State 8"))
MAKE_SAVE_STATE_HOTKEY(false, 8, TRANSLATE_NOOP("Hotkeys", "Save Game State 8"))
MAKE_LOAD_STATE_HOTKEY(false, 9, TRANSLATE_NOOP("Hotkeys", "Load Game State 9"))
MAKE_SAVE_STATE_HOTKEY(false, 9, TRANSLATE_NOOP("Hotkeys", "Save Game State 9"))
MAKE_LOAD_STATE_HOTKEY(false, 10, TRANSLATE_NOOP("Hotkeys", "Load Game State 10"))
MAKE_SAVE_STATE_HOTKEY(false, 10, TRANSLATE_NOOP("Hotkeys", "Save Game State 10"))
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_LOAD_STATE_HOTKEY(true, 2, TRANSLATE_NOOP("Hotkeys", "Load Global State 2"))
MAKE_SAVE_STATE_HOTKEY(true, 2,
TRANSLATE_NOOP("Hotkeys", "Save Global State 2"))
MAKE_LOAD_STATE_HOTKEY(true,
3, TRANSLATE_NOOP("Hotkeys", "Load Global State 3"))
MAKE_SAVE_STATE_HOTKEY(true, 3,
TRANSLATE_NOOP("Hotkeys", "Save Global State 3"))
MAKE_LOAD_STATE_HOTKEY(true, 4,
TRANSLATE_NOOP("Hotkeys", "Load Global State 4"))
MAKE_SAVE_STATE_HOTKEY(true, 4,
TRANSLATE_NOOP("Hotkeys", "Save Global State 4"))
MAKE_LOAD_STATE_HOTKEY(true, 5,
TRANSLATE_NOOP("Hotkeys",
"Load Global State 5"))
MAKE_SAVE_STATE_HOTKEY(true, 5,
TRANSLATE_NOOP("Hotkeys",
"Save Global State 5"))
MAKE_LOAD_STATE_HOTKEY(true, 6,
TRANSLATE_NOOP("Hotkeys",
"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"))
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_LOAD_STATE_HOTKEY(true, 2, TRANSLATE_NOOP("Hotkeys", "Load Global State 2"))
MAKE_SAVE_STATE_HOTKEY(true, 2, TRANSLATE_NOOP("Hotkeys", "Save Global State 2"))
MAKE_LOAD_STATE_HOTKEY(true, 3, TRANSLATE_NOOP("Hotkeys", "Load Global State 3"))
MAKE_SAVE_STATE_HOTKEY(true, 3, TRANSLATE_NOOP("Hotkeys", "Save Global State 3"))
MAKE_LOAD_STATE_HOTKEY(true, 4, TRANSLATE_NOOP("Hotkeys", "Load Global State 4"))
MAKE_SAVE_STATE_HOTKEY(true, 4, TRANSLATE_NOOP("Hotkeys", "Save Global State 4"))
MAKE_LOAD_STATE_HOTKEY(true, 5, TRANSLATE_NOOP("Hotkeys", "Load Global State 5"))
MAKE_SAVE_STATE_HOTKEY(true, 5, TRANSLATE_NOOP("Hotkeys", "Save Global State 5"))
MAKE_LOAD_STATE_HOTKEY(true, 6, TRANSLATE_NOOP("Hotkeys", "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"))
// clang-format on
#undef MAKE_SAVE_STATE_HOTKEY
#undef MAKE_LOAD_STATE_HOTKEY
END_HOTKEY_LIST()
END_HOTKEY_LIST()

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)
if (g_settings.load_devices_from_save_states)
{
Host::AddFormattedOSDMessage(
10.0f, TRANSLATE("OSDMessage", "Save state contains controller type %s in port %u, but %s is used. Switching."),
state_cinfo ? state_cinfo->GetDisplayName() : "", i + 1u,
Controller::GetControllerInfo(controller_type)->GetDisplayName());
Host::AddOSDMessage(
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,
Controller::GetControllerInfo(controller_type)->GetDisplayName()),
Host::OSD_WARNING_DURATION);
}
else
{
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Ignoring mismatched controller type %s in port %u."),
state_cinfo ? state_cinfo->GetDisplayName() : "", i + 1u);
Host::AddOSDMessage(
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,

View File

@ -1161,17 +1161,17 @@ bool System::UpdateGameSettingsLayer()
std::string filename(GetGameSettingsPath(s_running_game_serial));
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));
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();
}
}
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",
Settings::GetRendererName(renderer));
Host::AddFormattedOSDMessage(
30.0f, TRANSLATE("OSDMessage", "Failed to initialize %s renderer, falling back to software renderer."),
Settings::GetRendererName(renderer));
Host::AddOSDMessage(
fmt::format(TRANSLATE_FS("System", "Failed to initialize {} renderer, falling back to software renderer."),
Settings::GetRendererName(renderer)),
Host::OSD_CRITICAL_ERROR_DURATION);
g_gpu.reset();
g_gpu = GPU::CreateSoftwareRenderer();
if (!g_gpu)
@ -2238,11 +2239,10 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
if (bios_hash != s_bios_hash)
{
WARNING_LOG("BIOS hash mismatch: System: {} | State: {}", s_bios_hash.ToString(), bios_hash.ToString());
Host::AddKeyedOSDMessage("StateBIOSMismatch",
TRANSLATE_STR("OSDMessage",
"This save state was created with a different BIOS version or patch "
"options. This may cause stability issues."),
10.0f);
Host::AddIconOSDMessage(
"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);
}
}
@ -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 ||
g_settings.cpu_overclock_denominator != cpu_overclock_denominator))))
{
Host::AddFormattedOSDMessage(
10.0f, TRANSLATE("OSDMessage", "WARNING: CPU overclock (%u%%) was different in save state (%u%%)."),
g_settings.cpu_overclock_enable ? g_settings.GetCPUOverclockPercent() : 100u,
cpu_overclock_active ?
Settings::CPUOverclockFractionToPercent(cpu_overclock_numerator, cpu_overclock_denominator) :
100u);
Host::AddIconOSDMessage(
"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,
cpu_overclock_active ?
Settings::CPUOverclockFractionToPercent(cpu_overclock_numerator, cpu_overclock_denominator) :
100u),
Host::OSD_WARNING_DURATION);
UpdateOverclock();
}
@ -2617,7 +2619,7 @@ bool System::SaveStateToStream(ByteStream* state, Error* error, u32 screenshot_s
{
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);
}
else
@ -3177,7 +3179,7 @@ bool SetExpansionROM(const char* filename)
std::FILE* fp = FileSystem::OpenCFile(filename, "rb");
if (!fp)
{
Log_ErrorPrintf("Failed to open '%s'", filename);
ERROR_LOG("Failed to open '{}'", Path::GetFileName(filename));
return false;
}
@ -3188,14 +3190,14 @@ bool SetExpansionROM(const char* filename)
std::vector<u8> data(size);
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);
return false;
}
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));
return true;
}
@ -3752,17 +3754,21 @@ bool System::SwitchMediaSubImage(u32 index)
Error error;
if (!image->SwitchSubImage(index, &error))
{
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Failed to switch to subimage %u in '%s': %s."),
index + 1u, image->GetFileName().c_str(), error.GetDescription().c_str());
Host::AddIconOSDMessage("media_switch_subimage", ICON_FA_COMPACT_DISC,
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());
CDROM::InsertMedia(std::move(image), region);
return false;
}
Host::AddFormattedOSDMessage(20.0f, TRANSLATE("OSDMessage", "Switched to sub-image %s (%u) in '%s'."),
image->GetSubImageMetadata(index, "title").c_str(), index + 1u,
image->GetMetadata("title").c_str());
Host::AddIconOSDMessage("media_switch_subimage", ICON_FA_COMPACT_DISC,
fmt::format(TRANSLATE_FS("System", "Switched to sub-image {} ({}) in '{}'."),
image->GetSubImageMetadata(index, "title"), index + 1u,
image->GetMetadata("title")),
Host::OSD_INFO_DURATION);
const DiscRegion region = GetRegionForImage(image.get());
CDROM::InsertMedia(std::move(image), region);
@ -4594,12 +4600,18 @@ bool System::StartDumpingAudio(const char* 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;
}
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;
}
}
@ -4609,7 +4621,8 @@ void System::StopDumpingAudio()
if (System::IsShutdown() || !SPU::StopDumpingAudio())
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,
@ -4922,8 +4935,9 @@ bool System::LoadCheatList()
std::unique_ptr<CheatList> cl = std::make_unique<CheatList>();
if (!cl->LoadFromFile(filename.c_str(), CheatList::Format::Autodetect))
{
Host::AddIconOSDMessage("cheats_loaded", ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("OSDMessage", "Failed to load cheats from '{}'."), filename));
Host::AddIconOSDMessage(
"cheats_loaded", ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("System", "Failed to load cheats from '{}'."), Path::GetFileName(filename)));
return false;
}
@ -4956,26 +4970,15 @@ bool System::SaveCheatList()
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;
}
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()
{
if (!System::IsValid())
@ -4987,7 +4990,10 @@ bool System::DeleteCheatList()
if (!FileSystem::DeleteFile(filename.c_str()))
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);
@ -5029,11 +5035,15 @@ void System::SetCheatCodeState(u32 index, bool 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
{
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();
@ -5048,12 +5058,15 @@ void System::ApplyCheatCode(u32 index)
if (!cc.enabled)
{
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
{
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Cheat '%s' is already enabled."),
cc.description.c_str());
Host::AddIconOSDMessage(fmt::format("cheat_{}_state", index), ICON_FA_EXCLAMATION_TRIANGLE,
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.
bool SaveCheatList();
/// Saves the current cheat list to the specified file.
bool SaveCheatList(const char* filename);
/// Deletes the cheat list, if present.
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));
}
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 */)
{
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)
{
if (!ImGuiManager::s_show_osd_messages)

View File

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