Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add portable build option #279

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct EmulatorConfig {

bool sdCardInserted = true;
bool sdWriteProtected = false;
bool usePortableBuild = false;

bool chargerPlugged = true;
// Default to 3% battery to make users suffer
Expand Down
2 changes: 2 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void EmulatorConfig::load(const std::filesystem::path& path) {
auto general = generalResult.unwrap();

discordRpcEnabled = toml::find_or<toml::boolean>(general, "EnableDiscordRPC", false);
usePortableBuild = toml::find_or<toml::boolean>(general, "UsePortableBuild", false);
}
}

Expand Down Expand Up @@ -102,6 +103,7 @@ void EmulatorConfig::save(const std::filesystem::path& path) {
}

data["General"]["EnableDiscordRPC"] = discordRpcEnabled;
data["General"]["UsePortableBuild"] = usePortableBuild;
data["GPU"]["EnableShaderJIT"] = shaderJitEnabled;
data["GPU"]["Renderer"] = std::string(Renderer::typeToString(rendererType));

Expand Down
16 changes: 13 additions & 3 deletions src/emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,19 @@ bool Emulator::loadROM(const std::filesystem::path& path) {

// Get path for saving files (AppData on Windows, /home/user/.local/share/ApplcationName on Linux, etc)
// Inside that path, we be use a game-specific folder as well. Eg if we were loading a ROM called PenguinDemo.3ds, the savedata would be in
// %APPDATA%/Alber/PenguinDemo/SaveData on Windows, and so on. We do this because games save data in their own filesystem on the cart
char* appData = SDL_GetPrefPath(nullptr, "Alber");
const std::filesystem::path appDataPath = std::filesystem::path(appData);
// %APPDATA%/Alber/PenguinDemo/SaveData on Windows, and so on. We do this because games save data in their own filesystem on the cart.
// If the portable build setting is enabled, then those saves go in the executable directory instead
char* appData;
std::filesystem::path appDataPath;

if (!config.usePortableBuild) {
appData = SDL_GetPrefPath(nullptr, "Alber");
appDataPath = std::filesystem::path(appData);
} else {
appData = SDL_GetBasePath();
appDataPath = std::filesystem::path(appData) / "Emulator Files";
}

const std::filesystem::path dataPath = appDataPath / path.filename().stem();
const std::filesystem::path aesKeysPath = appDataPath / "sysdata" / "aes_keys.txt";
IOFile::setAppDataDir(dataPath);
Expand Down
Loading