Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into auth3
This commit is contained in:
commit
4f8b20437f
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -79,7 +79,7 @@ jobs:
|
|||||||
qt_ver: 6
|
qt_ver: 6
|
||||||
qt_host: windows
|
qt_host: windows
|
||||||
qt_arch: ""
|
qt_arch: ""
|
||||||
qt_version: "6.7.0"
|
qt_version: "6.7.1"
|
||||||
qt_modules: "qt5compat qtimageformats qtnetworkauth"
|
qt_modules: "qt5compat qtimageformats qtnetworkauth"
|
||||||
|
|
||||||
- os: windows-2022
|
- os: windows-2022
|
||||||
@ -90,7 +90,7 @@ jobs:
|
|||||||
qt_ver: 6
|
qt_ver: 6
|
||||||
qt_host: windows
|
qt_host: windows
|
||||||
qt_arch: "win64_msvc2019_arm64"
|
qt_arch: "win64_msvc2019_arm64"
|
||||||
qt_version: "6.7.0"
|
qt_version: "6.7.1"
|
||||||
qt_modules: "qt5compat qtimageformats qtnetworkauth"
|
qt_modules: "qt5compat qtimageformats qtnetworkauth"
|
||||||
|
|
||||||
- os: macos-12
|
- os: macos-12
|
||||||
@ -99,7 +99,7 @@ jobs:
|
|||||||
qt_ver: 6
|
qt_ver: 6
|
||||||
qt_host: mac
|
qt_host: mac
|
||||||
qt_arch: ""
|
qt_arch: ""
|
||||||
qt_version: "6.7.0"
|
qt_version: "6.7.1"
|
||||||
qt_modules: "qt5compat qtimageformats qtnetworkauth"
|
qt_modules: "qt5compat qtimageformats qtnetworkauth"
|
||||||
|
|
||||||
- os: macos-12
|
- os: macos-12
|
||||||
|
2
.github/workflows/update-flake.yml
vendored
2
.github/workflows/update-flake.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b # v27
|
- uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b # v27
|
||||||
|
|
||||||
- uses: DeterminateSystems/update-flake-lock@v21
|
- uses: DeterminateSystems/update-flake-lock@v22
|
||||||
with:
|
with:
|
||||||
commit-msg: "chore(nix): update lockfile"
|
commit-msg: "chore(nix): update lockfile"
|
||||||
pr-title: "chore(nix): update lockfile"
|
pr-title: "chore(nix): update lockfile"
|
||||||
|
@ -847,24 +847,17 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||||||
{
|
{
|
||||||
m_metacache.reset(new HttpMetaCache("metacache"));
|
m_metacache.reset(new HttpMetaCache("metacache"));
|
||||||
m_metacache->addBase("asset_indexes", QDir("assets/indexes").absolutePath());
|
m_metacache->addBase("asset_indexes", QDir("assets/indexes").absolutePath());
|
||||||
m_metacache->addBase("asset_objects", QDir("assets/objects").absolutePath());
|
|
||||||
m_metacache->addBase("versions", QDir("versions").absolutePath());
|
|
||||||
m_metacache->addBase("libraries", QDir("libraries").absolutePath());
|
m_metacache->addBase("libraries", QDir("libraries").absolutePath());
|
||||||
m_metacache->addBase("minecraftforge", QDir("mods/minecraftforge").absolutePath());
|
|
||||||
m_metacache->addBase("fmllibs", QDir("mods/minecraftforge/libs").absolutePath());
|
m_metacache->addBase("fmllibs", QDir("mods/minecraftforge/libs").absolutePath());
|
||||||
m_metacache->addBase("liteloader", QDir("mods/liteloader").absolutePath());
|
|
||||||
m_metacache->addBase("general", QDir("cache").absolutePath());
|
m_metacache->addBase("general", QDir("cache").absolutePath());
|
||||||
m_metacache->addBase("ATLauncherPacks", QDir("cache/ATLauncherPacks").absolutePath());
|
m_metacache->addBase("ATLauncherPacks", QDir("cache/ATLauncherPacks").absolutePath());
|
||||||
m_metacache->addBase("FTBPacks", QDir("cache/FTBPacks").absolutePath());
|
m_metacache->addBase("FTBPacks", QDir("cache/FTBPacks").absolutePath());
|
||||||
m_metacache->addBase("ModpacksCHPacks", QDir("cache/ModpacksCHPacks").absolutePath());
|
|
||||||
m_metacache->addBase("TechnicPacks", QDir("cache/TechnicPacks").absolutePath());
|
m_metacache->addBase("TechnicPacks", QDir("cache/TechnicPacks").absolutePath());
|
||||||
m_metacache->addBase("FlamePacks", QDir("cache/FlamePacks").absolutePath());
|
m_metacache->addBase("FlamePacks", QDir("cache/FlamePacks").absolutePath());
|
||||||
m_metacache->addBase("FlameMods", QDir("cache/FlameMods").absolutePath());
|
m_metacache->addBase("FlameMods", QDir("cache/FlameMods").absolutePath());
|
||||||
m_metacache->addBase("ModrinthPacks", QDir("cache/ModrinthPacks").absolutePath());
|
m_metacache->addBase("ModrinthPacks", QDir("cache/ModrinthPacks").absolutePath());
|
||||||
m_metacache->addBase("ModrinthModpacks", QDir("cache/ModrinthModpacks").absolutePath());
|
m_metacache->addBase("ModrinthModpacks", QDir("cache/ModrinthModpacks").absolutePath());
|
||||||
m_metacache->addBase("root", QDir::currentPath());
|
|
||||||
m_metacache->addBase("translations", QDir("translations").absolutePath());
|
m_metacache->addBase("translations", QDir("translations").absolutePath());
|
||||||
m_metacache->addBase("icons", QDir("cache/icons").absolutePath());
|
|
||||||
m_metacache->addBase("meta", QDir("meta").absolutePath());
|
m_metacache->addBase("meta", QDir("meta").absolutePath());
|
||||||
m_metacache->Load();
|
m_metacache->Load();
|
||||||
qDebug() << "<> Cache initialized.";
|
qDebug() << "<> Cache initialized.";
|
||||||
@ -945,8 +938,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
default: {
|
default: {
|
||||||
qDebug() << "Exiting because update lockfile is present";
|
qDebug() << "Exiting because update lockfile is present";
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(this, []() { exit(1); }, Qt::QueuedConnection);
|
||||||
this, []() { exit(1); }, Qt::QueuedConnection);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -978,8 +970,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
default: {
|
default: {
|
||||||
qDebug() << "Exiting because update lockfile is present";
|
qDebug() << "Exiting because update lockfile is present";
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(this, []() { exit(1); }, Qt::QueuedConnection);
|
||||||
this, []() { exit(1); }, Qt::QueuedConnection);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -991,7 +982,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||||||
"\n"
|
"\n"
|
||||||
"You are now running %1 .\n"
|
"You are now running %1 .\n"
|
||||||
"Check the Prism Launcher updater log at: \n"
|
"Check the Prism Launcher updater log at: \n"
|
||||||
"%1\n"
|
"%2\n"
|
||||||
"for details.")
|
"for details.")
|
||||||
.arg(BuildConfig.printableVersionString())
|
.arg(BuildConfig.printableVersionString())
|
||||||
.arg(update_log_path);
|
.arg(update_log_path);
|
||||||
@ -1673,8 +1664,7 @@ QString Application::getJarPath(QString jarFile)
|
|||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||||
FS::PathCombine(m_rootPath, "share", BuildConfig.LAUNCHER_NAME),
|
FS::PathCombine(m_rootPath, "share", BuildConfig.LAUNCHER_NAME),
|
||||||
#endif
|
#endif
|
||||||
FS::PathCombine(m_rootPath, "jars"),
|
FS::PathCombine(m_rootPath, "jars"), FS::PathCombine(applicationDirPath(), "jars"),
|
||||||
FS::PathCombine(applicationDirPath(), "jars"),
|
|
||||||
FS::PathCombine(applicationDirPath(), "..", "jars") // from inside build dir, for debuging
|
FS::PathCombine(applicationDirPath(), "..", "jars") // from inside build dir, for debuging
|
||||||
};
|
};
|
||||||
for (QString p : potentialPaths) {
|
for (QString p : potentialPaths) {
|
||||||
|
@ -29,7 +29,7 @@ class BaseVersion;
|
|||||||
class BaseInstaller {
|
class BaseInstaller {
|
||||||
public:
|
public:
|
||||||
BaseInstaller();
|
BaseInstaller();
|
||||||
virtual ~BaseInstaller(){};
|
virtual ~BaseInstaller() {};
|
||||||
bool isApplied(MinecraftInstance* on);
|
bool isApplied(MinecraftInstance* on);
|
||||||
|
|
||||||
virtual bool add(MinecraftInstance* to);
|
virtual bool add(MinecraftInstance* to);
|
||||||
|
@ -269,13 +269,18 @@ void BaseInstance::setRunning(bool running)
|
|||||||
|
|
||||||
m_isRunning = running;
|
m_isRunning = running;
|
||||||
|
|
||||||
if (!m_settings->get("RecordGameTime").toBool()) {
|
emit runningStatusChanged(running);
|
||||||
emit runningStatusChanged(running);
|
}
|
||||||
|
|
||||||
|
void BaseInstance::setMinecraftRunning(bool running)
|
||||||
|
{
|
||||||
|
if (!settings()->get("RecordGameTime").toBool()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (running) {
|
if (running) {
|
||||||
m_timeStarted = QDateTime::currentDateTime();
|
m_timeStarted = QDateTime::currentDateTime();
|
||||||
|
setLastLaunch(m_timeStarted.toMSecsSinceEpoch());
|
||||||
} else {
|
} else {
|
||||||
QDateTime timeEnded = QDateTime::currentDateTime();
|
QDateTime timeEnded = QDateTime::currentDateTime();
|
||||||
|
|
||||||
@ -285,8 +290,6 @@ void BaseInstance::setRunning(bool running)
|
|||||||
|
|
||||||
emit propertiesChanged(this);
|
emit propertiesChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit runningStatusChanged(running);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t BaseInstance::totalTimePlayed() const
|
int64_t BaseInstance::totalTimePlayed() const
|
||||||
|
@ -104,6 +104,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
|||||||
/// be unique.
|
/// be unique.
|
||||||
virtual QString id() const;
|
virtual QString id() const;
|
||||||
|
|
||||||
|
void setMinecraftRunning(bool running);
|
||||||
void setRunning(bool running);
|
void setRunning(bool running);
|
||||||
bool isRunning() const;
|
bool isRunning() const;
|
||||||
int64_t totalTimePlayed() const;
|
int64_t totalTimePlayed() const;
|
||||||
|
@ -163,6 +163,8 @@ set(LAUNCH_SOURCES
|
|||||||
launch/steps/Update.h
|
launch/steps/Update.h
|
||||||
launch/steps/QuitAfterGameStop.cpp
|
launch/steps/QuitAfterGameStop.cpp
|
||||||
launch/steps/QuitAfterGameStop.h
|
launch/steps/QuitAfterGameStop.h
|
||||||
|
launch/steps/PrintServers.cpp
|
||||||
|
launch/steps/PrintServers.h
|
||||||
launch/LaunchStep.cpp
|
launch/LaunchStep.cpp
|
||||||
launch/LaunchStep.h
|
launch/LaunchStep.h
|
||||||
launch/LaunchTask.cpp
|
launch/LaunchTask.cpp
|
||||||
|
@ -22,7 +22,7 @@ class InstancePageProvider : protected QObject, public BasePageProvider {
|
|||||||
public:
|
public:
|
||||||
explicit InstancePageProvider(InstancePtr parent) { inst = parent; }
|
explicit InstancePageProvider(InstancePtr parent) { inst = parent; }
|
||||||
|
|
||||||
virtual ~InstancePageProvider(){};
|
virtual ~InstancePageProvider() {};
|
||||||
virtual QList<BasePage*> getPages() override
|
virtual QList<BasePage*> getPages() override
|
||||||
{
|
{
|
||||||
QList<BasePage*> values;
|
QList<BasePage*> values;
|
||||||
|
@ -24,7 +24,7 @@ class TestCheck : public QObject {
|
|||||||
TestCheck(QWidget* parent, QString path, QString args, int minMem, int maxMem, int permGen)
|
TestCheck(QWidget* parent, QString path, QString args, int minMem, int maxMem, int permGen)
|
||||||
: m_parent(parent), m_path(path), m_args(args), m_minMem(minMem), m_maxMem(maxMem), m_permGen(permGen)
|
: m_parent(parent), m_path(path), m_args(args), m_minMem(minMem), m_maxMem(maxMem), m_permGen(permGen)
|
||||||
{}
|
{}
|
||||||
virtual ~TestCheck(){};
|
virtual ~TestCheck() {};
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include "LaunchController.h"
|
#include "LaunchController.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "launch/steps/PrintServers.h"
|
||||||
#include "minecraft/auth/AccountData.h"
|
#include "minecraft/auth/AccountData.h"
|
||||||
#include "minecraft/auth/AccountList.h"
|
#include "minecraft/auth/AccountList.h"
|
||||||
|
|
||||||
@ -193,7 +194,8 @@ void LaunchController::login()
|
|||||||
bool tryagain = true;
|
bool tryagain = true;
|
||||||
unsigned int tries = 0;
|
unsigned int tries = 0;
|
||||||
|
|
||||||
if (m_accountToUse->accountType() != AccountType::Offline && m_accountToUse->accountState() == AccountState::Offline) {
|
if ((m_accountToUse->accountType() != AccountType::Offline && m_accountToUse->accountState() == AccountState::Offline) ||
|
||||||
|
m_accountToUse->shouldRefresh()) {
|
||||||
// Force account refresh on the account used to launch the instance updating the AccountState
|
// Force account refresh on the account used to launch the instance updating the AccountState
|
||||||
// only on first try and if it is not meant to be offline
|
// only on first try and if it is not meant to be offline
|
||||||
auto accounts = APPLICATION->accounts();
|
auto accounts = APPLICATION->accounts();
|
||||||
@ -345,25 +347,8 @@ void LaunchController::launchInstance()
|
|||||||
|
|
||||||
// Prepend Server Status
|
// Prepend Server Status
|
||||||
QStringList servers = { "login.microsoftonline.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com" };
|
QStringList servers = { "login.microsoftonline.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com" };
|
||||||
QString resolved_servers = "";
|
|
||||||
QHostInfo host_info;
|
|
||||||
|
|
||||||
for (QString server : servers) {
|
m_launcher->prependStep(makeShared<PrintServers>(m_launcher.get(), servers));
|
||||||
host_info = QHostInfo::fromName(server);
|
|
||||||
resolved_servers = resolved_servers + server + " resolves to:\n [";
|
|
||||||
if (!host_info.addresses().isEmpty()) {
|
|
||||||
for (QHostAddress address : host_info.addresses()) {
|
|
||||||
resolved_servers = resolved_servers + address.toString();
|
|
||||||
if (!host_info.addresses().endsWith(address)) {
|
|
||||||
resolved_servers = resolved_servers + ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
resolved_servers = resolved_servers + "N/A";
|
|
||||||
}
|
|
||||||
resolved_servers = resolved_servers + "]\n\n";
|
|
||||||
}
|
|
||||||
m_launcher->prependStep(makeShared<TextPrint>(m_launcher.get(), resolved_servers, MessageLevel::Launcher));
|
|
||||||
} else {
|
} else {
|
||||||
online_mode = m_demo ? "demo" : "offline";
|
online_mode = m_demo ? "demo" : "offline";
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class LaunchController : public Task {
|
|||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
|
||||||
LaunchController(QObject* parent = nullptr);
|
LaunchController(QObject* parent = nullptr);
|
||||||
virtual ~LaunchController(){};
|
virtual ~LaunchController() {};
|
||||||
|
|
||||||
void setInstance(InstancePtr instance) { m_instance = instance; }
|
void setInstance(InstancePtr instance) { m_instance = instance; }
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ class ExportToZipTask : public Task {
|
|||||||
QString destinationPrefix = "",
|
QString destinationPrefix = "",
|
||||||
bool followSymlinks = false,
|
bool followSymlinks = false,
|
||||||
bool utf8Enabled = false)
|
bool utf8Enabled = false)
|
||||||
: ExportToZipTask(outputPath, QDir(dir), files, destinationPrefix, followSymlinks, utf8Enabled){};
|
: ExportToZipTask(outputPath, QDir(dir), files, destinationPrefix, followSymlinks, utf8Enabled) {};
|
||||||
|
|
||||||
virtual ~ExportToZipTask() = default;
|
virtual ~ExportToZipTask() = default;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class NullInstance : public BaseInstance {
|
|||||||
{
|
{
|
||||||
setVersionBroken(true);
|
setVersionBroken(true);
|
||||||
}
|
}
|
||||||
virtual ~NullInstance(){};
|
virtual ~NullInstance() {};
|
||||||
void saveNow() override {}
|
void saveNow() override {}
|
||||||
void loadSpecificSettings() override { setSpecificSettingsLoaded(true); }
|
void loadSpecificSettings() override { setSpecificSettingsLoaded(true); }
|
||||||
QString getStatusbarDescription() override { return tr("Unknown instance type"); };
|
QString getStatusbarDescription() override { return tr("Unknown instance type"); };
|
||||||
|
@ -14,7 +14,7 @@ class VersionProxyModel : public QAbstractProxyModel {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
VersionProxyModel(QObject* parent = 0);
|
VersionProxyModel(QObject* parent = 0);
|
||||||
virtual ~VersionProxyModel(){};
|
virtual ~VersionProxyModel() {};
|
||||||
|
|
||||||
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||||
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||||
|
@ -52,7 +52,7 @@ class IconList : public QAbstractListModel {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit IconList(const QStringList& builtinPaths, QString path, QObject* parent = 0);
|
explicit IconList(const QStringList& builtinPaths, QString path, QObject* parent = 0);
|
||||||
virtual ~IconList(){};
|
virtual ~IconList() {};
|
||||||
|
|
||||||
QIcon getIcon(const QString& key) const;
|
QIcon getIcon(const QString& key) const;
|
||||||
int getIconIndex(const QString& key) const;
|
int getIconIndex(const QString& key) const;
|
||||||
|
@ -26,8 +26,8 @@ using JavaCheckerJobPtr = shared_qobject_ptr<JavaCheckerJob>;
|
|||||||
class JavaCheckerJob : public Task {
|
class JavaCheckerJob : public Task {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit JavaCheckerJob(QString job_name) : Task(), m_job_name(job_name){};
|
explicit JavaCheckerJob(QString job_name) : Task(), m_job_name(job_name) {};
|
||||||
virtual ~JavaCheckerJob(){};
|
virtual ~JavaCheckerJob() {};
|
||||||
|
|
||||||
bool addJavaCheckerAction(JavaCheckerPtr base)
|
bool addJavaCheckerAction(JavaCheckerPtr base)
|
||||||
{
|
{
|
||||||
|
@ -79,11 +79,9 @@ QProcessEnvironment CleanEnviroment()
|
|||||||
|
|
||||||
QStringList stripped = {
|
QStringList stripped = {
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||||
"LD_LIBRARY_PATH",
|
"LD_LIBRARY_PATH", "LD_PRELOAD",
|
||||||
"LD_PRELOAD",
|
|
||||||
#endif
|
#endif
|
||||||
"QT_PLUGIN_PATH",
|
"QT_PLUGIN_PATH", "QT_FONTPATH"
|
||||||
"QT_FONTPATH"
|
|
||||||
};
|
};
|
||||||
for (auto key : rawenv.keys()) {
|
for (auto key : rawenv.keys()) {
|
||||||
auto value = rawenv.value(key);
|
auto value = rawenv.value(key);
|
||||||
@ -376,7 +374,19 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
auto home = qEnvironmentVariable("HOME");
|
auto home = qEnvironmentVariable("HOME");
|
||||||
|
|
||||||
// javas downloaded by sdkman
|
// javas downloaded by sdkman
|
||||||
javas.append(FS::PathCombine(home, ".sdkman/candidates/java"));
|
QDir sdkmanDir(FS::PathCombine(home, ".sdkman/candidates/java"));
|
||||||
|
QStringList sdkmanJavas = sdkmanDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
foreach (const QString& java, sdkmanJavas) {
|
||||||
|
javas.append(sdkmanDir.absolutePath() + "/" + java + "/bin/java");
|
||||||
|
}
|
||||||
|
|
||||||
|
// java in user library folder (like from intellij downloads)
|
||||||
|
QDir userLibraryJVMDir(FS::PathCombine(home, "Library/Java/JavaVirtualMachines/"));
|
||||||
|
QStringList userLibraryJVMJavas = userLibraryJVMDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
foreach (const QString& java, userLibraryJVMJavas) {
|
||||||
|
javas.append(userLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Home/bin/java");
|
||||||
|
javas.append(userLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Commands/java");
|
||||||
|
}
|
||||||
|
|
||||||
javas.append(getMinecraftJavaBundle());
|
javas.append(getMinecraftJavaBundle());
|
||||||
javas = addJavasFromEnv(javas);
|
javas = addJavasFromEnv(javas);
|
||||||
@ -415,6 +425,10 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
scanJavaDirs("/usr/lib/jvm");
|
scanJavaDirs("/usr/lib/jvm");
|
||||||
scanJavaDirs("/usr/lib64/jvm");
|
scanJavaDirs("/usr/lib64/jvm");
|
||||||
scanJavaDirs("/usr/lib32/jvm");
|
scanJavaDirs("/usr/lib32/jvm");
|
||||||
|
// Gentoo's locations for openjdk and openjdk-bin respectively
|
||||||
|
scanJavaDir("/usr/lib64");
|
||||||
|
scanJavaDir("/usr/lib");
|
||||||
|
scanJavaDir("/opt");
|
||||||
// javas stored in Prism Launcher's folder
|
// javas stored in Prism Launcher's folder
|
||||||
scanJavaDirs("java");
|
scanJavaDirs("java");
|
||||||
// manually installed JDKs in /opt
|
// manually installed JDKs in /opt
|
||||||
|
@ -25,7 +25,7 @@ class LaunchStep : public Task {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public: /* methods */
|
public: /* methods */
|
||||||
explicit LaunchStep(LaunchTask* parent) : Task(nullptr), m_parent(parent) { bind(parent); };
|
explicit LaunchStep(LaunchTask* parent) : Task(nullptr), m_parent(parent) { bind(parent); };
|
||||||
virtual ~LaunchStep(){};
|
virtual ~LaunchStep() {};
|
||||||
|
|
||||||
private: /* methods */
|
private: /* methods */
|
||||||
void bind(LaunchTask* parent);
|
void bind(LaunchTask* parent);
|
||||||
@ -37,9 +37,9 @@ class LaunchStep : public Task {
|
|||||||
void progressReportingRequest();
|
void progressReportingRequest();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void proceed(){};
|
virtual void proceed() {};
|
||||||
// called in the opposite order than the Task launch(), used to clean up or otherwise undo things after the launch ends
|
// called in the opposite order than the Task launch(), used to clean up or otherwise undo things after the launch ends
|
||||||
virtual void finalize(){};
|
virtual void finalize() {};
|
||||||
|
|
||||||
protected: /* data */
|
protected: /* data */
|
||||||
LaunchTask* m_parent;
|
LaunchTask* m_parent;
|
||||||
|
@ -55,7 +55,7 @@ class LaunchTask : public Task {
|
|||||||
|
|
||||||
public: /* methods */
|
public: /* methods */
|
||||||
static shared_qobject_ptr<LaunchTask> create(InstancePtr inst);
|
static shared_qobject_ptr<LaunchTask> create(InstancePtr inst);
|
||||||
virtual ~LaunchTask(){};
|
virtual ~LaunchTask() {};
|
||||||
|
|
||||||
void appendStep(shared_qobject_ptr<LaunchStep> step);
|
void appendStep(shared_qobject_ptr<LaunchStep> step);
|
||||||
void prependStep(shared_qobject_ptr<LaunchStep> step);
|
void prependStep(shared_qobject_ptr<LaunchStep> step);
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
class CheckJava : public LaunchStep {
|
class CheckJava : public LaunchStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CheckJava(LaunchTask* parent) : LaunchStep(parent){};
|
explicit CheckJava(LaunchTask* parent) : LaunchStep(parent) {};
|
||||||
virtual ~CheckJava(){};
|
virtual ~CheckJava() {};
|
||||||
|
|
||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
virtual bool canAbort() const { return false; }
|
virtual bool canAbort() const { return false; }
|
||||||
|
@ -25,7 +25,7 @@ class LookupServerAddress : public LaunchStep {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LookupServerAddress(LaunchTask* parent);
|
explicit LookupServerAddress(LaunchTask* parent);
|
||||||
virtual ~LookupServerAddress(){};
|
virtual ~LookupServerAddress() {};
|
||||||
|
|
||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
virtual bool abort();
|
virtual bool abort();
|
||||||
|
@ -22,7 +22,7 @@ class PostLaunchCommand : public LaunchStep {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PostLaunchCommand(LaunchTask* parent);
|
explicit PostLaunchCommand(LaunchTask* parent);
|
||||||
virtual ~PostLaunchCommand(){};
|
virtual ~PostLaunchCommand() {};
|
||||||
|
|
||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
virtual bool abort();
|
virtual bool abort();
|
||||||
|
@ -22,7 +22,7 @@ class PreLaunchCommand : public LaunchStep {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PreLaunchCommand(LaunchTask* parent);
|
explicit PreLaunchCommand(LaunchTask* parent);
|
||||||
virtual ~PreLaunchCommand(){};
|
virtual ~PreLaunchCommand() {};
|
||||||
|
|
||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
virtual bool abort();
|
virtual bool abort();
|
||||||
|
65
launcher/launch/steps/PrintServers.cpp
Normal file
65
launcher/launch/steps/PrintServers.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* Prism Launcher - Minecraft Launcher
|
||||||
|
* Copyright (c) 2024 Leia uwu <leia@tutamail.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 "PrintServers.h"
|
||||||
|
#include "QHostInfo"
|
||||||
|
|
||||||
|
PrintServers::PrintServers(LaunchTask* parent, const QStringList& servers) : LaunchStep(parent)
|
||||||
|
{
|
||||||
|
m_servers = servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintServers::executeTask()
|
||||||
|
{
|
||||||
|
for (QString server : m_servers) {
|
||||||
|
QHostInfo::lookupHost(server, this, &PrintServers::resolveServer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintServers::resolveServer(const QHostInfo& host_info)
|
||||||
|
{
|
||||||
|
QString server = host_info.hostName();
|
||||||
|
QString addresses = server + " resolves to:\n [";
|
||||||
|
|
||||||
|
if (!host_info.addresses().isEmpty()) {
|
||||||
|
for (QHostAddress address : host_info.addresses()) {
|
||||||
|
addresses += address.toString();
|
||||||
|
if (!host_info.addresses().endsWith(address)) {
|
||||||
|
addresses += ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addresses += "N/A";
|
||||||
|
}
|
||||||
|
addresses += "]\n\n";
|
||||||
|
|
||||||
|
m_server_to_address.insert(server, addresses);
|
||||||
|
|
||||||
|
// print server info in order once all servers are resolved
|
||||||
|
if (m_server_to_address.size() >= m_servers.size()) {
|
||||||
|
for (QString serv : m_servers) {
|
||||||
|
emit logLine(m_server_to_address.value(serv), MessageLevel::Launcher);
|
||||||
|
}
|
||||||
|
emitSucceeded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PrintServers::canAbort() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
37
launcher/launch/steps/PrintServers.h
Normal file
37
launcher/launch/steps/PrintServers.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* Prism Launcher - Minecraft Launcher
|
||||||
|
* Copyright (c) 2024 Leia uwu <leia@tutamail.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 <LoggedProcess.h>
|
||||||
|
#include <java/JavaChecker.h>
|
||||||
|
#include <launch/LaunchStep.h>
|
||||||
|
#include <QHostInfo>
|
||||||
|
|
||||||
|
class PrintServers : public LaunchStep {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
PrintServers(LaunchTask* parent, const QStringList& servers);
|
||||||
|
|
||||||
|
virtual void executeTask();
|
||||||
|
virtual bool canAbort() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void resolveServer(const QHostInfo& host_info);
|
||||||
|
QMap<QString, QString> m_server_to_address;
|
||||||
|
QStringList m_servers;
|
||||||
|
};
|
@ -23,8 +23,8 @@
|
|||||||
class QuitAfterGameStop : public LaunchStep {
|
class QuitAfterGameStop : public LaunchStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QuitAfterGameStop(LaunchTask* parent) : LaunchStep(parent){};
|
explicit QuitAfterGameStop(LaunchTask* parent) : LaunchStep(parent) {};
|
||||||
virtual ~QuitAfterGameStop(){};
|
virtual ~QuitAfterGameStop() {};
|
||||||
|
|
||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
virtual bool canAbort() const { return false; }
|
virtual bool canAbort() const { return false; }
|
||||||
|
@ -28,7 +28,7 @@ class TextPrint : public LaunchStep {
|
|||||||
public:
|
public:
|
||||||
explicit TextPrint(LaunchTask* parent, const QStringList& lines, MessageLevel::Enum level);
|
explicit TextPrint(LaunchTask* parent, const QStringList& lines, MessageLevel::Enum level);
|
||||||
explicit TextPrint(LaunchTask* parent, const QString& line, MessageLevel::Enum level);
|
explicit TextPrint(LaunchTask* parent, const QString& line, MessageLevel::Enum level);
|
||||||
virtual ~TextPrint(){};
|
virtual ~TextPrint() {};
|
||||||
|
|
||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
virtual bool canAbort() const;
|
virtual bool canAbort() const;
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
class Update : public LaunchStep {
|
class Update : public LaunchStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Update(LaunchTask* parent, Net::Mode mode) : LaunchStep(parent), m_mode(mode){};
|
explicit Update(LaunchTask* parent, Net::Mode mode) : LaunchStep(parent), m_mode(mode) {};
|
||||||
virtual ~Update(){};
|
virtual ~Update() {};
|
||||||
|
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
bool canAbort() const override;
|
bool canAbort() const override;
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
class ParsingValidator : public Net::Validator {
|
class ParsingValidator : public Net::Validator {
|
||||||
public: /* con/des */
|
public: /* con/des */
|
||||||
ParsingValidator(Meta::BaseEntity* entity) : m_entity(entity){};
|
ParsingValidator(Meta::BaseEntity* entity) : m_entity(entity) {};
|
||||||
virtual ~ParsingValidator(){};
|
virtual ~ParsingValidator() {};
|
||||||
|
|
||||||
public: /* methods */
|
public: /* methods */
|
||||||
bool init(QNetworkRequest&) override { return true; }
|
bool init(QNetworkRequest&) override { return true; }
|
||||||
|
@ -56,7 +56,7 @@ class MinecraftInstance : public BaseInstance {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir);
|
MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir);
|
||||||
virtual ~MinecraftInstance(){};
|
virtual ~MinecraftInstance() {};
|
||||||
virtual void saveNow() override;
|
virtual void saveNow() override;
|
||||||
|
|
||||||
void loadSpecificSettings() override;
|
void loadSpecificSettings() override;
|
||||||
|
@ -31,7 +31,7 @@ class MinecraftLoadAndCheck : public Task {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MinecraftLoadAndCheck(MinecraftInstance* inst, QObject* parent = 0);
|
explicit MinecraftLoadAndCheck(MinecraftInstance* inst, QObject* parent = 0);
|
||||||
virtual ~MinecraftLoadAndCheck(){};
|
virtual ~MinecraftLoadAndCheck() {};
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -33,7 +33,7 @@ class MinecraftUpdate : public Task {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MinecraftUpdate(MinecraftInstance* inst, QObject* parent = 0);
|
explicit MinecraftUpdate(MinecraftInstance* inst, QObject* parent = 0);
|
||||||
virtual ~MinecraftUpdate(){};
|
virtual ~MinecraftUpdate() {};
|
||||||
|
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
bool canAbort() const override;
|
bool canAbort() const override;
|
||||||
|
@ -27,7 +27,7 @@ class AuthStep : public QObject {
|
|||||||
public:
|
public:
|
||||||
using Ptr = shared_qobject_ptr<AuthStep>;
|
using Ptr = shared_qobject_ptr<AuthStep>;
|
||||||
|
|
||||||
explicit AuthStep(AccountData* data) : QObject(nullptr), m_data(data){};
|
explicit AuthStep(AccountData* data) : QObject(nullptr), m_data(data) {};
|
||||||
virtual ~AuthStep() noexcept = default;
|
virtual ~AuthStep() noexcept = default;
|
||||||
|
|
||||||
virtual QString describe() = 0;
|
virtual QString describe() = 0;
|
||||||
|
@ -22,7 +22,7 @@ class ClaimAccount : public LaunchStep {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ClaimAccount(LaunchTask* parent, AuthSessionPtr session);
|
explicit ClaimAccount(LaunchTask* parent, AuthSessionPtr session);
|
||||||
virtual ~ClaimAccount(){};
|
virtual ~ClaimAccount() {};
|
||||||
|
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
void finalize() override;
|
void finalize() override;
|
||||||
|
@ -24,7 +24,7 @@ class CreateGameFolders : public LaunchStep {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CreateGameFolders(LaunchTask* parent);
|
explicit CreateGameFolders(LaunchTask* parent);
|
||||||
virtual ~CreateGameFolders(){};
|
virtual ~CreateGameFolders() {};
|
||||||
|
|
||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
virtual bool canAbort() const { return false; }
|
virtual bool canAbort() const { return false; }
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
class ExtractNatives : public LaunchStep {
|
class ExtractNatives : public LaunchStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ExtractNatives(LaunchTask* parent) : LaunchStep(parent){};
|
explicit ExtractNatives(LaunchTask* parent) : LaunchStep(parent) {};
|
||||||
virtual ~ExtractNatives(){};
|
virtual ~ExtractNatives() {};
|
||||||
|
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
bool canAbort() const override { return false; }
|
bool canAbort() const override { return false; }
|
||||||
|
@ -178,6 +178,7 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state)
|
|||||||
APPLICATION->showMainWindow();
|
APPLICATION->showMainWindow();
|
||||||
|
|
||||||
m_parent->setPid(-1);
|
m_parent->setPid(-1);
|
||||||
|
m_parent->instance()->setMinecraftRunning(false);
|
||||||
// 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();
|
||||||
if (exitCode != 0) {
|
if (exitCode != 0) {
|
||||||
@ -193,7 +194,6 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state)
|
|||||||
case LoggedProcess::Running:
|
case LoggedProcess::Running:
|
||||||
emit logLine(QString("Minecraft process ID: %1\n\n").arg(m_process.processId()), MessageLevel::Launcher);
|
emit logLine(QString("Minecraft process ID: %1\n\n").arg(m_process.processId()), MessageLevel::Launcher);
|
||||||
m_parent->setPid(m_process.processId());
|
m_parent->setPid(m_process.processId());
|
||||||
m_parent->instance()->setLastLaunch();
|
|
||||||
// send the launch script to the launcher part
|
// send the launch script to the launcher part
|
||||||
m_process.write(m_launchScript.toUtf8());
|
m_process.write(m_launchScript.toUtf8());
|
||||||
|
|
||||||
@ -213,6 +213,7 @@ void LauncherPartLaunch::setWorkingDirectory(const QString& wd)
|
|||||||
void LauncherPartLaunch::proceed()
|
void LauncherPartLaunch::proceed()
|
||||||
{
|
{
|
||||||
if (mayProceed) {
|
if (mayProceed) {
|
||||||
|
m_parent->instance()->setMinecraftRunning(true);
|
||||||
QString launchString("launch\n");
|
QString launchString("launch\n");
|
||||||
m_process.write(launchString.toUtf8());
|
m_process.write(launchString.toUtf8());
|
||||||
mayProceed = false;
|
mayProceed = false;
|
||||||
|
@ -25,7 +25,7 @@ class LauncherPartLaunch : public LaunchStep {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LauncherPartLaunch(LaunchTask* parent);
|
explicit LauncherPartLaunch(LaunchTask* parent);
|
||||||
virtual ~LauncherPartLaunch(){};
|
virtual ~LauncherPartLaunch() {};
|
||||||
|
|
||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
virtual bool abort();
|
virtual bool abort();
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
class ModMinecraftJar : public LaunchStep {
|
class ModMinecraftJar : public LaunchStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ModMinecraftJar(LaunchTask* parent) : LaunchStep(parent){};
|
explicit ModMinecraftJar(LaunchTask* parent) : LaunchStep(parent) {};
|
||||||
virtual ~ModMinecraftJar(){};
|
virtual ~ModMinecraftJar() {};
|
||||||
|
|
||||||
virtual void executeTask() override;
|
virtual void executeTask() override;
|
||||||
virtual bool canAbort() const override { return false; }
|
virtual bool canAbort() const override { return false; }
|
||||||
|
@ -25,8 +25,8 @@ class PrintInstanceInfo : public LaunchStep {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PrintInstanceInfo(LaunchTask* parent, AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin)
|
explicit PrintInstanceInfo(LaunchTask* parent, AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin)
|
||||||
: LaunchStep(parent), m_session(session), m_serverToJoin(serverToJoin){};
|
: LaunchStep(parent), m_session(session), m_serverToJoin(serverToJoin) {};
|
||||||
virtual ~PrintInstanceInfo(){};
|
virtual ~PrintInstanceInfo() {};
|
||||||
|
|
||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
virtual bool canAbort() const { return false; }
|
virtual bool canAbort() const { return false; }
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
class ReconstructAssets : public LaunchStep {
|
class ReconstructAssets : public LaunchStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ReconstructAssets(LaunchTask* parent) : LaunchStep(parent){};
|
explicit ReconstructAssets(LaunchTask* parent) : LaunchStep(parent) {};
|
||||||
virtual ~ReconstructAssets(){};
|
virtual ~ReconstructAssets() {};
|
||||||
|
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
bool canAbort() const override { return false; }
|
bool canAbort() const override { return false; }
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
class ScanModFolders : public LaunchStep {
|
class ScanModFolders : public LaunchStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ScanModFolders(LaunchTask* parent) : LaunchStep(parent){};
|
explicit ScanModFolders(LaunchTask* parent) : LaunchStep(parent) {};
|
||||||
virtual ~ScanModFolders(){};
|
virtual ~ScanModFolders() {};
|
||||||
|
|
||||||
virtual void executeTask() override;
|
virtual void executeTask() override;
|
||||||
virtual bool canAbort() const override { return false; }
|
virtual bool canAbort() const override { return false; }
|
||||||
|
@ -42,7 +42,7 @@ class VerifyJavaInstall : public LaunchStep {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VerifyJavaInstall(LaunchTask* parent) : LaunchStep(parent){};
|
explicit VerifyJavaInstall(LaunchTask* parent) : LaunchStep(parent) {};
|
||||||
~VerifyJavaInstall() override = default;
|
~VerifyJavaInstall() override = default;
|
||||||
|
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
@ -282,8 +282,7 @@ void ResourceFolderModel::resolveResource(Resource* res)
|
|||||||
|
|
||||||
connect(
|
connect(
|
||||||
task.get(), &Task::succeeded, this, [=] { onParseSucceeded(ticket, res->internal_id()); }, Qt::ConnectionType::QueuedConnection);
|
task.get(), &Task::succeeded, this, [=] { onParseSucceeded(ticket, res->internal_id()); }, Qt::ConnectionType::QueuedConnection);
|
||||||
connect(
|
connect(task.get(), &Task::failed, this, [=] { onParseFailed(ticket, res->internal_id()); }, Qt::ConnectionType::QueuedConnection);
|
||||||
task.get(), &Task::failed, this, [=] { onParseFailed(ticket, res->internal_id()); }, Qt::ConnectionType::QueuedConnection);
|
|
||||||
connect(
|
connect(
|
||||||
task.get(), &Task::finished, this,
|
task.get(), &Task::finished, this,
|
||||||
[=] {
|
[=] {
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
#include "StringUtils.h"
|
|
||||||
#include "TexturePackFolderModel.h"
|
#include "TexturePackFolderModel.h"
|
||||||
|
|
||||||
#include "minecraft/mod/tasks/BasicFolderLoadTask.h"
|
#include "minecraft/mod/tasks/BasicFolderLoadTask.h"
|
||||||
|
@ -9,7 +9,7 @@ class FMLLibrariesTask : public Task {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FMLLibrariesTask(MinecraftInstance* inst);
|
FMLLibrariesTask(MinecraftInstance* inst);
|
||||||
virtual ~FMLLibrariesTask(){};
|
virtual ~FMLLibrariesTask() {};
|
||||||
|
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ class FoldersTask : public Task {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FoldersTask(MinecraftInstance* inst);
|
FoldersTask(MinecraftInstance* inst);
|
||||||
virtual ~FoldersTask(){};
|
virtual ~FoldersTask() {};
|
||||||
|
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ class LibrariesTask : public Task {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
LibrariesTask(MinecraftInstance* inst);
|
LibrariesTask(MinecraftInstance* inst);
|
||||||
virtual ~LibrariesTask(){};
|
virtual ~LibrariesTask() {};
|
||||||
|
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class CheckUpdateTask : public Task {
|
|||||||
std::list<Version>& mcVersions,
|
std::list<Version>& mcVersions,
|
||||||
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
std::optional<ModPlatform::ModLoaderTypes> loaders,
|
||||||
std::shared_ptr<ModFolderModel> mods_folder)
|
std::shared_ptr<ModFolderModel> mods_folder)
|
||||||
: Task(nullptr), m_mods(mods), m_game_versions(mcVersions), m_loaders(loaders), m_mods_folder(mods_folder){};
|
: Task(nullptr), m_mods(mods), m_game_versions(mcVersions), m_loaders(loaders), m_mods_folder(mods_folder) {};
|
||||||
|
|
||||||
struct UpdatableMod {
|
struct UpdatableMod {
|
||||||
QString name;
|
QString name;
|
||||||
|
@ -9,7 +9,7 @@ class FileResolvingTask : public Task {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit FileResolvingTask(const shared_qobject_ptr<QNetworkAccessManager>& network, Flame::Manifest& toProcess);
|
explicit FileResolvingTask(const shared_qobject_ptr<QNetworkAccessManager>& network, Flame::Manifest& toProcess);
|
||||||
virtual ~FileResolvingTask(){};
|
virtual ~FileResolvingTask() {};
|
||||||
|
|
||||||
bool canAbort() const override { return true; }
|
bool canAbort() const override { return true; }
|
||||||
bool abort() override;
|
bool abort() override;
|
||||||
|
@ -20,6 +20,9 @@ void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
|||||||
QJsonObject logo = Json::ensureObject(obj, "logo");
|
QJsonObject logo = Json::ensureObject(obj, "logo");
|
||||||
pack.logoName = Json::ensureString(logo, "title");
|
pack.logoName = Json::ensureString(logo, "title");
|
||||||
pack.logoUrl = Json::ensureString(logo, "thumbnailUrl");
|
pack.logoUrl = Json::ensureString(logo, "thumbnailUrl");
|
||||||
|
if (pack.logoUrl.isEmpty()) {
|
||||||
|
pack.logoUrl = Json::ensureString(logo, "url");
|
||||||
|
}
|
||||||
|
|
||||||
auto authors = Json::ensureArray(obj, "authors");
|
auto authors = Json::ensureArray(obj, "authors");
|
||||||
for (auto authorIter : authors) {
|
for (auto authorIter : authors) {
|
||||||
|
@ -13,7 +13,7 @@ class PackFetchTask : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PackFetchTask(shared_qobject_ptr<QNetworkAccessManager> network) : QObject(nullptr), m_network(network){};
|
PackFetchTask(shared_qobject_ptr<QNetworkAccessManager> network) : QObject(nullptr), m_network(network) {};
|
||||||
virtual ~PackFetchTask() = default;
|
virtual ~PackFetchTask() = default;
|
||||||
|
|
||||||
void fetch();
|
void fetch();
|
||||||
|
@ -131,8 +131,9 @@ void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack, QJsonArra
|
|||||||
pack.versionsLoaded = true;
|
pack.versionsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_type, QString preferred_file_name)
|
auto Modrinth::loadIndexedPackVersion(QJsonObject& obj,
|
||||||
-> ModPlatform::IndexedVersion
|
QString preferred_hash_type,
|
||||||
|
QString preferred_file_name) -> ModPlatform::IndexedVersion
|
||||||
{
|
{
|
||||||
ModPlatform::IndexedVersion file;
|
ModPlatform::IndexedVersion file;
|
||||||
|
|
||||||
@ -246,8 +247,9 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Modrinth::loadDependencyVersions([[maybe_unused]] const ModPlatform::Dependency& m, QJsonArray& arr, const BaseInstance* inst)
|
auto Modrinth::loadDependencyVersions([[maybe_unused]] const ModPlatform::Dependency& m,
|
||||||
-> ModPlatform::IndexedVersion
|
QJsonArray& arr,
|
||||||
|
const BaseInstance* inst) -> ModPlatform::IndexedVersion
|
||||||
{
|
{
|
||||||
auto profile = (dynamic_cast<const MinecraftInstance*>(inst))->getPackProfile();
|
auto profile = (dynamic_cast<const MinecraftInstance*>(inst))->getPackProfile();
|
||||||
QString mcVersion = profile->getComponentVersion("net.minecraft");
|
QString mcVersion = profile->getComponentVersion("net.minecraft");
|
||||||
|
@ -90,8 +90,9 @@ auto intEntry(toml::table table, QString entry_name) -> int
|
|||||||
return node.value_or(0);
|
return node.value_or(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto V1::createModFormat([[maybe_unused]] QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version)
|
auto V1::createModFormat([[maybe_unused]] QDir& index_dir,
|
||||||
-> Mod
|
ModPlatform::IndexedPack& mod_pack,
|
||||||
|
ModPlatform::IndexedVersion& mod_version) -> Mod
|
||||||
{
|
{
|
||||||
Mod mod;
|
Mod mod;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace Net {
|
|||||||
*/
|
*/
|
||||||
class ByteArraySink : public Sink {
|
class ByteArraySink : public Sink {
|
||||||
public:
|
public:
|
||||||
ByteArraySink(std::shared_ptr<QByteArray> output) : m_output(output){};
|
ByteArraySink(std::shared_ptr<QByteArray> output) : m_output(output) {};
|
||||||
|
|
||||||
virtual ~ByteArraySink() = default;
|
virtual ~ByteArraySink() = default;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ namespace Net {
|
|||||||
class ChecksumValidator : public Validator {
|
class ChecksumValidator : public Validator {
|
||||||
public:
|
public:
|
||||||
ChecksumValidator(QCryptographicHash::Algorithm algorithm, QByteArray expected = QByteArray())
|
ChecksumValidator(QCryptographicHash::Algorithm algorithm, QByteArray expected = QByteArray())
|
||||||
: m_checksum(algorithm), m_expected(expected){};
|
: m_checksum(algorithm), m_expected(expected) {};
|
||||||
virtual ~ChecksumValidator() = default;
|
virtual ~ChecksumValidator() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
namespace Net {
|
namespace Net {
|
||||||
class FileSink : public Sink {
|
class FileSink : public Sink {
|
||||||
public:
|
public:
|
||||||
FileSink(QString filename) : m_filename(filename){};
|
FileSink(QString filename) : m_filename(filename) {};
|
||||||
virtual ~FileSink() = default;
|
virtual ~FileSink() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -175,6 +175,8 @@ void HttpMetaCache::evictAll()
|
|||||||
if (!evictEntry(entry))
|
if (!evictEntry(entry))
|
||||||
qCWarning(taskHttpMetaCacheLogC) << "Unexpected missing cache entry" << entry->m_basePath;
|
qCWarning(taskHttpMetaCacheLogC) << "Unexpected missing cache entry" << entry->m_basePath;
|
||||||
}
|
}
|
||||||
|
map.entry_list.clear();
|
||||||
|
FS::deletePath(map.base_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ namespace Net {
|
|||||||
|
|
||||||
class StaticHeaderProxy : public HeaderProxy {
|
class StaticHeaderProxy : public HeaderProxy {
|
||||||
public:
|
public:
|
||||||
StaticHeaderProxy(QList<HeaderPair> hdrs = {}) : HeaderProxy(), m_hdrs(hdrs){};
|
StaticHeaderProxy(QList<HeaderPair> hdrs = {}) : HeaderProxy(), m_hdrs(hdrs) {};
|
||||||
virtual ~StaticHeaderProxy() = default;
|
virtual ~StaticHeaderProxy() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
class FSTreeMatcher : public IPathMatcher {
|
class FSTreeMatcher : public IPathMatcher {
|
||||||
public:
|
public:
|
||||||
virtual ~FSTreeMatcher(){};
|
virtual ~FSTreeMatcher() {};
|
||||||
FSTreeMatcher(SeparatorPrefixTree<'/'>& tree) : m_fsTree(tree) {}
|
FSTreeMatcher(SeparatorPrefixTree<'/'>& tree) : m_fsTree(tree) {}
|
||||||
|
|
||||||
bool matches(const QString& string) const override { return m_fsTree.covers(string); }
|
bool matches(const QString& string) const override { return m_fsTree.covers(string); }
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
class MultiMatcher : public IPathMatcher {
|
class MultiMatcher : public IPathMatcher {
|
||||||
public:
|
public:
|
||||||
virtual ~MultiMatcher(){};
|
virtual ~MultiMatcher() {};
|
||||||
MultiMatcher() {}
|
MultiMatcher() {}
|
||||||
MultiMatcher& add(Ptr add)
|
MultiMatcher& add(Ptr add)
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
class SimplePrefixMatcher : public IPathMatcher {
|
class SimplePrefixMatcher : public IPathMatcher {
|
||||||
public:
|
public:
|
||||||
virtual ~SimplePrefixMatcher(){};
|
virtual ~SimplePrefixMatcher() {};
|
||||||
SimplePrefixMatcher(const QString& prefix)
|
SimplePrefixMatcher(const QString& prefix)
|
||||||
{
|
{
|
||||||
m_prefix = prefix;
|
m_prefix = prefix;
|
||||||
|
@ -49,7 +49,7 @@ class ImgurAlbumCreation : public Net::NetRequest {
|
|||||||
|
|
||||||
class Sink : public Net::Sink {
|
class Sink : public Net::Sink {
|
||||||
public:
|
public:
|
||||||
Sink(std::shared_ptr<Result> res) : m_result(res){};
|
Sink(std::shared_ptr<Result> res) : m_result(res) {};
|
||||||
virtual ~Sink() = default;
|
virtual ~Sink() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -43,7 +43,7 @@ class ImgurUpload : public Net::NetRequest {
|
|||||||
public:
|
public:
|
||||||
class Sink : public Net::Sink {
|
class Sink : public Net::Sink {
|
||||||
public:
|
public:
|
||||||
Sink(ScreenShot::Ptr shot) : m_shot(shot){};
|
Sink(ScreenShot::Ptr shot) : m_shot(shot) {};
|
||||||
virtual ~Sink() = default;
|
virtual ~Sink() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
class GenericProfilerFactory : public BaseProfilerFactory {
|
class GenericProfilerFactory : public BaseProfilerFactory {
|
||||||
public:
|
public:
|
||||||
QString name() const override { return "Generic"; }
|
QString name() const override { return "Generic"; }
|
||||||
void registerSettings([[maybe_unused]] SettingsObjectPtr settings) override{};
|
void registerSettings([[maybe_unused]] SettingsObjectPtr settings) override {};
|
||||||
BaseExternalTool* createTool(InstancePtr instance, QObject* parent = 0) override;
|
BaseExternalTool* createTool(InstancePtr instance, QObject* parent = 0) override;
|
||||||
bool check([[maybe_unused]] QString* error) override { return true; };
|
bool check([[maybe_unused]] QString* error) override { return true; };
|
||||||
bool check([[maybe_unused]] const QString& path, [[maybe_unused]] QString* error) override { return true; };
|
bool check([[maybe_unused]] const QString& path, [[maybe_unused]] QString* error) override { return true; };
|
||||||
|
@ -1568,7 +1568,7 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
|
|||||||
QFileDialog fileDialog;
|
QFileDialog fileDialog;
|
||||||
// workaround to make sure the portal file dialog opens in the desktop directory
|
// workaround to make sure the portal file dialog opens in the desktop directory
|
||||||
fileDialog.setDirectoryUrl(desktopPath);
|
fileDialog.setDirectoryUrl(desktopPath);
|
||||||
desktopFilePath = fileDialog.getSaveFileName(this, tr("Create Shortcut"), desktopFilePath, tr("Desktop Entries (*.desktop)"));
|
desktopFilePath = fileDialog.getSaveFileName(this, tr("Create Shortcut"), desktopFilePath, tr("Desktop Entries") + " (*.desktop)");
|
||||||
if (desktopFilePath.isEmpty())
|
if (desktopFilePath.isEmpty())
|
||||||
return; // file dialog canceled by user
|
return; // file dialog canceled by user
|
||||||
appPath = "flatpak";
|
appPath = "flatpak";
|
||||||
|
@ -129,14 +129,14 @@ void ExportPackDialog::done(int result)
|
|||||||
QString output;
|
QString output;
|
||||||
if (m_provider == ModPlatform::ResourceProvider::MODRINTH) {
|
if (m_provider == ModPlatform::ResourceProvider::MODRINTH) {
|
||||||
output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(name), FS::PathCombine(QDir::homePath(), filename + ".mrpack"),
|
output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(name), FS::PathCombine(QDir::homePath(), filename + ".mrpack"),
|
||||||
"Modrinth pack (*.mrpack *.zip)", nullptr);
|
tr("Modrinth pack") + " (*.mrpack *.zip)", nullptr);
|
||||||
if (output.isEmpty())
|
if (output.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (!(output.endsWith(".zip") || output.endsWith(".mrpack")))
|
if (!(output.endsWith(".zip") || output.endsWith(".mrpack")))
|
||||||
output.append(".mrpack");
|
output.append(".mrpack");
|
||||||
} else {
|
} else {
|
||||||
output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(name), FS::PathCombine(QDir::homePath(), filename + ".zip"),
|
output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(name), FS::PathCombine(QDir::homePath(), filename + ".zip"),
|
||||||
"CurseForge pack (*.zip)", nullptr);
|
tr("CurseForge pack") + " (*.zip)", nullptr);
|
||||||
if (output.isEmpty())
|
if (output.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (!output.endsWith(".zip"))
|
if (!output.endsWith(".zip"))
|
||||||
|
@ -160,7 +160,7 @@ void ExportToModListDialog::done(int result)
|
|||||||
const QString filename = FS::RemoveInvalidFilenameChars(m_name);
|
const QString filename = FS::RemoveInvalidFilenameChars(m_name);
|
||||||
const QString output =
|
const QString output =
|
||||||
QFileDialog::getSaveFileName(this, tr("Export %1").arg(m_name), FS::PathCombine(QDir::homePath(), filename + extension()),
|
QFileDialog::getSaveFileName(this, tr("Export %1").arg(m_name), FS::PathCombine(QDir::homePath(), filename + extension()),
|
||||||
"File (*.txt *.html *.md *.json *.csv)", nullptr);
|
tr("File") + " (*.txt *.html *.md *.json *.csv)", nullptr);
|
||||||
|
|
||||||
if (output.isEmpty())
|
if (output.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -92,17 +92,15 @@ void ModUpdateDialog::checkCandidates()
|
|||||||
|
|
||||||
if (!m_modrinth_to_update.empty()) {
|
if (!m_modrinth_to_update.empty()) {
|
||||||
m_modrinth_check_task.reset(new ModrinthCheckUpdate(m_modrinth_to_update, versions, loaders, m_mod_model));
|
m_modrinth_check_task.reset(new ModrinthCheckUpdate(m_modrinth_to_update, versions, loaders, m_mod_model));
|
||||||
connect(m_modrinth_check_task.get(), &CheckUpdateTask::checkFailed, this, [this](Mod* mod, QString reason, QUrl recover_url) {
|
connect(m_modrinth_check_task.get(), &CheckUpdateTask::checkFailed, this,
|
||||||
m_failed_check_update.append({ mod, reason, recover_url });
|
[this](Mod* mod, QString reason, QUrl recover_url) { m_failed_check_update.append({ mod, reason, recover_url }); });
|
||||||
});
|
|
||||||
check_task.addTask(m_modrinth_check_task);
|
check_task.addTask(m_modrinth_check_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_flame_to_update.empty()) {
|
if (!m_flame_to_update.empty()) {
|
||||||
m_flame_check_task.reset(new FlameCheckUpdate(m_flame_to_update, versions, loaders, m_mod_model));
|
m_flame_check_task.reset(new FlameCheckUpdate(m_flame_to_update, versions, loaders, m_mod_model));
|
||||||
connect(m_flame_check_task.get(), &CheckUpdateTask::checkFailed, this, [this](Mod* mod, QString reason, QUrl recover_url) {
|
connect(m_flame_check_task.get(), &CheckUpdateTask::checkFailed, this,
|
||||||
m_failed_check_update.append({ mod, reason, recover_url });
|
[this](Mod* mod, QString reason, QUrl recover_url) { m_failed_check_update.append({ mod, reason, recover_url }); });
|
||||||
});
|
|
||||||
check_task.addTask(m_flame_check_task);
|
check_task.addTask(m_flame_check_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ void NewInstanceDialog::setSuggestedPack(const QString& name, InstanceTask* task
|
|||||||
importVersion.clear();
|
importVersion.clear();
|
||||||
|
|
||||||
if (!task) {
|
if (!task) {
|
||||||
ui->iconButton->setIcon(APPLICATION->icons()->getIcon("default"));
|
ui->iconButton->setIcon(APPLICATION->icons()->getIcon(InstIconKey));
|
||||||
importIcon = false;
|
importIcon = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ void NewInstanceDialog::setSuggestedPack(const QString& name, QString version, I
|
|||||||
importVersion = std::move(version);
|
importVersion = std::move(version);
|
||||||
|
|
||||||
if (!task) {
|
if (!task) {
|
||||||
ui->iconButton->setIcon(APPLICATION->icons()->getIcon("default"));
|
ui->iconButton->setIcon(APPLICATION->icons()->getIcon(InstIconKey));
|
||||||
importIcon = false;
|
importIcon = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,6 +236,9 @@ void NewInstanceDialog::setSuggestedIconFromFile(const QString& path, const QStr
|
|||||||
|
|
||||||
void NewInstanceDialog::setSuggestedIcon(const QString& key)
|
void NewInstanceDialog::setSuggestedIcon(const QString& key)
|
||||||
{
|
{
|
||||||
|
if (key == "default")
|
||||||
|
return;
|
||||||
|
|
||||||
auto icon = APPLICATION->icons()->getIcon(key);
|
auto icon = APPLICATION->icons()->getIcon(key);
|
||||||
importIcon = false;
|
importIcon = false;
|
||||||
|
|
||||||
|
@ -92,6 +92,19 @@ void ResourceDownloadDialog::accept()
|
|||||||
|
|
||||||
void ResourceDownloadDialog::reject()
|
void ResourceDownloadDialog::reject()
|
||||||
{
|
{
|
||||||
|
auto selected = getTasks();
|
||||||
|
if (selected.count() > 0) {
|
||||||
|
auto reply = CustomMessageBox::selectable(this, tr("Confirmation Needed"),
|
||||||
|
tr("You have %1 selected resources.\n"
|
||||||
|
"Are you sure you want to close this dialog?")
|
||||||
|
.arg(selected.count()),
|
||||||
|
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||||
|
->exec();
|
||||||
|
if (reply != QMessageBox::Yes) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!geometrySaveKey().isEmpty())
|
if (!geometrySaveKey().isEmpty())
|
||||||
APPLICATION->settings()->set(geometrySaveKey(), saveGeometry().toBase64());
|
APPLICATION->settings()->set(geometrySaveKey(), saveGeometry().toBase64());
|
||||||
|
|
||||||
@ -356,4 +369,20 @@ QList<BasePage*> ShaderPackDownloadDialog::getPages()
|
|||||||
return pages;
|
return pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModDownloadDialog::setModMetadata(std::shared_ptr<Metadata::ModStruct> meta)
|
||||||
|
{
|
||||||
|
switch (meta->provider) {
|
||||||
|
case ModPlatform::ResourceProvider::MODRINTH:
|
||||||
|
selectPage(Modrinth::id());
|
||||||
|
break;
|
||||||
|
case ModPlatform::ResourceProvider::FLAME:
|
||||||
|
selectPage(Flame::id());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setWindowTitle(tr("Change %1 version").arg(meta->name));
|
||||||
|
m_container->hidePageList();
|
||||||
|
m_buttons.hide();
|
||||||
|
auto page = selectedPage();
|
||||||
|
page->openProject(meta->project_id);
|
||||||
|
}
|
||||||
} // namespace ResourceDownload
|
} // namespace ResourceDownload
|
||||||
|
@ -107,6 +107,8 @@ class ModDownloadDialog final : public ResourceDownloadDialog {
|
|||||||
QList<BasePage*> getPages() override;
|
QList<BasePage*> getPages() override;
|
||||||
GetModDependenciesTask::Ptr getModDependenciesTask() override;
|
GetModDependenciesTask::Ptr getModDependenciesTask() override;
|
||||||
|
|
||||||
|
void setModMetadata(std::shared_ptr<Metadata::ModStruct>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BaseInstance* m_instance;
|
BaseInstance* m_instance;
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,7 @@ class VersionSelectDialog : public QDialog {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VersionSelectDialog(BaseVersionList* vlist, QString title, QWidget* parent = 0, bool cancelable = true);
|
explicit VersionSelectDialog(BaseVersionList* vlist, QString title, QWidget* parent = 0, bool cancelable = true);
|
||||||
virtual ~VersionSelectDialog(){};
|
virtual ~VersionSelectDialog() {};
|
||||||
|
|
||||||
int exec() override;
|
int exec() override;
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ void SkinManageDialog::selectionChanged(QItemSelection selected, QItemSelection
|
|||||||
auto skin = m_list.skin(key);
|
auto skin = m_list.skin(key);
|
||||||
if (!skin)
|
if (!skin)
|
||||||
return;
|
return;
|
||||||
ui->selectedModel->setPixmap(skin->getTexture().scaled(128, 128, Qt::KeepAspectRatio, Qt::FastTransformation));
|
ui->selectedModel->setPixmap(skin->getTexture().scaled(size() * (1. / 3), Qt::KeepAspectRatio, Qt::FastTransformation));
|
||||||
ui->capeCombo->setCurrentIndex(m_capes_idx.value(skin->getCapeId()));
|
ui->capeCombo->setCurrentIndex(m_capes_idx.value(skin->getCapeId()));
|
||||||
ui->steveBtn->setChecked(skin->getModel() == SkinModel::CLASSIC);
|
ui->steveBtn->setChecked(skin->getModel() == SkinModel::CLASSIC);
|
||||||
ui->alexBtn->setChecked(skin->getModel() == SkinModel::SLIM);
|
ui->alexBtn->setChecked(skin->getModel() == SkinModel::SLIM);
|
||||||
@ -212,7 +212,7 @@ void SkinManageDialog::setupCapes()
|
|||||||
void SkinManageDialog::on_capeCombo_currentIndexChanged(int index)
|
void SkinManageDialog::on_capeCombo_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
auto id = ui->capeCombo->currentData();
|
auto id = ui->capeCombo->currentData();
|
||||||
ui->capeImage->setPixmap(m_capes.value(id.toString(), {}));
|
ui->capeImage->setPixmap(m_capes.value(id.toString(), {}).scaled(size() * (1. / 3), Qt::KeepAspectRatio, Qt::FastTransformation));
|
||||||
if (auto skin = m_list.skin(m_selected_skin); skin) {
|
if (auto skin = m_list.skin(m_selected_skin); skin) {
|
||||||
skin->setCapeId(id.toString());
|
skin->setCapeId(id.toString());
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ void SkinManageDialog::on_urlBtn_clicked()
|
|||||||
|
|
||||||
class WaitTask : public Task {
|
class WaitTask : public Task {
|
||||||
public:
|
public:
|
||||||
WaitTask() : m_loop(), m_done(false){};
|
WaitTask() : m_loop(), m_done(false) {};
|
||||||
virtual ~WaitTask() = default;
|
virtual ~WaitTask() = default;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -498,3 +498,15 @@ void SkinManageDialog::on_userBtn_clicked()
|
|||||||
}
|
}
|
||||||
m_list.updateSkin(&s);
|
m_list.updateSkin(&s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkinManageDialog::resizeEvent(QResizeEvent* event)
|
||||||
|
{
|
||||||
|
QWidget::resizeEvent(event);
|
||||||
|
QSize s = size() * (1. / 3);
|
||||||
|
|
||||||
|
if (auto skin = m_list.skin(m_selected_skin); skin) {
|
||||||
|
ui->selectedModel->setPixmap(skin->getTexture().scaled(s, Qt::KeepAspectRatio, Qt::FastTransformation));
|
||||||
|
}
|
||||||
|
auto id = ui->capeCombo->currentData();
|
||||||
|
ui->capeImage->setPixmap(m_capes.value(id.toString(), {}).scaled(s, Qt::KeepAspectRatio, Qt::FastTransformation));
|
||||||
|
}
|
||||||
|
@ -34,6 +34,7 @@ class SkinManageDialog : public QDialog {
|
|||||||
public:
|
public:
|
||||||
explicit SkinManageDialog(QWidget* parent, MinecraftAccountPtr acct);
|
explicit SkinManageDialog(QWidget* parent, MinecraftAccountPtr acct);
|
||||||
virtual ~SkinManageDialog();
|
virtual ~SkinManageDialog();
|
||||||
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void selectionChanged(QItemSelection, QItemSelection);
|
void selectionChanged(QItemSelection, QItemSelection);
|
||||||
|
@ -24,7 +24,10 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
<property name="scaledContents">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -75,7 +78,10 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
<property name="scaledContents">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -4,7 +4,7 @@ class BasePage;
|
|||||||
|
|
||||||
class BasePageContainer {
|
class BasePageContainer {
|
||||||
public:
|
public:
|
||||||
virtual ~BasePageContainer(){};
|
virtual ~BasePageContainer() {};
|
||||||
virtual bool selectPage(QString pageId) = 0;
|
virtual bool selectPage(QString pageId) = 0;
|
||||||
virtual BasePage* selectedPage() const = 0;
|
virtual BasePage* selectedPage() const = 0;
|
||||||
virtual BasePage* getPage(QString pageId) { return nullptr; };
|
virtual BasePage* getPage(QString pageId) { return nullptr; };
|
||||||
|
@ -371,7 +371,7 @@ void ModrinthManagedPackPage::update()
|
|||||||
|
|
||||||
void ModrinthManagedPackPage::updateFromFile()
|
void ModrinthManagedPackPage::updateFromFile()
|
||||||
{
|
{
|
||||||
auto output = QFileDialog::getOpenFileUrl(this, tr("Choose update file"), QDir::homePath(), "Modrinth pack (*.mrpack *.zip)");
|
auto output = QFileDialog::getOpenFileUrl(this, tr("Choose update file"), QDir::homePath(), tr("Modrinth pack") + " (*.mrpack *.zip)");
|
||||||
if (output.isEmpty())
|
if (output.isEmpty())
|
||||||
return;
|
return;
|
||||||
QMap<QString, QString> extra_info;
|
QMap<QString, QString> extra_info;
|
||||||
@ -538,7 +538,7 @@ void FlameManagedPackPage::update()
|
|||||||
|
|
||||||
void FlameManagedPackPage::updateFromFile()
|
void FlameManagedPackPage::updateFromFile()
|
||||||
{
|
{
|
||||||
auto output = QFileDialog::getOpenFileUrl(this, tr("Choose update file"), QDir::homePath(), "CurseForge pack (*.zip)");
|
auto output = QFileDialog::getOpenFileUrl(this, tr("Choose update file"), QDir::homePath(), tr("CurseForge pack") + " (*.zip)");
|
||||||
if (output.isEmpty())
|
if (output.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class ManagedPackPage : public QWidget, public BasePage {
|
|||||||
|
|
||||||
/** Gets the necessary information about the managed pack, such as
|
/** Gets the necessary information about the managed pack, such as
|
||||||
* available versions*/
|
* available versions*/
|
||||||
virtual void parseManagedPack(){};
|
virtual void parseManagedPack() {};
|
||||||
|
|
||||||
/** URL of the managed pack.
|
/** URL of the managed pack.
|
||||||
* Not the version-specific one.
|
* Not the version-specific one.
|
||||||
@ -64,8 +64,8 @@ class ManagedPackPage : public QWidget, public BasePage {
|
|||||||
*/
|
*/
|
||||||
virtual void suggestVersion();
|
virtual void suggestVersion();
|
||||||
|
|
||||||
virtual void update(){};
|
virtual void update() {};
|
||||||
virtual void updateFromFile(){};
|
virtual void updateFromFile() {};
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
/** Does the necessary UI changes for when something failed.
|
/** Does the necessary UI changes for when something failed.
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "ui_ExternalResourcesPage.h"
|
#include "ui_ExternalResourcesPage.h"
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
#include <QAction>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
@ -122,13 +123,19 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
|
|||||||
ui->actionsToolbar->addAction(ui->actionVisitItemPage);
|
ui->actionsToolbar->addAction(ui->actionVisitItemPage);
|
||||||
connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);
|
connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);
|
||||||
|
|
||||||
|
auto changeVersion = new QAction(tr("Change Version"));
|
||||||
|
changeVersion->setToolTip(tr("Change mod version"));
|
||||||
|
changeVersion->setEnabled(false);
|
||||||
|
ui->actionsToolbar->insertActionAfter(ui->actionUpdateItem, changeVersion);
|
||||||
|
connect(changeVersion, &QAction::triggered, this, &ModFolderPage::changeModVersion);
|
||||||
|
|
||||||
ui->actionsToolbar->insertActionAfter(ui->actionVisitItemPage, ui->actionExportMetadata);
|
ui->actionsToolbar->insertActionAfter(ui->actionVisitItemPage, ui->actionExportMetadata);
|
||||||
connect(ui->actionExportMetadata, &QAction::triggered, this, &ModFolderPage::exportModMetadata);
|
connect(ui->actionExportMetadata, &QAction::triggered, this, &ModFolderPage::exportModMetadata);
|
||||||
|
|
||||||
auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); };
|
auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); };
|
||||||
|
|
||||||
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||||
[this, check_allow_update, actionRemoveItemMetadata] {
|
[this, check_allow_update, actionRemoveItemMetadata, changeVersion] {
|
||||||
ui->actionUpdateItem->setEnabled(check_allow_update());
|
ui->actionUpdateItem->setEnabled(check_allow_update());
|
||||||
|
|
||||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
||||||
@ -138,11 +145,12 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
|
|||||||
if (selected <= 1) {
|
if (selected <= 1) {
|
||||||
ui->actionVisitItemPage->setText(tr("Visit mod's page"));
|
ui->actionVisitItemPage->setText(tr("Visit mod's page"));
|
||||||
ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
|
ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ui->actionVisitItemPage->setText(tr("Visit mods' pages"));
|
ui->actionVisitItemPage->setText(tr("Visit mods' pages"));
|
||||||
ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods"));
|
ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeVersion->setEnabled(mods_list.length() == 1 && mods_list[0]->metadata() != nullptr);
|
||||||
ui->actionVisitItemPage->setEnabled(selected != 0);
|
ui->actionVisitItemPage->setEnabled(selected != 0);
|
||||||
actionRemoveItemMetadata->setEnabled(selected != 0);
|
actionRemoveItemMetadata->setEnabled(selected != 0);
|
||||||
});
|
});
|
||||||
@ -377,6 +385,57 @@ void ModFolderPage::deleteModMetadata()
|
|||||||
m_model->deleteModsMetadata(selection);
|
m_model->deleteModsMetadata(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModFolderPage::changeModVersion()
|
||||||
|
{
|
||||||
|
if (m_instance->typeName() != "Minecraft")
|
||||||
|
return; // this is a null instance or a legacy instance
|
||||||
|
|
||||||
|
auto profile = static_cast<MinecraftInstance*>(m_instance)->getPackProfile();
|
||||||
|
if (!profile->getModLoaders().has_value()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Mod updates are unavailable when metadata is disabled!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
||||||
|
auto mods_list = m_model->selectedMods(selection);
|
||||||
|
if (mods_list.length() != 1 || mods_list[0]->metadata() == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ResourceDownload::ModDownloadDialog mdownload(this, m_model, m_instance);
|
||||||
|
mdownload.setModMetadata((*mods_list.begin())->metadata());
|
||||||
|
if (mdownload.exec()) {
|
||||||
|
auto tasks = new ConcurrentTask(this, "Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
|
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||||
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
connect(tasks, &Task::aborted, [this, tasks]() {
|
||||||
|
CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show();
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
connect(tasks, &Task::succeeded, [this, tasks]() {
|
||||||
|
QStringList warnings = tasks->warnings();
|
||||||
|
if (warnings.count())
|
||||||
|
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
||||||
|
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto& task : mdownload.getTasks()) {
|
||||||
|
tasks->addTask(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressDialog loadDialog(this);
|
||||||
|
loadDialog.setSkipButton(true, tr("Abort"));
|
||||||
|
loadDialog.execWithTask(tasks);
|
||||||
|
|
||||||
|
m_model->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ModFolderPage::exportModMetadata()
|
void ModFolderPage::exportModMetadata()
|
||||||
{
|
{
|
||||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
||||||
|
@ -67,6 +67,7 @@ class ModFolderPage : public ExternalResourcesPage {
|
|||||||
void installMods();
|
void installMods();
|
||||||
void updateMods(bool includeDeps = false);
|
void updateMods(bool includeDeps = false);
|
||||||
void visitModPages();
|
void visitModPages();
|
||||||
|
void changeModVersion();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<ModFolderModel> m_model;
|
std::shared_ptr<ModFolderModel> m_model;
|
||||||
|
@ -168,7 +168,7 @@ class ServersModel : public QAbstractListModel {
|
|||||||
m_saveTimer.setInterval(5000);
|
m_saveTimer.setInterval(5000);
|
||||||
connect(&m_saveTimer, &QTimer::timeout, this, &ServersModel::save_internal);
|
connect(&m_saveTimer, &QTimer::timeout, this, &ServersModel::save_internal);
|
||||||
}
|
}
|
||||||
virtual ~ServersModel(){};
|
virtual ~ServersModel() {};
|
||||||
|
|
||||||
void observe()
|
void observe()
|
||||||
{
|
{
|
||||||
|
@ -297,7 +297,7 @@ void VersionPage::on_actionRemove_triggered()
|
|||||||
|
|
||||||
void VersionPage::on_actionAdd_to_Minecraft_jar_triggered()
|
void VersionPage::on_actionAdd_to_Minecraft_jar_triggered()
|
||||||
{
|
{
|
||||||
auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"),
|
auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods") + " (*.zip *.jar)",
|
||||||
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
||||||
if (!list.empty()) {
|
if (!list.empty()) {
|
||||||
m_profile->installJarMods(list);
|
m_profile->installJarMods(list);
|
||||||
@ -307,7 +307,7 @@ void VersionPage::on_actionAdd_to_Minecraft_jar_triggered()
|
|||||||
|
|
||||||
void VersionPage::on_actionReplace_Minecraft_jar_triggered()
|
void VersionPage::on_actionReplace_Minecraft_jar_triggered()
|
||||||
{
|
{
|
||||||
auto jarPath = GuiUtil::BrowseForFile("jar", tr("Select jar"), tr("Minecraft.jar replacement (*.jar)"),
|
auto jarPath = GuiUtil::BrowseForFile("jar", tr("Select jar"), tr("Minecraft.jar replacement") + " (*.jar)",
|
||||||
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
||||||
if (!jarPath.isEmpty()) {
|
if (!jarPath.isEmpty()) {
|
||||||
m_profile->installCustomJar(jarPath);
|
m_profile->installCustomJar(jarPath);
|
||||||
@ -317,7 +317,7 @@ void VersionPage::on_actionReplace_Minecraft_jar_triggered()
|
|||||||
|
|
||||||
void VersionPage::on_actionImport_Components_triggered()
|
void VersionPage::on_actionImport_Components_triggered()
|
||||||
{
|
{
|
||||||
QStringList list = GuiUtil::BrowseForFiles("component", tr("Select components"), tr("Components (*.json)"),
|
QStringList list = GuiUtil::BrowseForFiles("component", tr("Select components"), tr("Components") + " (*.json)",
|
||||||
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
||||||
|
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
@ -332,7 +332,7 @@ void VersionPage::on_actionImport_Components_triggered()
|
|||||||
|
|
||||||
void VersionPage::on_actionAdd_Agents_triggered()
|
void VersionPage::on_actionAdd_Agents_triggered()
|
||||||
{
|
{
|
||||||
QStringList list = GuiUtil::BrowseForFiles("agent", tr("Select agents"), tr("Java agents (*.jar)"),
|
QStringList list = GuiUtil::BrowseForFiles("agent", tr("Select agents"), tr("Java agents") + " (*.jar)",
|
||||||
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
||||||
|
|
||||||
if (!list.isEmpty())
|
if (!list.isEmpty())
|
||||||
|
@ -343,7 +343,7 @@ void WorldListPage::worldChanged([[maybe_unused]] const QModelIndex& current, [[
|
|||||||
|
|
||||||
void WorldListPage::on_actionAdd_triggered()
|
void WorldListPage::on_actionAdd_triggered()
|
||||||
{
|
{
|
||||||
auto list = GuiUtil::BrowseForFiles(displayName(), tr("Select a Minecraft world zip"), tr("Minecraft World Zip File (*.zip)"),
|
auto list = GuiUtil::BrowseForFiles(displayName(), tr("Select a Minecraft world zip"), tr("Minecraft World Zip File") + " (*.zip)",
|
||||||
QString(), this->parentWidget());
|
QString(), this->parentWidget());
|
||||||
if (!list.empty()) {
|
if (!list.empty()) {
|
||||||
m_worlds->stopWatching();
|
m_worlds->stopWatching();
|
||||||
|
@ -88,6 +88,17 @@ bool ModModel::isPackInstalled(ModPlatform::IndexedPack::Ptr pack) const
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant ModModel::getInstalledPackVersion(ModPlatform::IndexedPack::Ptr pack) const
|
||||||
|
{
|
||||||
|
auto allMods = static_cast<MinecraftInstance&>(m_base_instance).loaderModList()->allMods();
|
||||||
|
for (auto mod : allMods) {
|
||||||
|
if (auto meta = mod->metadata(); meta && meta->provider == pack->provider && meta->project_id == pack->addonId) {
|
||||||
|
return meta->version();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
bool checkSide(QString filter, QString value)
|
bool checkSide(QString filter, QString value)
|
||||||
{
|
{
|
||||||
return filter.isEmpty() || value.isEmpty() || filter == "both" || value == "both" || filter == value;
|
return filter.isEmpty() || value.isEmpty() || filter == "both" || value == "both" || filter == value;
|
||||||
|
@ -35,6 +35,7 @@ class ModModel : public ResourceModel {
|
|||||||
virtual ModPlatform::IndexedVersion loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) = 0;
|
virtual ModPlatform::IndexedVersion loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) = 0;
|
||||||
|
|
||||||
void setFilter(std::shared_ptr<ModFilterWidget::Filter> filter) { m_filter = filter; }
|
void setFilter(std::shared_ptr<ModFilterWidget::Filter> filter) { m_filter = filter; }
|
||||||
|
virtual QVariant getInstalledPackVersion(ModPlatform::IndexedPack::Ptr) const override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
ResourceAPI::SearchArgs createSearchArguments() override;
|
ResourceAPI::SearchArgs createSearchArguments() override;
|
||||||
|
@ -59,7 +59,7 @@ class ModPage : public ResourcePage {
|
|||||||
protected:
|
protected:
|
||||||
ModPage(ModDownloadDialog* dialog, BaseInstance& instance);
|
ModPage(ModDownloadDialog* dialog, BaseInstance& instance);
|
||||||
|
|
||||||
virtual void prepareProviderCategories(){};
|
virtual void prepareProviderCategories() {};
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void filterMods();
|
virtual void filterMods();
|
||||||
|
@ -56,6 +56,7 @@ class ResourceModel : public QAbstractListModel {
|
|||||||
|
|
||||||
[[nodiscard]] auto getSortingMethods() const { return m_api->getSortingMethods(); }
|
[[nodiscard]] auto getSortingMethods() const { return m_api->getSortingMethods(); }
|
||||||
|
|
||||||
|
virtual QVariant getInstalledPackVersion(ModPlatform::IndexedPack::Ptr) const { return {}; }
|
||||||
/** Whether the version is opted out or not. Currently only makes sense in CF. */
|
/** Whether the version is opted out or not. Currently only makes sense in CF. */
|
||||||
virtual bool optedOut(const ModPlatform::IndexedVersion& ver) const
|
virtual bool optedOut(const ModPlatform::IndexedVersion& ver) const
|
||||||
{
|
{
|
||||||
|
@ -271,7 +271,9 @@ void ResourcePage::updateVersionList()
|
|||||||
m_ui->versionSelectionBox->clear();
|
m_ui->versionSelectionBox->clear();
|
||||||
m_ui->versionSelectionBox->blockSignals(false);
|
m_ui->versionSelectionBox->blockSignals(false);
|
||||||
|
|
||||||
if (current_pack)
|
if (current_pack) {
|
||||||
|
auto installedVersion = m_model->getInstalledPackVersion(current_pack);
|
||||||
|
|
||||||
for (int i = 0; i < current_pack->versions.size(); i++) {
|
for (int i = 0; i < current_pack->versions.size(); i++) {
|
||||||
auto& version = current_pack->versions[i];
|
auto& version = current_pack->versions[i];
|
||||||
if (!m_model->checkVersionFilters(version))
|
if (!m_model->checkVersionFilters(version))
|
||||||
@ -280,9 +282,10 @@ void ResourcePage::updateVersionList()
|
|||||||
auto release_type = current_pack->versions[i].version_type.isValid()
|
auto release_type = current_pack->versions[i].version_type.isValid()
|
||||||
? QString(" [%1]").arg(current_pack->versions[i].version_type.toString())
|
? QString(" [%1]").arg(current_pack->versions[i].version_type.toString())
|
||||||
: "";
|
: "";
|
||||||
m_ui->versionSelectionBox->addItem(current_pack->versions[i].version, QVariant(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
m_ui->versionSelectionBox->addItem(QString("%1%2").arg(version.version, release_type), QVariant(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
if (m_ui->versionSelectionBox->count() == 0) {
|
if (m_ui->versionSelectionBox->count() == 0) {
|
||||||
m_ui->versionSelectionBox->addItem(tr("No valid version found."), QVariant(-1));
|
m_ui->versionSelectionBox->addItem(tr("No valid version found."), QVariant(-1));
|
||||||
m_ui->resourceSelectionButton->setText(tr("Cannot select invalid version :("));
|
m_ui->resourceSelectionButton->setText(tr("Cannot select invalid version :("));
|
||||||
@ -399,7 +402,7 @@ void ResourcePage::openUrl(const QUrl& url)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!page.isNull()) {
|
if (!page.isNull() && !m_do_not_jump_to_mod) {
|
||||||
const QString slug = match.captured(1);
|
const QString slug = match.captured(1);
|
||||||
|
|
||||||
// ensure the user isn't opening the same mod
|
// ensure the user isn't opening the same mod
|
||||||
@ -443,4 +446,52 @@ void ResourcePage::openUrl(const QUrl& url)
|
|||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourcePage::openProject(QVariant projectID)
|
||||||
|
{
|
||||||
|
m_ui->sortByBox->hide();
|
||||||
|
m_ui->searchEdit->hide();
|
||||||
|
m_ui->resourceFilterButton->hide();
|
||||||
|
m_ui->packView->hide();
|
||||||
|
m_ui->resourceSelectionButton->hide();
|
||||||
|
m_do_not_jump_to_mod = true;
|
||||||
|
|
||||||
|
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||||
|
|
||||||
|
auto okBtn = buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
okBtn->setDefault(true);
|
||||||
|
okBtn->setAutoDefault(true);
|
||||||
|
okBtn->setText(tr("Reinstall"));
|
||||||
|
okBtn->setShortcut(tr("Ctrl+Return"));
|
||||||
|
okBtn->setEnabled(false);
|
||||||
|
|
||||||
|
auto cancelBtn = buttonBox->button(QDialogButtonBox::Cancel);
|
||||||
|
cancelBtn->setDefault(false);
|
||||||
|
cancelBtn->setAutoDefault(false);
|
||||||
|
|
||||||
|
connect(okBtn, &QPushButton::clicked, this, [this] {
|
||||||
|
onResourceSelected();
|
||||||
|
m_parent_dialog->accept();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(cancelBtn, &QPushButton::clicked, m_parent_dialog, &ResourceDownloadDialog::reject);
|
||||||
|
m_ui->gridLayout_4->addWidget(buttonBox, 1, 2);
|
||||||
|
|
||||||
|
auto jump = [this, okBtn] {
|
||||||
|
for (int row = 0; row < m_model->rowCount({}); row++) {
|
||||||
|
const QModelIndex index = m_model->index(row);
|
||||||
|
m_ui->packView->setCurrentIndex(index);
|
||||||
|
okBtn->setEnabled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_ui->packDescription->setText(tr("The resource was not found"));
|
||||||
|
};
|
||||||
|
|
||||||
|
m_ui->searchEdit->setText("#" + projectID.toString());
|
||||||
|
triggerSearch();
|
||||||
|
|
||||||
|
if (m_model->hasActiveSearchJob())
|
||||||
|
connect(m_model->activeSearchJob().get(), &Task::finished, jump);
|
||||||
|
else
|
||||||
|
jump();
|
||||||
|
}
|
||||||
} // namespace ResourceDownload
|
} // namespace ResourceDownload
|
||||||
|
@ -83,6 +83,8 @@ class ResourcePage : public QWidget, public BasePage {
|
|||||||
QList<DownloadTaskPtr> selectedPacks() { return m_model->selectedPacks(); }
|
QList<DownloadTaskPtr> selectedPacks() { return m_model->selectedPacks(); }
|
||||||
bool hasSelectedPacks() { return !(m_model->selectedPacks().isEmpty()); }
|
bool hasSelectedPacks() { return !(m_model->selectedPacks().isEmpty()); }
|
||||||
|
|
||||||
|
virtual void openProject(QVariant projectID);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void triggerSearch() = 0;
|
virtual void triggerSearch() = 0;
|
||||||
|
|
||||||
@ -111,6 +113,8 @@ class ResourcePage : public QWidget, public BasePage {
|
|||||||
|
|
||||||
// Used to do instant searching with a delay to cache quick changes
|
// Used to do instant searching with a delay to cache quick changes
|
||||||
QTimer m_search_timer;
|
QTimer m_search_timer;
|
||||||
|
|
||||||
|
bool m_do_not_jump_to_mod = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ResourceDownload
|
} // namespace ResourceDownload
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
class BaseWizardPage : public QWizardPage {
|
class BaseWizardPage : public QWizardPage {
|
||||||
public:
|
public:
|
||||||
explicit BaseWizardPage(QWidget* parent = Q_NULLPTR) : QWizardPage(parent) {}
|
explicit BaseWizardPage(QWidget* parent = Q_NULLPTR) : QWizardPage(parent) {}
|
||||||
virtual ~BaseWizardPage(){};
|
virtual ~BaseWizardPage() {};
|
||||||
|
|
||||||
virtual bool wantsRefreshButton() { return false; }
|
virtual bool wantsRefreshButton() { return false; }
|
||||||
virtual void refresh() {}
|
virtual void refresh() {}
|
||||||
|
@ -9,7 +9,7 @@ class JavaWizardPage : public BaseWizardPage {
|
|||||||
public:
|
public:
|
||||||
explicit JavaWizardPage(QWidget* parent = Q_NULLPTR);
|
explicit JavaWizardPage(QWidget* parent = Q_NULLPTR);
|
||||||
|
|
||||||
virtual ~JavaWizardPage(){};
|
virtual ~JavaWizardPage() {};
|
||||||
|
|
||||||
bool wantsRefreshButton() override;
|
bool wantsRefreshButton() override;
|
||||||
void refresh() override;
|
void refresh() override;
|
||||||
|
@ -25,7 +25,7 @@ class JavaSettingsWidget : public QWidget {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit JavaSettingsWidget(QWidget* parent);
|
explicit JavaSettingsWidget(QWidget* parent);
|
||||||
virtual ~JavaSettingsWidget(){};
|
virtual ~JavaSettingsWidget() {};
|
||||||
|
|
||||||
enum class JavaStatus { NotSet, Pending, Good, DoesNotExist, DoesNotStart, ReturnedInvalidData } javaStatus = JavaStatus::NotSet;
|
enum class JavaStatus { NotSet, Pending, Good, DoesNotExist, DoesNotStart, ReturnedInvalidData } javaStatus = JavaStatus::NotSet;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class LanguageSelectionWidget : public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LanguageSelectionWidget(QWidget* parent = 0);
|
explicit LanguageSelectionWidget(QWidget* parent = 0);
|
||||||
virtual ~LanguageSelectionWidget(){};
|
virtual ~LanguageSelectionWidget() {};
|
||||||
|
|
||||||
QString getSelectedLanguageKey() const;
|
QString getSelectedLanguageKey() const;
|
||||||
void retranslate();
|
void retranslate();
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QListView>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@ -86,6 +87,8 @@ class PageContainer : public QWidget, public BasePageContainer {
|
|||||||
|
|
||||||
void changeEvent(QEvent*) override;
|
void changeEvent(QEvent*) override;
|
||||||
|
|
||||||
|
void hidePageList() { m_pageList->hide(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createUI();
|
void createUI();
|
||||||
void retranslate();
|
void retranslate();
|
||||||
|
@ -469,8 +469,7 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar
|
|||||||
target_dir = QDir(m_rootPath).absoluteFilePath("..");
|
target_dir = QDir(m_rootPath).absoluteFilePath("..");
|
||||||
}
|
}
|
||||||
|
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(this, [this, target_dir]() { moveAndFinishUpdate(target_dir); }, Qt::QueuedConnection);
|
||||||
this, [this, target_dir]() { moveAndFinishUpdate(target_dir); }, Qt::QueuedConnection);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
QMetaObject::invokeMethod(this, &PrismUpdaterApp::loadReleaseList, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, &PrismUpdaterApp::loadReleaseList, Qt::QueuedConnection);
|
||||||
|
@ -24,10 +24,7 @@ class Reader {
|
|||||||
virtual void goToBeginning() = 0;
|
virtual void goToBeginning() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t hash(
|
uint32_t hash(Reader* file_stream, std::size_t buffer_size = 4 * MiB, std::function<bool(char)> filter_out = [](char) { return false; });
|
||||||
Reader* file_stream,
|
|
||||||
std::size_t buffer_size = 4 * MiB,
|
|
||||||
std::function<bool(char)> filter_out = [](char) { return false; });
|
|
||||||
|
|
||||||
struct IncrementalHashInfo {
|
struct IncrementalHashInfo {
|
||||||
uint32_t h;
|
uint32_t h;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
tools.clang-tools = lib.mkForce pkgs.clang-tools_16;
|
tools.clang-tools = lib.mkForce pkgs.clang-tools_18;
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
|
@ -203,7 +203,10 @@ class ResourceFolderModelTest : public QObject {
|
|||||||
|
|
||||||
QCOMPARE(model.size(), 0);
|
QCOMPARE(model.size(), 0);
|
||||||
|
|
||||||
{ EXEC_UPDATE_TASK(model.installResource(folder_resource), QVERIFY) } {
|
{
|
||||||
|
EXEC_UPDATE_TASK(model.installResource(folder_resource), QVERIFY)
|
||||||
|
}
|
||||||
|
{
|
||||||
EXEC_UPDATE_TASK(model.installResource(file_mod), QVERIFY)
|
EXEC_UPDATE_TASK(model.installResource(file_mod), QVERIFY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user