diff options
Diffstat (limited to 'launcher/minecraft')
-rw-r--r-- | launcher/minecraft/MinecraftInstance.cpp | 36 | ||||
-rw-r--r-- | launcher/minecraft/MinecraftInstance.h | 4 | ||||
-rw-r--r-- | launcher/minecraft/MojangVersionFormat.cpp | 17 | ||||
-rw-r--r-- | launcher/minecraft/OneSixVersionFormat.cpp | 29 | ||||
-rw-r--r-- | launcher/minecraft/PackProfile.cpp | 6 | ||||
-rw-r--r-- | launcher/minecraft/Rule.h | 2 | ||||
-rw-r--r-- | launcher/minecraft/WorldList.cpp | 6 | ||||
-rw-r--r-- | launcher/minecraft/WorldList.h | 2 | ||||
-rw-r--r-- | launcher/minecraft/auth/AccountList.cpp | 10 | ||||
-rw-r--r-- | launcher/minecraft/mod/ModFolderModel.cpp | 2 | ||||
-rw-r--r-- | launcher/minecraft/mod/ResourceFolderModel.cpp | 2 | ||||
-rw-r--r-- | launcher/minecraft/mod/ResourceFolderModel.h | 6 | ||||
-rw-r--r-- | launcher/minecraft/mod/ResourcePackFolderModel.cpp | 2 | ||||
-rw-r--r-- | launcher/minecraft/mod/tasks/LocalModParseTask.cpp | 2 | ||||
-rw-r--r-- | launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp | 2 |
15 files changed, 76 insertions, 52 deletions
diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 3a820951..70d0b949 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> * Copyright (C) 2022 Jamie Mansfield <jmansfield@cadixdev.org> + * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me> * * 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 @@ -43,7 +44,6 @@ #include "settings/SettingsObject.h" #include "Application.h" -#include "MMCStrings.h" #include "pathmatcher/RegexpMatcher.h" #include "pathmatcher/MultiMatcher.h" #include "FileSystem.h" @@ -437,6 +437,17 @@ QStringList MinecraftInstance::javaArguments() return args; } +QString MinecraftInstance::getLauncher() +{ + auto profile = m_components->getProfile(); + + // use legacy launcher if the traits are set + if (profile->getTraits().contains("legacyLaunch") || profile->getTraits().contains("alphaLaunch")) + return "legacy"; + + return "standard"; +} + QMap<QString, QString> MinecraftInstance::getVariables() { QMap<QString, QString> out; @@ -628,26 +639,13 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS launchScript += "sessionId " + session->session + "\n"; } - // libraries and class path. - { - QStringList jars, nativeJars; - profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot()); - for(auto file: jars) - { - launchScript += "cp " + file + "\n"; - } - for(auto file: nativeJars) - { - launchScript += "ext " + file + "\n"; - } - launchScript += "natives " + getNativePath() + "\n"; - } - for (auto trait : profile->getTraits()) { launchScript += "traits " + trait + "\n"; } - launchScript += "launcher onesix\n"; + + launchScript += "launcher " + getLauncher() + "\n"; + // qDebug() << "Generated launch script:" << launchScript; return launchScript; } @@ -783,6 +781,8 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr out << "Window size: " + QString::number(width) + " x " + QString::number(height); } out << ""; + out << "Launcher: " + getLauncher(); + out << ""; return out; } diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h index 1895d187..1bbd7b83 100644 --- a/launcher/minecraft/MinecraftInstance.h +++ b/launcher/minecraft/MinecraftInstance.h @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> + * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -130,6 +131,7 @@ public: QString createLaunchScript(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin); /// get arguments passed to java QStringList javaArguments(); + QString getLauncher(); /// get variables for launch command variable substitution/environment QMap<QString, QString> getVariables() override; diff --git a/launcher/minecraft/MojangVersionFormat.cpp b/launcher/minecraft/MojangVersionFormat.cpp index 9bbb4ada..623dcdfa 100644 --- a/launcher/minecraft/MojangVersionFormat.cpp +++ b/launcher/minecraft/MojangVersionFormat.cpp @@ -135,7 +135,7 @@ QJsonObject libDownloadInfoToJson(MojangLibraryDownloadInfo::Ptr libinfo) { out.insert("artifact", downloadInfoToJson(libinfo->artifact)); } - if(libinfo->classifiers.size()) + if(!libinfo->classifiers.isEmpty()) { QJsonObject classifiersOut; for(auto iter = libinfo->classifiers.begin(); iter != libinfo->classifiers.end(); iter++) @@ -297,7 +297,7 @@ void MojangVersionFormat::writeVersionProperties(const VersionFile* in, QJsonObj { out.insert("assetIndex", assetIndexToJson(in->mojangAssetIndex)); } - if(in->mojangDownloads.size()) + if(!in->mojangDownloads.isEmpty()) { QJsonObject downloadsOut; for(auto iter = in->mojangDownloads.begin(); iter != in->mojangDownloads.end(); iter++) @@ -306,6 +306,15 @@ void MojangVersionFormat::writeVersionProperties(const VersionFile* in, QJsonObj } out.insert("downloads", downloadsOut); } + if(!in->compatibleJavaMajors.isEmpty()) + { + QJsonArray compatibleJavaMajorsOut; + for(auto compatibleJavaMajor : in->compatibleJavaMajors) + { + compatibleJavaMajorsOut.append(compatibleJavaMajor); + } + out.insert("compatibleJavaMajors", compatibleJavaMajorsOut); + } } QJsonDocument MojangVersionFormat::versionFileToJson(const VersionFilePtr &patch) @@ -396,7 +405,7 @@ QJsonObject MojangVersionFormat::libraryToJson(Library *library) iter++; } libRoot.insert("natives", nativeList); - if (library->m_extractExcludes.size()) + if (!library->m_extractExcludes.isEmpty()) { QJsonArray excludes; QJsonObject extract; @@ -408,7 +417,7 @@ QJsonObject MojangVersionFormat::libraryToJson(Library *library) libRoot.insert("extract", extract); } } - if (library->m_rules.size()) + if (!library->m_rules.isEmpty()) { QJsonArray allRules; for (auto &rule : library->m_rules) diff --git a/launcher/minecraft/OneSixVersionFormat.cpp b/launcher/minecraft/OneSixVersionFormat.cpp index cec4a55b..280f6b26 100644 --- a/launcher/minecraft/OneSixVersionFormat.cpp +++ b/launcher/minecraft/OneSixVersionFormat.cpp @@ -63,13 +63,13 @@ LibraryPtr OneSixVersionFormat::libraryFromJson(ProblemContainer & problems, con QJsonObject OneSixVersionFormat::libraryToJson(Library *library) { QJsonObject libRoot = MojangVersionFormat::libraryToJson(library); - if (library->m_absoluteURL.size()) + if (!library->m_absoluteURL.isEmpty()) libRoot.insert("MMC-absoluteUrl", library->m_absoluteURL); - if (library->m_hint.size()) + if (!library->m_hint.isEmpty()) libRoot.insert("MMC-hint", library->m_hint); - if (library->m_filename.size()) + if (!library->m_filename.isEmpty()) libRoot.insert("MMC-filename", library->m_filename); - if (library->m_displayname.size()) + if (!library->m_displayname.isEmpty()) libRoot.insert("MMC-displayname", library->m_displayname); return libRoot; } @@ -225,11 +225,10 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc { QJsonObject agentObj = requireObject(agentVal); auto lib = libraryFromJson(*out, agentObj, filename); + QString arg = ""; - if (agentObj.contains("argument")) - { - readString(agentObj, "argument", arg); - } + readString(agentObj, "argument", arg); + AgentPtr agent(new Agent(lib, arg)); out->agents.append(agent); } @@ -332,6 +331,20 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch writeString(root, "appletClass", patch->appletClass); writeStringList(root, "+tweakers", patch->addTweakers); writeStringList(root, "+traits", patch->traits.values()); + writeStringList(root, "+jvmArgs", patch->addnJvmArguments); + if (!patch->agents.isEmpty()) + { + QJsonArray array; + for (auto value: patch->agents) + { + QJsonObject agentOut = OneSixVersionFormat::libraryToJson(value->library().get()); + if (!value->argument().isEmpty()) + agentOut.insert("argument", value->argument()); + + array.append(agentOut); + } + root.insert("+agents", array); + } if (!patch->libraries.isEmpty()) { QJsonArray array; diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp index 1618458f..6ce525eb 100644 --- a/launcher/minecraft/PackProfile.cpp +++ b/launcher/minecraft/PackProfile.cpp @@ -613,7 +613,7 @@ QVariant PackProfile::data(const QModelIndex &index, int role) const bool PackProfile::setData(const QModelIndex& index, const QVariant& value, int role) { - if (!index.isValid() || index.row() < 0 || index.row() >= rowCount(index)) + if (!index.isValid() || index.row() < 0 || index.row() >= rowCount(index.parent())) { return false; } @@ -675,12 +675,12 @@ Qt::ItemFlags PackProfile::flags(const QModelIndex &index) const int PackProfile::rowCount(const QModelIndex &parent) const { - return d->components.size(); + return parent.isValid() ? 0 : d->components.size(); } int PackProfile::columnCount(const QModelIndex &parent) const { - return NUM_COLUMNS; + return parent.isValid() ? 0 : NUM_COLUMNS; } void PackProfile::move(const int index, const MoveDirection direction) diff --git a/launcher/minecraft/Rule.h b/launcher/minecraft/Rule.h index 236f9a87..846e8e42 100644 --- a/launcher/minecraft/Rule.h +++ b/launcher/minecraft/Rule.h @@ -104,7 +104,7 @@ public: class ImplicitRule : public Rule { protected: - virtual bool applies(const Library *, const RuntimeContext & runtimeContext) + virtual bool applies(const Library *, [[maybe_unused]] const RuntimeContext & runtimeContext) { return true; } diff --git a/launcher/minecraft/WorldList.cpp b/launcher/minecraft/WorldList.cpp index aee7be35..ae29a972 100644 --- a/launcher/minecraft/WorldList.cpp +++ b/launcher/minecraft/WorldList.cpp @@ -173,7 +173,7 @@ bool WorldList::resetIcon(int row) int WorldList::columnCount(const QModelIndex &parent) const { - return 4; + return parent.isValid()? 0 : 4; } QVariant WorldList::data(const QModelIndex &index, int role) const @@ -398,8 +398,8 @@ void WorldList::installWorld(QFileInfo filename) w.install(m_dir.absolutePath()); } -bool WorldList::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, - const QModelIndex &parent) +bool WorldList::dropMimeData(const QMimeData *data, Qt::DropAction action, [[maybe_unused]] int row, [[maybe_unused]] int column, + [[maybe_unused]] const QModelIndex &parent) { if (action == Qt::IgnoreAction) return true; diff --git a/launcher/minecraft/WorldList.h b/launcher/minecraft/WorldList.h index 5138e583..08294755 100644 --- a/launcher/minecraft/WorldList.h +++ b/launcher/minecraft/WorldList.h @@ -54,7 +54,7 @@ public: virtual int rowCount(const QModelIndex &parent = QModelIndex()) const { - return size(); + return parent.isValid() ? 0 : static_cast<int>(size()); }; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; diff --git a/launcher/minecraft/auth/AccountList.cpp b/launcher/minecraft/auth/AccountList.cpp index b3b57c74..9e2fd111 100644 --- a/launcher/minecraft/auth/AccountList.cpp +++ b/launcher/minecraft/auth/AccountList.cpp @@ -408,20 +408,20 @@ QVariant AccountList::headerData(int section, Qt::Orientation orientation, int r } } -int AccountList::rowCount(const QModelIndex &) const +int AccountList::rowCount(const QModelIndex &parent) const { // Return count - return count(); + return parent.isValid() ? 0 : count(); } -int AccountList::columnCount(const QModelIndex &) const +int AccountList::columnCount(const QModelIndex &parent) const { - return NUM_COLUMNS; + return parent.isValid() ? 0 : NUM_COLUMNS; } Qt::ItemFlags AccountList::flags(const QModelIndex &index) const { - if (index.row() < 0 || index.row() >= rowCount(index) || !index.isValid()) + if (index.row() < 0 || index.row() >= rowCount(index.parent()) || !index.isValid()) { return Qt::NoItemFlags; } diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index 66e80f4a..4ccc5d4d 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -144,7 +144,7 @@ QVariant ModFolderModel::headerData(int section, Qt::Orientation orientation, in int ModFolderModel::columnCount(const QModelIndex &parent) const { - return NUM_COLUMNS; + return parent.isValid() ? 0 : NUM_COLUMNS; } Task* ModFolderModel::createUpdateTask() diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp index b2356309..0310c8f6 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel.cpp @@ -426,7 +426,7 @@ QVariant ResourceFolderModel::data(const QModelIndex& index, int role) const bool ResourceFolderModel::setData(const QModelIndex& index, const QVariant& value, int role) { int row = index.row(); - if (row < 0 || row >= rowCount(index) || !index.isValid()) + if (row < 0 || row >= rowCount(index.parent()) || !index.isValid()) return false; if (role == Qt::CheckStateRole) diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h index 25095a45..fe283b04 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.h +++ b/launcher/minecraft/mod/ResourceFolderModel.h @@ -90,8 +90,8 @@ class ResourceFolderModel : public QAbstractListModel { /* Basic columns */ enum Columns { ACTIVE_COLUMN = 0, NAME_COLUMN, DATE_COLUMN, NUM_COLUMNS }; - [[nodiscard]] int rowCount(const QModelIndex& = {}) const override { return size(); } - [[nodiscard]] int columnCount(const QModelIndex& = {}) const override { return NUM_COLUMNS; }; + [[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : static_cast<int>(size()); } + [[nodiscard]] int columnCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : NUM_COLUMNS; }; [[nodiscard]] Qt::DropActions supportedDropActions() const override; @@ -176,7 +176,7 @@ class ResourceFolderModel : public QAbstractListModel { * if the resource is complex and has more stuff to parse. */ virtual void onParseSucceeded(int ticket, QString resource_id); - virtual void onParseFailed(int ticket, QString resource_id) {} + virtual void onParseFailed(int ticket, QString resource_id) { Q_UNUSED(ticket); Q_UNUSED(resource_id); } protected: // Represents the relationship between a column's index (represented by the list index), and it's sorting key. diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.cpp b/launcher/minecraft/mod/ResourcePackFolderModel.cpp index f8a6c1cf..ebac707d 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.cpp +++ b/launcher/minecraft/mod/ResourcePackFolderModel.cpp @@ -137,7 +137,7 @@ QVariant ResourcePackFolderModel::headerData(int section, Qt::Orientation orient int ResourcePackFolderModel::columnCount(const QModelIndex& parent) const { - return NUM_COLUMNS; + return parent.isValid() ? 0 : NUM_COLUMNS; } Task* ResourcePackFolderModel::createUpdateTask() diff --git a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp index a694e7b2..774f6114 100644 --- a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp @@ -121,7 +121,7 @@ ModDetails ReadMCModTOML(QByteArray contents) return {}; } auto modsTable = tomlModsTable0->as_table(); - if (!tomlModsTable0) { + if (!modsTable) { qWarning() << "Corrupted mods.toml? [[mods]] was not a table!"; return {}; } diff --git a/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp b/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp index 4b878918..cc4e252c 100644 --- a/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp @@ -36,7 +36,7 @@ LocalModUpdateTask::LocalModUpdateTask(QDir index_dir, ModPlatform::IndexedPack& } #ifdef Q_OS_WIN32 - SetFileAttributesA(index_dir.path().toStdString().c_str(), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED); + SetFileAttributesW(index_dir.path().toStdWString().c_str(), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED); #endif } |