Decouple data save paths from Emulator

This change allows the frontend to select the appdata and configuration
file locations when instantiating the emulator, allowing for more
flexibility in placing the files.

This also fixes configuration not working in MacOS app bundles,
as it will now look for config.toml in the user's "Application Support"
directory and default there.
This commit is contained in:
Thomas 2024-12-26 21:43:42 +01:00
parent 8cc9bfbb36
commit 80d8337592
8 changed files with 50 additions and 57 deletions

View file

@ -28,6 +28,8 @@
#include "gl/context.h"
#endif
static const std::string EmulatorConfigFilename = "config.toml";
struct SDL_Window;
enum class ROMType {
@ -51,6 +53,8 @@ class Emulator {
MiniAudioDevice audioDevice;
Cheats cheats;
std::filesystem::path appDataPath;
public:
static constexpr u32 width = 400;
static constexpr u32 height = 240 * 2; // * 2 because 2 screens
@ -85,7 +89,7 @@ class Emulator {
// Used in CPU::runFrame
bool frameDone = false;
Emulator();
Emulator(std::vector<std::filesystem::path> configSearchPaths, std::filesystem::path appDataPath);
~Emulator();
void step();