9 changes: 9 additions & 0 deletions Source/Core/Core/CMakeLists.txt
@@ -1,4 +1,6 @@
add_library(core
AchievementManager.cpp
AchievementManager.h
ActionReplay.cpp
ActionReplay.h
ARDecrypt.cpp
Expand All @@ -21,6 +23,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
Expand Down Expand Up @@ -747,3 +751,8 @@ if(MSVC)
# Add precompiled header
target_link_libraries(core PRIVATE use_pch)
endif()

if(USE_RETRO_ACHIEVEMENTS)
target_link_libraries(core PRIVATE rcheevos)
target_compile_definitions(core PRIVATE -DUSE_RETRO_ACHIEVEMENTS)
endif()
16 changes: 16 additions & 0 deletions 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 <string>

#include "Common/Config/Config.h"

namespace Config
{
// Configuration Information
const Info<bool> RA_ENABLED{{System::Achievements, "Achievements", "Enabled"}, false};
const Info<std::string> RA_USERNAME{{System::Achievements, "Achievements", "Username"}, ""};
const Info<std::string> RA_API_TOKEN{{System::Achievements, "Achievements", "ApiToken"}, ""};
} // namespace Config
14 changes: 14 additions & 0 deletions 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<bool> RA_ENABLED;
extern const Info<std::string> RA_USERNAME;
extern const Info<std::string> RA_API_TOKEN;
} // namespace Config
1 change: 1 addition & 0 deletions Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp
Expand Up @@ -94,6 +94,7 @@ const std::map<Config::System, int> 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
};

Expand Down
7 changes: 7 additions & 0 deletions Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp
Expand Up @@ -7,6 +7,7 @@
#include <vector>

#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"
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/DolphinLib.props
Expand Up @@ -161,6 +161,7 @@
<ClInclude Include="Common\WindowsRegistry.h" />
<ClInclude Include="Common\WindowSystemInfo.h" />
<ClInclude Include="Common\WorkQueueThread.h" />
<ClInclude Include="Core\AchievementManager.h" />
<ClInclude Include="Core\ActionReplay.h" />
<ClInclude Include="Core\ARDecrypt.h" />
<ClInclude Include="Core\Boot\Boot.h" />
Expand All @@ -172,6 +173,7 @@
<ClInclude Include="Core\CheatGeneration.h" />
<ClInclude Include="Core\CheatSearch.h" />
<ClInclude Include="Core\CommonTitles.h" />
<ClInclude Include="Core\Config\AchievementSettings.h" />
<ClInclude Include="Core\Config\DefaultLocale.h" />
<ClInclude Include="Core\Config\FreeLookSettings.h" />
<ClInclude Include="Core\Config\GraphicsSettings.h" />
Expand Down Expand Up @@ -795,6 +797,7 @@
<ClCompile Include="Common\UPnP.cpp" />
<ClCompile Include="Common\WindowsRegistry.cpp" />
<ClCompile Include="Common\Version.cpp" />
<ClCompile Include="Core\AchievementManager.cpp" />
<ClCompile Include="Core\ActionReplay.cpp" />
<ClCompile Include="Core\ARDecrypt.cpp" />
<ClCompile Include="Core\Boot\Boot_BS2Emu.cpp" />
Expand All @@ -805,6 +808,7 @@
<ClCompile Include="Core\BootManager.cpp" />
<ClCompile Include="Core\CheatGeneration.cpp" />
<ClCompile Include="Core\CheatSearch.cpp" />
<ClCompile Include="Core\Config\AchievementSettings.cpp" />
<ClCompile Include="Core\Config\DefaultLocale.cpp" />
<ClCompile Include="Core\Config\FreeLookSettings.cpp" />
<ClCompile Include="Core\Config\GraphicsSettings.cpp" />
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinLib.vcxproj
Expand Up @@ -52,6 +52,7 @@
<Import Project="$(ExternalsDir)minizip\exports.props" />
<Import Project="$(ExternalsDir)picojson\exports.props" />
<Import Project="$(ExternalsDir)pugixml\exports.props" />
<Import Project="$(ExternalsDir)rcheevos\exports.props" />
<Import Project="$(ExternalsDir)SDL\exports.props" />
<Import Project="$(ExternalsDir)SFML\exports.props" />
<Import Project="$(ExternalsDir)soundtouch\exports.props" />
Expand Down
7 changes: 6 additions & 1 deletion Source/Core/DolphinQt/CMakeLists.txt
Expand Up @@ -686,4 +686,9 @@ endif()

if(USE_DISCORD_PRESENCE)
target_compile_definitions(dolphin-emu PRIVATE -DUSE_DISCORD_PRESENCE)
endif()
endif()

