mirror of https://github.com/PCSX2/pcsx2.git
Achievements: Rework challenge mode enabling
Fixes enabling hardcore mode per-game not having any effect.
This commit is contained in:
parent
53bd98394b
commit
ddf839beb0
|
@ -28,7 +28,7 @@ namespace Achievements
|
|||
extern void GameChanged(u32 crc);
|
||||
|
||||
/// Re-enables hardcode mode if it is enabled in the settings.
|
||||
extern void ResetChallengeMode();
|
||||
extern bool ResetChallengeMode();
|
||||
|
||||
/// Forces hardcore mode off until next reset.
|
||||
extern void DisableChallengeMode();
|
||||
|
@ -62,7 +62,10 @@ namespace Achievements
|
|||
return false;
|
||||
}
|
||||
|
||||
static inline void ResetChallengeMode() {}
|
||||
static inline bool ResetChallengeMode()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void DisableChallengeMode() {}
|
||||
|
||||
|
|
|
@ -548,6 +548,7 @@ void Achievements::UpdateSettings(const Pcsx2Config::AchievementsOptions& old_co
|
|||
}
|
||||
else if (!s_challenge_mode && EmuConfig.Achievements.ChallengeMode)
|
||||
{
|
||||
if (HasActiveGame())
|
||||
ImGuiFullscreen::ShowToast(std::string(), "Hardcore mode will be enabled on system reset.", 10.0f);
|
||||
}
|
||||
}
|
||||
|
@ -610,15 +611,18 @@ void Achievements::DisableChallengeMode()
|
|||
SetChallengeMode(false);
|
||||
}
|
||||
|
||||
void Achievements::ResetChallengeMode()
|
||||
bool Achievements::ResetChallengeMode()
|
||||
{
|
||||
if (!s_active)
|
||||
return;
|
||||
return false;
|
||||
|
||||
Host::RemoveKeyedOSDMessage("challenge_mode_reset");
|
||||
|
||||
if (s_challenge_mode != EmuConfig.Achievements.ChallengeMode)
|
||||
if (s_challenge_mode == EmuConfig.Achievements.ChallengeMode)
|
||||
return false;
|
||||
|
||||
SetChallengeMode(EmuConfig.Achievements.ChallengeMode);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Achievements::SetChallengeMode(bool enabled)
|
||||
|
@ -701,19 +705,14 @@ bool Achievements::OnReset()
|
|||
return true;
|
||||
|
||||
std::unique_lock lock(s_achievements_mutex);
|
||||
DevCon.WriteLn("Resetting rcheevos state...");
|
||||
rc_runtime_reset(&s_rcheevos_runtime);
|
||||
|
||||
// we can re-enable hardcore mode, since we're rebooting the system
|
||||
if (EmuConfig.Achievements.ChallengeMode && !s_challenge_mode)
|
||||
{
|
||||
// but, clear the game first. otherwise, we re-query the current game in hardcore mode,
|
||||
// reset to nothing (booting), then back to the game again and spam the user.
|
||||
// Clear the game out, we'll re-query it once the ELF is loaded.
|
||||
ClearGameInfo(true, true);
|
||||
ClearGameHash();
|
||||
ResetChallengeMode();
|
||||
}
|
||||
|
||||
// Reset runtime, there shouldn't be anything left in it though.
|
||||
DevCon.WriteLn("Resetting rcheevos state...");
|
||||
rc_runtime_reset(&s_rcheevos_runtime);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -693,6 +693,12 @@ void VMManager::UpdateRunningGame(bool resetting, bool game_starting)
|
|||
if (s_patches_crc != s_game_crc)
|
||||
ReloadPatches(game_starting, false);
|
||||
|
||||
#ifdef ENABLE_ACHIEVEMENTS
|
||||
// Per-game ini enabling of hardcore mode. We need to re-enforce the settings if so.
|
||||
if (game_starting && Achievements::ResetChallengeMode())
|
||||
ApplySettings();
|
||||
#endif
|
||||
|
||||
GetMTGS().SendGameCRC(new_crc);
|
||||
|
||||
Host::OnGameChanged(s_disc_path, s_game_serial, s_game_name, s_game_crc);
|
||||
|
@ -1095,17 +1101,8 @@ void VMManager::Shutdown(bool save_resume_state)
|
|||
void VMManager::Reset()
|
||||
{
|
||||
#ifdef ENABLE_ACHIEVEMENTS
|
||||
const bool previous_challenge_mode = Achievements::ChallengeModeActive();
|
||||
if (!Achievements::OnReset())
|
||||
return;
|
||||
|
||||
if (Achievements::ChallengeModeActive() && !previous_challenge_mode)
|
||||
{
|
||||
// Hardcore mode enabled, so reload settings. This only covers the BIOS
|
||||
// portion of the boot, once the game loads we'll reset anyway, but better
|
||||
// to change things like the speed now rather than later.
|
||||
ApplySettings();
|
||||
}
|
||||
#endif
|
||||
|
||||
const bool game_was_started = g_GameStarted;
|
||||
|
|
Loading…
Reference in New Issue