aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/InstanceWindow.cpp
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2022-09-18 14:41:25 +0200
committerGitHub <noreply@github.com>2022-09-18 14:41:25 +0200
commit098327f12809ac584e9683acf69ed88b3325d050 (patch)
tree56ebc3d98fa9d2de6865095be9149cbf74afb131 /launcher/ui/InstanceWindow.cpp
parent8674ac4f68f92757b422f5db89388077ab11a7c6 (diff)
parent81e326571bb31dc4a92f1dbe32cb3ec50ace71f8 (diff)
downloadPrismLauncher-098327f12809ac584e9683acf69ed88b3325d050.tar.gz
PrismLauncher-098327f12809ac584e9683acf69ed88b3325d050.tar.bz2
PrismLauncher-098327f12809ac584e9683acf69ed88b3325d050.zip
Merge pull request #903 from jopejoe1/demo-launch
Diffstat (limited to 'launcher/ui/InstanceWindow.cpp')
-rw-r--r--launcher/ui/InstanceWindow.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/launcher/ui/InstanceWindow.cpp b/launcher/ui/InstanceWindow.cpp
index 0ad8c594..09ce0d67 100644
--- a/launcher/ui/InstanceWindow.cpp
+++ b/launcher/ui/InstanceWindow.cpp
@@ -95,8 +95,14 @@ InstanceWindow::InstanceWindow(InstancePtr instance, QWidget *parent)
m_launchOfflineButton = new QPushButton();
horizontalLayout->addWidget(m_launchOfflineButton);
m_launchOfflineButton->setText(tr("Launch Offline"));
+
+ m_launchDemoButton = new QPushButton();
+ horizontalLayout->addWidget(m_launchDemoButton);
+ m_launchDemoButton->setText(tr("Launch Demo"));
+
updateLaunchButtons();
connect(m_launchOfflineButton, SIGNAL(clicked(bool)), SLOT(on_btnLaunchMinecraftOffline_clicked()));
+ connect(m_launchDemoButton, SIGNAL(clicked(bool)), SLOT(on_btnLaunchMinecraftDemo_clicked()));
m_closeButton = new QPushButton();
m_closeButton->setText(tr("Close"));
@@ -143,6 +149,7 @@ void InstanceWindow::updateLaunchButtons()
if(m_instance->isRunning())
{
m_launchOfflineButton->setEnabled(false);
+ m_launchDemoButton->setEnabled(false);
m_killButton->setText(tr("Kill"));
m_killButton->setObjectName("killButton");
m_killButton->setToolTip(tr("Kill the running instance"));
@@ -150,6 +157,7 @@ void InstanceWindow::updateLaunchButtons()
else if(!m_instance->canLaunch())
{
m_launchOfflineButton->setEnabled(false);
+ m_launchDemoButton->setEnabled(false);
m_killButton->setText(tr("Launch"));
m_killButton->setObjectName("launchButton");
m_killButton->setToolTip(tr("Launch the instance"));
@@ -158,6 +166,13 @@ void InstanceWindow::updateLaunchButtons()
else
{
m_launchOfflineButton->setEnabled(true);
+
+ // Disable demo-mode if not available.
+ auto instance = dynamic_cast<MinecraftInstance*>(m_instance.get());
+ if (instance) {
+ m_launchDemoButton->setEnabled(instance->supportsDemo());
+ }
+
m_killButton->setText(tr("Launch"));
m_killButton->setObjectName("launchButton");
m_killButton->setToolTip(tr("Launch the instance"));
@@ -169,7 +184,12 @@ void InstanceWindow::updateLaunchButtons()
void InstanceWindow::on_btnLaunchMinecraftOffline_clicked()
{
- APPLICATION->launch(m_instance, false, nullptr);
+ APPLICATION->launch(m_instance, false, false, nullptr);
+}
+
+void InstanceWindow::on_btnLaunchMinecraftDemo_clicked()
+{
+ APPLICATION->launch(m_instance, false, true, nullptr);
}
void InstanceWindow::instanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc)
@@ -223,7 +243,7 @@ void InstanceWindow::on_btnKillMinecraft_clicked()
}
else
{
- APPLICATION->launch(m_instance, true, nullptr);
+ APPLICATION->launch(m_instance, true, false, nullptr);
}
}