Hotkeys: Display reason why rewind is unavailable

This commit is contained in:
Stenzek
2026-06-20 12:59:57 +10:00
parent cdce0f7a37
commit a3dbace1a3
3 changed files with 53 additions and 33 deletions
+2 -1
View File
@@ -2299,7 +2299,8 @@ void Achievements::ConfirmHardcoreModeDisableAsync(std::string_view trigger, std
Host::RunOnCoreThread([callback = std::move(callback), res]() {
if (res)
DisableHardcoreMode(true, true);
callback(res);
if (callback)
callback(res);
});
});
}
+43 -1
View File
@@ -85,6 +85,45 @@ static void HotkeyToggleOSD()
VideoThread::UpdateSettings(true, false, false);
}
static bool HotkeyCheckRewindAvailability(bool enabled)
{
if (g_settings.rewind_enable)
return true;
// don't do anything on key release
if (!enabled)
return false;
// figure out why it's disabled...
std::string summary;
const bool rewind_actually_enabled = Core::GetBoolSettingValue("Main", "RewindEnable", false);
if (rewind_actually_enabled)
{
if (g_settings.IsRunaheadEnabled())
{
summary = TRANSLATE_STR("OSDMessage", "Rewinding is disabled while runahead is enabled.");
}
else if (g_settings.disable_all_enhancements)
{
summary = TRANSLATE_STR("OSDMessage", "Rewinding is disabled while safe mode is enabled.");
}
else if (Achievements::IsHardcoreModeActive())
{
// because this is keypress-based, don't enable it on accept
Achievements::ConfirmHardcoreModeDisableAsync("Rewinding", {});
return false;
}
}
else
{
summary = TRANSLATE_STR("OSDMessage", "Rewinding is not enabled.");
}
Host::AddIconOSDMessage(OSDMessageType::Warning, "SetRewindState", ICON_EMOJI_WARNING,
TRANSLATE_STR("OSDMessage", "Rewinding unavailable."), std::move(summary));
return false;
}
static constexpr const HotkeyInfo s_hotkey_list[] = {
#ifndef __ANDROID__
@@ -197,7 +236,10 @@ static constexpr const HotkeyInfo s_hotkey_list[] = {
[](s32 pressed) {
if (pressed < 0)
return;
System::SetRewindState(pressed > 0);
const bool enabled = (pressed > 0);
if (HotkeyCheckRewindAvailability(enabled))
System::SetRewindState(enabled);
}},
#ifndef __ANDROID__
+8 -31
View File
@@ -209,7 +209,6 @@ static void DoMemoryState(StateWrapper& sw, MemorySaveState& mss, bool update_di
static bool IsExecutionInterrupted();
static void CheckForAndExitExecution();
static void SetRewinding(bool enabled);
static void DoRewind();
static bool DoRunahead();
@@ -3699,35 +3698,6 @@ void System::SetTurboEnabled(bool enabled)
UpdateSpeedLimiterState();
}
void System::SetRewindState(bool enabled)
{
if (!System::IsValid())
return;
if (!g_settings.rewind_enable)
{
if (enabled)
{
Host::AddKeyedOSDMessage(OSDMessageType::Info, "SetRewindState",
TRANSLATE_STR("OSDMessage", "Rewinding is not enabled."));
}
return;
}
if (Achievements::IsHardcoreModeActive() && enabled)
{
Achievements::ConfirmHardcoreModeDisableAsync("Rewinding", [](bool approved) {
if (approved)
SetRewindState(true);
});
return;
}
System::SetRewinding(enabled);
UpdateSpeedLimiterState();
}
void System::FrameStep()
{
if (!IsValid())
@@ -5072,9 +5042,14 @@ bool System::IsRewinding()
return (s_state.rewind_load_frequency >= 0);
}
void System::SetRewinding(bool enabled)
void System::SetRewindState(bool enabled)
{
if (!System::IsValid() || !g_settings.rewind_enable)
return;
const bool was_enabled = IsRewinding();
if (enabled == was_enabled)
return;
if (enabled)
{
@@ -5106,6 +5081,8 @@ void System::SetRewinding(bool enabled)
s_state.rewind_save_counter = s_state.rewind_save_frequency;
}
}
UpdateSpeedLimiterState();
}
void System::DoRewind()