mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-26 12:21:39 +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
|
try
|
||||||
{
|
{
|
||||||
auto toml = toml::parse_file(TOML_FILE);
|
auto toml = toml::parse_file((GetUserPath() / TOML_FILE).string());
|
||||||
|
|
||||||
TOML_BEGIN_SECTION("System")
|
TOML_BEGIN_SECTION("System")
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// TODO: move this outside of the game directory?
|
#define USER_DIRECTORY "SWA"
|
||||||
#define TOML_FILE "SWA.toml"
|
|
||||||
|
#define TOML_FILE "config.toml"
|
||||||
|
|
||||||
#define TOML_BEGIN_SECTION(name) if (auto pSection = toml[name].as_table()) { const auto& section = *pSection;
|
#define TOML_BEGIN_SECTION(name) if (auto pSection = toml[name].as_table()) { const auto& section = *pSection;
|
||||||
#define TOML_END_SECTION() }
|
#define TOML_END_SECTION() }
|
||||||
|
|
@ -111,6 +112,23 @@ public:
|
||||||
CONFIG_DEFINE(EMovieScaleMode, MovieScaleMode, EMovieScaleMode_Fit);
|
CONFIG_DEFINE(EMovieScaleMode, MovieScaleMode, EMovieScaleMode_Fit);
|
||||||
CONFIG_DEFINE(EUIScaleMode, UIScaleMode, EUIScaleMode_Centre);
|
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 Load();
|
||||||
static void Save();
|
static void Save();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,12 @@ void KiSystemStartup()
|
||||||
XamRegisterContent(gameContent, DirectoryExists(".\\game") ? ".\\game" : ".");
|
XamRegisterContent(gameContent, DirectoryExists(".\\game") ? ".\\game" : ".");
|
||||||
XamRegisterContent(updateContent, ".\\update");
|
XamRegisterContent(updateContent, ".\\update");
|
||||||
|
|
||||||
if (FileExists(".\\save\\SYS-DATA"))
|
const auto savePath = Config::GetUserPath() / "save";
|
||||||
{
|
const auto saveName = "SYS-DATA";
|
||||||
XamRegisterContent(XamMakeContent(XCONTENTTYPE_SAVEDATA, "SYS-DATA"), ".\\save");
|
|
||||||
}
|
// TODO: implement save slots?
|
||||||
else if (FileExists(".\\SYS-DATA"))
|
if (std::filesystem::exists(savePath / saveName))
|
||||||
{
|
XamRegisterContent(XamMakeContent(XCONTENTTYPE_SAVEDATA, saveName), savePath.string());
|
||||||
XamRegisterContent(XamMakeContent(XCONTENTTYPE_SAVEDATA, "SYS-DATA"), ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mount game
|
// Mount game
|
||||||
XamContentCreateEx(0, "game", &gameContent, OPEN_EXISTING, nullptr, nullptr, 0, 0, nullptr);
|
XamContentCreateEx(0, "game", &gameContent, OPEN_EXISTING, nullptr, nullptr, 0, 0, nullptr);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,10 @@
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <ShlObj_core.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <filesystem>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue