mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-10-30 07:11:05 +00:00
Move config and save data to %APPDATA%
This commit is contained in:
parent
5508b23f39
commit
2e9d49f17d
4 changed files with 29 additions and 11 deletions
|
|
@ -2,7 +2,7 @@ void Config::Load()
|
|||
{
|
||||
try
|
||||
{
|
||||
auto toml = toml::parse_file(TOML_FILE);
|
||||
auto toml = toml::parse_file((GetUserPath() / TOML_FILE).string());
|
||||
|
||||
TOML_BEGIN_SECTION("System")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
// TODO: move this outside of the game directory?
|
||||
#define TOML_FILE "SWA.toml"
|
||||
#define USER_DIRECTORY "SWA"
|
||||
|
||||
#define TOML_FILE "config.toml"
|
||||
|
||||
#define TOML_BEGIN_SECTION(name) if (auto pSection = toml[name].as_table()) { const auto& section = *pSection;
|
||||
#define TOML_END_SECTION() }
|
||||
|
|
@ -111,6 +112,23 @@ public:
|
|||
CONFIG_DEFINE(EMovieScaleMode, MovieScaleMode, EMovieScaleMode_Fit);
|
||||
CONFIG_DEFINE(EUIScaleMode, UIScaleMode, EUIScaleMode_Centre);
|
||||
|
||||
static std::filesystem::path GetUserPath()
|
||||
{
|
||||
if (std::filesystem::exists("portable.txt"))
|
||||
return std::filesystem::current_path();
|
||||
|
||||
std::filesystem::path userPath{};
|
||||
|
||||
// TODO: handle platform-specific paths.
|
||||
PWSTR knownPath = NULL;
|
||||
if (SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &knownPath) == S_OK)
|
||||
userPath = std::filesystem::path{ knownPath } / USER_DIRECTORY;
|
||||
|
||||
CoTaskMemFree(knownPath);
|
||||
|
||||
return userPath;
|
||||
}
|
||||
|
||||
static void Load();
|
||||
static void Save();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,14 +39,12 @@ void KiSystemStartup()
|
|||
XamRegisterContent(gameContent, DirectoryExists(".\\game") ? ".\\game" : ".");
|
||||
XamRegisterContent(updateContent, ".\\update");
|
||||
|
||||
if (FileExists(".\\save\\SYS-DATA"))
|
||||
{
|
||||
XamRegisterContent(XamMakeContent(XCONTENTTYPE_SAVEDATA, "SYS-DATA"), ".\\save");
|
||||
}
|
||||
else if (FileExists(".\\SYS-DATA"))
|
||||
{
|
||||
XamRegisterContent(XamMakeContent(XCONTENTTYPE_SAVEDATA, "SYS-DATA"), ".");
|
||||
}
|
||||
const auto savePath = Config::GetUserPath() / "save";
|
||||
const auto saveName = "SYS-DATA";
|
||||
|
||||
// TODO: implement save slots?
|
||||
if (std::filesystem::exists(savePath / saveName))
|
||||
XamRegisterContent(XamMakeContent(XCONTENTTYPE_SAVEDATA, saveName), savePath.string());
|
||||
|
||||
// Mount game
|
||||
XamContentCreateEx(0, "game", &gameContent, OPEN_EXISTING, nullptr, nullptr, 0, 0, nullptr);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
#define NOMINMAX
|
||||
|
||||
#include <windows.h>
|
||||
#include <ShlObj_core.h>
|
||||
#include <algorithm>
|
||||
#include <mutex>
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue