Achievements: Use rc_client for pause throttling
This commit is contained in:
parent
852239ec8a
commit
9fa8fee193
|
@ -1969,6 +1969,15 @@ std::string Achievements::GetLoggedInUserBadgePath()
|
||||||
return badge_path;
|
return badge_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 Achievements::GetPauseThrottleFrames()
|
||||||
|
{
|
||||||
|
if (!IsActive() || !IsHardcoreModeActive() || IsUsingRAIntegration())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
u32 frames_remaining = 0;
|
||||||
|
return rc_client_can_pause(s_client, &frames_remaining) ? 0 : frames_remaining;
|
||||||
|
}
|
||||||
|
|
||||||
void Achievements::Logout()
|
void Achievements::Logout()
|
||||||
{
|
{
|
||||||
if (IsActive())
|
if (IsActive())
|
||||||
|
|
|
@ -129,6 +129,9 @@ const char* GetLoggedInUserName();
|
||||||
/// Should be called with the lock held.
|
/// Should be called with the lock held.
|
||||||
std::string GetLoggedInUserBadgePath();
|
std::string GetLoggedInUserBadgePath();
|
||||||
|
|
||||||
|
/// Returns 0 if pausing is allowed, otherwise the number of frames until pausing is allowed.
|
||||||
|
u32 GetPauseThrottleFrames();
|
||||||
|
|
||||||
/// Clears all cached state used to render the UI.
|
/// Clears all cached state used to render the UI.
|
||||||
void ClearUIState();
|
void ClearUIState();
|
||||||
|
|
||||||
|
|
|
@ -139,29 +139,18 @@ static void HotkeyToggleOSD()
|
||||||
|
|
||||||
static bool CanPause()
|
static bool CanPause()
|
||||||
{
|
{
|
||||||
static constexpr const float PAUSE_INTERVAL = 3.0f;
|
const u32 frames_until_pause_allowed = Achievements::GetPauseThrottleFrames();
|
||||||
static Common::Timer::Value s_last_pause_time = 0;
|
if (frames_until_pause_allowed == 0)
|
||||||
|
|
||||||
if (!Achievements::IsHardcoreModeActive() || System::IsPaused())
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const Common::Timer::Value time = Common::Timer::GetCurrentValue();
|
const float seconds = static_cast<float>(frames_until_pause_allowed) / System::GetVideoFrameRate();
|
||||||
const float delta = static_cast<float>(Common::Timer::ConvertValueToSeconds(time - s_last_pause_time));
|
|
||||||
if (delta < PAUSE_INTERVAL)
|
|
||||||
{
|
|
||||||
Host::AddIconOSDMessage("PauseCooldown", ICON_FA_CLOCK,
|
Host::AddIconOSDMessage("PauseCooldown", ICON_FA_CLOCK,
|
||||||
TRANSLATE_PLURAL_STR("Hotkeys", "You cannot pause until another %n second(s) have passed.",
|
TRANSLATE_PLURAL_STR("Hotkeys", "You cannot pause until another %n second(s) have passed.",
|
||||||
"", static_cast<int>(std::ceil(PAUSE_INTERVAL - delta))),
|
"", static_cast<int>(std::ceil(seconds))),
|
||||||
Host::OSD_QUICK_DURATION);
|
std::max(seconds, Host::OSD_QUICK_DURATION));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Host::RemoveKeyedOSDMessage("PauseCooldown");
|
|
||||||
s_last_pause_time = time;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BEGIN_HOTKEY_LIST(g_common_hotkeys)
|
BEGIN_HOTKEY_LIST(g_common_hotkeys)
|
||||||
|
|
Loading…
Reference in New Issue