diff --git a/application/pages/InstanceSettingsPage.cpp b/application/pages/InstanceSettingsPage.cpp
index 296de379f..c651fcbdd 100644
--- a/application/pages/InstanceSettingsPage.cpp
+++ b/application/pages/InstanceSettingsPage.cpp
@@ -119,11 +119,13 @@ void InstanceSettingsPage::applySettings()
if (custcmd)
{
m_settings->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text());
+ m_settings->set("WrapperCommand", ui->preLaunchCmdTextBox->text());
m_settings->set("PostExitCommand", ui->postExitCmdTextBox->text());
}
else
{
m_settings->reset("PreLaunchCommand");
+ m_settings->reset("WrapperCommand");
m_settings->reset("PostExitCommand");
}
}
@@ -161,6 +163,7 @@ void InstanceSettingsPage::loadSettings()
// Custom Commands
ui->customCommandsGroupBox->setChecked(m_settings->get("OverrideCommands").toBool());
ui->preLaunchCmdTextBox->setText(m_settings->get("PreLaunchCommand").toString());
+ ui->wrapperCmdTextBox->setText(m_settings->get("WrapperCommand").toString());
ui->postExitCmdTextBox->setText(m_settings->get("PostExitCommand").toString());
}
diff --git a/application/pages/InstanceSettingsPage.ui b/application/pages/InstanceSettingsPage.ui
index 641093780..c9c16a6c3 100644
--- a/application/pages/InstanceSettingsPage.ui
+++ b/application/pages/InstanceSettingsPage.ui
@@ -45,7 +45,7 @@
true
- Java installation
+ Java ins&tallation
true
@@ -87,7 +87,7 @@
true
- Memory
+ Memor&y
true
@@ -305,7 +305,7 @@
true
- Console Settings
+ Conso&le Settings
true
@@ -357,7 +357,7 @@
true
- Custom Commands
+ Cus&tom Commands
true
@@ -366,16 +366,16 @@
false
- -
-
-
- -
+
-
Post-exit command:
+ -
+
+
-
@@ -383,9 +383,19 @@
- -
+
-
+ -
+
+
+ Wrapper command:
+
+
+
+ -
+
+
@@ -446,6 +456,7 @@
autoCloseConsoleCheck
customCommandsGroupBox
preLaunchCmdTextBox
+ wrapperCmdTextBox
postExitCmdTextBox
diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp
index 9ed7ce502..3e02235e5 100644
--- a/logic/BaseInstance.cpp
+++ b/logic/BaseInstance.cpp
@@ -40,16 +40,16 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
m_settings->registerSetting("lastLaunchTime", 0);
// Custom Commands
- m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false);
- m_settings->registerOverride(globalSettings->getSetting("PreLaunchCommand"));
- m_settings->registerOverride(globalSettings->getSetting("WrapperCommand"));
- m_settings->registerOverride(globalSettings->getSetting("PostExitCommand"));
+ auto commandSetting = m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false);
+ m_settings->registerOverride(globalSettings->getSetting("PreLaunchCommand"), commandSetting);
+ m_settings->registerOverride(globalSettings->getSetting("WrapperCommand"), commandSetting);
+ m_settings->registerOverride(globalSettings->getSetting("PostExitCommand"), commandSetting);
// Console
- m_settings->registerSetting("OverrideConsole", false);
- m_settings->registerOverride(globalSettings->getSetting("ShowConsole"));
- m_settings->registerOverride(globalSettings->getSetting("AutoCloseConsole"));
- m_settings->registerOverride(globalSettings->getSetting("LogPrePostOutput"));
+ auto consoleSetting = m_settings->registerSetting("OverrideConsole", false);
+ m_settings->registerOverride(globalSettings->getSetting("ShowConsole"), consoleSetting);
+ m_settings->registerOverride(globalSettings->getSetting("AutoCloseConsole"), consoleSetting);
+ m_settings->registerOverride(globalSettings->getSetting("LogPrePostOutput"), consoleSetting);
}
QString BaseInstance::getPreLaunchCommand()
diff --git a/logic/minecraft/MinecraftInstance.cpp b/logic/minecraft/MinecraftInstance.cpp
index d61801c99..e694045b3 100644
--- a/logic/minecraft/MinecraftInstance.cpp
+++ b/logic/minecraft/MinecraftInstance.cpp
@@ -39,26 +39,30 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO
// Java Settings
auto javaOverride = m_settings->registerSetting("OverrideJava", false);
auto locationOverride = m_settings->registerSetting("OverrideJavaLocation", false);
+ auto argsOverride = m_settings->registerSetting("OverrideJavaArgs", false);
+
+ // combinations
auto javaOrLocation = std::make_shared("JavaOrLocationOverride", javaOverride, locationOverride);
- m_settings->registerSetting("OverrideJavaArgs", false);
- m_settings->registerOverride(globalSettings->getSetting("JavaPath"));
- m_settings->registerOverride(globalSettings->getSetting("JvmArgs"));
+ auto javaOrArgs = std::make_shared("JavaOrArgsOverride", javaOverride, argsOverride);
+
+ m_settings->registerOverride(globalSettings->getSetting("JavaPath"), javaOrLocation);
+ m_settings->registerOverride(globalSettings->getSetting("JvmArgs"), javaOrArgs);
// special!
m_settings->registerPassthrough(globalSettings->getSetting("JavaTimestamp"), javaOrLocation);
m_settings->registerPassthrough(globalSettings->getSetting("JavaVersion"), javaOrLocation);
// Window Size
- m_settings->registerSetting("OverrideWindow", false);
- m_settings->registerOverride(globalSettings->getSetting("LaunchMaximized"));
- m_settings->registerOverride(globalSettings->getSetting("MinecraftWinWidth"));
- m_settings->registerOverride(globalSettings->getSetting("MinecraftWinHeight"));
+ auto windowSetting = m_settings->registerSetting("OverrideWindow", false);
+ m_settings->registerOverride(globalSettings->getSetting("LaunchMaximized"), windowSetting);
+ m_settings->registerOverride(globalSettings->getSetting("MinecraftWinWidth"), windowSetting);
+ m_settings->registerOverride(globalSettings->getSetting("MinecraftWinHeight"), windowSetting);
// Memory
- m_settings->registerSetting("OverrideMemory", false);
- m_settings->registerOverride(globalSettings->getSetting("MinMemAlloc"));
- m_settings->registerOverride(globalSettings->getSetting("MaxMemAlloc"));
- m_settings->registerOverride(globalSettings->getSetting("PermGen"));
+ auto memorySetting = m_settings->registerSetting("OverrideMemory", false);
+ m_settings->registerOverride(globalSettings->getSetting("MinMemAlloc"), memorySetting);
+ m_settings->registerOverride(globalSettings->getSetting("MaxMemAlloc"), memorySetting);
+ m_settings->registerOverride(globalSettings->getSetting("PermGen"), memorySetting);
}
QString MinecraftInstance::minecraftRoot() const
diff --git a/logic/settings/OverrideSetting.cpp b/logic/settings/OverrideSetting.cpp
index e8a9bfff2..25162dff9 100644
--- a/logic/settings/OverrideSetting.cpp
+++ b/logic/settings/OverrideSetting.cpp
@@ -15,16 +15,40 @@
#include "OverrideSetting.h"
-OverrideSetting::OverrideSetting(std::shared_ptr other)
+OverrideSetting::OverrideSetting(std::shared_ptr other, std::shared_ptr gate)
: Setting(other->configKeys(), QVariant())
{
+ Q_ASSERT(other);
+ Q_ASSERT(gate);
m_other = other;
+ m_gate = gate;
+}
+
+bool OverrideSetting::isOverriding() const
+{
+ return m_gate->get().toBool();
}
QVariant OverrideSetting::defValue() const
{
- if (m_other)
- return m_other->get();
- else
- return QVariant();
+ return m_other->get();
+}
+
+QVariant OverrideSetting::get() const
+{
+ if(isOverriding())
+ {
+ return Setting::get();
+ }
+ return m_other->get();
+}
+
+void OverrideSetting::reset()
+{
+ Setting::reset();
+}
+
+void OverrideSetting::set(QVariant value)
+{
+ Setting::set(value);
}
diff --git a/logic/settings/OverrideSetting.h b/logic/settings/OverrideSetting.h
index 7534692f4..68595cdea 100644
--- a/logic/settings/OverrideSetting.h
+++ b/logic/settings/OverrideSetting.h
@@ -30,10 +30,17 @@ class OverrideSetting : public Setting
{
Q_OBJECT
public:
- explicit OverrideSetting(std::shared_ptr other);
+ explicit OverrideSetting(std::shared_ptr overriden, std::shared_ptr gate);
virtual QVariant defValue() const;
+ virtual QVariant get() const;
+ virtual void set (QVariant value);
+ virtual void reset();
+
+private:
+ bool isOverriding() const;
protected:
std::shared_ptr m_other;
+ std::shared_ptr m_gate;
};
diff --git a/logic/settings/SettingsObject.cpp b/logic/settings/SettingsObject.cpp
index 5e682cbf8..f2ffdf9b6 100644
--- a/logic/settings/SettingsObject.cpp
+++ b/logic/settings/SettingsObject.cpp
@@ -30,7 +30,8 @@ SettingsObject::~SettingsObject()
m_settings.clear();
}
-std::shared_ptr SettingsObject::registerOverride(std::shared_ptr original)
+std::shared_ptr SettingsObject::registerOverride(std::shared_ptr original,
+ std::shared_ptr gate)
{
if (contains(original->id()))
{
@@ -38,7 +39,7 @@ std::shared_ptr SettingsObject::registerOverride(std::shared_ptrid());
return nullptr; // Fail
}
- auto override = std::make_shared(original);
+ auto override = std::make_shared(original, gate);
override->m_storage = this;
connectSignals(*override);
m_settings.insert(override->id(), override);
diff --git a/logic/settings/SettingsObject.h b/logic/settings/SettingsObject.h
index 6272d24c9..0f299c5d2 100644
--- a/logic/settings/SettingsObject.h
+++ b/logic/settings/SettingsObject.h
@@ -62,12 +62,13 @@ public:
virtual ~SettingsObject();
/*!
* Registers an override setting for the given original setting in this settings object
+ * gate decides if the passthrough (true) or the original (false) is used for value
*
* This will fail if there is already a setting with the same ID as
* the one that is being registered.
* \return A valid Setting shared pointer if successful.
*/
- std::shared_ptr registerOverride(std::shared_ptr original);
+ std::shared_ptr registerOverride(std::shared_ptr original, std::shared_ptr gate);
/*!
* Registers a passthorugh setting for the given original setting in this settings object