aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Sonin <10217842+byteduck@users.noreply.github.com>2023-01-12 20:11:46 -0800
committerGitHub <noreply@github.com>2023-01-12 20:11:46 -0800
commitb2f48eaeb8cd6dbdf9b8bbbf1a163339c88173a7 (patch)
tree80773415691e538d437bc03c42f73a8abd01f126
parent160dd09fc2788fea17c8e9e332c2877586640971 (diff)
parent5e89ba70797df863c7eeae9b147080e7dbdf6d3b (diff)
downloadPrismLauncher-b2f48eaeb8cd6dbdf9b8bbbf1a163339c88173a7.tar.gz
PrismLauncher-b2f48eaeb8cd6dbdf9b8bbbf1a163339c88173a7.tar.bz2
PrismLauncher-b2f48eaeb8cd6dbdf9b8bbbf1a163339c88173a7.zip
Merge branch 'PrismLauncher:develop' into instance-accounts
-rw-r--r--.github/workflows/build.yml9
-rw-r--r--launcher/Application.cpp42
-rw-r--r--launcher/Application.h4
-rw-r--r--launcher/CMakeLists.txt30
-rw-r--r--launcher/FileSystem.cpp21
-rw-r--r--launcher/FileSystem.h8
-rw-r--r--launcher/minecraft/mod/DataPack.cpp108
-rw-r--r--launcher/minecraft/mod/DataPack.h73
-rw-r--r--launcher/minecraft/mod/Mod.cpp10
-rw-r--r--launcher/minecraft/mod/Mod.h3
-rw-r--r--launcher/minecraft/mod/ModDetails.h6
-rw-r--r--launcher/minecraft/mod/ResourcePack.cpp13
-rw-r--r--launcher/minecraft/mod/ShaderPack.cpp37
-rw-r--r--launcher/minecraft/mod/ShaderPack.h62
-rw-r--r--launcher/minecraft/mod/WorldSave.cpp43
-rw-r--r--launcher/minecraft/mod/WorldSave.h61
-rw-r--r--launcher/minecraft/mod/tasks/LocalDataPackParseTask.cpp177
-rw-r--r--launcher/minecraft/mod/tasks/LocalDataPackParseTask.h65
-rw-r--r--launcher/minecraft/mod/tasks/LocalModParseTask.cpp143
-rw-r--r--launcher/minecraft/mod/tasks/LocalModParseTask.h34
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp110
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h8
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourceParse.cpp60
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourceParse.h31
-rw-r--r--launcher/minecraft/mod/tasks/LocalShaderPackParseTask.cpp113
-rw-r--r--launcher/minecraft/mod/tasks/LocalShaderPackParseTask.h62
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp59
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h8
-rw-r--r--launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.cpp190
-rw-r--r--launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.h62
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.cpp148
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.h3
-rw-r--r--launcher/modplatform/technic/TechnicPackProcessor.cpp2
-rw-r--r--launcher/resources/backgrounds/backgrounds.qrc12
-rw-r--r--launcher/resources/backgrounds/teawie-bday.pngbin0 -> 190586 bytes
-rw-r--r--launcher/resources/backgrounds/teawie-spooky.pngbin0 -> 204756 bytes
-rw-r--r--launcher/resources/backgrounds/teawie-xmas.pngbin0 -> 200137 bytes
-rw-r--r--launcher/resources/backgrounds/teawie.pngbin0 -> 187972 bytes
-rw-r--r--launcher/ui/MainWindow.cpp34
-rw-r--r--launcher/ui/WinDarkmode.cpp32
-rw-r--r--launcher/ui/WinDarkmode.h60
-rw-r--r--launcher/ui/pages/global/LauncherPage.cpp105
-rw-r--r--launcher/ui/pages/global/LauncherPage.ui161
-rw-r--r--launcher/ui/pages/modplatform/ModPage.cpp4
-rw-r--r--launcher/ui/setupwizard/SetupWizard.cpp3
-rw-r--r--launcher/ui/setupwizard/ThemeWizardPage.cpp70
-rw-r--r--launcher/ui/setupwizard/ThemeWizardPage.h43
-rw-r--r--launcher/ui/setupwizard/ThemeWizardPage.ui371
-rw-r--r--launcher/ui/themes/CustomTheme.cpp31
-rw-r--r--launcher/ui/themes/ITheme.cpp40
-rw-r--r--launcher/ui/themes/ITheme.h48
-rw-r--r--launcher/ui/themes/SystemTheme.cpp21
-rw-r--r--launcher/ui/themes/SystemTheme.h44
-rw-r--r--launcher/ui/themes/ThemeManager.cpp310
-rw-r--r--launcher/ui/themes/ThemeManager.h109
-rw-r--r--launcher/ui/widgets/ThemeCustomizationWidget.cpp150
-rw-r--r--launcher/ui/widgets/ThemeCustomizationWidget.h77
-rw-r--r--launcher/ui/widgets/ThemeCustomizationWidget.ui132
-rw-r--r--tests/CMakeLists.txt9
-rw-r--r--tests/DataPackParse_test.cpp79
-rw-r--r--tests/ResourcePackParse_test.cpp9
-rw-r--r--tests/ShaderPackParse_test.cpp77
-rw-r--r--tests/TexturePackParse_test.cpp9
-rw-r--r--tests/WorldSaveParse_test.cpp94
-rw-r--r--tests/testdata/DataPackParse/another_test_folder/data/dummy/tags/item/foo_proof/bar.json1
-rw-r--r--tests/testdata/DataPackParse/another_test_folder/pack.mcmeta6
-rw-r--r--tests/testdata/DataPackParse/test_data_pack_boogaloo.zipbin0 -> 898 bytes
-rw-r--r--tests/testdata/DataPackParse/test_folder/data/dummy/tags/item/foo_proof/bar.json1
-rw-r--r--tests/testdata/DataPackParse/test_folder/pack.mcmeta6
-rw-r--r--tests/testdata/ResourcePackParse/test_resource_pack_idk.zipbin322 -> 804 bytes
-rw-r--r--tests/testdata/ShaderPackParse/shaderpack1.zipbin0 -> 242 bytes
-rw-r--r--tests/testdata/ShaderPackParse/shaderpack2/shaders/shaders.properties0
-rw-r--r--tests/testdata/ShaderPackParse/shaderpack3.zipbin0 -> 128 bytes
-rw-r--r--tests/testdata/WorldSaveParse/minecraft_save_1.zipbin0 -> 184 bytes
-rw-r--r--tests/testdata/WorldSaveParse/minecraft_save_2.zipbin0 -> 352 bytes
-rw-r--r--tests/testdata/WorldSaveParse/minecraft_save_3/world_3/level.dat0
-rw-r--r--tests/testdata/WorldSaveParse/minecraft_save_4/saves/world_4/level.dat0
77 files changed, 3118 insertions, 835 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b6e179e1..d074863d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -61,7 +61,7 @@ jobs:
qt_ver: 6
qt_host: windows
qt_arch: ''
- qt_version: '6.4.0'
+ qt_version: '6.4.2'
qt_modules: 'qt5compat qtimageformats'
qt_tools: ''
@@ -73,7 +73,7 @@ jobs:
qt_ver: 6
qt_host: windows
qt_arch: 'win64_msvc2019_arm64'
- qt_version: '6.4.0'
+ qt_version: '6.4.2'
qt_modules: 'qt5compat qtimageformats'
qt_tools: ''
@@ -105,6 +105,7 @@ jobs:
INSTALL_APPIMAGE_DIR: "install-appdir"
BUILD_DIR: "build"
CCACHE_VAR: ""
+ HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
steps:
##
@@ -143,7 +144,7 @@ jobs:
- name: Setup ccache
if: (runner.os != 'Windows' || matrix.msystem == '') && inputs.build_type == 'Debug'
- uses: hendrikmuhs/ccache-action@v1.2.5
+ uses: hendrikmuhs/ccache-action@v1.2.6
with:
key: ${{ matrix.os }}-qt${{ matrix.qt_ver }}-${{ matrix.architecture }}
@@ -165,7 +166,7 @@ jobs:
- name: Retrieve ccache cache (Windows MinGW-w64)
if: runner.os == 'Windows' && matrix.msystem != '' && inputs.build_type == 'Debug'
- uses: actions/cache@v3.2.2
+ uses: actions/cache@v3.2.3
with:
path: '${{ github.workspace }}\.ccache'
key: ${{ matrix.os }}-mingw-w64
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index ff34a168..ed8d8d2c 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -62,15 +62,11 @@
#include "ui/pages/global/APIPage.h"
#include "ui/pages/global/CustomCommandsPage.h"
-#ifdef Q_OS_WIN
-#include "ui/WinDarkmode.h"
-#include <versionhelpers.h>
-#endif
-
#include "ui/setupwizard/SetupWizard.h"
#include "ui/setupwizard/LanguageWizardPage.h"
#include "ui/setupwizard/JavaWizardPage.h"
#include "ui/setupwizard/PasteWizardPage.h"
+#include "ui/setupwizard/ThemeWizardPage.h"
#include "ui/dialogs/CustomMessageBox.h"
@@ -502,7 +498,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
// Theming
m_settings->registerSetting("IconTheme", QString("pe_colored"));
- m_settings->registerSetting("ApplicationTheme", QString("system"));
+ m_settings->registerSetting("ApplicationTheme", QString());
m_settings->registerSetting("BackgroundCat", QString("kitteh"));
// Remembered state
@@ -851,10 +847,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
});
{
- setIconTheme(settings()->get("IconTheme").toString());
- qDebug() << "<> Icon theme set.";
- setApplicationTheme(settings()->get("ApplicationTheme").toString(), true);
- qDebug() << "<> Application theme set.";
+ applyCurrentlySelectedTheme();
}
updateCapabilities();
@@ -897,7 +890,8 @@ bool Application::createSetupWizard()
return false;
}();
bool pasteInterventionRequired = settings()->get("PastebinURL") != "";
- bool wizardRequired = javaRequired || languageRequired || pasteInterventionRequired;
+ bool themeInterventionRequired = settings()->get("ApplicationTheme") == "";
+ bool wizardRequired = javaRequired || languageRequired || pasteInterventionRequired || themeInterventionRequired;
if(wizardRequired)
{
@@ -916,6 +910,12 @@ bool Application::createSetupWizard()
{
m_setupWizard->addPage(new PasteWizardPage(m_setupWizard));
}
+
+ if (themeInterventionRequired)
+ {
+ settings()->set("ApplicationTheme", QString("system")); // set default theme after going into theme wizard
+ m_setupWizard->addPage(new ThemeWizardPage(m_setupWizard));
+ }
connect(m_setupWizard, &QDialog::finished, this, &Application::setupWizardFinished);
m_setupWizard->show();
return true;
@@ -1123,9 +1123,14 @@ QList<ITheme*> Application::getValidApplicationThemes()
return m_themeManager->getValidApplicationThemes();
}
-void Application::setApplicationTheme(const QString& name, bool initial)
+void Application::applyCurrentlySelectedTheme()
+{
+ m_themeManager->applyCurrentlySelectedTheme();
+}
+
+void Application::setApplicationTheme(const QString& name)
{
- m_themeManager->setApplicationTheme(name, initial);
+ m_themeManager->setApplicationTheme(name);
}
void Application::setIconTheme(const QString& name)
@@ -1353,16 +1358,7 @@ MainWindow* Application::showMainWindow(bool minimized)
m_mainWindow = new MainWindow();
m_mainWindow->restoreState(QByteArray::fromBase64(APPLICATION->settings()->get("MainWindowState").toByteArray()));
m_mainWindow->restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("MainWindowGeometry").toByteArray()));
-#ifdef Q_OS_WIN
- if (IsWindows10OrGreater())
- {
- if (QString::compare(settings()->get("ApplicationTheme").toString(), "dark") == 0) {
- WinDarkmode::setDarkWinTitlebar(m_mainWindow->winId(), true);
- } else {
- WinDarkmode::setDarkWinTitlebar(m_mainWindow->winId(), false);
- }
- }
-#endif
+
if(minimized)
{
m_mainWindow->showMinimized();
diff --git a/launcher/Application.h b/launcher/Application.h
index 7884227a..a7938629 100644
--- a/launcher/Application.h
+++ b/launcher/Application.h
@@ -120,9 +120,11 @@ public:
void setIconTheme(const QString& name);
+ void applyCurrentlySelectedTheme();
+
QList<ITheme*> getValidApplicationThemes();
- void setApplicationTheme(const QString& name, bool initial);
+ void setApplicationTheme(const QString& name);
shared_qobject_ptr<UpdateChecker> updateChecker() {
return m_updateChecker;
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 6ca88ec6..74b7b212 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -331,12 +331,18 @@ set(MINECRAFT_SOURCES
minecraft/mod/Resource.cpp
minecraft/mod/ResourceFolderModel.h
minecraft/mod/ResourceFolderModel.cpp
+ minecraft/mod/DataPack.h
+ minecraft/mod/DataPack.cpp
minecraft/mod/ResourcePack.h
minecraft/mod/ResourcePack.cpp
minecraft/mod/ResourcePackFolderModel.h
minecraft/mod/ResourcePackFolderModel.cpp
minecraft/mod/TexturePack.h
minecraft/mod/TexturePack.cpp
+ minecraft/mod/ShaderPack.h
+ minecraft/mod/ShaderPack.cpp
+ minecraft/mod/WorldSave.h
+ minecraft/mod/WorldSave.cpp
minecraft/mod/TexturePackFolderModel.h
minecraft/mod/TexturePackFolderModel.cpp
minecraft/mod/ShaderPackFolderModel.h
@@ -347,10 +353,18 @@ set(MINECRAFT_SOURCES
minecraft/mod/tasks/LocalModParseTask.cpp
minecraft/mod/tasks/LocalModUpdateTask.h
minecraft/mod/tasks/LocalModUpdateTask.cpp
+ minecraft/mod/tasks/LocalDataPackParseTask.h
+ minecraft/mod/tasks/LocalDataPackParseTask.cpp
minecraft/mod/tasks/LocalResourcePackParseTask.h
minecraft/mod/tasks/LocalResourcePackParseTask.cpp
minecraft/mod/tasks/LocalTexturePackParseTask.h
minecraft/mod/tasks/LocalTexturePackParseTask.cpp
+ minecraft/mod/tasks/LocalShaderPackParseTask.h
+ minecraft/mod/tasks/LocalShaderPackParseTask.cpp
+ minecraft/mod/tasks/LocalWorldSaveParseTask.h
+ minecraft/mod/tasks/LocalWorldSaveParseTask.cpp
+ minecraft/mod/tasks/LocalResourceParse.h
+ minecraft/mod/tasks/LocalResourceParse.cpp
# Assets
minecraft/AssetsUtils.h
@@ -669,6 +683,8 @@ SET(LAUNCHER_SOURCES
ui/setupwizard/LanguageWizardPage.h
ui/setupwizard/PasteWizardPage.cpp
ui/setupwizard/PasteWizardPage.h
+ ui/setupwizard/ThemeWizardPage.cpp
+ ui/setupwizard/ThemeWizardPage.h
# GUI - themes
ui/themes/FusionTheme.cpp
@@ -908,6 +924,8 @@ SET(LAUNCHER_SOURCES
ui/widgets/ProgressWidget.cpp
ui/widgets/WideBar.h
ui/widgets/WideBar.cpp
+ ui/widgets/ThemeCustomizationWidget.h
+ ui/widgets/ThemeCustomizationWidget.cpp
# GUI - instance group view
ui/instanceview/InstanceProxyModel.cpp
@@ -923,18 +941,9 @@ SET(LAUNCHER_SOURCES
ui/instanceview/VisualGroup.h
)
-if(WIN32)
- set(LAUNCHER_SOURCES
- ${LAUNCHER_SOURCES}
-
- # GUI - dark titlebar for Windows 10/11
- ui/WinDarkmode.h
- ui/WinDarkmode.cpp
- )
-endif()
-
qt_wrap_ui(LAUNCHER_UI
ui/setupwizard/PasteWizardPage.ui
+ ui/setupwizard/ThemeWizardPage.ui
ui/pages/global/AccountListPage.ui
ui/pages/global/JavaPage.ui
ui/pages/global/LauncherPage.ui
@@ -967,6 +976,7 @@ qt_wrap_ui(LAUNCHER_UI
ui/widgets/CustomCommands.ui
ui/widgets/InfoFrame.ui
ui/widgets/ModFilterWidget.ui
+ ui/widgets/ThemeCustomizationWidget.ui
ui/dialogs/CopyInstanceDialog.ui
ui/dialogs/ProfileSetupDialog.ui
ui/dialogs/ProgressDialog.ui
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index b3af4f4e..aee5245d 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -57,6 +57,7 @@
#include <shlobj.h>
#include <shobjidl.h>
#include <sys/utime.h>
+#include <versionhelpers.h>
#include <windows.h>
#include <winnls.h>
#include <string>
@@ -214,6 +215,22 @@ bool copy::operator()(const QString& offset, bool dryRun)
return err.value() == 0;
}
+bool move(const QString& source, const QString& dest)
+{
+ std::error_code err;
+
+ ensureFilePathExists(dest);
+ fs::rename(StringUtils::toStdString(source), StringUtils::toStdString(dest), err);
+
+ if (err) {
+ qWarning() << "Failed to move file:" << QString::fromStdString(err.message());
+ qDebug() << "Source file:" << source;
+ qDebug() << "Destination file:" << dest;
+ }
+
+ return err.value() == 0;
+}
+
bool deletePath(QString path)
{
std::error_code err;
@@ -235,6 +252,10 @@ bool trash(QString path, QString *pathInTrash)
// FIXME: Figure out trash in Flatpak. Qt seemingly doesn't use the Trash portal
if (DesktopServices::isFlatpak())
return false;
+#if defined Q_OS_WIN32
+ if (IsWindowsServer())
+ return false;
+#endif
return QFile::moveToTrash(path, pathInTrash);
#endif
}
diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h
index 15233b66..f083f3c7 100644
--- a/launcher/FileSystem.h
+++ b/launcher/FileSystem.h
@@ -123,6 +123,14 @@ class copy : public QObject {
};
/**
+ * @brief moves a file by renaming it
+ * @param source source file path
+ * @param dest destination filepath
+ *
+ */
+bool move(const QString& source, const QString& dest);
+
+/**
* Delete a folder recursively
*/
bool deletePath(QString path);
diff --git a/launcher/minecraft/mod/DataPack.cpp b/launcher/minecraft/mod/DataPack.cpp
new file mode 100644
index 00000000..5c58f6b2
--- /dev/null
+++ b/launcher/minecraft/mod/DataPack.cpp
@@ -0,0 +1,108 @@
+// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.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 "DataPack.h"
+
+#include <QDebug>
+#include <QMap>
+#include <QRegularExpression>
+
+#include "Version.h"
+
+// Values taken from:
+// https://minecraft.fandom.com/wiki/Tutorials/Creating_a_data_pack#%22pack_format%22
+static const QMap<int, std::pair<Version, Version>> s_pack_format_versions = {
+ { 4, { Version("1.13"), Version("1.14.4") } }, { 5, { Version("1.15"), Version("1.16.1") } },
+ { 6, { Version("1.16.2"), Version("1.16.5") } }, { 7, { Version("1.17"), Version("1.17.1") } },
+ { 8, { Version("1.18"), Version("1.18.1") } }, { 9, { Version("1.18.2"), Version("1.18.2") } },
+ { 10, { Version("1.19"), Version("1.19.3") } },
+};
+
+void DataPack::setPackFormat(int new_format_id)
+{
+ QMutexLocker locker(&m_data_lock);
+
+ if (!s_pack_format_versions.contains(new_format_id)) {
+ qWarning() << "Pack format '" << new_format_id << "' is not a recognized data pack id!";
+ }
+
+ m_pack_format = new_format_id;
+}
+
+void DataPack::setDescription(QString new_description)
+{
+ QMutexLocker locker(&m_data_lock);
+
+ m_description = new_description;
+}
+
+std::pair<Version, Version> DataPack::compatibleVersions() const
+{
+ if (!s_pack_format_versions.contains(m_pack_format)) {
+ return { {}, {} };
+ }
+
+ return s_pack_format_versions.constFind(m_pack_format).value();
+}
+
+std::pair<int, bool> DataPack::compare(const Resource& other, SortType type) const
+{
+ auto const& cast_other = static_cast<DataPack const&>(other);
+
+ switch (type) {
+ default: {
+ auto res = Resource::compare(other, type);
+ if (res.first != 0)
+ return res;
+ }
+ case SortType::PACK_FORMAT: {
+ auto this_ver = packFormat();
+ auto other_ver = cast_other.packFormat();
+
+ if (this_ver > other_ver)
+ return { 1, type == SortType::PACK_FORMAT };
+ if (this_ver < other_ver)
+ return { -1, type == SortType::PACK_FORMAT };
+ }
+ }
+ return { 0, false };
+}
+
+bool DataPack::applyFilter(QRegularExpression filter) const
+{
+ if (filter.match(description()).hasMatch())
+ return true;
+
+ if (filter.match(QString::number(packFormat())).hasMatch())
+ return true;
+
+ if (filter.match(compatibleVersions().fir