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;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if (IsActive())
|
||||
|
|
|
@ -129,6 +129,9 @@ const char* GetLoggedInUserName();
|
|||
/// Should be called with the lock held.
|
||||
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.
|
||||
void ClearUIState();
|
||||
|
||||
|
|
|
@ -139,27 +139,16 @@ static void HotkeyToggleOSD()
|
|||
|
||||
static bool CanPause()
|
||||
{
|
||||
static constexpr const float PAUSE_INTERVAL = 3.0f;
|
||||
static Common::Timer::Value s_last_pause_time = 0;
|
||||
|
||||
if (!Achievements::IsHardcoreModeActive() || System::IsPaused())
|
||||
const u32 frames_until_pause_allowed = Achievements::GetPauseThrottleFrames();
|
||||
if (frames_until_pause_allowed == 0)
|
||||
return true;
|
||||
|
||||
const Common::Timer::Value time = Common::Timer::GetCurrentValue();
|
||||
const float delta = static_cast<float>(Common::Timer::ConvertValueToSeconds(time - s_last_pause_time));
|
||||
if (delta < PAUSE_INTERVAL)
|
||||
{
|
||||
Host::AddIconOSDMessage("PauseCooldown", ICON_FA_CLOCK,
|
||||
TRANSLATE_PLURAL_STR("Hotkeys", "You cannot pause until another %n second(s) have passed.",
|
||||
"", static_cast<int>(std::ceil(PAUSE_INTERVAL - delta))),
|
||||
Host::OSD_QUICK_DURATION);
|
||||
return false;
|
||||
}
|
||||
|
||||
Host::RemoveKeyedOSDMessage("PauseCooldown");
|
||||
s_last_pause_time = time;
|
||||
|
||||
return true;
|
||||
const float seconds = static_cast<float>(frames_until_pause_allowed) / System::GetVideoFrameRate();
|
||||
Host::AddIconOSDMessage("PauseCooldown", ICON_FA_CLOCK,
|
||||
TRANSLATE_PLURAL_STR("Hotkeys", "You cannot pause until another %n second(s) have passed.",
|
||||
"", static_cast<int>(std::ceil(seconds))),
|
||||
std::max(seconds, Host::OSD_QUICK_DURATION));
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue