mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-24 14:24:54 +00:00
Load RA_Integration.DLL at init if present
This commit is contained in:
parent
cab5bc5680
commit
36c7e7f3c7
4 changed files with 53 additions and 4 deletions
|
@ -42,6 +42,12 @@
|
|||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
#include "VideoCommon/VideoEvents.h"
|
||||
|
||||
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
#include <libloaderapi.h>
|
||||
#include <rcheevos/include/rc_client_raintegration.h>
|
||||
#include <shlwapi.h>
|
||||
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
|
||||
static const Common::HttpRequest::Headers USER_AGENT_HEADER = {
|
||||
{"User-Agent", Common::GetUserAgentStr()}};
|
||||
|
||||
|
@ -51,7 +57,7 @@ AchievementManager& AchievementManager::GetInstance()
|
|||
return s_instance;
|
||||
}
|
||||
|
||||
void AchievementManager::Init()
|
||||
void AchievementManager::Init(void* hwnd)
|
||||
{
|
||||
LoadDefaultBadges();
|
||||
if (!m_client && Config::Get(Config::RA_ENABLED))
|
||||
|
@ -73,9 +79,19 @@ void AchievementManager::Init()
|
|||
m_queue.Reset("AchievementManagerQueue", [](const std::function<void()>& func) { func(); });
|
||||
m_image_queue.Reset("AchievementManagerImageQueue",
|
||||
[](const std::function<void()>& func) { func(); });
|
||||
|
||||
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
// Attempt to load the integration DLL from the directory containing the main client executable.
|
||||
// In x64 build, will look for RA_Integration-x64.dll, then RA_Integration.dll.
|
||||
// In non-x64 build, will only look for RA_Integration.dll.
|
||||
rc_client_begin_load_raintegration(
|
||||
m_client, UTF8ToWString(File::GetExeDirectory()).c_str(), reinterpret_cast<HWND>(hwnd),
|
||||
"Dolphin", Common::GetScmDescStr().c_str(), LoadIntegrationCallback, NULL);
|
||||
#else // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
if (HasAPIToken())
|
||||
Login("");
|
||||
INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager Initialized");
|
||||
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1395,4 +1411,32 @@ void AchievementManager::EventHandler(const rc_client_event_t* event, rc_client_
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
void AchievementManager::LoadIntegrationCallback(int result, const char* error_message,
|
||||
rc_client_t* client, void* userdata)
|
||||
{
|
||||
auto& instance = AchievementManager::GetInstance();
|
||||
switch (result)
|
||||
{
|
||||
case RC_OK:
|
||||
INFO_LOG_FMT(ACHIEVEMENTS, "RAIntegration.dll found.");
|
||||
// TODO: hook up menu and dll event handlers
|
||||
break;
|
||||
|
||||
case RC_MISSING_VALUE:
|
||||
INFO_LOG_FMT(ACHIEVEMENTS, "RAIntegration.dll not found.");
|
||||
// DLL is not present; do nothing.
|
||||
break;
|
||||
|
||||
default:
|
||||
WARN_LOG_FMT(ACHIEVEMENTS, "Failed to load RAIntegration.dll. {}", error_message);
|
||||
break;
|
||||
}
|
||||
|
||||
if (instance.HasAPIToken())
|
||||
instance.Login("");
|
||||
INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager Initialized");
|
||||
}
|
||||
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
using UpdateCallback = std::function<void(const UpdatedItems&)>;
|
||||
|
||||
static AchievementManager& GetInstance();
|
||||
void Init();
|
||||
void Init(void* hwnd);
|
||||
void SetUpdateCallback(UpdateCallback callback);
|
||||
void Login(const std::string& password);
|
||||
bool HasAPIToken() const;
|
||||
|
@ -235,6 +235,11 @@ private:
|
|||
const UpdatedItems callback_data);
|
||||
static void EventHandler(const rc_client_event_t* event, rc_client_t* client);
|
||||
|
||||
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
static void LoadIntegrationCallback(int result, const char* error_message, rc_client_t* client,
|
||||
void* userdata);
|
||||
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
|
||||
rc_runtime_t m_runtime{};
|
||||
rc_client_t* m_client{};
|
||||
std::atomic<Core::System*> m_system{};
|
||||
|
|
|
@ -256,7 +256,7 @@ void AchievementSettingsWidget::ToggleRAIntegration()
|
|||
|
||||
auto& instance = AchievementManager::GetInstance();
|
||||
if (Config::Get(Config::RA_ENABLED))
|
||||
instance.Init();
|
||||
instance.Init(reinterpret_cast<void*>(winId()));
|
||||
else
|
||||
instance.Shutdown();
|
||||
UpdateHardcoreMode();
|
||||
|
|
|
@ -272,7 +272,7 @@ MainWindow::MainWindow(Core::System& system, std::unique_ptr<BootParameters> boo
|
|||
NetPlayInit();
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
AchievementManager::GetInstance().Init();
|
||||
AchievementManager::GetInstance().Init(reinterpret_cast<void*>(winId()));
|
||||
if (AchievementManager::GetInstance().IsHardcoreModeActive())
|
||||
Settings::Instance().SetDebugModeEnabled(false);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
|
Loading…
Add table
Reference in a new issue