diff options
Diffstat (limited to 'launcher/ui/MainWindow.cpp')
-rw-r--r-- | launcher/ui/MainWindow.cpp | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 299401f5..58b1ae80 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -240,6 +240,7 @@ public: TranslatedAction actionCAT; TranslatedAction actionCopyInstance; TranslatedAction actionLaunchInstanceOffline; + TranslatedAction actionLaunchInstanceDemo; TranslatedAction actionScreenshots; TranslatedAction actionExportInstance; QVector<TranslatedAction *> all_actions; @@ -499,6 +500,7 @@ public: fileMenu->addAction(actionAddInstance); fileMenu->addAction(actionLaunchInstance); fileMenu->addAction(actionLaunchInstanceOffline); + fileMenu->addAction(actionLaunchInstanceDemo); fileMenu->addAction(actionKillInstance); fileMenu->addAction(actionCloseWindow); fileMenu->addSeparator(); @@ -669,6 +671,12 @@ public: actionLaunchInstanceOffline.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Launch the selected instance in offline mode.")); all_actions.append(&actionLaunchInstanceOffline); + actionLaunchInstanceDemo = TranslatedAction(MainWindow); + actionLaunchInstanceDemo->setObjectName(QStringLiteral("actionLaunchInstanceDemo")); + actionLaunchInstanceDemo.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Launch &Demo")); + actionLaunchInstanceDemo.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Launch the selected instance in demo mode.")); + all_actions.append(&actionLaunchInstanceDemo); + actionKillInstance = TranslatedAction(MainWindow); actionKillInstance->setObjectName(QStringLiteral("actionKillInstance")); actionKillInstance->setDisabled(true); @@ -1195,6 +1203,7 @@ void MainWindow::updateToolsMenu() ui->actionLaunchInstance->setDisabled(!m_selectedInstance || currentInstanceRunning); ui->actionLaunchInstanceOffline->setDisabled(!m_selectedInstance || currentInstanceRunning); + ui->actionLaunchInstanceDemo->setDisabled(!m_selectedInstance || currentInstanceRunning); QMenu *launchMenu = ui->actionLaunchInstance->menu(); QMenu *launchOfflineMenu = ui->actionLaunchInstanceOffline->menu(); @@ -1220,23 +1229,37 @@ void MainWindow::updateToolsMenu() normalLaunch->setShortcut(QKeySequence::Open); QAction *normalLaunchOffline = launchOfflineMenu->addAction(tr("Launch Offline")); normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O"))); + QAction *normalLaunchDemo = launchOfflineMenu->addAction(tr("Launch Demo")); + normalLaunchDemo->setShortcut(QKeySequence(tr("Ctrl+Alt+O"))); if (m_selectedInstance) { normalLaunch->setEnabled(m_selectedInstance->canLaunch()); normalLaunchOffline->setEnabled(m_selectedInstance->canLaunch()); + normalLaunchDemo->setEnabled(m_selectedInstance->canLaunch()); connect(normalLaunch, &QAction::triggered, [this]() { - APPLICATION->launch(m_selectedInstance, true); + APPLICATION->launch(m_selectedInstance, true, false); }); connect(normalLaunchOffline, &QAction::triggered, [this]() { - APPLICATION->launch(m_selectedInstance, false); + APPLICATION->launch(m_selectedInstance, false, false); + }); + connect(normalLaunchDemo, &QAction::triggered, [this]() { + APPLICATION->launch(m_selectedInstance, false, true); }); } else { normalLaunch->setDisabled(true); normalLaunchOffline->setDisabled(true); + normalLaunchDemo->setDisabled(true); + } + + // Disable demo-mode if not available. + auto instance = dynamic_cast<MinecraftInstance*>(m_selectedInstance.get()); + if (instance) { + normalLaunchDemo->setEnabled(instance->supportsDemo()); } + QString profilersTitle = tr("Profilers"); launchMenu->addSeparator()->setText(profilersTitle); launchOfflineMenu->addSeparator()->setText(profilersTitle); @@ -1260,11 +1283,11 @@ void MainWindow::updateToolsMenu() connect(profilerAction, &QAction::triggered, [this, profiler]() { - APPLICATION->launch(m_selectedInstance, true, profiler.get()); + APPLICATION->launch(m_selectedInstance, true, false, profiler.get()); }); connect(profilerOfflineAction, &QAction::triggered, [this, profiler]() { - APPLICATION->launch(m_selectedInstance, false, profiler.get()); + APPLICATION->launch(m_selectedInstance, false, false, profiler.get()); }); } else @@ -2096,6 +2119,14 @@ void MainWindow::on_actionLaunchInstanceOffline_triggered() } } +void MainWindow::on_actionLaunchInstanceDemo_triggered() +{ + if (m_selectedInstance) + { + APPLICATION->launch(m_selectedInstance, false, true); + } +} + void MainWindow::on_actionKillInstance_triggered() { if(m_selectedInstance && m_selectedInstance->isRunning()) @@ -2139,6 +2170,14 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & ui->setInstanceActionsEnabled(true); ui->actionLaunchInstance->setEnabled(m_selectedInstance->canLaunch()); ui->actionLaunchInstanceOffline->setEnabled(m_selectedInstance->canLaunch()); + ui->actionLaunchInstanceDemo->setEnabled(m_selectedInstance->canLaunch()); + + // Disable demo-mode if not available. + auto instance = dynamic_cast<MinecraftInstance*>(m_selectedInstance.get()); + if (instance) { + ui->actionLaunchInstanceDemo->setEnabled(instance->supportsDemo()); + } + ui->actionKillInstance->setEnabled(m_selectedInstance->isRunning()); ui->actionExportInstance->setEnabled(m_selectedInstance->canExport()); ui->renameButton->setText(m_selectedInstance->name()); @@ -2158,6 +2197,7 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & ui->setInstanceActionsEnabled(false); ui->actionLaunchInstance->setEnabled(false); ui->actionLaunchInstanceOffline->setEnabled(false); + ui->actionLaunchInstanceDemo->setEnabled(false); ui->actionKillInstance->setEnabled(false); APPLICATION->settings()->set("SelectedInstance", QString()); selectionBad(); |