Added ActivateDeactivateLeaderboards to AchievementManager
This activates or deactivates leaderboards in the rcheevos runtime similarly to achievements. The logic is much more straightforward - all leaderboards are active together; there is nothing requiring some leaderboards to be active while others are unactive, and even a leaderboard that has been submitted to in this session is still active to be submitted to again. The only criteria are that leaderboards must be enabled in the settings, and hardcore mode must be on, the latter of which is false until a future PR.
This commit is contained in:
parent
da1de36cb9
commit
64e3a64c87
|
@ -141,6 +141,7 @@ void AchievementManager::LoadGameByFilenameAsync(const std::string& iso_path,
|
|||
LoadUnlockData([](ResponseType r_type) {});
|
||||
ActivateDeactivateAchievements();
|
||||
}
|
||||
ActivateDeactivateLeaderboards();
|
||||
|
||||
callback(fetch_game_data_response);
|
||||
});
|
||||
|
@ -173,6 +174,23 @@ void AchievementManager::ActivateDeactivateAchievements()
|
|||
}
|
||||
}
|
||||
|
||||
void AchievementManager::ActivateDeactivateLeaderboards()
|
||||
{
|
||||
bool leaderboards_enabled = Config::Get(Config::RA_LEADERBOARDS_ENABLED);
|
||||
for (u32 ix = 0; ix < m_game_data.num_leaderboards; ix++)
|
||||
{
|
||||
auto leaderboard = m_game_data.leaderboards[ix];
|
||||
if (m_is_game_loaded && leaderboards_enabled && hardcore_mode_enabled)
|
||||
{
|
||||
rc_runtime_activate_lboard(&m_runtime, leaderboard.id, leaderboard.definition, nullptr, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc_runtime_deactivate_lboard(&m_runtime, m_game_data.leaderboards[ix].id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AchievementManager::CloseGame()
|
||||
{
|
||||
m_is_game_loaded = false;
|
||||
|
@ -180,6 +198,7 @@ void AchievementManager::CloseGame()
|
|||
m_queue.Cancel();
|
||||
m_unlock_map.clear();
|
||||
ActivateDeactivateAchievements();
|
||||
ActivateDeactivateLeaderboards();
|
||||
}
|
||||
|
||||
void AchievementManager::Logout()
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
|
||||
void LoadUnlockData(const ResponseCallback& callback);
|
||||
void ActivateDeactivateAchievements();
|
||||
void ActivateDeactivateLeaderboards();
|
||||
void CloseGame();
|
||||
void Logout();
|
||||
void Shutdown();
|
||||
|
|
|
@ -15,6 +15,8 @@ const Info<std::string> RA_USERNAME{{System::Achievements, "Achievements", "User
|
|||
const Info<std::string> RA_API_TOKEN{{System::Achievements, "Achievements", "ApiToken"}, ""};
|
||||
const Info<bool> RA_ACHIEVEMENTS_ENABLED{
|
||||
{System::Achievements, "Achievements", "AchievementsEnabled"}, false};
|
||||
const Info<bool> RA_LEADERBOARDS_ENABLED{
|
||||
{System::Achievements, "Achievements", "LeaderboardsEnabled"}, false};
|
||||
const Info<bool> RA_UNOFFICIAL_ENABLED{{System::Achievements, "Achievements", "UnofficialEnabled"},
|
||||
false};
|
||||
const Info<bool> RA_ENCORE_ENABLED{{System::Achievements, "Achievements", "EncoreEnabled"}, false};
|
||||
|
|
|
@ -12,6 +12,7 @@ extern const Info<bool> RA_ENABLED;
|
|||
extern const Info<std::string> RA_USERNAME;
|
||||
extern const Info<std::string> RA_API_TOKEN;
|
||||
extern const Info<bool> RA_ACHIEVEMENTS_ENABLED;
|
||||
extern const Info<bool> RA_LEADERBOARDS_ENABLED;
|
||||
extern const Info<bool> RA_UNOFFICIAL_ENABLED;
|
||||
extern const Info<bool> RA_ENCORE_ENABLED;
|
||||
} // namespace Config
|
||||
|
|
Loading…
Reference in New Issue