From 07d2f3d305136180b753b5e13db692f68af2519b Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Thu, 16 Mar 2023 09:06:24 -0400 Subject: [PATCH] Added Initial Achievement Settings Added AchievementSettings in Config with RA_INTEGRATION_ENABLED, RA_USERNAME, and RA_API_TOKEN. Includes code to load and store from Achievements.ini file in config folder. --- Source/Core/Common/CommonPaths.h | 1 + Source/Core/Common/Config/Config.cpp | 3 ++- Source/Core/Common/Config/Enums.h | 1 + Source/Core/Common/FileUtil.cpp | 2 ++ Source/Core/Common/FileUtil.h | 1 + Source/Core/Core/CMakeLists.txt | 2 ++ Source/Core/Core/Config/AchievementSettings.cpp | 16 ++++++++++++++++ Source/Core/Core/Config/AchievementSettings.h | 14 ++++++++++++++ .../Core/Core/ConfigLoaders/BaseConfigLoader.cpp | 1 + .../Core/ConfigLoaders/IsSettingSaveable.cpp | 7 +++++++ Source/Core/DolphinLib.props | 2 ++ 11 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 Source/Core/Core/Config/AchievementSettings.cpp create mode 100644 Source/Core/Core/Config/AchievementSettings.h diff --git a/Source/Core/Common/CommonPaths.h b/Source/Core/Common/CommonPaths.h index 047f5dc967..b22033a5cd 100644 --- a/Source/Core/Common/CommonPaths.h +++ b/Source/Core/Common/CommonPaths.h @@ -112,6 +112,7 @@ #define LOGGER_CONFIG "Logger.ini" #define DUALSHOCKUDPCLIENT_CONFIG "DSUClient.ini" #define FREELOOK_CONFIG "FreeLook.ini" +#define RETROACHIEVEMENTS_CONFIG "RetroAchievements.ini" // Files in the directory returned by GetUserPath(D_LOGS_IDX) #define MAIN_LOG "dolphin.log" diff --git a/Source/Core/Common/Config/Config.cpp b/Source/Core/Common/Config/Config.cpp index 4a55ab5b7b..ff3a8c6783 100644 --- a/Source/Core/Common/Config/Config.cpp +++ b/Source/Core/Common/Config/Config.cpp @@ -160,7 +160,8 @@ static const std::map system_to_name = { {System::DualShockUDPClient, "DualShockUDPClient"}, {System::FreeLook, "FreeLook"}, {System::Session, "Session"}, - {System::GameSettingsOnly, "GameSettingsOnly"}}; + {System::GameSettingsOnly, "GameSettingsOnly"}, + {System::Achievements, "Achievements"}}; const std::string& GetSystemName(System system) { diff --git a/Source/Core/Common/Config/Enums.h b/Source/Core/Common/Config/Enums.h index 1f6d0a1966..69d8c954c3 100644 --- a/Source/Core/Common/Config/Enums.h +++ b/Source/Core/Common/Config/Enums.h @@ -34,6 +34,7 @@ enum class System FreeLook, Session, GameSettingsOnly, + Achievements, }; constexpr std::array SEARCH_ORDER{{ diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index d456952980..b97185e769 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -847,6 +847,8 @@ static void RebuildUserDirectories(unsigned int dir_index) s_user_paths[F_DUALSHOCKUDPCLIENTCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + DUALSHOCKUDPCLIENT_CONFIG; s_user_paths[F_FREELOOKCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + FREELOOK_CONFIG; + s_user_paths[F_RETROACHIEVEMENTSCONFIG_IDX] = + s_user_paths[D_CONFIG_IDX] + RETROACHIEVEMENTS_CONFIG; s_user_paths[F_MAINLOG_IDX] = s_user_paths[D_LOGS_IDX] + MAIN_LOG; s_user_paths[F_MEM1DUMP_IDX] = s_user_paths[D_DUMP_IDX] + MEM1_DUMP; s_user_paths[F_MEM2DUMP_IDX] = s_user_paths[D_DUMP_IDX] + MEM2_DUMP; diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h index cadabbd541..f6dc396966 100644 --- a/Source/Core/Common/FileUtil.h +++ b/Source/Core/Common/FileUtil.h @@ -85,6 +85,7 @@ enum F_DUALSHOCKUDPCLIENTCONFIG_IDX, F_FREELOOKCONFIG_IDX, F_GBABIOS_IDX, + F_RETROACHIEVEMENTSCONFIG_IDX, NUM_PATH_INDICES }; diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 08b8ffa9c7..a53eb20705 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -21,6 +21,8 @@ add_library(core CheatSearch.cpp CheatSearch.h CommonTitles.h + Config/AchievementSettings.cpp + Config/AchievementSettings.h Config/DefaultLocale.cpp Config/DefaultLocale.h Config/FreeLookSettings.cpp diff --git a/Source/Core/Core/Config/AchievementSettings.cpp b/Source/Core/Core/Config/AchievementSettings.cpp new file mode 100644 index 0000000000..f7ec642881 --- /dev/null +++ b/Source/Core/Core/Config/AchievementSettings.cpp @@ -0,0 +1,16 @@ +// Copyright 2023 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "Core/Config/AchievementSettings.h" + +#include + +#include "Common/Config/Config.h" + +namespace Config +{ +// Configuration Information +const Info RA_ENABLED{{System::Achievements, "Achievements", "Enabled"}, false}; +const Info RA_USERNAME{{System::Achievements, "Achievements", "Username"}, ""}; +const Info RA_API_TOKEN{{System::Achievements, "Achievements", "ApiToken"}, ""}; +} // namespace Config diff --git a/Source/Core/Core/Config/AchievementSettings.h b/Source/Core/Core/Config/AchievementSettings.h new file mode 100644 index 0000000000..8f26769d7f --- /dev/null +++ b/Source/Core/Core/Config/AchievementSettings.h @@ -0,0 +1,14 @@ +// Copyright 2023 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "Common/Config/Config.h" + +namespace Config +{ +// Configuration Information +extern const Info RA_ENABLED; +extern const Info RA_USERNAME; +extern const Info RA_API_TOKEN; +} // namespace Config diff --git a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp index acce10521b..6b8ed12e7b 100644 --- a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp @@ -94,6 +94,7 @@ const std::map system_to_ini = { {Config::System::Debugger, F_DEBUGGERCONFIG_IDX}, {Config::System::DualShockUDPClient, F_DUALSHOCKUDPCLIENTCONFIG_IDX}, {Config::System::FreeLook, F_FREELOOKCONFIG_IDX}, + {Config::System::Achievements, F_RETROACHIEVEMENTSCONFIG_IDX}, // Config::System::Session should not be added to this list }; diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index d7746baa41..852fbb74ca 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -7,6 +7,7 @@ #include #include "Common/Config/Config.h" +#include "Core/Config/AchievementSettings.h" #include "Core/Config/GraphicsSettings.h" #include "Core/Config/MainSettings.h" #include "Core/Config/UISettings.h" @@ -37,6 +38,12 @@ bool IsSettingSaveable(const Config::Location& config_location) &Config::WIIMOTE_3_SOURCE.GetLocation(), &Config::WIIMOTE_4_SOURCE.GetLocation(), &Config::WIIMOTE_BB_SOURCE.GetLocation(), + + // Achievements + + &Config::RA_ENABLED.GetLocation(), + &Config::RA_USERNAME.GetLocation(), + &Config::RA_API_TOKEN.GetLocation(), }; return std::any_of(begin(s_setting_saveable), end(s_setting_saveable), diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index c99d353df6..4cada3066e 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -172,6 +172,7 @@ + @@ -805,6 +806,7 @@ +