summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-01-01 15:08:40 +0100
committerPetr Mrázek <peterix@gmail.com>2014-01-01 15:10:35 +0100
commit396e63500ec189b003d36504bae91a2b6a78a69d (patch)
treeb78022c1877536af1293a24d657a451085c55a4c /logic
parent6648c7ad903f4c8120193fa6f276ce8dde3b0b77 (diff)
downloadMultiMC-396e63500ec189b003d36504bae91a2b6a78a69d.tar
MultiMC-396e63500ec189b003d36504bae91a2b6a78a69d.tar.gz
MultiMC-396e63500ec189b003d36504bae91a2b6a78a69d.tar.lz
MultiMC-396e63500ec189b003d36504bae91a2b6a78a69d.tar.xz
MultiMC-396e63500ec189b003d36504bae91a2b6a78a69d.zip
Allow the use of synonyms in settings. Refactor settings.
Remove a bunch of obsolete/unused code.
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseInstance.cpp58
-rw-r--r--logic/InstanceFactory.cpp6
-rw-r--r--logic/LegacyInstance.cpp10
-rw-r--r--logic/OneSixInstance.cpp4
-rw-r--r--logic/icons/IconList.cpp6
5 files changed, 36 insertions, 48 deletions
diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp
index b39db03b..ac66a8d5 100644
--- a/logic/BaseInstance.cpp
+++ b/logic/BaseInstance.cpp
@@ -37,11 +37,11 @@ BaseInstance::BaseInstance(BaseInstancePrivate *d_in, const QString &rootDir,
d->m_settings = settings_obj;
d->m_rootDir = rootDir;
- settings().registerSetting(new Setting("name", "Unnamed Instance"));
- settings().registerSetting(new Setting("iconKey", "default"));
+ settings().registerSetting("name", "Unnamed Instance");
+ settings().registerSetting("iconKey", "default");
connect(MMC->icons().get(), SIGNAL(iconUpdated(QString)), SLOT(iconUpdated(QString)));
- settings().registerSetting(new Setting("notes", ""));
- settings().registerSetting(new Setting("lastLaunchTime", 0));
+ settings().registerSetting("notes", "");
+ settings().registerSetting("lastLaunchTime", 0);
/*
* custom base jar has no default. it is determined in code... see the accessor methods for
@@ -50,49 +50,37 @@ BaseInstance::BaseInstance(BaseInstancePrivate *d_in, const QString &rootDir,
* for instances that DO NOT have the CustomBaseJar setting (legacy instances),
* [.]minecraft/bin/mcbackup.jar is the default base jar
*/
- settings().registerSetting(new Setting("UseCustomBaseJar", true));
- settings().registerSetting(new Setting("CustomBaseJar", ""));
+ settings().registerSetting("UseCustomBaseJar", true);
+ settings().registerSetting("CustomBaseJar", "");
auto globalSettings = MMC->settings();
// Java Settings
- settings().registerSetting(new Setting("OverrideJava", false));
- settings().registerSetting(
- new OverrideSetting("JavaPath", globalSettings->getSetting("JavaPath")));
- settings().registerSetting(
- new OverrideSetting("JvmArgs", globalSettings->getSetting("JvmArgs")));
+ settings().registerSetting("OverrideJava", false);
+ settings().registerOverride(globalSettings->getSetting("JavaPath"));
+ settings().registerOverride(globalSettings->getSetting("JvmArgs"));
// Custom Commands
- settings().registerSetting(new Setting("OverrideCommands", false));
- settings().registerSetting(new OverrideSetting(
- "PreLaunchCommand", globalSettings->getSetting("PreLaunchCommand")));
- settings().registerSetting(
- new OverrideSetting("PostExitCommand", globalSettings->getSetting("PostExitCommand")));
+ settings().registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false);
+ settings().registerOverride(globalSettings->getSetting("PreLaunchCommand"));
+ settings().registerOverride(globalSettings->getSetting("PostExitCommand"));
// Window Size
- settings().registerSetting(new Setting("OverrideWindow", false));
- settings().registerSetting(
- new OverrideSetting("LaunchMaximized", globalSettings->getSetting("LaunchMaximized")));
- settings().registerSetting(new OverrideSetting(
- "MinecraftWinWidth", globalSettings->getSetting("MinecraftWinWidth")));
- settings().registerSetting(new OverrideSetting(
- "MinecraftWinHeight", globalSettings->getSetting("MinecraftWinHeight")));
+ settings().registerSetting("OverrideWindow", false);
+ settings().registerOverride(globalSettings->getSetting("LaunchMaximized"));
+ settings().registerOverride(globalSettings->getSetting("MinecraftWinWidth"));
+ settings().registerOverride(globalSettings->getSetting("MinecraftWinHeight"));
// Memory
- settings().registerSetting(new Setting("OverrideMemory", false));
- settings().registerSetting(
- new OverrideSetting("MinMemAlloc", globalSettings->getSetting("MinMemAlloc")));
- settings().registerSetting(
- new OverrideSetting("MaxMemAlloc", globalSettings->getSetting("MaxMemAlloc")));
- settings().registerSetting(
- new OverrideSetting("PermGen", globalSettings->getSetting("PermGen")));
+ settings().registerSetting("OverrideMemory", false);
+ settings().registerOverride(globalSettings->getSetting("MinMemAlloc"));
+ settings().registerOverride(globalSettings->getSetting("MaxMemAlloc"));
+ settings().registerOverride(globalSettings->getSetting("PermGen"));
// Console
- settings().registerSetting(new Setting("OverrideConsole", false));
- settings().registerSetting(
- new OverrideSetting("ShowConsole", globalSettings->getSetting("ShowConsole")));
- settings().registerSetting(new OverrideSetting(
- "AutoCloseConsole", globalSettings->getSetting("AutoCloseConsole")));
+ settings().registerSetting("OverrideConsole", false);
+ settings().registerOverride(globalSettings->getSetting("ShowConsole"));
+ settings().registerOverride(globalSettings->getSetting("AutoCloseConsole"));
}
void BaseInstance::iconUpdated(QString key)
diff --git a/logic/InstanceFactory.cpp b/logic/InstanceFactory.cpp
index 7c778035..1f1a5879 100644
--- a/logic/InstanceFactory.cpp
+++ b/logic/InstanceFactory.cpp
@@ -45,7 +45,7 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
{
auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
- m_settings->registerSetting(new Setting("InstanceType", "Legacy"));
+ m_settings->registerSetting("InstanceType", "Legacy");
QString inst_type = m_settings->get("InstanceType").toString();
@@ -94,7 +94,7 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
return InstanceFactory::NoSuchVersion;
auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
- m_settings->registerSetting(new Setting("InstanceType", "Legacy"));
+ m_settings->registerSetting("InstanceType", "Legacy");
if (type == NormalInst)
{
@@ -171,7 +171,7 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne
return InstanceFactory::CantCreateDir;
}
auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
- m_settings->registerSetting(new Setting("InstanceType", "Legacy"));
+ m_settings->registerSetting("InstanceType", "Legacy");
QString inst_type = m_settings->get("InstanceType").toString();
if(inst_type == "OneSixFTB")
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index 08d7c147..0bc0961e 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -37,11 +37,11 @@ LegacyInstance::LegacyInstance(const QString &rootDir, SettingsObject *settings,
QObject *parent)
: BaseInstance(new LegacyInstancePrivate(), rootDir, settings, parent)
{
- settings->registerSetting(new Setting("NeedsRebuild", true));
- settings->registerSetting(new Setting("ShouldUpdate", false));
- settings->registerSetting(new Setting("JarVersion", "Unknown"));
- settings->registerSetting(new Setting("LwjglVersion", "2.9.0"));
- settings->registerSetting(new Setting("IntendedJarVersion", ""));
+ settings->registerSetting("NeedsRebuild", true);
+ settings->registerSetting("ShouldUpdate", false);
+ settings->registerSetting("JarVersion", "Unknown");
+ settings->registerSetting("LwjglVersion", "2.9.0");
+ settings->registerSetting("IntendedJarVersion", "");
}
std::shared_ptr<Task> LegacyInstance::doUpdate(bool only_prepare)
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index fd41b9e5..2392c683 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -33,8 +33,8 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_o
: BaseInstance(new OneSixInstancePrivate(), rootDir, setting_obj, parent)
{
I_D(OneSixInstance);
- d->m_settings->registerSetting(new Setting("IntendedVersion", ""));
- d->m_settings->registerSetting(new Setting("ShouldUpdate", false));
+ d->m_settings->registerSetting("IntendedVersion", "");
+ d->m_settings->registerSetting("ShouldUpdate", false);
reloadFullVersion();
}
diff --git a/logic/icons/IconList.cpp b/logic/icons/IconList.cpp
index 1e692d1d..3a745662 100644
--- a/logic/icons/IconList.cpp
+++ b/logic/icons/IconList.cpp
@@ -42,10 +42,10 @@ IconList::IconList(QObject *parent) : QAbstractListModel(parent)
connect(m_watcher.get(), SIGNAL(directoryChanged(QString)),
SLOT(directoryChanged(QString)));
connect(m_watcher.get(), SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString)));
-
+
auto setting = MMC->settings()->getSetting("IconsDir");
QString path = setting->get().toString();
- connect(setting, SIGNAL(settingChanged(const Setting &, QVariant)),
+ connect(setting.get(), SIGNAL(settingChanged(const Setting &, QVariant)),
SLOT(settingChanged(const Setting &, QVariant)));
directoryChanged(path);
}
@@ -145,7 +145,7 @@ void IconList::fileChanged(const QString &path)
void IconList::settingChanged(const Setting &setting, QVariant value)
{
- if(setting.configKey() != "IconsDir")
+ if(setting.id() != "IconsDir")
return;
directoryChanged(value.toString());