aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/winget.yml14
-rw-r--r--flake.nix28
-rw-r--r--launcher/Application.cpp6
-rw-r--r--launcher/Application.h3
-rw-r--r--launcher/CMakeLists.txt26
-rw-r--r--launcher/InstanceImportTask.cpp15
-rw-r--r--launcher/minecraft/auth/AccountTask.cpp2
-rw-r--r--launcher/minecraft/launch/LauncherPartLaunch.cpp1
-rw-r--r--launcher/minecraft/mod/ModFolderModel.cpp14
-rw-r--r--launcher/modplatform/flame/FileResolvingTask.cpp4
-rw-r--r--launcher/modplatform/flame/FlameAPI.h2
-rw-r--r--launcher/modplatform/technic/TechnicPackProcessor.cpp14
-rw-r--r--launcher/net/PasteUpload.cpp2
-rw-r--r--launcher/translations/POTranslator.cpp5
-rw-r--r--launcher/translations/POTranslator.h1
-rw-r--r--launcher/ui/GuiUtil.cpp1
-rw-r--r--launcher/ui/MainWindow.cpp10
-rw-r--r--launcher/ui/MainWindow.h8
-rw-r--r--launcher/ui/pages/global/LauncherPage.cpp9
-rw-r--r--launcher/ui/pages/global/LauncherPage.h5
-rw-r--r--launcher/ui/pages/global/LauncherPage.ui3
-rw-r--r--launcher/ui/pages/instance/LogPage.cpp1
-rw-r--r--launcher/ui/pages/instance/ScreenshotsPage.h1
-rw-r--r--launcher/ui/pages/instance/ServersPage.cpp1
-rw-r--r--launcher/ui/pages/instance/WorldListPage.cpp1
-rw-r--r--launcher/ui/pages/modplatform/ModModel.cpp4
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModel.cpp16
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModel.h1
-rw-r--r--launcher/ui/pages/modplatform/flame/FlamePage.cpp25
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp2
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/Page.ui6
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp15
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.h2
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp35
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui3
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicModel.cpp5
-rw-r--r--launcher/updater/DownloadTask_test.cpp204
-rw-r--r--launcher/updater/UpdateChecker_test.cpp148
-rw-r--r--launcher/updater/testdata/1.json43
-rw-r--r--launcher/updater/testdata/2.json31
-rw-r--r--launcher/updater/testdata/channels.json23
-rw-r--r--launcher/updater/testdata/errorChannels.json23
-rw-r--r--launcher/updater/testdata/fileOneA1
-rw-r--r--launcher/updater/testdata/fileOneB3
-rw-r--r--launcher/updater/testdata/fileThree1
-rw-r--r--launcher/updater/testdata/fileTwo1
-rw-r--r--launcher/updater/testdata/garbageChannels.json22
-rw-r--r--launcher/updater/testdata/index.json9
-rw-r--r--launcher/updater/testdata/noChannels.json5
-rw-r--r--launcher/updater/testdata/oneChannel.json11
-rw-r--r--launcher/updater/testdata/tst_DownloadTask-test_writeInstallScript.xml17
-rw-r--r--libraries/LocalPeer/src/LocalPeer.cpp8
-rw-r--r--libraries/classparser/src/annotations.cpp4
-rw-r--r--libraries/classparser/src/classfile.h4
-rw-r--r--libraries/classparser/src/constants.h5
55 files changed, 180 insertions, 674 deletions
diff --git a/.github/workflows/winget.yml b/.github/workflows/winget.yml
new file mode 100644
index 00000000..b8ecce13
--- /dev/null
+++ b/.github/workflows/winget.yml
@@ -0,0 +1,14 @@
+name: Publish to WinGet
+on:
+ release:
+ types: [released]
+
+jobs:
+ publish:
+ runs-on: windows-latest
+ steps:
+ - uses: vedantmgoyal2009/winget-releaser@latest
+ with:
+ identifier: PolyMC.PolyMC
+ installers-regex: '\.exe$'
+ token: ${{ secrets.WINGET_TOKEN }}
diff --git a/flake.nix b/flake.nix
index b378fbb0..c2fdffda 100644
--- a/flake.nix
+++ b/flake.nix
@@ -9,31 +9,29 @@
outputs = { self, nixpkgs, libnbtplusplus, ... }:
let
- # Generate a user-friendly version number.
+ # User-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
- # System types to support (qtbase is currently broken for "aarch64-darwin")
+ # Supported systems (qtbase is currently broken for "aarch64-darwin")
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
- # Nixpkgs instantiated for supported system types.
+ # Nixpkgs instantiated for supported systems.
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
+
+ packagesFn = pkgs: rec {
+ polymc = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus; };
+ polymc-qt6 = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus; };
+ };
in
{
- packages = forAllSystems (system: rec {
- polymc = pkgs.${system}.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus; };
- polymc-qt6 = pkgs.${system}.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus; };
-
- default = polymc;
- });
-
- defaultPackage = forAllSystems (system: self.packages.${system}.default);
-
- apps = forAllSystems (system: rec { polymc = { type = "app"; program = "${self.defaultPackage.${system}}/bin/polymc"; }; default = polymc; });
- defaultApp = forAllSystems (system: self.apps.${system}.default);
+ packages = forAllSystems (system:
+ let packages = packagesFn pkgs.${system}; in
+ packages // { default = packages.polymc; }
+ );
- overlay = final: prev: { polymc = self.defaultPackage.${final.system}; };
+ overlay = final: packagesFn;
};
}
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index 0ef641ba..c6e04a85 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -154,7 +154,6 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QSt
fflush(stderr);
}
-#ifdef LAUNCHER_WITH_UPDATER
QString getIdealPlatform(QString currentPlatform) {
auto info = Sys::getKernelInfo();
switch(info.kernelType) {
@@ -193,7 +192,6 @@ QString getIdealPlatform(QString currentPlatform) {
}
return currentPlatform;
}
-#endif
}
@@ -758,7 +756,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
qDebug() << "<> Translations loaded.";
}
-#ifdef LAUNCHER_WITH_UPDATER
// initialize the updater
if(BuildConfig.UPDATER_ENABLED)
{
@@ -768,7 +765,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_updateChecker.reset(new UpdateChecker(m_network, channelUrl, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
qDebug() << "<> Updater started.";
}
-#endif
// Instance icons
{
@@ -1414,9 +1410,7 @@ MainWindow* Application::showMainWindow(bool minimized)
}
m_mainWindow->checkInstancePathForProblems();
-#ifdef LAUNCHER_WITH_UPDATER
connect(this, &Application::updateAllowedChanged, m_mainWindow, &MainWindow::updatesAllowedChanged);
-#endif
connect(m_mainWindow, &MainWindow::isClosing, this, &Application::on_windowClose);
m_openWindows++;
}
diff --git a/launcher/Application.h b/launcher/Application.h
index 18461ad8..e3b4fced 100644
--- a/launcher/Application.h
+++ b/launcher/Application.h
@@ -42,10 +42,7 @@
#include <QIcon>
#include <QDateTime>
#include <QUrl>
-
-#ifdef LAUNCHER_WITH_UPDATER
#include <updater/GoUpdate.h>
-#endif
#include <BaseInstance.h>
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index eb5a68cd..ec8e84c9 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -149,23 +149,15 @@ set(LAUNCH_SOURCES
launch/LogModel.h
)
-if (Launcher_UPDATER_BASE)
- set(Launcher_APP_BINARY_DEFS "-DLAUNCHER_WITH_UPDATER ${Launcher_APP_BINARY_DEFS}")
- # Old update system
- set(UPDATE_SOURCES
- updater/GoUpdate.h
- updater/GoUpdate.cpp
- updater/UpdateChecker.h
- updater/UpdateChecker.cpp
- updater/DownloadTask.h
- updater/DownloadTask.cpp
- )
-
- ecm_add_test(updater/UpdateChecker_test.cpp LINK_LIBRARIES Launcher_logic Qt5::Test
- TEST_NAME UpdateChecker)
- ecm_add_test(updater/DownloadTask_test.cpp LINK_LIBRARIES Launcher_logic Qt5::Test
- TEST_NAME DownloadTask)
-endif()
+# Old update system
+set(UPDATE_SOURCES
+ updater/GoUpdate.h
+ updater/GoUpdate.cpp
+ updater/UpdateChecker.h
+ updater/UpdateChecker.cpp
+ updater/DownloadTask.h
+ updater/DownloadTask.cpp
+)
# Backend for the news bar... there's usually no news.
set(NEWS_SOURCES
diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp
index cbac4b37..dad2c1ad 100644
--- a/launcher/InstanceImportTask.cpp
+++ b/launcher/InstanceImportTask.cpp
@@ -412,12 +412,8 @@ void InstanceImportTask::processFlame()
"You will need to manually download them and add them to the modpack"),
text);
message_dialog->setModal(true);
- message_dialog->show();
- connect(message_dialog, &QDialog::rejected, [&]() {
- m_modIdResolver.reset();
- emitFailed("Canceled");
- });
- connect(message_dialog, &QDialog::accepted, [&]() {
+
+ if (message_dialog->exec()) {
m_filesNetJob = new NetJob(tr("Mod download"), APPLICATION->network());
for (const auto &result: m_modIdResolver->getResults().files) {
QString filename = result.fileName;
@@ -469,8 +465,11 @@ void InstanceImportTask::processFlame()
});
setStatus(tr("Downloading mods..."));
m_filesNetJob->start();
- });
- }else{
+ } else {
+ m_modIdResolver.reset();
+ emitFailed("Canceled");
+ }
+ } else {
//TODO extract to function ?
m_filesNetJob = new NetJob(tr("Mod download"), APPLICATION->network());
for (const auto &result: m_modIdResolver->getResults().files) {
diff --git a/launcher/minecraft/auth/AccountTask.cpp b/launcher/minecraft/auth/AccountTask.cpp
index 49b6e46f..4118c3c5 100644
--- a/launcher/minecraft/auth/AccountTask.cpp
+++ b/launcher/minecraft/auth/AccountTask.cpp
@@ -79,6 +79,8 @@ QString AccountTask::getStateMessage() const
bool AccountTask::changeState(AccountTaskState newState, QString reason)
{
m_taskState = newState;
+ // FIXME: virtual method invoked in constructor.
+ // We want that behavior, but maybe make it less weird?
setStatus(getStateMessage());
switch(newState) {
case AccountTaskState::STATE_CREATED: {
diff --git a/launcher/minecraft/launch/LauncherPartLaunch.cpp b/launcher/minecraft/launch/LauncherPartLaunch.cpp
index 9965ef89..63e4d90f 100644
--- a/launcher/minecraft/launch/LauncherPartLaunch.cpp
+++ b/launcher/minecraft/launch/LauncherPartLaunch.cpp
@@ -36,7 +36,6 @@
#include "LauncherPartLaunch.h"
#include <QStandardPaths>
-#include <QRegularExpression>
#include "launch/LaunchTask.h"
#include "minecraft/MinecraftInstance.h"
diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp
index ded2d3a2..bc2362a9 100644
--- a/launcher/minecraft/mod/ModFolderModel.cpp
+++ b/launcher/minecraft/mod/ModFolderModel.cpp
@@ -167,12 +167,16 @@ void ModFolderModel::finishUpdate()
{
QSet<QString> added = newSet;
added.subtract(currentSet);
- beginInsertRows(QModelIndex(), mods.size(), mods.size() + added.size() - 1);
- for(auto & addedMod: added) {
- mods.append(newMods[addedMod]);
- resolveMod(mods.last());
+
+ // When you have a Qt build with assertions turned on, proceeding here will abort the application
+ if (added.size() > 0) {
+ beginInsertRows(QModelIndex(), mods.size(), mods.size() + added.size() - 1);
+ for (auto& addedMod : added) {
+ mods.append(newMods[addedMod]);
+ resolveMod(mods.last());
+ }
+ endInsertRows();
}
- endInsertRows();
}
// update index
diff --git a/launcher/modplatform/flame/FileResolvingTask.cpp b/launcher/modplatform/flame/FileResolvingTask.cpp
index a790ab9c..c1f56658 100644
--- a/launcher/modplatform/flame/FileResolvingTask.cpp
+++ b/launcher/modplatform/flame/FileResolvingTask.cpp
@@ -10,7 +10,7 @@ Flame::FileResolvingTask::FileResolvingTask(const shared_qobject_ptr<QNetworkAcc
void Flame::FileResolvingTask::executeTask()
{
setStatus(tr("Resolving mod IDs..."));
- setProgress(0, m_toProcess.files.size());
+ setProgress(0, 3);
m_dljob = new NetJob("Mod id resolver", m_network);
result.reset(new QByteArray());
//build json data to send
@@ -29,6 +29,7 @@ void Flame::FileResolvingTask::executeTask()
void Flame::FileResolvingTask::netJobFinished()
{
+ setProgress(1, 3);
int index = 0;
// job to check modrinth for blocked projects
auto job = new NetJob("Modrinth check", m_network);
@@ -63,6 +64,7 @@ void Flame::FileResolvingTask::netJobFinished()
}
void Flame::FileResolvingTask::modrinthCheckFinished() {
+ setProgress(2, 3);
qDebug() << "Finished with blocked mods : " << blockedProjects.size();
for (auto it = blockedProjects.keyBegin(); it != blockedProjects.keyEnd(); it++) {
diff --git a/launcher/modplatform/flame/FlameAPI.h b/launcher/modplatform/flame/FlameAPI.h
index 424153d2..aea76ff1 100644
--- a/launcher/modplatform/flame/FlameAPI.h
+++ b/launcher/modplatform/flame/FlameAPI.h
@@ -59,7 +59,7 @@ class FlameAPI : public NetworkModAPI {
};
public:
- static auto getMappedModLoader(const ModLoaderTypes loaders) -> const int
+ static auto getMappedModLoader(const ModLoaderTypes loaders) -> int
{
// https://docs.curseforge.com/?http#tocS_ModLoaderType
if (loaders & Forge)
diff --git a/launcher/modplatform/technic/TechnicPackProcessor.cpp b/launcher/modplatform/technic/TechnicPackProcessor.cpp
index 471b4a2f..95feb4b2 100644
--- a/launcher/modplatform/technic/TechnicPackProcessor.cpp
+++ b/launcher/modplatform/technic/TechnicPackProcessor.cpp
@@ -187,17 +187,17 @@ void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings, const
}
else
{
- static QStringList possibleLoaders{
- "net.minecraftforge:minecraftforge:",
- "net.fabricmc:fabric-loader:",
- "org.quiltmc:quilt-loader:"
+ // <Technic library name prefix> -> <our component name>
+ static QMap<QString, QString> loaderMap {
+ {"net.minecraftforge:minecraftforge:", "net.minecraftforge"},
+ {"net.fabricmc:fabric-loader:", "net.fabricmc.fabric-loader"},
+ {"org.quiltmc:quilt-loader:", "org.quiltmc.quilt-loader"}
};
- for (const auto& loader : possibleLoaders)
+ for (const auto& loader : loaderMap.keys())
{
if (libraryName.startsWith(loader))
{
- auto loaderComponent = loader.chopped(1).replace(":", ".");
- components->setComponentVersion(loaderComponent, libraryName.section(':', 2));
+ components->setComponentVersion(loaderMap.value(loader), libraryName.section(':', 2));
break;
}
}
diff --git a/launcher/net/PasteUpload.cpp b/launcher/net/PasteUpload.cpp
index 7438e1a1..835e4cd1 100644
--- a/launcher/net/PasteUpload.cpp
+++ b/launcher/net/PasteUpload.cpp
@@ -44,8 +44,6 @@
#include <QJsonArray>
#include <QJsonDocument>
#include <QFile>
-#include <QHttpPart>
-#include <QUrlQuery>
std::array<PasteUpload::PasteTypeInfo, 4> PasteUpload::PasteTypes = {
{{"0x0.st", "https://0x0.st", ""},
diff --git a/launcher/translations/POTranslator.cpp b/launcher/translations/POTranslator.cpp
index 1ffcb9a4..c77ae45d 100644
--- a/launcher/translations/POTranslator.cpp
+++ b/launcher/translations/POTranslator.cpp
@@ -329,6 +329,11 @@ POTranslator::POTranslator(const QString& filename, QObject* parent) : QTranslat
d->reload();
}
+POTranslator::~POTranslator()
+{
+ delete d;
+}
+
QString POTranslator::translate(const char* context, const char* sourceText, const char* disambiguation, int n) const
{
if(disambiguation)
diff --git a/launcher/translations/POTranslator.h b/launcher/translations/POTranslator.h
index 6d518560..1634018c 100644
--- a/launcher/translations/POTranslator.h
+++ b/launcher/translations/POTranslator.h
@@ -9,6 +9,7 @@ class POTranslator : public QTranslator
Q_OBJECT
public:
explicit POTranslator(const QString& filename, QObject * parent = nullptr);
+ virtual ~POTranslator();
QString translate(const char * context, const char * sourceText, const char * disambiguation, int n) const override;
bool isEmpty() const override;
private:
diff --git a/launcher/ui/GuiUtil.cpp b/launcher/ui/GuiUtil.cpp
index b1ea5ee9..5a62e4d0 100644
--- a/launcher/ui/GuiUtil.cpp
+++ b/launcher/ui/GuiUtil.cpp
@@ -39,7 +39,6 @@
#include <QClipboard>
#include <QApplication>
#include <QFileDialog>
-#include <QStandardPaths>
#include "ui/dialogs/ProgressDialog.h"
#include "ui/dialogs/CustomMessageBox.h"
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index f68cf61a..aeff8073 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -1024,7 +1024,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
}
-#ifdef LAUNCHER_WITH_UPDATER
if(BuildConfig.UPDATER_ENABLED)
{
bool updatesAllowed = APPLICATION->updatesAreAllowed();
@@ -1043,7 +1042,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
updater->checkForUpdate(APPLICATION->settings()->get("UpdateChannel").toString(), false);
}
}
-#endif
setSelectedInstanceById(APPLICATION->settings()->get("SelectedInstance").toString());
@@ -1355,7 +1353,6 @@ void MainWindow::repopulateAccountsMenu()
ui->profileMenu->addAction(ui->actionManageAccounts);
}
-#ifdef LAUNCHER_WITH_UPDATER
void MainWindow::updatesAllowedChanged(bool allowed)
{
if(!BuildConfig.UPDATER_ENABLED)
@@ -1364,7 +1361,6 @@ void MainWindow::updatesAllowedChanged(bool allowed)
}
ui->actionCheckUpdate->setEnabled(allowed);
}
-#endif
/*
* Assumes the sender is a QAction
@@ -1470,7 +1466,6 @@ void MainWindow::updateNewsLabel()
}
}
-#ifdef LAUNCHER_WITH_UPDATER
void MainWindow::updateAvailable(GoUpdate::Status status)
{
if(!APPLICATION->updatesAreAllowed())
@@ -1496,7 +1491,6 @@ void MainWindow::updateNotAvailable()
UpdateDialog dlg(false, this);
dlg.exec();
}
-#endif
QList<int> stringToIntList(const QString &string)
{
@@ -1518,7 +1512,6 @@ QString intListToString(const QList<int> &list)
return slist.join(',');
}
-#ifdef LAUNCHER_WITH_UPDATER
void MainWindow::downloadUpdates(GoUpdate::Status status)
{
if(!APPLICATION->updatesAreAllowed())
@@ -1552,7 +1545,6 @@ void MainWindow::downloadUpdates(GoUpdate::Status status)
CustomMessageBox::selectable(this, tr("Error"), updateTask.failReason(), QMessageBox::Warning)->show();
}
}
-#endif
void MainWindow::onCatToggled(bool state)
{
@@ -1865,7 +1857,6 @@ void MainWindow::on_actionConfig_Folder_triggered()
}
}
-#ifdef LAUNCHER_WITH_UPDATER
void MainWindow::checkForUpdates()
{
if(BuildConfig.UPDATER_ENABLED)
@@ -1878,7 +1869,6 @@ void MainWindow::checkForUpdates()
qWarning() << "Updater not set up. Cannot check for updates.";
}
}
-#endif
void MainWindow::on_actionSettings_triggered()
{
diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h
index 4615975e..0ca8ec7b 100644
--- a/launcher/ui/MainWindow.h
+++ b/launcher/ui/MainWindow.h
@@ -78,9 +78,7 @@ public:
void checkInstancePathForProblems();
-#ifdef LAUNCHER_WITH_UPDATER
void updatesAllowedChanged(bool allowed);
-#endif
void droppedURLs(QList<QUrl> urls);
signals:
@@ -126,9 +124,7 @@ private slots:
void on_actionViewCentralModsFolder_triggered();
-#ifdef LAUNCHER_WITH_UPDATER
void checkForUpdates();
-#endif
void on_actionSettings_triggered();
@@ -197,11 +193,9 @@ private slots:
void startTask(Task *task);
-#ifdef LAUNCHER_WITH_UPDATER
void updateAvailable(GoUpdate::Status status);
void updateNotAvailable();
-#endif
void defaultAccountChanged();
@@ -211,12 +205,10 @@ private slots:
void updateNewsLabel();
-#ifdef LAUNCHER_WITH_UPDATER
/*!
* Runs the DownloadTask and installs updates.
*/
void downloadUpdates(GoUpdate::Status status);
-#endif
void konamiTriggered();
diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp
index edbf609f..4be24979 100644
--- a/