qt: Implement migration prompt to bring data from Citra/Lime3DS (#638)

This commit is contained in:
OpenSauce
2025-03-09 12:10:02 +00:00
committed by GitHub
parent 43dbe42b29
commit ac7671e247
5 changed files with 187 additions and 10 deletions

View File

@@ -23,18 +23,28 @@
#define EMU_DATA_DIR USER_DIR
#else
#ifdef _WIN32
#define EMU_DATA_DIR "Citra"
#define EMU_DATA_DIR "Azahar"
#define LEGACY_CITRA_DATA_DIR "Citra"
#define LEGACY_LIME3DS_DATA_DIR "Lime3DS"
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE
#define APPLE_EMU_DATA_DIR "Documents" DIR_SEP "Citra"
#define EMU_APPLE_DATA_DIR "Documents" DIR_SEP "Azahar"
#define LEGACY_CITRA_APPLE_DATA_DIR "Documents" DIR_SEP "Citra"
#define LEGACY_LIME3DS_APPLE_DATA_DIR "Documents" DIR_SEP "Lime3DS"
#else
#define APPLE_EMU_DATA_DIR "Library" DIR_SEP "Application Support" DIR_SEP "Citra"
#define EMU_APPLE_DATA_DIR "Library" DIR_SEP "Application Support" DIR_SEP "Azahar"
#define LEGACY_CITRA_APPLE_DATA_DIR "Library" DIR_SEP "Application Support" DIR_SEP "Citra"
#define LEGACY_LIME3DS_APPLE_DATA_DIR "Library" DIR_SEP "Application Support" DIR_SEP "Lime3DS"
#endif
// For compatibility with XDG paths.
#define EMU_DATA_DIR "citra-emu"
#define EMU_DATA_DIR "azahar-emu"
#define LEGACY_CITRA_DATA_DIR "citra-emu"
#define LEGACY_LIME3DS_DATA_DIR "lime3ds-emu"
#else
#define EMU_DATA_DIR "citra-emu"
#define EMU_DATA_DIR "azahar-emu"
#define LEGACY_CITRA_DATA_DIR "citra-emu"
#define LEGACY_LIME3DS_DATA_DIR "lime3ds-emu"
#endif
#endif

View File

@@ -783,8 +783,15 @@ void SetUserPath(const std::string& path) {
} else {
#ifdef _WIN32
user_path = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
std::string& legacy_citra_user_path = g_paths[UserPath::LegacyCitraUserDir];
std::string& legacy_lime3ds_user_path = g_paths[UserPath::LegacyLime3DSUserDir];
if (!FileUtil::IsDirectory(user_path)) {
user_path = AppDataRoamingDirectory() + DIR_SEP EMU_DATA_DIR DIR_SEP;
legacy_citra_user_path =
AppDataRoamingDirectory() + DIR_SEP LEGACY_CITRA_DATA_DIR DIR_SEP;
legacy_lime3ds_user_path =
AppDataRoamingDirectory() + DIR_SEP LEGACY_LIME3DS_DATA_DIR DIR_SEP;
} else {
LOG_INFO(Common_Filesystem, "Using the local user directory");
}
@@ -796,6 +803,8 @@ void SetUserPath(const std::string& path) {
g_paths.emplace(UserPath::ConfigDir, user_path + CONFIG_DIR DIR_SEP);
g_paths.emplace(UserPath::CacheDir, user_path + CACHE_DIR DIR_SEP);
#else
std::string& legacy_citra_user_path = g_paths[UserPath::LegacyCitraUserDir];
std::string& legacy_lime3ds_user_path = g_paths[UserPath::LegacyLime3DSUserDir];
auto current_dir = FileUtil::GetCurrentDir();
if (current_dir.has_value() &&
FileUtil::Exists(current_dir.value() + USERDATA_DIR DIR_SEP)) {
@@ -804,23 +813,47 @@ void SetUserPath(const std::string& path) {
g_paths.emplace(UserPath::CacheDir, user_path + CACHE_DIR DIR_SEP);
} else {
std::string data_dir = GetUserDirectory("XDG_DATA_HOME") + DIR_SEP EMU_DATA_DIR DIR_SEP;
std::string legacy_citra_data_dir =
GetUserDirectory("XDG_DATA_HOME") + DIR_SEP LEGACY_CITRA_DATA_DIR DIR_SEP;
std::string legacy_lime3ds_data_dir =
GetUserDirectory("XDG_DATA_HOME") + DIR_SEP LEGACY_LIME3DS_DATA_DIR DIR_SEP;
std::string config_dir =
GetUserDirectory("XDG_CONFIG_HOME") + DIR_SEP EMU_DATA_DIR DIR_SEP;
std::string cache_dir =
GetUserDirectory("XDG_CACHE_HOME") + DIR_SEP EMU_DATA_DIR DIR_SEP;
g_paths.emplace(UserPath::LegacyCitraConfigDir,
GetUserDirectory("XDG_CONFIG_HOME") +
DIR_SEP LEGACY_CITRA_DATA_DIR DIR_SEP);
g_paths.emplace(UserPath::LegacyCitraCacheDir,
GetUserDirectory("XDG_CACHE_HOME") +
DIR_SEP LEGACY_CITRA_DATA_DIR DIR_SEP);
g_paths.emplace(UserPath::LegacyLime3DSConfigDir,
GetUserDirectory("XDG_CONFIG_HOME") +
DIR_SEP LEGACY_LIME3DS_DATA_DIR DIR_SEP);
g_paths.emplace(UserPath::LegacyLime3DSCacheDir,
GetUserDirectory("XDG_CACHE_HOME") +
DIR_SEP LEGACY_LIME3DS_DATA_DIR DIR_SEP);
#if defined(__APPLE__)
// If XDG directories don't already exist from a previous setup, use standard macOS
// paths.
if (!FileUtil::Exists(data_dir) && !FileUtil::Exists(config_dir) &&
!FileUtil::Exists(cache_dir)) {
data_dir = GetHomeDirectory() + DIR_SEP APPLE_EMU_DATA_DIR DIR_SEP;
data_dir = GetHomeDirectory() + DIR_SEP EMU_APPLE_DATA_DIR DIR_SEP;
legacy_citra_data_dir =
GetHomeDirectory() + DIR_SEP LEGACY_CITRA_APPLE_DATA_DIR DIR_SEP;
legacy_lime3ds_data_dir =
GetHomeDirectory() + DIR_SEP LEGACY_LIME3DS_APPLE_DATA_DIR DIR_SEP;
config_dir = data_dir + CONFIG_DIR DIR_SEP;
cache_dir = data_dir + CACHE_DIR DIR_SEP;
}
#endif
user_path = data_dir;
legacy_citra_user_path = legacy_citra_data_dir;
legacy_lime3ds_user_path = legacy_lime3ds_data_dir;
g_paths.emplace(UserPath::ConfigDir, config_dir);
g_paths.emplace(UserPath::CacheDir, cache_dir);
}

View File

@@ -39,17 +39,23 @@ enum class UserPath {
ConfigDir,
DLLDir,
DumpDir,
IconsDir,
LegacyCitraCacheDir, // LegacyXXXCacheDir and LegacyXXXConfigDir are only defined if migrating
LegacyCitraConfigDir, // these directories is necessary (aka not a child of LegacyXXXUserDir)
LegacyCitraUserDir,
LegacyLime3DSCacheDir,
LegacyLime3DSConfigDir,
LegacyLime3DSUserDir,
LoadDir,
LogDir,
NANDDir,
PlayTimeDir,
RootDir,
SDMCDir,
ShaderDir,
StatesDir,
SysDataDir,
UserDir,
IconsDir,
PlayTimeDir,
};
// Replaces install-specific paths with standard placeholders, and back again