Add a spot in the UI to authenticate with RetroAchievements

This commit is contained in:
Chase Harkcom 2026-02-18 16:40:08 -07:00
parent 30beb5d972
commit 6a737183c0
9 changed files with 131 additions and 13 deletions

View File

@ -328,3 +328,7 @@ endif()
if (CITRA_USE_PRECOMPILED_HEADERS) if (CITRA_USE_PRECOMPILED_HEADERS)
target_precompile_headers(citra_qt PRIVATE precompiled_headers.h) target_precompile_headers(citra_qt PRIVATE precompiled_headers.h)
endif() endif()
if (ENABLE_RETROACHIEVEMENTS)
target_link_libraries(citra_qt PRIVATE rcheevos_integration)
endif()

View File

@ -11,6 +11,10 @@
#include "citra_qt/uisettings.h" #include "citra_qt/uisettings.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/settings.h" #include "common/settings.h"
#include "core/core.h"
#ifdef ENABLE_RETROACHIEVEMENTS
#include "rcheevos_integration/rcheevos_integration.h"
#endif
#include "ui_configure_general.h" #include "ui_configure_general.h"
// The QSlider doesn't have an easy way to set a custom step amount, // The QSlider doesn't have an easy way to set a custom step amount,
@ -47,6 +51,10 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)
ui->updates_group->setVisible(false); ui->updates_group->setVisible(false);
#endif #endif
#ifndef ENABLE_RETROACHIEVEMENTS
ui->retro_achievements_group->setVisible(false);
#endif
SetupPerGameUI(); SetupPerGameUI();
SetConfiguration(); SetConfiguration();
@ -74,6 +82,9 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)
} }
ui->change_screenshot_dir->setEnabled(true); ui->change_screenshot_dir->setEnabled(true);
}); });
connect(ui->retro_achievements_log_in_button, &QPushButton::clicked, this,
&ConfigureGeneral::RetroAchievementsLogIn);
} }
ConfigureGeneral::~ConfigureGeneral() = default; ConfigureGeneral::~ConfigureGeneral() = default;
@ -196,6 +207,15 @@ void ConfigureGeneral::RetranslateUI() {
ui->retranslateUi(this); ui->retranslateUi(this);
} }
void ConfigureGeneral::RetroAchievementsLogIn() {
#ifdef ENABLE_RETROACHIEVEMENTS
std::string username = ui->retro_achievements_username_input->text().toStdString(),
password = ui->retro_achievements_password_input->text().toStdString();
Core::System::GetInstance().GetRcheevosClient().LogInRetroachievementsUser(username.c_str(), password.c_str());
#endif
}
void ConfigureGeneral::SetupPerGameUI() { void ConfigureGeneral::SetupPerGameUI() {
if (Settings::IsConfiguringGlobal()) { if (Settings::IsConfiguringGlobal()) {
ui->frame_limit->setEnabled(Settings::values.frame_limit.UsingGlobal()); ui->frame_limit->setEnabled(Settings::values.frame_limit.UsingGlobal());

View File

@ -24,6 +24,7 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
void RetranslateUI(); void RetranslateUI();
void SetConfiguration(); void SetConfiguration();
void RetroAchievementsLogIn();
void SetupPerGameUI(); void SetupPerGameUI();

View File

@ -295,7 +295,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="screenshot_dir_label"> <widget class="QLabel">
<property name="text"> <property name="text">
<string>Save Screenshots To</string> <string>Save Screenshots To</string>
</property> </property>
@ -317,6 +317,78 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="retro_achievements_group">
<property name="title">
<string>RetroAchievements</string>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QWidget" name="widget_retro_achievements_username" native="true">
<layout class="QHBoxLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel">
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="retro_achievements_username_input"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_retro_achievements_password" native="true">
<layout class="QHBoxLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="retro_achievements_password_input"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="retro_achievements_log_in_button">
<property name="text">
<string>Log In</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignRight"> <item alignment="Qt::AlignRight">
<widget class="QPushButton" name="button_reset_defaults"> <widget class="QPushButton" name="button_reset_defaults">
<property name="text"> <property name="text">

View File

@ -506,6 +506,7 @@ target_link_libraries(citra_core PUBLIC dds-ktx PRIVATE cryptopp fmt lodepng ope
if (ENABLE_RETROACHIEVEMENTS) if (ENABLE_RETROACHIEVEMENTS)
target_link_libraries(citra_core PUBLIC rcheevos_integration) target_link_libraries(citra_core PUBLIC rcheevos_integration)
target_compile_definitions(citra_core PUBLIC ENABLE_RETROACHIEVEMENTS)
endif() endif()
if (ENABLE_WEB_SERVICE) if (ENABLE_WEB_SERVICE)

View File

@ -50,6 +50,9 @@
#include "core/rpc/server.h" #include "core/rpc/server.h"
#endif #endif
#include "network/network.h" #include "network/network.h"
#ifdef ENABLE_RETROACHIEVEMENTS
#include "rcheevos_integration/rcheevos_integration.h"
#endif
#include "video_core/custom_textures/custom_tex_manager.h" #include "video_core/custom_textures/custom_tex_manager.h"
#include "video_core/gpu.h" #include "video_core/gpu.h"
#include "video_core/renderer_base.h" #include "video_core/renderer_base.h"
@ -73,11 +76,12 @@ Core::Timing& Global() {
return System::GetInstance().CoreTiming(); return System::GetInstance().CoreTiming();
} }
System::System() : movie{*this}, cheat_engine{*this} System::System() : movie{*this}, cheat_engine{*this} {
#ifdef ENABLE_RETROACHIEVEMENTS #ifdef ENABLE_RETROACHIEVEMENTS
, rcheevos_client{*this} rcheevos_client = std::make_unique<RcheevosClient>(*this);
rcheevos_client->InitializeClient();
#endif #endif
{} }
System::~System() = default; System::~System() = default;
@ -595,11 +599,6 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window,
plg_ldr->SetAllowGameChangeState(Settings::values.allow_plugin_loader.GetValue()); plg_ldr->SetAllowGameChangeState(Settings::values.allow_plugin_loader.GetValue());
} }
#ifdef ENABLE_RETROACHIEVEMENTS
rcheevos_client.InitializeClient();
rcheevos_client.LoginRetroachievementsUser("", "");
#endif
LOG_DEBUG(Core, "Initialized OK"); LOG_DEBUG(Core, "Initialized OK");
is_powered_on = true; is_powered_on = true;
@ -663,6 +662,16 @@ const Cheats::CheatEngine& System::CheatEngine() const {
return cheat_engine; return cheat_engine;
} }
#ifdef ENABLE_RETROACHIEVEMENTS
RcheevosClient &System::GetRcheevosClient() {
return *rcheevos_client;
}
const RcheevosClient &System::GetRcheevosClient() const {
return *rcheevos_client;
}
#endif
void System::RegisterVideoDumper(std::shared_ptr<VideoDumper::Backend> dumper) { void System::RegisterVideoDumper(std::shared_ptr<VideoDumper::Backend> dumper) {
video_dumper = std::move(dumper); video_dumper = std::move(dumper);
} }

View File

@ -18,7 +18,6 @@
#include "core/hle/service/plgldr/plgldr.h" #include "core/hle/service/plgldr/plgldr.h"
#include "core/movie.h" #include "core/movie.h"
#include "core/perf_stats.h" #include "core/perf_stats.h"
#include "rcheevos_integration/rcheevos_integration.h"
namespace Frontend { namespace Frontend {
class EmuWindow; class EmuWindow;
@ -71,6 +70,10 @@ namespace Loader {
class AppLoader; class AppLoader;
} }
#ifdef ENABLE_RETROACHIEVEMENTS
class RcheevosClient;
#endif
namespace Core { namespace Core {
class ARM_Interface; class ARM_Interface;
@ -278,6 +281,14 @@ public:
/// Gets a const reference to the cheat engine /// Gets a const reference to the cheat engine
[[nodiscard]] const Cheats::CheatEngine& CheatEngine() const; [[nodiscard]] const Cheats::CheatEngine& CheatEngine() const;
#ifdef ENABLE_RETROACHIEVEMENTS
// Gets a reference to the Rcheevos client
[[nodiscard]] RcheevosClient &GetRcheevosClient();
// Gets a const reference to the Rcheevos client
[[nodiscard]] const RcheevosClient &GetRcheevosClient() const;
#endif
/// Gets a reference to the custom texture cache system /// Gets a reference to the custom texture cache system
[[nodiscard]] VideoCore::CustomTexManager& CustomTexManager(); [[nodiscard]] VideoCore::CustomTexManager& CustomTexManager();
@ -442,7 +453,7 @@ private:
#ifdef ENABLE_RETROACHIEVEMENTS #ifdef ENABLE_RETROACHIEVEMENTS
/// RetroAchievements /// RetroAchievements
RcheevosClient rcheevos_client; std::unique_ptr<RcheevosClient> rcheevos_client;
#endif #endif
/// Video dumper backend /// Video dumper backend

View File

@ -91,7 +91,7 @@ static void login_callback(int result, const char* error_message, rc_client_t* c
} }
void RcheevosClient::LoginRetroachievementsUser(const char* username, const char* password) void RcheevosClient::LogInRetroachievementsUser(const char* username, const char* password)
{ {
rc_client_begin_login_with_password(rc_client, username, password, login_callback, NULL); rc_client_begin_login_with_password(rc_client, username, password, login_callback, NULL);
} }

View File

@ -12,7 +12,7 @@ public:
~RcheevosClient(); ~RcheevosClient();
void InitializeClient(); void InitializeClient();
void LoginRetroachievementsUser(const char* username, const char* password); void LogInRetroachievementsUser(const char* username, const char* password);
private: private:
const Core::System& system; const Core::System& system;
rc_client_t* rc_client = nullptr; rc_client_t* rc_client = nullptr;