Merge pull request #560 from kthchew/feature/close-pmc-override

Add instance overrides for miscellaneous settings
This commit is contained in:
flow 2022-05-15 17:40:53 -03:00 committed by GitHub
commit a67f3131e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 3 deletions

View File

@ -162,6 +162,11 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO
m_settings->registerSetting("JoinServerOnLaunch", false);
m_settings->registerSetting("JoinServerOnLaunchAddress", "");
// Miscellaneous
auto miscellaneousOverride = m_settings->registerSetting("OverrideMiscellaneous", false);
m_settings->registerOverride(globalSettings->getSetting("CloseAfterLaunch"), miscellaneousOverride);
m_settings->registerOverride(globalSettings->getSetting("QuitAfterGameStop"), miscellaneousOverride);
m_components.reset(new PackProfile(this));
}
@ -984,7 +989,7 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
{
process->setCensorFilter(createCensorFilterFromSession(session));
}
if(APPLICATION->settings()->get("QuitAfterGameStop").toBool())
if(m_settings->get("QuitAfterGameStop").toBool())
{
auto step = new QuitAfterGameStop(pptr);
process->appendStep(step);

View File

@ -25,7 +25,8 @@
LauncherPartLaunch::LauncherPartLaunch(LaunchTask *parent) : LaunchStep(parent)
{
if (APPLICATION->settings()->get("CloseAfterLaunch").toBool())
auto instance = parent->instance();
if (instance->settings()->get("CloseAfterLaunch").toBool())
{
std::shared_ptr<QMetaObject::Connection> connection{new QMetaObject::Connection};
*connection = connect(&m_process, &LoggedProcess::log, this, [=](QStringList lines, MessageLevel::Enum level) {
@ -168,7 +169,8 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state)
}
case LoggedProcess::Finished:
{
if (APPLICATION->settings()->get("CloseAfterLaunch").toBool())
auto instance = m_parent->instance();
if (instance->settings()->get("CloseAfterLaunch").toBool())
APPLICATION->showMainWindow();
m_parent->setPid(-1);

View File

@ -101,6 +101,20 @@ void InstanceSettingsPage::applySettings()
{
SettingsObject::Lock lock(m_settings);
// Miscellaneous
bool miscellaneous = ui->miscellaneousSettingsBox->isChecked();
m_settings->set("OverrideMiscellaneous", miscellaneous);
if (miscellaneous)
{
m_settings->set("CloseAfterLaunch", ui->closeAfterLaunchCheck->isChecked());
m_settings->set("QuitAfterGameStop", ui->quitAfterGameStopCheck->isChecked());
}
else
{
m_settings->reset("CloseAfterLaunch");
m_settings->reset("QuitAfterGameStop");
}
// Console
bool console = ui->consoleSettingsBox->isChecked();
m_settings->set("OverrideConsole", console);
@ -247,6 +261,11 @@ void InstanceSettingsPage::applySettings()
void InstanceSettingsPage::loadSettings()
{
// Miscellaneous
ui->miscellaneousSettingsBox->setChecked(m_settings->get("OverrideMiscellaneous").toBool());
ui->closeAfterLaunchCheck->setChecked(m_settings->get("CloseAfterLaunch").toBool());
ui->quitAfterGameStopCheck->setChecked(m_settings->get("QuitAfterGameStop").toBool());
// Console
ui->consoleSettingsBox->setChecked(m_settings->get("OverrideConsole").toBool());
ui->showConsoleCheck->setChecked(m_settings->get("ShowConsole").toBool());

View File

@ -349,6 +349,35 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="miscellaneousSettingsBox">
<property name="title">
<string>Miscellaneous</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QCheckBox" name="closeAfterLaunchCheck">
<property name="text">
<string>Close the launcher after game window opens</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="quitAfterGameStopCheck">
<property name="text">
<string>Quit the launcher after game window closes</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacerMinecraft_2">
<property name="orientation">