Merge pull request #1320 from TheKodeToad/better-launch
Combine launch buttons in instance window, persist profiler
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
* Copyright (c) 2023 seth <getchoo at tuta dot io>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -88,6 +88,10 @@
|
||||
#include "minecraft/gameoptions/GameOptions.h"
|
||||
#include "minecraft/update/FoldersTask.h"
|
||||
|
||||
#include "tools/BaseProfiler.h"
|
||||
|
||||
#include <QActionGroup>
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include "MangoHud.h"
|
||||
#endif
|
||||
@ -231,6 +235,50 @@ QSet<QString> MinecraftInstance::traits() const
|
||||
return profile->getTraits();
|
||||
}
|
||||
|
||||
// FIXME: move UI code out of MinecraftInstance
|
||||
void MinecraftInstance::populateLaunchMenu(QMenu* menu)
|
||||
{
|
||||
QAction* normalLaunch = menu->addAction(tr("&Launch"));
|
||||
normalLaunch->setShortcut(QKeySequence::Open);
|
||||
QAction* normalLaunchOffline = menu->addAction(tr("Launch &Offline"));
|
||||
normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
|
||||
QAction* normalLaunchDemo = menu->addAction(tr("Launch &Demo"));
|
||||
normalLaunchDemo->setShortcut(QKeySequence(tr("Ctrl+Alt+O")));
|
||||
|
||||
normalLaunchDemo->setEnabled(supportsDemo());
|
||||
|
||||
connect(normalLaunch, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this()); });
|
||||
connect(normalLaunchOffline, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this(), false, false); });
|
||||
connect(normalLaunchDemo, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this(), false, true); });
|
||||
|
||||
QString profilersTitle = tr("Profilers");
|
||||
menu->addSeparator()->setText(profilersTitle);
|
||||
|
||||
auto profilers = new QActionGroup(menu);
|
||||
profilers->setExclusive(true);
|
||||
connect(profilers, &QActionGroup::triggered, [this](QAction* action) {
|
||||
settings()->set("Profiler", action->data());
|
||||
emit profilerChanged();
|
||||
});
|
||||
|
||||
QAction* noProfilerAction = menu->addAction(tr("&No Profiler"));
|
||||
noProfilerAction->setData("");
|
||||
noProfilerAction->setCheckable(true);
|
||||
noProfilerAction->setChecked(true);
|
||||
profilers->addAction(noProfilerAction);
|
||||
|
||||
for (auto profiler = APPLICATION->profilers().begin(); profiler != APPLICATION->profilers().end(); profiler++) {
|
||||
QAction* profilerAction = menu->addAction(profiler.value()->name());
|
||||
profilers->addAction(profilerAction);
|
||||
profilerAction->setData(profiler.key());
|
||||
profilerAction->setCheckable(true);
|
||||
profilerAction->setChecked(settings()->get("Profiler").toString() == profiler.key());
|
||||
|
||||
QString error;
|
||||
profilerAction->setEnabled(profiler.value()->check(&error));
|
||||
}
|
||||
}
|
||||
|
||||
QString MinecraftInstance::gameRoot() const
|
||||
{
|
||||
QFileInfo mcDir(FS::PathCombine(instanceRoot(), "minecraft"));
|
||||
|
@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -70,6 +70,8 @@ class MinecraftInstance : public BaseInstance {
|
||||
|
||||
bool canExport() const override { return true; }
|
||||
|
||||
void populateLaunchMenu(QMenu* menu) override;
|
||||
|
||||
////// Directories and files //////
|
||||
QString jarModsDir() const;
|
||||
QString resourcePacksDir() const;
|
||||
|
Reference in New Issue
Block a user