AutoSave configuration for ease of use.
Add option to load .ini file from different location. Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
f144cb037f
commit
7a8a162d78
5 changed files with 20 additions and 11 deletions
|
@ -49,7 +49,7 @@ namespace
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string myFilename;
|
const std::string myFilename;
|
||||||
const bool mySaveOnExit;
|
bool mySaveOnExit;
|
||||||
};
|
};
|
||||||
|
|
||||||
Configuration::Configuration(const std::string & filename, const bool saveOnExit) : myFilename(filename), mySaveOnExit(saveOnExit)
|
Configuration::Configuration(const std::string & filename, const bool saveOnExit) : myFilename(filename), mySaveOnExit(saveOnExit)
|
||||||
|
@ -60,6 +60,7 @@ namespace
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
mySaveOnExit = false;
|
||||||
LogFileOutput("Registry: configuration file '%s' not found\n", filename.c_str());
|
LogFileOutput("Registry: configuration file '%s' not found\n", filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,8 +118,8 @@ namespace common2
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
filename = GetConfigFile("applewin.conf");
|
filename = options.configurationFile;
|
||||||
saveOnExit = !filename.empty() && options.saveConfigurationOnExit;
|
saveOnExit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Configuration> config(new Configuration(filename, saveOnExit));
|
std::shared_ptr<Configuration> config(new Configuration(filename, saveOnExit));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "frontends/common2/programoptions.h"
|
#include "frontends/common2/programoptions.h"
|
||||||
#include "frontends/common2/utils.h"
|
#include "frontends/common2/utils.h"
|
||||||
|
#include "frontends/common2/fileregistry.h"
|
||||||
#include "linux/version.h"
|
#include "linux/version.h"
|
||||||
#include "linux/paddle.h"
|
#include "linux/paddle.h"
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Disk.h"
|
#include "Disk.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
#include "Core.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
@ -45,6 +47,12 @@ namespace
|
||||||
namespace common2
|
namespace common2
|
||||||
{
|
{
|
||||||
|
|
||||||
|
EmulatorOptions::EmulatorOptions()
|
||||||
|
{
|
||||||
|
memclear = g_nMemoryClearType;
|
||||||
|
configurationFile = GetConfigFile("applewin.conf");
|
||||||
|
}
|
||||||
|
|
||||||
bool getEmulatorOptions(int argc, const char * argv [], const std::string & edition, EmulatorOptions & options)
|
bool getEmulatorOptions(int argc, const char * argv [], const std::string & edition, EmulatorOptions & options)
|
||||||
{
|
{
|
||||||
const std::string name = "Apple Emulator for " + edition + " (based on AppleWin " + getVersion() + ")";
|
const std::string name = "Apple Emulator for " + edition + " (based on AppleWin " + getVersion() + ")";
|
||||||
|
@ -55,8 +63,8 @@ namespace common2
|
||||||
|
|
||||||
po::options_description configDesc("configuration");
|
po::options_description configDesc("configuration");
|
||||||
configDesc.add_options()
|
configDesc.add_options()
|
||||||
("save-conf", "Save configuration on exit")
|
("conf", po::value<std::string>()->default_value(options.configurationFile), "Select configuration file")
|
||||||
("config,c", po::value<std::vector<std::string>>(), "Registry options section.path=value")
|
("registry,r", po::value<std::vector<std::string>>(), "Registry options section.path=value")
|
||||||
("qt-ini,q", "Use Qt ini file (read only)")
|
("qt-ini,q", "Use Qt ini file (read only)")
|
||||||
;
|
;
|
||||||
desc.add(configDesc);
|
desc.add(configDesc);
|
||||||
|
@ -96,7 +104,7 @@ namespace common2
|
||||||
("sdl-driver", po::value<int>()->default_value(options.sdlDriver), "SDL driver")
|
("sdl-driver", po::value<int>()->default_value(options.sdlDriver), "SDL driver")
|
||||||
("gl-swap", po::value<int>()->default_value(options.glSwapInterval), "SDL_GL_SwapInterval")
|
("gl-swap", po::value<int>()->default_value(options.glSwapInterval), "SDL_GL_SwapInterval")
|
||||||
("imgui", "Render with Dear ImGui")
|
("imgui", "Render with Dear ImGui")
|
||||||
("geometry", po::value<std::string>(), "WxH(+X+Y)")
|
("geometry", po::value<std::string>(), "WxH[+X+Y]")
|
||||||
;
|
;
|
||||||
desc.add(sdlDesc);
|
desc.add(sdlDesc);
|
||||||
|
|
||||||
|
@ -118,7 +126,7 @@ namespace common2
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
options.saveConfigurationOnExit = vm.count("save-conf");
|
options.configurationFile = vm["conf"].as<std::string>();
|
||||||
options.useQtIni = vm.count("qt-ini");
|
options.useQtIni = vm.count("qt-ini");
|
||||||
options.sdlDriver = vm["sdl-driver"].as<int>();
|
options.sdlDriver = vm["sdl-driver"].as<int>();
|
||||||
options.glSwapInterval = vm["gl-swap"].as<int>();
|
options.glSwapInterval = vm["gl-swap"].as<int>();
|
||||||
|
|
|
@ -17,13 +17,15 @@ namespace common2
|
||||||
|
|
||||||
struct EmulatorOptions
|
struct EmulatorOptions
|
||||||
{
|
{
|
||||||
|
EmulatorOptions();
|
||||||
|
|
||||||
std::string disk1;
|
std::string disk1;
|
||||||
std::string disk2;
|
std::string disk2;
|
||||||
|
|
||||||
std::string snapshotFilename;
|
std::string snapshotFilename;
|
||||||
bool loadSnapshot = false;
|
bool loadSnapshot = false;
|
||||||
|
|
||||||
int memclear = 0;
|
int memclear;
|
||||||
|
|
||||||
bool log = false;
|
bool log = false;
|
||||||
|
|
||||||
|
@ -36,7 +38,7 @@ namespace common2
|
||||||
// "/dev/input/by-id/usb-©Microsoft_Corporation_Controller_1BBE3DB-event-joystick"
|
// "/dev/input/by-id/usb-©Microsoft_Corporation_Controller_1BBE3DB-event-joystick"
|
||||||
std::string paddleDeviceName;
|
std::string paddleDeviceName;
|
||||||
|
|
||||||
bool saveConfigurationOnExit = false;
|
std::string configurationFile;
|
||||||
bool useQtIni = false; // use Qt .ini file (read only)
|
bool useQtIni = false; // use Qt .ini file (read only)
|
||||||
|
|
||||||
bool run = true; // false if options include "-h"
|
bool run = true; // false if options include "-h"
|
||||||
|
|
|
@ -141,7 +141,6 @@ namespace
|
||||||
int run_ncurses(int argc, const char * argv [])
|
int run_ncurses(int argc, const char * argv [])
|
||||||
{
|
{
|
||||||
common2::EmulatorOptions options;
|
common2::EmulatorOptions options;
|
||||||
options.memclear = g_nMemoryClearType;
|
|
||||||
const bool run = getEmulatorOptions(argc, argv, "ncurses", options);
|
const bool run = getEmulatorOptions(argc, argv, "ncurses", options);
|
||||||
|
|
||||||
if (!run)
|
if (!run)
|
||||||
|
|
|
@ -84,7 +84,6 @@ void run_sdl(int argc, const char * argv [])
|
||||||
options.geometry.height = sh * 2;
|
options.geometry.height = sh * 2;
|
||||||
options.geometry.x = SDL_WINDOWPOS_UNDEFINED;
|
options.geometry.x = SDL_WINDOWPOS_UNDEFINED;
|
||||||
options.geometry.y = SDL_WINDOWPOS_UNDEFINED;
|
options.geometry.y = SDL_WINDOWPOS_UNDEFINED;
|
||||||
options.memclear = g_nMemoryClearType;
|
|
||||||
const bool run = getEmulatorOptions(argc, argv, "SDL2", options);
|
const bool run = getEmulatorOptions(argc, argv, "SDL2", options);
|
||||||
|
|
||||||
if (!run)
|
if (!run)
|
||||||
|
|
Loading…
Add table
Reference in a new issue