GH-991 implement wrapper commands
This commit is contained in:
parent
ce99fabe13
commit
dfb0a3b724
@ -472,6 +472,9 @@ void MultiMC::initGlobalSettings(bool test_mode)
|
|||||||
m_settings->registerSetting("JavaDetectionHack", "");
|
m_settings->registerSetting("JavaDetectionHack", "");
|
||||||
m_settings->registerSetting("JvmArgs", "");
|
m_settings->registerSetting("JvmArgs", "");
|
||||||
|
|
||||||
|
// Wrapper command for launch
|
||||||
|
m_settings->registerSetting("WrapperCommand", "");
|
||||||
|
|
||||||
// Custom Commands
|
// Custom Commands
|
||||||
m_settings->registerSetting({"PreLaunchCommand", "PreLaunchCmd"}, "");
|
m_settings->registerSetting({"PreLaunchCommand", "PreLaunchCmd"}, "");
|
||||||
m_settings->registerSetting({"PostExitCommand", "PostExitCmd"}, "");
|
m_settings->registerSetting({"PostExitCommand", "PostExitCmd"}, "");
|
||||||
|
@ -70,6 +70,7 @@ void JavaPage::applySettings()
|
|||||||
|
|
||||||
// Custom Commands
|
// Custom Commands
|
||||||
s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text());
|
s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text());
|
||||||
|
s->set("WrapperCommand", ui->wrapperCmdTextBox->text());
|
||||||
s->set("PostExitCommand", ui->postExitCmdTextBox->text());
|
s->set("PostExitCommand", ui->postExitCmdTextBox->text());
|
||||||
}
|
}
|
||||||
void JavaPage::loadSettings()
|
void JavaPage::loadSettings()
|
||||||
@ -86,6 +87,7 @@ void JavaPage::loadSettings()
|
|||||||
|
|
||||||
// Custom Commands
|
// Custom Commands
|
||||||
ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString());
|
ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString());
|
||||||
|
ui->wrapperCmdTextBox->setText(s->get("WrapperCommand").toString());
|
||||||
ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString());
|
ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>545</width>
|
<width>545</width>
|
||||||
<height>609</height>
|
<height>559</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -238,7 +238,7 @@
|
|||||||
<string>Custom Commands</string>
|
<string>Custom Commands</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<item row="1" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="labelPostExitCmd">
|
<widget class="QLabel" name="labelPostExitCmd">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Post-exit command:</string>
|
<string>Post-exit command:</string>
|
||||||
@ -255,9 +255,19 @@
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="preLaunchCmdTextBox"/>
|
<widget class="QLineEdit" name="preLaunchCmdTextBox"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLineEdit" name="postExitCmdTextBox"/>
|
<widget class="QLineEdit" name="postExitCmdTextBox"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="labelWrapperCmd">
|
||||||
|
<property name="text">
|
||||||
|
<string>Wrapper command:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="wrapperCmdTextBox"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -270,7 +280,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Pre-launch command runs before the instance launches and post-exit command runs after it exits. Both will be run in MultiMC's working directory with INST_ID, INST_DIR, and INST_NAME as environment variables.</string>
|
<string><html><head/><body><p>Pre-launch command runs before the instance launches and post-exit command runs after it exits. Both will be run in MultiMC's working directory with INST_ID, INST_DIR, and INST_NAME as environment variables.</p><p>Wrapper command allows running java using an extra wrapper program (like 'optirun' on Linux)</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
@ -290,11 +300,15 @@
|
|||||||
<tabstop>minMemSpinBox</tabstop>
|
<tabstop>minMemSpinBox</tabstop>
|
||||||
<tabstop>maxMemSpinBox</tabstop>
|
<tabstop>maxMemSpinBox</tabstop>
|
||||||
<tabstop>permGenSpinBox</tabstop>
|
<tabstop>permGenSpinBox</tabstop>
|
||||||
<tabstop>javaPathTextBox</tabstop>
|
|
||||||
<tabstop>javaBrowseBtn</tabstop>
|
<tabstop>javaBrowseBtn</tabstop>
|
||||||
|
<tabstop>javaPathTextBox</tabstop>
|
||||||
<tabstop>jvmArgsTextBox</tabstop>
|
<tabstop>jvmArgsTextBox</tabstop>
|
||||||
|
<tabstop>javaDetectBtn</tabstop>
|
||||||
|
<tabstop>javaTestBtn</tabstop>
|
||||||
<tabstop>preLaunchCmdTextBox</tabstop>
|
<tabstop>preLaunchCmdTextBox</tabstop>
|
||||||
|
<tabstop>wrapperCmdTextBox</tabstop>
|
||||||
<tabstop>postExitCmdTextBox</tabstop>
|
<tabstop>postExitCmdTextBox</tabstop>
|
||||||
|
<tabstop>tabWidget</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -42,6 +42,7 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
|
|||||||
// Custom Commands
|
// Custom Commands
|
||||||
m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false);
|
m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false);
|
||||||
m_settings->registerOverride(globalSettings->getSetting("PreLaunchCommand"));
|
m_settings->registerOverride(globalSettings->getSetting("PreLaunchCommand"));
|
||||||
|
m_settings->registerOverride(globalSettings->getSetting("WrapperCommand"));
|
||||||
m_settings->registerOverride(globalSettings->getSetting("PostExitCommand"));
|
m_settings->registerOverride(globalSettings->getSetting("PostExitCommand"));
|
||||||
|
|
||||||
// Console
|
// Console
|
||||||
|
@ -238,8 +238,27 @@ void MinecraftProcess::arm()
|
|||||||
QString allArgs = args.join(", ");
|
QString allArgs = args.join(", ");
|
||||||
emit log("Java Arguments:\n[" + censorPrivateInfo(allArgs) + "]\n\n");
|
emit log("Java Arguments:\n[" + censorPrivateInfo(allArgs) + "]\n\n");
|
||||||
|
|
||||||
// instantiate the launcher part
|
QString wrapperCommand = m_instance->settings()->get("WrapperCommand").toString();
|
||||||
|
if(!wrapperCommand.isEmpty())
|
||||||
|
{
|
||||||
|
auto realWrapperCommand = QStandardPaths::findExecutable(wrapperCommand);
|
||||||
|
if (realWrapperCommand.isEmpty())
|
||||||
|
{
|
||||||
|
emit log(tr("The wrapper command \"%1\" couldn't be found.").arg(wrapperCommand), MessageLevel::Warning);
|
||||||
|
m_instance->cleanupAfterRun();
|
||||||
|
emit launch_failed(m_instance);
|
||||||
|
m_instance->setRunning(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit log("Wrapper command is:\n" + wrapperCommand + "\n\n");
|
||||||
|
args.prepend(JavaPath);
|
||||||
|
start(wrapperCommand, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
start(JavaPath, args);
|
start(JavaPath, args);
|
||||||
|
}
|
||||||
|
|
||||||
if (!waitForStarted())
|
if (!waitForStarted())
|
||||||
{
|
{
|
||||||
//: Error message displayed if instace can't start
|
//: Error message displayed if instace can't start
|
||||||
|
Loading…
Reference in New Issue
Block a user