Add quit launcher after game stops option (Steam Deck)
lecense
This commit is contained in:
parent
c7fdfb8116
commit
b1af689546
@ -727,6 +727,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
m_settings->registerSetting("PastebinURL", "https://0x0.st");
|
m_settings->registerSetting("PastebinURL", "https://0x0.st");
|
||||||
|
|
||||||
m_settings->registerSetting("CloseAfterLaunch", false);
|
m_settings->registerSetting("CloseAfterLaunch", false);
|
||||||
|
m_settings->registerSetting("QuitAfterGameStop", false);
|
||||||
|
|
||||||
// Custom MSA credentials
|
// Custom MSA credentials
|
||||||
m_settings->registerSetting("MSAClientIDOverride", "");
|
m_settings->registerSetting("MSAClientIDOverride", "");
|
||||||
|
@ -144,6 +144,8 @@ set(LAUNCH_SOURCES
|
|||||||
launch/steps/TextPrint.h
|
launch/steps/TextPrint.h
|
||||||
launch/steps/Update.cpp
|
launch/steps/Update.cpp
|
||||||
launch/steps/Update.h
|
launch/steps/Update.h
|
||||||
|
launch/steps/QuitAfterGameStop.cpp
|
||||||
|
launch/steps/QuitAfterGameStop.h
|
||||||
launch/LaunchStep.cpp
|
launch/LaunchStep.cpp
|
||||||
launch/LaunchStep.h
|
launch/LaunchStep.h
|
||||||
launch/LaunchTask.cpp
|
launch/LaunchTask.cpp
|
||||||
|
26
launcher/launch/steps/QuitAfterGameStop.cpp
Normal file
26
launcher/launch/steps/QuitAfterGameStop.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 dada513 <dada513@protonmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "QuitAfterGameStop.h"
|
||||||
|
#include <launch/LaunchTask.h>
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
|
void QuitAfterGameStop::executeTask()
|
||||||
|
{
|
||||||
|
APPLICATION->quit();
|
||||||
|
}
|
35
launcher/launch/steps/QuitAfterGameStop.h
Normal file
35
launcher/launch/steps/QuitAfterGameStop.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 dada513 <dada513@protonmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <launch/LaunchStep.h>
|
||||||
|
|
||||||
|
class QuitAfterGameStop: public LaunchStep
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit QuitAfterGameStop(LaunchTask *parent) :LaunchStep(parent){};
|
||||||
|
virtual ~QuitAfterGameStop() {};
|
||||||
|
|
||||||
|
virtual void executeTask();
|
||||||
|
virtual bool canAbort() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
@ -20,6 +20,7 @@
|
|||||||
#include "launch/steps/PreLaunchCommand.h"
|
#include "launch/steps/PreLaunchCommand.h"
|
||||||
#include "launch/steps/TextPrint.h"
|
#include "launch/steps/TextPrint.h"
|
||||||
#include "launch/steps/CheckJava.h"
|
#include "launch/steps/CheckJava.h"
|
||||||
|
#include "launch/steps/QuitAfterGameStop.h"
|
||||||
|
|
||||||
#include "minecraft/launch/LauncherPartLaunch.h"
|
#include "minecraft/launch/LauncherPartLaunch.h"
|
||||||
#include "minecraft/launch/DirectJavaLaunch.h"
|
#include "minecraft/launch/DirectJavaLaunch.h"
|
||||||
@ -935,6 +936,11 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
|
|||||||
{
|
{
|
||||||
process->setCensorFilter(createCensorFilterFromSession(session));
|
process->setCensorFilter(createCensorFilterFromSession(session));
|
||||||
}
|
}
|
||||||
|
if(APPLICATION->settings()->get("QuitAfterGameStop").toBool())
|
||||||
|
{
|
||||||
|
auto step = new QuitAfterGameStop(pptr);
|
||||||
|
process->appendStep(step);
|
||||||
|
}
|
||||||
m_launchProcess = process;
|
m_launchProcess = process;
|
||||||
emit launchTaskChanged(m_launchProcess);
|
emit launchTaskChanged(m_launchProcess);
|
||||||
return m_launchProcess;
|
return m_launchProcess;
|
||||||
|
@ -170,6 +170,7 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state)
|
|||||||
{
|
{
|
||||||
if (APPLICATION->settings()->get("CloseAfterLaunch").toBool())
|
if (APPLICATION->settings()->get("CloseAfterLaunch").toBool())
|
||||||
APPLICATION->showMainWindow();
|
APPLICATION->showMainWindow();
|
||||||
|
|
||||||
m_parent->setPid(-1);
|
m_parent->setPid(-1);
|
||||||
// if the exit code wasn't 0, report this as a crash
|
// if the exit code wasn't 0, report this as a crash
|
||||||
auto exitCode = m_process.exitCode();
|
auto exitCode = m_process.exitCode();
|
||||||
|
@ -94,6 +94,7 @@ void MinecraftPage::applySettings()
|
|||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
s->set("CloseAfterLaunch", ui->closeAfterLaunchCheck->isChecked());
|
s->set("CloseAfterLaunch", ui->closeAfterLaunchCheck->isChecked());
|
||||||
|
s->set("QuitAfterGameStop", ui->quitAfterGameStopCheck->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftPage::loadSettings()
|
void MinecraftPage::loadSettings()
|
||||||
@ -113,6 +114,7 @@ void MinecraftPage::loadSettings()
|
|||||||
ui->recordGameTime->setChecked(s->get("RecordGameTime").toBool());
|
ui->recordGameTime->setChecked(s->get("RecordGameTime").toBool());
|
||||||
|
|
||||||
ui->closeAfterLaunchCheck->setChecked(s->get("CloseAfterLaunch").toBool());
|
ui->closeAfterLaunchCheck->setChecked(s->get("CloseAfterLaunch").toBool());
|
||||||
|
ui->quitAfterGameStopCheck->setChecked(s->get("QuitAfterGameStop").toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftPage::retranslate()
|
void MinecraftPage::retranslate()
|
||||||
|
@ -180,6 +180,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="quitAfterGameStopCheck">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>PolyMC will automatically exit if the game crashes or exists.</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Quit PolyMC after game window stops</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user