mirror of https://github.com/stella-emu/stella.git
Reset video setting on mac.
This commit is contained in:
parent
528df82641
commit
796cf27202
|
@ -34,6 +34,9 @@ Settings::Settings()
|
||||||
{
|
{
|
||||||
myRespository = make_shared<KeyValueRepositoryNoop>();
|
myRespository = make_shared<KeyValueRepositoryNoop>();
|
||||||
|
|
||||||
|
// If no version is recorded with the persisted settings, we set it to zero
|
||||||
|
setPermanent(SETTINGS_VERSION_KEY, 0);
|
||||||
|
|
||||||
// Video-related options
|
// Video-related options
|
||||||
setPermanent("video", "");
|
setPermanent("video", "");
|
||||||
setPermanent("speed", "1.0");
|
setPermanent("speed", "1.0");
|
||||||
|
@ -225,6 +228,8 @@ void Settings::load(const Options& options)
|
||||||
for (const auto& opt: fromFile)
|
for (const auto& opt: fromFile)
|
||||||
setValue(opt.first, opt.second, false);
|
setValue(opt.first, opt.second, false);
|
||||||
|
|
||||||
|
migrate();
|
||||||
|
|
||||||
// Apply commandline options, which override those from settings file
|
// Apply commandline options, which override those from settings file
|
||||||
for(const auto& opt: options)
|
for(const auto& opt: options)
|
||||||
setValue(opt.first, opt.second, false);
|
setValue(opt.first, opt.second, false);
|
||||||
|
@ -648,3 +653,29 @@ void Settings::setTemporary(const string& key, const Variant& value)
|
||||||
{
|
{
|
||||||
myTemporarySettings[key] = value;
|
myTemporarySettings[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Settings::migrateOne()
|
||||||
|
{
|
||||||
|
const int version = getInt(SETTINGS_VERSION_KEY);
|
||||||
|
if (version >= SETTINGS_VERSION) return;
|
||||||
|
|
||||||
|
switch (version) {
|
||||||
|
case 0:
|
||||||
|
#if defined BSPF_MACOS || defined DARWIN
|
||||||
|
setPermanent("video", "");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPermanent(SETTINGS_VERSION_KEY, version + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Settings::migrate()
|
||||||
|
{
|
||||||
|
while (getInt(SETTINGS_VERSION_KEY) < SETTINGS_VERSION) migrateOne();
|
||||||
|
|
||||||
|
myRespository->save(SETTINGS_VERSION_KEY, SETTINGS_VERSION);
|
||||||
|
}
|
||||||
|
|
|
@ -51,6 +51,9 @@ class Settings
|
||||||
|
|
||||||
using Options = std::map<string, Variant>;
|
using Options = std::map<string, Variant>;
|
||||||
|
|
||||||
|
static constexpr int SETTINGS_VERSION = 1;
|
||||||
|
static constexpr const char* SETTINGS_VERSION_KEY = "settings.version";
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
This method should be called to display usage information.
|
This method should be called to display usage information.
|
||||||
|
@ -134,6 +137,16 @@ class Settings
|
||||||
*/
|
*/
|
||||||
void validate();
|
void validate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Migrate settings over one version.
|
||||||
|
*/
|
||||||
|
void migrateOne();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Migrate settings.
|
||||||
|
*/
|
||||||
|
void migrate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Holds key/value pairs that are necessary for Stella to
|
// Holds key/value pairs that are necessary for Stella to
|
||||||
// function and must be saved on each program exit.
|
// function and must be saved on each program exit.
|
||||||
|
|
Loading…
Reference in New Issue