Add rc_client to AchievementManager
Also includes init and shutdown V2s.
This commit is contained in:
parent
4ec662bcdf
commit
ba519e4670
|
@ -33,13 +33,18 @@ AchievementManager& AchievementManager::GetInstance()
|
||||||
|
|
||||||
void AchievementManager::Init()
|
void AchievementManager::Init()
|
||||||
{
|
{
|
||||||
if (!m_is_runtime_initialized && Config::Get(Config::RA_ENABLED))
|
if (!m_client && Config::Get(Config::RA_ENABLED))
|
||||||
{
|
{
|
||||||
|
m_client = rc_client_create(MemoryPeekerV2, RequestV2);
|
||||||
std::string host_url = Config::Get(Config::RA_HOST_URL);
|
std::string host_url = Config::Get(Config::RA_HOST_URL);
|
||||||
if (!host_url.empty())
|
if (!host_url.empty())
|
||||||
rc_api_set_host(host_url.c_str());
|
rc_client_set_host(m_client, host_url.c_str());
|
||||||
rc_runtime_init(&m_runtime);
|
rc_client_enable_logging(m_client, RC_CLIENT_LOG_LEVEL_VERBOSE,
|
||||||
m_is_runtime_initialized = true;
|
[](const char* message, const rc_client_t* client) {
|
||||||
|
INFO_LOG_FMT(ACHIEVEMENTS, "{}", message);
|
||||||
|
});
|
||||||
|
rc_client_set_hardcore_enabled(m_client, 0);
|
||||||
|
rc_client_set_unofficial_enabled(m_client, 1);
|
||||||
m_queue.Reset("AchievementManagerQueue", [](const std::function<void()>& func) { func(); });
|
m_queue.Reset("AchievementManagerQueue", [](const std::function<void()>& func) { func(); });
|
||||||
m_image_queue.Reset("AchievementManagerImageQueue",
|
m_image_queue.Reset("AchievementManagerImageQueue",
|
||||||
[](const std::function<void()>& func) { func(); });
|
[](const std::function<void()>& func) { func(); });
|
||||||
|
@ -941,15 +946,18 @@ void AchievementManager::Logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
void AchievementManager::Shutdown()
|
void AchievementManager::Shutdown()
|
||||||
|
{
|
||||||
|
if (m_client)
|
||||||
{
|
{
|
||||||
CloseGame();
|
CloseGame();
|
||||||
SetDisabled(false);
|
SetDisabled(false);
|
||||||
m_is_runtime_initialized = false;
|
|
||||||
m_queue.Shutdown();
|
m_queue.Shutdown();
|
||||||
// DON'T log out - keep those credentials for next run.
|
// DON'T log out - keep those credentials for next run.
|
||||||
rc_runtime_destroy(&m_runtime);
|
rc_client_destroy(m_client);
|
||||||
|
m_client = nullptr;
|
||||||
INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager shut down.");
|
INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager shut down.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void* AchievementManager::FilereaderOpenByFilepath(const char* path_utf8)
|
void* AchievementManager::FilereaderOpenByFilepath(const char* path_utf8)
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,6 +210,7 @@ private:
|
||||||
static u32 MemoryPeekerV2(u32 address, u8* buffer, u32 num_bytes, rc_client_t* client);
|
static u32 MemoryPeekerV2(u32 address, u8* buffer, u32 num_bytes, rc_client_t* client);
|
||||||
|
|
||||||
rc_runtime_t m_runtime{};
|
rc_runtime_t m_runtime{};
|
||||||
|
rc_client_t* m_client{};
|
||||||
Core::System* m_system{};
|
Core::System* m_system{};
|
||||||
bool m_is_runtime_initialized = false;
|
bool m_is_runtime_initialized = false;
|
||||||
UpdateCallback m_update_callback = [] {};
|
UpdateCallback m_update_callback = [] {};
|
||||||
|
|
Loading…
Reference in New Issue