if(USE_RETRO_ACHIEVEMENTS)
target_link_libraries(dolphin-emu PRIVATE rcheevos)
target_compile_definitions(dolphin-emu PRIVATE -DUSE_RETRO_ACHIEVEMENTS)
endif()
1 change: 1 addition & 0 deletions Source/Core/DolphinQt/DolphinQt.vcxproj
Expand Up @@ -436,6 +436,7 @@
<Import Project="$(ExternalsDir)mbedtls\exports.props" />
<Import Project="$(ExternalsDir)mGBA\exports.props" />
<Import Project="$(ExternalsDir)picojson\exports.props" />
<Import Project="$(ExternalsDir)rcheevos\exports.props" />
<Import Project="$(ExternalsDir)SFML\exports.props" />
<Import Project="$(ExternalsDir)soundtouch\exports.props" />
<Import Project="$(ExternalsDir)zstd\exports.props" />
Expand Down
10 changes: 10 additions & 0 deletions Source/Core/DolphinQt/MainWindow.cpp
Expand Up @@ -37,6 +37,7 @@
#include "Common/Version.h"
#include "Common/WindowSystemInfo.h"

#include "Core/AchievementManager.h"
#include "Core/Boot/Boot.h"
#include "Core/BootManager.h"
#include "Core/CommonTitles.h"
Expand Down Expand Up @@ -222,6 +223,11 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters,

InitControllers();

#ifdef USE_RETRO_ACHIEVEMENTS
// This has to be done before CreateComponents() so it's initialized.
AchievementManager::GetInstance()->Init();
#endif // USE_RETRO_ACHIEVEMENTS

CreateComponents();

ConnectGameList();
Expand Down Expand Up @@ -301,6 +307,10 @@ MainWindow::~MainWindow()
Settings::Instance().ResetNetPlayClient();
Settings::Instance().ResetNetPlayServer();

#ifdef USE_RETRO_ACHIEVEMENTS
AchievementManager::GetInstance()->Shutdown();
#endif // USE_RETRO_ACHIEVEMENTS

delete m_render_widget;
delete m_netplay_dialog;

Expand Down
1 change: 1 addition & 0 deletions Source/VSProps/Base.Dolphin.props
Expand Up @@ -45,6 +45,7 @@
<PreprocessorDefinitions Condition="'$(AutoUpdate)'!='false'">AUTOUPDATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>HAVE_SDL2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Steam)'=='true'">STEAM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>USE_RETRO_ACHIEVEMENTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

<!-- Warnings one may want to ignore when using Level4.
4201 nonstandard extension used : nameless struct/union
Expand Down
11 changes: 11 additions & 0 deletions Source/dolphin-emu.sln
Expand Up @@ -87,6 +87,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FatFs", "..\Externals\FatFs
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spng", "..\Externals\libspng\spng.vcxproj", "{447B7B1E-1D74-4AEF-B2B9-6EB41C5D5313}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rcheevos", "..\Externals\rcheevos\rcheevos.vcxproj", "{CC99A910-3752-4465-95AA-7DC240D92A99}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Expand Down Expand Up @@ -419,6 +421,14 @@ Global
{447B7B1E-1D74-4AEF-B2B9-6EB41C5D5313}.Release|ARM64.Build.0 = Release|ARM64
{447B7B1E-1D74-4AEF-B2B9-6EB41C5D5313}.Release|x64.ActiveCfg = Release|x64
{447B7B1E-1D74-4AEF-B2B9-6EB41C5D5313}.Release|x64.Build.0 = Release|x64
{CC99A910-3752-4465-95AA-7DC240D92A99}.Debug|ARM64.ActiveCfg = Debug|ARM64
{CC99A910-3752-4465-95AA-7DC240D92A99}.Debug|ARM64.Build.0 = Debug|ARM64
{CC99A910-3752-4465-95AA-7DC240D92A99}.Debug|x64.ActiveCfg = Debug|x64
{CC99A910-3752-4465-95AA-7DC240D92A99}.Debug|x64.Build.0 = Debug|x64
{CC99A910-3752-4465-95AA-7DC240D92A99}.Release|ARM64.ActiveCfg = Release|ARM64
{CC99A910-3752-4465-95AA-7DC240D92A99}.Release|ARM64.Build.0 = Release|ARM64
{CC99A910-3752-4465-95AA-7DC240D92A99}.Release|x64.ActiveCfg = Release|x64
{CC99A910-3752-4465-95AA-7DC240D92A99}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -455,6 +465,7 @@ Global
{8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
{3F17D282-A77D-4931-B844-903AD0809A5E} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
{447B7B1E-1D74-4AEF-B2B9-6EB41C5D5313} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
{CC99A910-3752-4465-95AA-7DC240D92A99} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {64B0A343-3B94-4522-9C24-6937FE5EFB22}
Expand Down