Achievements: Fix a few minor issues

This commit is contained in:
Connor McLaughlin 2022-10-08 20:59:18 +10:00
parent 8d53eb5df8
commit 42768c3101
6 changed files with 35 additions and 30 deletions

View file

@ -15,7 +15,7 @@ extern bool DoState(StateWrapper& sw);
extern void GameChanged(const std::string& path, CDImage* image); extern void GameChanged(const std::string& path, CDImage* image);
/// Re-enables hardcode mode if it is enabled in the settings. /// Re-enables hardcode mode if it is enabled in the settings.
extern void ResetChallengeMode(); extern bool ResetChallengeMode();
/// Forces hardcore mode off until next reset. /// Forces hardcore mode off until next reset.
extern void DisableChallengeMode(); extern void DisableChallengeMode();
@ -43,7 +43,10 @@ static constexpr inline bool ChallengeModeActive()
return false; return false;
} }
static inline void ResetChallengeMode() {} static inline bool ResetChallengeMode()
{
return false;
}
static inline void DisableChallengeMode() {} static inline void DisableChallengeMode() {}

View file

@ -908,6 +908,9 @@ void System::ResetSystem()
#ifdef WITH_CHEEVOS #ifdef WITH_CHEEVOS
if (!Achievements::ConfirmSystemReset()) if (!Achievements::ConfirmSystemReset())
return; return;
if (Achievements::ResetChallengeMode())
ApplySettings(false);
#endif #endif
InternalReset(); InternalReset();
@ -915,10 +918,6 @@ void System::ResetSystem()
ResetThrottler(); ResetThrottler();
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "System reset.")); Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "System reset."));
#ifdef WITH_CHEEVOS
Achievements::ResetChallengeMode();
#endif
// need to clear this here, because of eject disc -> reset. // need to clear this here, because of eject disc -> reset.
s_running_bios = !s_running_game_path.empty(); s_running_bios = !s_running_game_path.empty();
} }
@ -2925,21 +2924,21 @@ void System::UpdateRunningGame(const char* path, CDImage* image, bool booting)
g_texture_replacements.SetGameID(s_running_game_serial); g_texture_replacements.SetGameID(s_running_game_serial);
s_cheat_list.reset();
if (g_settings.auto_load_cheats && !Achievements::ChallengeModeActive())
LoadCheatListFromGameTitle();
UpdateGameSettingsLayer();
ApplySettings(true);
Host::OnGameChanged(s_running_game_path, s_running_game_serial, s_running_game_title);
#ifdef WITH_CHEEVOS #ifdef WITH_CHEEVOS
if (booting) if (booting)
Achievements::ResetChallengeMode(); Achievements::ResetChallengeMode();
Achievements::GameChanged(s_running_game_path, image); Achievements::GameChanged(s_running_game_path, image);
#endif #endif
UpdateGameSettingsLayer();
ApplySettings(true);
s_cheat_list.reset();
if (g_settings.auto_load_cheats && !Achievements::ChallengeModeActive())
LoadCheatListFromGameTitle();
Host::OnGameChanged(s_running_game_path, s_running_game_serial, s_running_game_title);
} }
bool System::CheckForSBIFile(CDImage* image) bool System::CheckForSBIFile(CDImage* image)

View file

@ -498,9 +498,9 @@ void Achievements::UpdateSettings(const Settings& old_config)
} }
else if (!s_challenge_mode && g_settings.achievements_challenge_mode) else if (!s_challenge_mode && g_settings.achievements_challenge_mode)
{ {
Host::AddKeyedOSDMessage( ImGuiFullscreen::ShowToast(
"challenge_mode_reset", std::string(), Host::TranslateStdString("Achievements", "Hardcore mode will be enabled on system reset."),
Host::TranslateStdString("Achievements", "Hardcore mode will be enabled on system reset."), 10.0f); 10.0f);
} }
} }
@ -560,13 +560,13 @@ void Achievements::DisableChallengeMode()
SetChallengeMode(false); SetChallengeMode(false);
} }
void Achievements::ResetChallengeMode() bool Achievements::ResetChallengeMode()
{ {
if (!s_active) if (!s_active || s_challenge_mode == g_settings.achievements_challenge_mode)
return; return false;
if (s_challenge_mode != g_settings.achievements_challenge_mode) SetChallengeMode(g_settings.achievements_challenge_mode);
SetChallengeMode(g_settings.achievements_challenge_mode); return true;
} }
void Achievements::SetChallengeMode(bool enabled) void Achievements::SetChallengeMode(bool enabled)
@ -579,10 +579,10 @@ void Achievements::SetChallengeMode(bool enabled)
if (HasActiveGame()) if (HasActiveGame())
{ {
Host::AddKeyedOSDMessage("achievements_set_challenge_mode", ImGuiFullscreen::ShowToast(std::string(),
enabled ? Host::TranslateStdString("Achievements", "Hardcore mode is now enabled.") : enabled ? Host::TranslateStdString("Achievements", "Hardcore mode is now enabled.") :
Host::TranslateStdString("Achievements", "Hardcore mode is now disabled."), Host::TranslateStdString("Achievements", "Hardcore mode is now disabled."),
10.0f); 10.0f);
} }
if (HasActiveGame() && !IsTestModeActive()) if (HasActiveGame() && !IsTestModeActive())

View file

@ -119,7 +119,7 @@ void Logout();
void GameChanged(const std::string& path, CDImage* image); void GameChanged(const std::string& path, CDImage* image);
/// Re-enables hardcode mode if it is enabled in the settings. /// Re-enables hardcode mode if it is enabled in the settings.
void ResetChallengeMode(); bool ResetChallengeMode();
/// Forces hardcore mode off until next reset. /// Forces hardcore mode off until next reset.
void DisableChallengeMode(); void DisableChallengeMode();

View file

@ -585,7 +585,10 @@ void FullscreenUI::CheckForConfigChanges(const Settings& old_settings)
// If achievements got disabled, we might have the menu open... // If achievements got disabled, we might have the menu open...
// That means we're going to be reading achievement state. // That means we're going to be reading achievement state.
if (old_settings.achievements_enabled && !g_settings.achievements_enabled) if (old_settings.achievements_enabled && !g_settings.achievements_enabled)
ReturnToMainWindow(); {
if (s_current_main_window == MainWindowType::Achievements || s_current_main_window == MainWindowType::Leaderboards)
ReturnToMainWindow();
}
#endif #endif
} }

View file

@ -2144,7 +2144,7 @@ void ImGuiFullscreen::DrawMessageDialog()
} }
} }
static float s_notification_vertical_position = 0.3f; static float s_notification_vertical_position = 0.15f;
static float s_notification_vertical_direction = 1.0f; static float s_notification_vertical_direction = 1.0f;
float ImGuiFullscreen::GetNotificationVerticalPosition() float ImGuiFullscreen::GetNotificationVerticalPosition()