Disable loading state in hardcore mode

While saving states is allowed (especially for the purpose of debugging), RetroAchievements does not allow loading saved states when hardcore mode is on.
This commit is contained in:
LillyJadeKatrin 2023-06-07 21:37:13 -04:00
parent 71f3039f96
commit 2c40d6ba31
2 changed files with 27 additions and 1 deletions

View File

@ -31,6 +31,8 @@
#include "Common/Version.h"
#include "Common/WorkQueueThread.h"
#include "Core/AchievementManager.h"
#include "Core/Config/AchievementSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
@ -204,6 +206,14 @@ void LoadFromBuffer(std::vector<u8>& buffer)
return;
}
#ifdef USE_RETRO_ACHIEVEMENTS
if (AchievementManager::GetInstance()->IsHardcoreModeActive())
{
OSD::AddMessage("Loading savestates is disabled in RetroAchievements hardcore mode");
return;
}
#endif // USE_RETRO_ACHIEVEMENTS
Core::RunOnCPUThread(
[&] {
u8* ptr = buffer.data();
@ -842,6 +852,14 @@ void LoadAs(const std::string& filename)
return;
}
#ifdef USE_RETRO_ACHIEVEMENTS
if (AchievementManager::GetInstance()->IsHardcoreModeActive())
{
OSD::AddMessage("Loading savestates is disabled in RetroAchievements hardcore mode");
return;
}
#endif // USE_RETRO_ACHIEVEMENTS
std::unique_lock lk(s_load_or_save_in_progress_mutex, std::try_to_lock);
if (!lk)
return;

View File

@ -20,6 +20,7 @@
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
#include "Core/AchievementManager.h"
#include "Core/Boot/Boot.h"
#include "Core/CommonTitles.h"
#include "Core/Config/AchievementSettings.h"
@ -122,9 +123,16 @@ void MenuBar::OnEmulationStateChanged(Core::State state)
m_fullscreen_action->setEnabled(running);
m_frame_advance_action->setEnabled(running);
m_screenshot_action->setEnabled(running);
m_state_load_menu->setEnabled(running);
m_state_save_menu->setEnabled(running);
#ifdef USE_RETRO_ACHIEVEMENTS
bool hardcore = AchievementManager::GetInstance()->IsHardcoreModeActive();
m_state_load_menu->setEnabled(running && !hardcore);
#else // USE_RETRO_ACHIEVEMENTS
m_state_load_menu->setEnabled(running);
#endif // USE_RETRO_ACHIEVEMENTS
// Movie
m_recording_read_only->setEnabled(running);
if (!running)