Update hardcore toggle to use rc_client

The client can take care of itself and handle its own hardcore status when it toggles, so I can tell the settings widget to contact the manager directly to set it.
Also, gradually reorganizing the settings dialog over the next handful of commits.
This commit is contained in:
LillyJadeKatrin committed 2024-05-01 07:04:32 -04:00
1 parent 9a40ec06b5
commit 0883aa114e
4 files changed
+22 -15

No files matched your search

+9 -6
View File
@@ -45,7 +45,7 @@ void AchievementManager::Init()
[](const char* message, const rc_client_t* client) {
INFO_LOG_FMT(ACHIEVEMENTS, "{}", message);
});
rc_client_set_hardcore_enabled(m_client, 0);
rc_client_set_hardcore_enabled(m_client, Config::Get(Config::RA_HARDCORE_ENABLED));
rc_client_set_unofficial_enabled(m_client, 1);
m_queue.Reset("AchievementManagerQueue", [](const std::function<void()>& func) { func(); });
m_image_queue.Reset("AchievementManagerImageQueue",
@@ -240,16 +240,19 @@ std::recursive_mutex& AchievementManager::GetLock()
return m_lock;
}
void AchievementManager::SetHardcoreMode()
{
rc_client_set_hardcore_enabled(m_client, Config::Get(Config::RA_HARDCORE_ENABLED));
}
bool AchievementManager::IsHardcoreModeActive() const
{
std::lock_guard lg{m_lock};
if (!Config::Get(Config::RA_HARDCORE_ENABLED))
if (!rc_client_get_hardcore_enabled(m_client))
return false;
if (!Core::IsRunning())
if (!rc_client_get_game_info(m_client))
return true;
if (!IsGameLoaded())
return false;
return (m_runtime.trigger_count + m_runtime.lboard_count > 0);
return rc_client_is_processing_required(m_client);
}
std::string_view AchievementManager::GetPlayerDisplayName() const
+1
View File
@@ -103,6 +103,7 @@ public:
void DoFrame();
std::recursive_mutex& GetLock();
void SetHardcoreMode();
bool IsHardcoreModeActive() const;
std::string_view GetPlayerDisplayName() const;
u32 GetPlayerScore() const;
@@ -16,7 +16,7 @@ const Info<std::string> RA_HOST_URL{{System::Achievements, "Achievements", "Host
const Info<std::string> RA_USERNAME{{System::Achievements, "Achievements", "Username"}, ""};
const Info<std::string> RA_API_TOKEN{{System::Achievements, "Achievements", "ApiToken"}, ""};
const Info<bool> RA_HARDCORE_ENABLED{{System::Achievements, "Achievements", "HardcoreEnabled"},
false};
true};
const Info<bool> RA_PROGRESS_ENABLED{{System::Achievements, "Achievements", "ProgressEnabled"},
false};
const Info<bool> RA_BADGES_ENABLED{{System::Achievements, "Achievements", "BadgesEnabled"}, false};