From 997a3709d40ad66e586c5b5342e8aeb8fe485a32 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 12 Jul 2023 18:10:13 +0100 Subject: [PATCH 01/36] Custom environment variables UI and implementation Signed-off-by: TheKodeToad --- launcher/Application.cpp | 4 + launcher/CMakeLists.txt | 5 + launcher/minecraft/MinecraftInstance.cpp | 22 + .../resources/breeze_dark/breeze_dark.qrc | 1 + .../scalable/environment-variables.svg | 13 + .../resources/breeze_light/breeze_light.qrc | 1 + .../scalable/environment-variables.svg | 13 + launcher/resources/flat/flat.qrc | 1 + .../flat/scalable/custom-commands.svg | 87 +- .../flat/scalable/environment-variables.svg | 86 + launcher/resources/flat_white/flat_white.qrc | 1 + .../flat_white/scalable/custom-commands.svg | 87 +- .../scalable/environment-variables.svg | 86 + launcher/resources/multimc/multimc.qrc | 2 +- .../multimc/scalable/custom-commands.svg | 4615 +++++++++++++++-- .../scalable/environment-variables.svg | 346 ++ launcher/resources/pe_blue/pe_blue.qrc | 1 + .../scalable/environment-variables.svg | 345 ++ launcher/resources/pe_colored/pe_colored.qrc | 1 + .../scalable/environment-variables.svg | 347 ++ launcher/resources/pe_dark/pe_dark.qrc | 1 + .../scalable/environment-variables.svg | 345 ++ launcher/resources/pe_light/pe_light.qrc | 1 + .../scalable/environment-variables.svg | 345 ++ .../pages/global/EnvironmentVariablesPage.cpp | 64 + .../pages/global/EnvironmentVariablesPage.h | 42 + .../pages/instance/InstanceSettingsPage.cpp | 17 + .../ui/pages/instance/InstanceSettingsPage.ui | 25 +- launcher/ui/widgets/EnvironmentVariables.cpp | 138 + launcher/ui/widgets/EnvironmentVariables.h | 44 + launcher/ui/widgets/EnvironmentVariables.ui | 122 + 31 files changed, 6722 insertions(+), 486 deletions(-) create mode 100644 launcher/resources/breeze_dark/scalable/environment-variables.svg create mode 100644 launcher/resources/breeze_light/scalable/environment-variables.svg create mode 100644 launcher/resources/flat/scalable/environment-variables.svg create mode 100644 launcher/resources/flat_white/scalable/environment-variables.svg create mode 100644 launcher/resources/multimc/scalable/environment-variables.svg create mode 100644 launcher/resources/pe_blue/scalable/environment-variables.svg create mode 100644 launcher/resources/pe_colored/scalable/environment-variables.svg create mode 100644 launcher/resources/pe_dark/scalable/environment-variables.svg create mode 100644 launcher/resources/pe_light/scalable/environment-variables.svg create mode 100644 launcher/ui/pages/global/EnvironmentVariablesPage.cpp create mode 100644 launcher/ui/pages/global/EnvironmentVariablesPage.h create mode 100644 launcher/ui/widgets/EnvironmentVariables.cpp create mode 100644 launcher/ui/widgets/EnvironmentVariables.h create mode 100644 launcher/ui/widgets/EnvironmentVariables.ui diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 7858d7132..862e4256e 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -64,6 +64,7 @@ #include "ui/pages/global/AccountListPage.h" #include "ui/pages/global/APIPage.h" #include "ui/pages/global/CustomCommandsPage.h" +#include "ui/pages/global/EnvironmentVariablesPage.h" #include "ui/setupwizard/SetupWizard.h" #include "ui/setupwizard/LanguageWizardPage.h" @@ -701,6 +702,8 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_settings->registerSetting("CloseAfterLaunch", false); m_settings->registerSetting("QuitAfterGameStop", false); + m_settings->registerSetting("Env", QVariant(QMap())); + // Custom Microsoft Authentication Client ID m_settings->registerSetting("MSAClientIDOverride", ""); @@ -726,6 +729,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); + m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index af3bc28e3..8992b1e6c 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -812,6 +812,8 @@ SET(LAUNCHER_SOURCES ui/pages/global/AccountListPage.h ui/pages/global/CustomCommandsPage.cpp ui/pages/global/CustomCommandsPage.h + ui/pages/global/EnvironmentVariablesPage.cpp + ui/pages/global/EnvironmentVariablesPage.h ui/pages/global/ExternalToolsPage.cpp ui/pages/global/ExternalToolsPage.h ui/pages/global/JavaPage.cpp @@ -953,6 +955,8 @@ SET(LAUNCHER_SOURCES ui/widgets/Common.h ui/widgets/CustomCommands.cpp ui/widgets/CustomCommands.h + ui/widgets/EnvironmentVariables.cpp + ui/widgets/EnvironmentVariables.h ui/widgets/DropLabel.cpp ui/widgets/DropLabel.h ui/widgets/FocusLineEdit.cpp @@ -1044,6 +1048,7 @@ qt_wrap_ui(LAUNCHER_UI ui/pages/modplatform/technic/TechnicPage.ui ui/widgets/InstanceCardWidget.ui ui/widgets/CustomCommands.ui + ui/widgets/EnvironmentVariables.ui ui/widgets/InfoFrame.ui ui/widgets/ModFilterWidget.ui ui/widgets/SubTaskProgressBar.ui diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 4867cc7a3..6afc4e9a5 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -186,6 +186,10 @@ void MinecraftInstance::loadSpecificSettings() m_settings->registerOverride(global_settings->getSetting("CloseAfterLaunch"), miscellaneousOverride); m_settings->registerOverride(global_settings->getSetting("QuitAfterGameStop"), miscellaneousOverride); + m_settings->registerSetting("UseEnv", false); + m_settings->registerSetting("OverrideEnv", false); + m_settings->registerSetting("Env", QVariant(QMap())); + m_settings->set("InstanceType", "OneSix"); } @@ -526,6 +530,24 @@ QProcessEnvironment MinecraftInstance::createLaunchEnvironment() } #endif + // custom env + + auto insertEnv = [&env](QMap envMap) { + if (envMap.isEmpty()) + return; + + for (auto iter = envMap.begin(); iter != envMap.end(); iter++) + env.insert(iter.key(), iter.value().toString()); + }; + + bool useEnv = settings()->get("UseEnv").toBool(); + bool overrideEnv = useEnv && settings()->get("OverrideEnv").toBool(); + + if (!overrideEnv) + insertEnv(APPLICATION->settings()->get("Env").toMap()); + if (useEnv) + insertEnv(settings()->get("Env").toMap()); + return env; } diff --git a/launcher/resources/breeze_dark/breeze_dark.qrc b/launcher/resources/breeze_dark/breeze_dark.qrc index 320ca8171..61d82ec30 100644 --- a/launcher/resources/breeze_dark/breeze_dark.qrc +++ b/launcher/resources/breeze_dark/breeze_dark.qrc @@ -9,6 +9,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/discord.svg scalable/externaltools.svg scalable/help.svg diff --git a/launcher/resources/breeze_dark/scalable/environment-variables.svg b/launcher/resources/breeze_dark/scalable/environment-variables.svg new file mode 100644 index 000000000..308c4a239 --- /dev/null +++ b/launcher/resources/breeze_dark/scalable/environment-variables.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/launcher/resources/breeze_light/breeze_light.qrc b/launcher/resources/breeze_light/breeze_light.qrc index e88cd9a00..2211c7188 100644 --- a/launcher/resources/breeze_light/breeze_light.qrc +++ b/launcher/resources/breeze_light/breeze_light.qrc @@ -9,6 +9,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/discord.svg scalable/externaltools.svg scalable/help.svg diff --git a/launcher/resources/breeze_light/scalable/environment-variables.svg b/launcher/resources/breeze_light/scalable/environment-variables.svg new file mode 100644 index 000000000..f5d4acc3b --- /dev/null +++ b/launcher/resources/breeze_light/scalable/environment-variables.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/launcher/resources/flat/flat.qrc b/launcher/resources/flat/flat.qrc index 2fd5daefe..8876027da 100644 --- a/launcher/resources/flat/flat.qrc +++ b/launcher/resources/flat/flat.qrc @@ -11,6 +11,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/discord.svg scalable/externaltools.svg scalable/help.svg diff --git a/launcher/resources/flat/scalable/custom-commands.svg b/launcher/resources/flat/scalable/custom-commands.svg index a35634b16..f2e587843 100644 --- a/launcher/resources/flat/scalable/custom-commands.svg +++ b/launcher/resources/flat/scalable/custom-commands.svg @@ -1,86 +1 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - + diff --git a/launcher/resources/flat/scalable/environment-variables.svg b/launcher/resources/flat/scalable/environment-variables.svg new file mode 100644 index 000000000..a35634b16 --- /dev/null +++ b/launcher/resources/flat/scalable/environment-variables.svg @@ -0,0 +1,86 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/flat_white/flat_white.qrc b/launcher/resources/flat_white/flat_white.qrc index a1c940da0..83b178cbf 100644 --- a/launcher/resources/flat_white/flat_white.qrc +++ b/launcher/resources/flat_white/flat_white.qrc @@ -11,6 +11,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/discord.svg scalable/externaltools.svg scalable/help.svg diff --git a/launcher/resources/flat_white/scalable/custom-commands.svg b/launcher/resources/flat_white/scalable/custom-commands.svg index fe1cf9987..0ba459cff 100644 --- a/launcher/resources/flat_white/scalable/custom-commands.svg +++ b/launcher/resources/flat_white/scalable/custom-commands.svg @@ -1,86 +1 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - + diff --git a/launcher/resources/flat_white/scalable/environment-variables.svg b/launcher/resources/flat_white/scalable/environment-variables.svg new file mode 100644 index 000000000..fe1cf9987 --- /dev/null +++ b/launcher/resources/flat_white/scalable/environment-variables.svg @@ -0,0 +1,86 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/multimc.qrc b/launcher/resources/multimc/multimc.qrc index 2c00f28fa..88a7829f5 100644 --- a/launcher/resources/multimc/multimc.qrc +++ b/launcher/resources/multimc/multimc.qrc @@ -73,8 +73,8 @@ 64x64/screenshots.png scalable/screenshots.svg - scalable/custom-commands.svg + scalable/environment-variables.svg 16x16/cat.png diff --git a/launcher/resources/multimc/scalable/custom-commands.svg b/launcher/resources/multimc/scalable/custom-commands.svg index b7f1a149b..0d502bb1d 100644 --- a/launcher/resources/multimc/scalable/custom-commands.svg +++ b/launcher/resources/multimc/scalable/custom-commands.svg @@ -1,338 +1,4339 @@ + + width="128" + height="128" + id="svg2756" + sodipodi:version="0.32" + inkscape:version="0.45.1" + version="1.0" + sodipodi:docname="konsole.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape" + sodipodi:docbase="/home/david/sandbox"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + inkscape:zoom="4" + inkscape:cx="64" + inkscape:cy="73.608336" + inkscape:document-units="px" + inkscape:current-layer="layer1" + height="128px" + width="128px" + showgrid="true" + gridspacingy="4px" + gridspacingx="4px" + gridempspacing="0" + inkscape:window-width="971" + inkscape:window-height="648" + inkscape:window-x="46" + inkscape:window-y="45" /> + id="metadata2761"> image/svg+xml - + inkscape:label="Livello 1" + inkscape:groupmode="layer" + id="layer1"> + + + + + + + + + + + - - + x="12" + y="16" + width="104" + height="80" + id="rect30" /> - - - - - - - - - - - - - - - - - - - - - + id="g32" + transform="matrix(1.0851064,0,0,1.1142857,3.2340422,6.9714286)"> + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + id="g2644"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/environment-variables.svg b/launcher/resources/multimc/scalable/environment-variables.svg new file mode 100644 index 000000000..5e136b202 --- /dev/null +++ b/launcher/resources/multimc/scalable/environment-variables.svg @@ -0,0 +1,346 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_blue/pe_blue.qrc b/launcher/resources/pe_blue/pe_blue.qrc index da45ef9a1..717d3972e 100644 --- a/launcher/resources/pe_blue/pe_blue.qrc +++ b/launcher/resources/pe_blue/pe_blue.qrc @@ -10,6 +10,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/externaltools.svg scalable/help.svg scalable/instance-settings.svg diff --git a/launcher/resources/pe_blue/scalable/environment-variables.svg b/launcher/resources/pe_blue/scalable/environment-variables.svg new file mode 100644 index 000000000..61c63a4c5 --- /dev/null +++ b/launcher/resources/pe_blue/scalable/environment-variables.svg @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_colored/pe_colored.qrc b/launcher/resources/pe_colored/pe_colored.qrc index ba5bd44f9..023c81e74 100644 --- a/launcher/resources/pe_colored/pe_colored.qrc +++ b/launcher/resources/pe_colored/pe_colored.qrc @@ -10,6 +10,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/externaltools.svg scalable/help.svg scalable/instance-settings.svg diff --git a/launcher/resources/pe_colored/scalable/environment-variables.svg b/launcher/resources/pe_colored/scalable/environment-variables.svg new file mode 100644 index 000000000..c1aab6bca --- /dev/null +++ b/launcher/resources/pe_colored/scalable/environment-variables.svg @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_dark/pe_dark.qrc b/launcher/resources/pe_dark/pe_dark.qrc index 2bfec42cb..c97fb469c 100644 --- a/launcher/resources/pe_dark/pe_dark.qrc +++ b/launcher/resources/pe_dark/pe_dark.qrc @@ -10,6 +10,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/externaltools.svg scalable/help.svg scalable/instance-settings.svg diff --git a/launcher/resources/pe_dark/scalable/environment-variables.svg b/launcher/resources/pe_dark/scalable/environment-variables.svg new file mode 100644 index 000000000..46a3445f4 --- /dev/null +++ b/launcher/resources/pe_dark/scalable/environment-variables.svg @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_light/pe_light.qrc b/launcher/resources/pe_light/pe_light.qrc index 25d5da73b..b590dd2c6 100644 --- a/launcher/resources/pe_light/pe_light.qrc +++ b/launcher/resources/pe_light/pe_light.qrc @@ -10,6 +10,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/externaltools.svg scalable/help.svg scalable/instance-settings.svg diff --git a/launcher/resources/pe_light/scalable/environment-variables.svg b/launcher/resources/pe_light/scalable/environment-variables.svg new file mode 100644 index 000000000..b8d562ffe --- /dev/null +++ b/launcher/resources/pe_light/scalable/environment-variables.svg @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/ui/pages/global/EnvironmentVariablesPage.cpp b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp new file mode 100644 index 000000000..2c3b716b8 --- /dev/null +++ b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * 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 . + */ + +#include +#include + +#include "EnvironmentVariablesPage.h" + +EnvironmentVariablesPage::EnvironmentVariablesPage(QWidget* parent) : QWidget(parent) +{ + auto verticalLayout = new QVBoxLayout(this); + verticalLayout->setContentsMargins(0, 0, 0, 0); + variables = new EnvironmentVariables(this); + variables->setContentsMargins(6, 6, 6, 6); + verticalLayout->addWidget(variables); + + variables->initialize(false, true, false, APPLICATION->settings()->get("Env").toMap()); +} + +QString EnvironmentVariablesPage::displayName() const +{ + return tr("Environment Variables"); +} + +QIcon EnvironmentVariablesPage::icon() const +{ + return APPLICATION->getThemedIcon("environment-variables"); +} + +QString EnvironmentVariablesPage::id() const +{ + return "environment-variables"; +} + +QString EnvironmentVariablesPage::helpPage() const +{ + return "Environment-variables"; +} + +bool EnvironmentVariablesPage::apply() +{ + APPLICATION->settings()->set("Env", variables->value()); + return true; +} + +void EnvironmentVariablesPage::retranslate() +{ + variables->retranslate(); +} diff --git a/launcher/ui/pages/global/EnvironmentVariablesPage.h b/launcher/ui/pages/global/EnvironmentVariablesPage.h new file mode 100644 index 000000000..6e80775ec --- /dev/null +++ b/launcher/ui/pages/global/EnvironmentVariablesPage.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * 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 . + */ + +#pragma once + +#include + +#include "ui/pages/BasePage.h" +#include "ui/widgets/EnvironmentVariables.h" + +class EnvironmentVariablesPage : public QWidget, public BasePage { + Q_OBJECT + + public: + explicit EnvironmentVariablesPage(QWidget* parent = nullptr); + + QString displayName() const override; + QIcon icon() const override; + QString id() const override; + QString helpPage() const override; + + bool apply() override; + void retranslate() override; + + private: + EnvironmentVariables* variables; +}; diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index 943ff17f1..5144e973c 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -84,6 +84,9 @@ void InstanceSettingsPage::globalSettingsButtonClicked(bool) case 2: APPLICATION->ShowGlobalSettings(this, "custom-commands"); return; + case 3: + APPLICATION->ShowGlobalSettings(this, "environment-variables"); + return; default: APPLICATION->ShowGlobalSettings(this, "minecraft-settings"); return; @@ -217,6 +220,11 @@ void InstanceSettingsPage::applySettings() m_settings->reset("PostExitCommand"); } + // Environment Variables + m_settings->set("UseEnv", ui->environmentVariables->checked()); + m_settings->set("OverrideEnv", ui->environmentVariables->override()); + m_settings->set("Env", ui->environmentVariables->value()); + // Workarounds bool workarounds = ui->nativeWorkaroundsGroupBox->isChecked(); m_settings->set("OverrideNativeWorkarounds", workarounds); @@ -345,6 +353,14 @@ void InstanceSettingsPage::loadSettings() m_settings->get("PostExitCommand").toString() ); + // Environment variables + ui->environmentVariables->initialize( + true, + m_settings->get("UseEnv").toBool(), + m_settings->get("OverrideEnv").toBool(), + m_settings->get("Env").toMap() + ); + // Workarounds ui->nativeWorkaroundsGroupBox->setChecked(m_settings->get("OverrideNativeWorkarounds").toBool()); ui->useNativeGLFWCheck->setChecked(m_settings->get("UseNativeGLFW").toBool()); @@ -492,6 +508,7 @@ void InstanceSettingsPage::retranslate() { ui->retranslateUi(this); ui->customCommands->retranslate(); // TODO: why is this seperate from the others? + ui->environmentVariables->retranslate(); } void InstanceSettingsPage::updateThresholds() diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.ui b/launcher/ui/pages/instance/InstanceSettingsPage.ui index 8427965de..7adeb8785 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.ui +++ b/launcher/ui/pages/instance/InstanceSettingsPage.ui @@ -35,13 +35,10 @@ - - QTabWidget::Rounded - 0 - + Java @@ -246,7 +243,7 @@ - + Game windows @@ -406,7 +403,7 @@ - + Custom commands @@ -416,6 +413,16 @@ + + + Environment variables + + + + + + + Workarounds @@ -669,6 +676,12 @@
ui/widgets/CustomCommands.h
1 + + EnvironmentVariables + QWidget +
ui/widgets/EnvironmentVariables.h
+ 1 +
openGlobalJavaSettingsButton diff --git a/launcher/ui/widgets/EnvironmentVariables.cpp b/launcher/ui/widgets/EnvironmentVariables.cpp new file mode 100644 index 000000000..a409f64fc --- /dev/null +++ b/launcher/ui/widgets/EnvironmentVariables.cpp @@ -0,0 +1,138 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * 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 . + */ + +#include + +#include "Application.h" +#include "EnvironmentVariables.h" +#include "ui/dialogs/CustomMessageBox.h" +#include "ui_EnvironmentVariables.h" + +EnvironmentVariables::EnvironmentVariables(QWidget* parent) : QWidget(parent), ui(new Ui::EnvironmentVariables) +{ + ui->setupUi(this); + ui->list->installEventFilter(this); + + ui->list->sortItems(0, Qt::AscendingOrder); + ui->list->setSortingEnabled(true); + ui->list->header()->resizeSections(QHeaderView::Interactive); + ui->list->header()->resizeSection(0, 200); + + connect(ui->add, &QPushButton::clicked, this, [this] { + auto item = new QTreeWidgetItem(ui->list); + item->setText(0, "ENV_VAR"); + item->setText(1, "value"); + item->setFlags(item->flags() | Qt::ItemIsEditable); + ui->list->addTopLevelItem(item); + ui->list->selectionModel()->select(ui->list->model()->index(ui->list->indexOfTopLevelItem(item), 0), + QItemSelectionModel::ClearAndSelect | QItemSelectionModel::SelectionFlag::Rows); + ui->list->editItem(item); + }); + + connect(ui->remove, &QPushButton::clicked, this, [this] { + for (QTreeWidgetItem* item : ui->list->selectedItems()) + ui->list->takeTopLevelItem(ui->list->indexOfTopLevelItem(item)); + }); + + connect(ui->clear, &QPushButton::clicked, this, [this] { ui->list->clear(); }); + + connect(ui->globalOverride, &QCheckBox::clicked, this, [this](bool state) { + if (!state) + return; + + auto global = APPLICATION->settings()->get("Env").toMap(); + if (global.isEmpty()) + return; + + auto response = CustomMessageBox::selectable( + this, tr("Reset"), + tr("You have chosen to ignore global settings.\n\nWould you like to clear the current variables and copy " + "the global variables over?"), + QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) + ->exec(); + + if (response == QMessageBox::Yes) + initialize(true, checked(), override(), global); + }); +} + +EnvironmentVariables::~EnvironmentVariables() +{ + delete ui; +} + +void EnvironmentVariables::initialize(bool instance, bool checked, bool override, const QMap& value) +{ + // update widgets to settings + ui->groupBox->setCheckable(instance); + ui->groupBox->setChecked(checked); + ui->globalOverride->setVisible(instance); + ui->globalOverride->setChecked(override); + + // populate + ui->list->clear(); + for (auto iter = value.begin(); iter != value.end(); iter++) { + auto item = new QTreeWidgetItem(ui->list); + item->setText(0, iter.key()); + item->setText(1, iter.value().toString()); + item->setFlags(item->flags() | Qt::ItemIsEditable); + ui->list->addTopLevelItem(item); + } +} + +bool EnvironmentVariables::eventFilter(QObject* watched, QEvent* event) +{ + if (watched == ui->list && event->type() == QEvent::KeyPress) { + const QKeyEvent* keyEvent = (QKeyEvent*)event; + if (keyEvent->key() == Qt::Key_Delete) { + emit ui->remove->clicked(); + return true; + } + } + + return QObject::eventFilter(watched, event); +} + +void EnvironmentVariables::retranslate() +{ + ui->retranslateUi(this); +} + +bool EnvironmentVariables::checked() const +{ + if (!ui->groupBox->isCheckable()) + return true; + return ui->groupBox->isChecked(); +} + +bool EnvironmentVariables::override() const +{ + if (!ui->globalOverride->isVisible()) + return false; + return ui->globalOverride->isChecked(); +} + +QMap EnvironmentVariables::value() const +{ + QMap result; + QTreeWidgetItem* item = ui->list->topLevelItem(0); + for (int i = 1; item != nullptr; item = ui->list->topLevelItem(i++)) + result[item->text(0)] = item->text(1); + + return result; +} diff --git a/launcher/ui/widgets/EnvironmentVariables.h b/launcher/ui/widgets/EnvironmentVariables.h new file mode 100644 index 000000000..ba4329dd9 --- /dev/null +++ b/launcher/ui/widgets/EnvironmentVariables.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * 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 . + */ + +#pragma once + +#include +#include + +namespace Ui { +class EnvironmentVariables; +} + +class EnvironmentVariables : public QWidget { + Q_OBJECT + + public: + explicit EnvironmentVariables(QWidget* state = nullptr); + ~EnvironmentVariables() override; + void initialize(bool instance, bool checked, bool override, const QMap& value); + bool eventFilter(QObject* watched, QEvent* event) override; + + void retranslate(); + bool checked() const; + bool override() const; + QMap value() const; + + private: + Ui::EnvironmentVariables* ui; +}; diff --git a/launcher/ui/widgets/EnvironmentVariables.ui b/launcher/ui/widgets/EnvironmentVariables.ui new file mode 100644 index 000000000..895b40d01 --- /dev/null +++ b/launcher/ui/widgets/EnvironmentVariables.ui @@ -0,0 +1,122 @@ + + + EnvironmentVariables + + + + 0 + 0 + 565 + 410 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + &Environment Variables + + + true + + + + + + &Ignore global settings + + + + + + + true + + + QAbstractItemView::ExtendedSelection + + + false + + + false + + + true + + + false + + + + Name + + + + + Value + + + + + + + + + + &Add + + + + + + + &Remove + + + + + + + &Clear + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + From 4f1ee854249f62c36dd9e8e1d9fbbc0b20bc09ec Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 6 Oct 2023 00:21:37 +0300 Subject: [PATCH 02/36] check for minecraft java runtime Signed-off-by: Trial97 --- launcher/java/JavaUtils.cpp | 43 +++++++++++++++++++++++++++++++++++++ launcher/java/JavaUtils.h | 1 + 2 files changed, 44 insertions(+) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index cca1ed6d4..9f682e086 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -335,6 +335,7 @@ QList JavaUtils::FindJavaPaths() } } + javas.append(getMinecraftJavaBundle()); candidates = addJavasFromEnv(candidates); candidates.removeDuplicates(); return candidates; @@ -360,6 +361,7 @@ QList JavaUtils::FindJavaPaths() javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Home/bin/java"); javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Commands/java"); } + javas.append(getMinecraftJavaBundle()); javas = addJavasFromEnv(javas); javas.removeDuplicates(); return javas; @@ -411,6 +413,7 @@ QList JavaUtils::FindJavaPaths() // javas downloaded by sdkman scanJavaDirs(FS::PathCombine(home, ".sdkman/candidates/java")); + javas.append(getMinecraftJavaBundle()); javas = addJavasFromEnv(javas); javas.removeDuplicates(); return javas; @@ -423,6 +426,7 @@ QList JavaUtils::FindJavaPaths() QList javas; javas.append(this->GetDefaultJava()->path); + javas.append(getMinecraftJavaBundle()); return addJavasFromEnv(javas); } #endif @@ -431,3 +435,42 @@ QString JavaUtils::getJavaCheckPath() { return APPLICATION->getJarPath("JavaCheck.jar"); } + +QStringList getMinecraftJavaBundle() +{ + QString partialPath; + QString executable = "java"; +#if defined(Q_OS_OSX) + partialPath = FS::PathCombine(QDir::homePath(), "Library/Application Support"); +#elif defined(Q_OS_WIN32) + partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); + executable += "w.exe"; +#else + partialPath = QDir::homePath(); +#endif + auto minecraftPath = FS::PathCombine(partialPath, ".minecraft", "runtime"); + QStringList javas; + QStringList processpaths{ minecraftPath }; + + while (!processpaths.isEmpty()) { + auto dirPath = processpaths.takeFirst(); + QDir dir(dirPath); + if (!dir.exists()) + continue; + auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + auto binFound = false; + for (auto& entry : entries) { + if (entry.baseName() == "bin") { + javas.append(FS::PathCombine(entry.canonicalFilePath(), executable)); + binFound = true; + break; + } + } + if (!binFound) { + for (auto& entry : entries) { + processpaths << entry.canonicalFilePath(); + } + } + } + return javas; +} diff --git a/launcher/java/JavaUtils.h b/launcher/java/JavaUtils.h index 616179706..2fb03af7a 100644 --- a/launcher/java/JavaUtils.h +++ b/launcher/java/JavaUtils.h @@ -26,6 +26,7 @@ QString stripVariableEntries(QString name, QString target, QString remove); QProcessEnvironment CleanEnviroment(); +QStringList getMinecraftJavaBundle(); class JavaUtils : public QObject { Q_OBJECT From 82461b1113b01a4305046b5da69dbf60e885f756 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 6 Oct 2023 08:51:45 +0300 Subject: [PATCH 03/36] rename for windows Signed-off-by: Trial97 --- launcher/java/JavaUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 9f682e086..10bbb1f1b 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -335,7 +335,7 @@ QList JavaUtils::FindJavaPaths() } } - javas.append(getMinecraftJavaBundle()); + candidates.append(getMinecraftJavaBundle()); candidates = addJavasFromEnv(candidates); candidates.removeDuplicates(); return candidates; From 8d0a53273f6fbd75c563b184f5bc326adfaf02d2 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 6 Oct 2023 18:42:54 +0300 Subject: [PATCH 04/36] Add no_color env variable Signed-off-by: Trial97 --- launcher/minecraft/MinecraftInstance.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index f9833b972..b536951a8 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -536,6 +536,7 @@ QMap MinecraftInstance::getVariables() out.insert("INST_MC_DIR", QDir::toNativeSeparators(QDir(gameRoot()).absolutePath())); out.insert("INST_JAVA", settings()->get("JavaPath").toString()); out.insert("INST_JAVA_ARGS", javaArguments().join(' ')); + out.insert("NO_COLOR", "1"); return out; } From e9fd02baca57db1af85dd4f8f36a4c0fed2de8ff Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 20 Oct 2023 13:12:16 +0100 Subject: [PATCH 05/36] Fix code style Signed-off-by: TheKodeToad --- launcher/minecraft/MinecraftInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index dd4a56596..cc33c05af 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -187,7 +187,7 @@ void MinecraftInstance::loadSpecificSettings() // Legacy-related options auto legacySettings = m_settings->registerSetting("OverrideLegacySettings", false); m_settings->registerOverride(global_settings->getSetting("OnlineFixes"), legacySettings); - + m_settings->registerSetting("UseEnv", false); m_settings->registerSetting("OverrideEnv", false); m_settings->registerSetting("Env", QVariant(QMap())); From 7b62d146838967903addc80247cf6e7db9862967 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 20 Oct 2023 17:15:12 +0300 Subject: [PATCH 06/36] fixed squished mod icons Signed-off-by: Trial97 --- launcher/minecraft/mod/ModFolderModel.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index a5f1489dd..b1e35f405 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -127,7 +127,18 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const if (column == NAME_COLUMN && (at(row)->isSymLinkUnder(instDirPath()) || at(row)->isMoreThanOneHardLink())) return APPLICATION->getThemedIcon("status-yellow"); if (column == ImageColumn) { - return at(row)->icon({ 32, 32 }, Qt::AspectRatioMode::KeepAspectRatioByExpanding); + QSize size(32, 32); + auto icon = at(row)->icon(size, Qt::AspectRatioMode::KeepAspectRatioByExpanding); + if (icon.isNull()) { + QPixmap transparent_image(size); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + transparent_image.fill(QColorConstants::Transparent); +#else + transparent_image.fill(QColor(0, 0, 0, 0)); +#endif + return transparent_image; + } + return icon; } return {}; } From 5d926582c7dcd4a288b9539a4a15338c1bfce21e Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 20 Oct 2023 19:08:56 +0300 Subject: [PATCH 07/36] added Image column size hint Signed-off-by: Trial97 --- launcher/minecraft/mod/ModFolderModel.cpp | 18 ++++++------------ .../minecraft/mod/ResourcePackFolderModel.cpp | 5 +++++ .../minecraft/mod/TexturePackFolderModel.cpp | 5 +++++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index b1e35f405..11f7cd0f1 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -127,21 +127,15 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const if (column == NAME_COLUMN && (at(row)->isSymLinkUnder(instDirPath()) || at(row)->isMoreThanOneHardLink())) return APPLICATION->getThemedIcon("status-yellow"); if (column == ImageColumn) { - QSize size(32, 32); - auto icon = at(row)->icon(size, Qt::AspectRatioMode::KeepAspectRatioByExpanding); - if (icon.isNull()) { - QPixmap transparent_image(size); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - transparent_image.fill(QColorConstants::Transparent); -#else - transparent_image.fill(QColor(0, 0, 0, 0)); -#endif - return transparent_image; - } - return icon; + return at(row)->icon({ 32, 32 }, Qt::AspectRatioMode::KeepAspectRatioByExpanding); } return {}; } + case Qt::SizeHintRole: + if (column == ImageColumn) { + return QSize(32, 32); + } + return {}; case Qt::CheckStateRole: switch (column) { case ActiveColumn: diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.cpp b/launcher/minecraft/mod/ResourcePackFolderModel.cpp index f27431576..efe1cc5dd 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.cpp +++ b/launcher/minecraft/mod/ResourcePackFolderModel.cpp @@ -117,6 +117,11 @@ QVariant ResourcePackFolderModel::data(const QModelIndex& index, int role) const } return m_resources[row]->internal_id(); } + case Qt::SizeHintRole: + if (column == ImageColumn) { + return QSize(32, 32); + } + return {}; case Qt::CheckStateRole: switch (column) { case ActiveColumn: diff --git a/launcher/minecraft/mod/TexturePackFolderModel.cpp b/launcher/minecraft/mod/TexturePackFolderModel.cpp index 5c5f2b7c1..e39be1fb9 100644 --- a/launcher/minecraft/mod/TexturePackFolderModel.cpp +++ b/launcher/minecraft/mod/TexturePackFolderModel.cpp @@ -104,6 +104,11 @@ QVariant TexturePackFolderModel::data(const QModelIndex& index, int role) const } return {}; } + case Qt::SizeHintRole: + if (column == ImageColumn) { + return QSize(32, 32); + } + return {}; case Qt::CheckStateRole: if (column == ActiveColumn) { return m_resources[row]->enabled() ? Qt::Checked : Qt::Unchecked; From 7d5206818b70cede91aad1bf0dbcec92e5acde5a Mon Sep 17 00:00:00 2001 From: Tayou Date: Sun, 22 Oct 2023 21:00:52 +0200 Subject: [PATCH 08/36] fix switch/case fallthrough Signed-off-by: Tayou --- launcher/minecraft/mod/tasks/LocalModParseTask.cpp | 2 ++ launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp | 2 ++ launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp index 7ec00c0c6..e9e12d86a 100644 --- a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp @@ -688,6 +688,7 @@ bool loadIconFile(const Mod& mod) return png_invalid(); // icon invalid } } + return false; } case ResourceType::ZIPFILE: { QuaZip zip(mod.fileinfo().filePath()); @@ -714,6 +715,7 @@ bool loadIconFile(const Mod& mod) } else { return png_invalid(); // could not set icon as current file. } + return false; } case ResourceType::LITEMOD: { return false; // can lightmods even have icons? diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp index 7b9f4f594..7e02fd51c 100644 --- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp @@ -232,6 +232,7 @@ bool processPackPNG(const ResourcePack& pack) } else { return png_invalid(); // pack.png does not exists or is not a valid file. } + return false; // not processed correctly; https://github.com/PrismLauncher/PrismLauncher/issues/1740 } case ResourceType::ZIPFILE: { Q_ASSERT(pack.type() == ResourceType::ZIPFILE); @@ -259,6 +260,7 @@ bool processPackPNG(const ResourcePack& pack) } else { return png_invalid(); // could not set pack.mcmeta as current file. } + return false; // not processed correctly; https://github.com/PrismLauncher/PrismLauncher/issues/1740 } default: qWarning() << "Invalid type for resource pack parse task!"; diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp index 887a1062e..13f157dff 100644 --- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp @@ -186,6 +186,7 @@ bool processPackPNG(const TexturePack& pack) } else { return png_invalid(); // pack.png does not exists or is not a valid file. } + return false; } case ResourceType::ZIPFILE: { Q_ASSERT(pack.type() == ResourceType::ZIPFILE); @@ -215,6 +216,7 @@ bool processPackPNG(const TexturePack& pack) zip.close(); return png_invalid(); // could not set pack.mcmeta as current file. } + return false; } default: qWarning() << "Invalid type for resource pack parse task!"; From 0fe3241df61e014a0b427282258d156546880019 Mon Sep 17 00:00:00 2001 From: Tayou Date: Sat, 21 Oct 2023 20:05:14 +0200 Subject: [PATCH 09/36] remove now unneeded Q_ASSERTs Signed-off-by: Tayou --- launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp | 2 -- launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp index 7e02fd51c..26bc07637 100644 --- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp @@ -235,8 +235,6 @@ bool processPackPNG(const ResourcePack& pack) return false; // not processed correctly; https://github.com/PrismLauncher/PrismLauncher/issues/1740 } case ResourceType::ZIPFILE: { - Q_ASSERT(pack.type() == ResourceType::ZIPFILE); - QuaZip zip(pack.fileinfo().filePath()); if (!zip.open(QuaZip::mdUnzip)) return false; // can't open zip file diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp index 13f157dff..d7e61ca90 100644 --- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp @@ -189,8 +189,6 @@ bool processPackPNG(const TexturePack& pack) return false; } case ResourceType::ZIPFILE: { - Q_ASSERT(pack.type() == ResourceType::ZIPFILE); - QuaZip zip(pack.fileinfo().filePath()); if (!zip.open(QuaZip::mdUnzip)) return false; // can't open zip file From 12d567a9b83142b102598a944c650849d4a0f94e Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 26 Oct 2023 22:51:38 +0300 Subject: [PATCH 10/36] made env vars behave like the rest of the settings Signed-off-by: Trial97 --- launcher/minecraft/MinecraftInstance.cpp | 10 +++--- .../pages/global/EnvironmentVariablesPage.cpp | 2 +- .../pages/instance/InstanceSettingsPage.cpp | 12 ++++--- launcher/ui/widgets/EnvironmentVariables.cpp | 36 +++---------------- launcher/ui/widgets/EnvironmentVariables.h | 3 +- launcher/ui/widgets/EnvironmentVariables.ui | 7 ---- 6 files changed, 17 insertions(+), 53 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index cc33c05af..b371a3751 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -188,9 +188,8 @@ void MinecraftInstance::loadSpecificSettings() auto legacySettings = m_settings->registerSetting("OverrideLegacySettings", false); m_settings->registerOverride(global_settings->getSetting("OnlineFixes"), legacySettings); - m_settings->registerSetting("UseEnv", false); - m_settings->registerSetting("OverrideEnv", false); - m_settings->registerSetting("Env", QVariant(QMap())); + auto envSetting = m_settings->registerSetting("OverrideEnv", false); + m_settings->registerOverride(global_settings->getSetting("Env"), envSetting); m_settings->set("InstanceType", "OneSix"); } @@ -612,12 +611,11 @@ QProcessEnvironment MinecraftInstance::createLaunchEnvironment() env.insert(iter.key(), iter.value().toString()); }; - bool useEnv = settings()->get("UseEnv").toBool(); - bool overrideEnv = useEnv && settings()->get("OverrideEnv").toBool(); + bool overrideEnv = settings()->get("OverrideEnv").toBool(); if (!overrideEnv) insertEnv(APPLICATION->settings()->get("Env").toMap()); - if (useEnv) + else insertEnv(settings()->get("Env").toMap()); return env; diff --git a/launcher/ui/pages/global/EnvironmentVariablesPage.cpp b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp index 2c3b716b8..2b76df362 100644 --- a/launcher/ui/pages/global/EnvironmentVariablesPage.cpp +++ b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp @@ -29,7 +29,7 @@ EnvironmentVariablesPage::EnvironmentVariablesPage(QWidget* parent) : QWidget(pa variables->setContentsMargins(6, 6, 6, 6); verticalLayout->addWidget(variables); - variables->initialize(false, true, false, APPLICATION->settings()->get("Env").toMap()); + variables->initialize(false, false, APPLICATION->settings()->get("Env").toMap()); } QString EnvironmentVariablesPage::displayName() const diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index 9f01cab42..74785f97e 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -203,9 +203,12 @@ void InstanceSettingsPage::applySettings() } // Environment Variables - m_settings->set("UseEnv", ui->environmentVariables->checked()); - m_settings->set("OverrideEnv", ui->environmentVariables->override()); - m_settings->set("Env", ui->environmentVariables->value()); + auto env = ui->environmentVariables->override(); + m_settings->set("OverrideEnv", env); + if (env) + m_settings->set("Env", ui->environmentVariables->value()); + else + m_settings->reset("Env"); // Workarounds bool workarounds = ui->nativeWorkaroundsGroupBox->isChecked(); @@ -327,8 +330,7 @@ void InstanceSettingsPage::loadSettings() m_settings->get("WrapperCommand").toString(), m_settings->get("PostExitCommand").toString()); // Environment variables - ui->environmentVariables->initialize(true, m_settings->get("UseEnv").toBool(), m_settings->get("OverrideEnv").toBool(), - m_settings->get("Env").toMap()); + ui->environmentVariables->initialize(true, m_settings->get("OverrideEnv").toBool(), m_settings->get("Env").toMap()); // Workarounds ui->nativeWorkaroundsGroupBox->setChecked(m_settings->get("OverrideNativeWorkarounds").toBool()); diff --git a/launcher/ui/widgets/EnvironmentVariables.cpp b/launcher/ui/widgets/EnvironmentVariables.cpp index a409f64fc..633fc6122 100644 --- a/launcher/ui/widgets/EnvironmentVariables.cpp +++ b/launcher/ui/widgets/EnvironmentVariables.cpp @@ -50,25 +50,6 @@ EnvironmentVariables::EnvironmentVariables(QWidget* parent) : QWidget(parent), u }); connect(ui->clear, &QPushButton::clicked, this, [this] { ui->list->clear(); }); - - connect(ui->globalOverride, &QCheckBox::clicked, this, [this](bool state) { - if (!state) - return; - - auto global = APPLICATION->settings()->get("Env").toMap(); - if (global.isEmpty()) - return; - - auto response = CustomMessageBox::selectable( - this, tr("Reset"), - tr("You have chosen to ignore global settings.\n\nWould you like to clear the current variables and copy " - "the global variables over?"), - QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) - ->exec(); - - if (response == QMessageBox::Yes) - initialize(true, checked(), override(), global); - }); } EnvironmentVariables::~EnvironmentVariables() @@ -76,13 +57,11 @@ EnvironmentVariables::~EnvironmentVariables() delete ui; } -void EnvironmentVariables::initialize(bool instance, bool checked, bool override, const QMap& value) +void EnvironmentVariables::initialize(bool instance, bool override, const QMap& value) { // update widgets to settings ui->groupBox->setCheckable(instance); - ui->groupBox->setChecked(checked); - ui->globalOverride->setVisible(instance); - ui->globalOverride->setChecked(override); + ui->groupBox->setChecked(override); // populate ui->list->clear(); @@ -113,18 +92,11 @@ void EnvironmentVariables::retranslate() ui->retranslateUi(this); } -bool EnvironmentVariables::checked() const -{ - if (!ui->groupBox->isCheckable()) - return true; - return ui->groupBox->isChecked(); -} - bool EnvironmentVariables::override() const { - if (!ui->globalOverride->isVisible()) + if (!ui->groupBox->isCheckable()) return false; - return ui->globalOverride->isChecked(); + return ui->groupBox->isChecked(); } QMap EnvironmentVariables::value() const diff --git a/launcher/ui/widgets/EnvironmentVariables.h b/launcher/ui/widgets/EnvironmentVariables.h index ba4329dd9..092d586bd 100644 --- a/launcher/ui/widgets/EnvironmentVariables.h +++ b/launcher/ui/widgets/EnvironmentVariables.h @@ -31,11 +31,10 @@ class EnvironmentVariables : public QWidget { public: explicit EnvironmentVariables(QWidget* state = nullptr); ~EnvironmentVariables() override; - void initialize(bool instance, bool checked, bool override, const QMap& value); + void initialize(bool instance, bool override, const QMap& value); bool eventFilter(QObject* watched, QEvent* event) override; void retranslate(); - bool checked() const; bool override() const; QMap value() const; diff --git a/launcher/ui/widgets/EnvironmentVariables.ui b/launcher/ui/widgets/EnvironmentVariables.ui index 895b40d01..ded5b2ded 100644 --- a/launcher/ui/widgets/EnvironmentVariables.ui +++ b/launcher/ui/widgets/EnvironmentVariables.ui @@ -35,13 +35,6 @@ true - - - - &Ignore global settings - - - From bd11b93a0cb917e67dceac2f8eb03562f0f7bdb6 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 26 Oct 2023 21:01:24 +0100 Subject: [PATCH 11/36] Use hidden tab bar like other pages Signed-off-by: TheKodeToad --- launcher/ui/pages/global/EnvironmentVariablesPage.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/launcher/ui/pages/global/EnvironmentVariablesPage.cpp b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp index 2b76df362..2d44ed624 100644 --- a/launcher/ui/pages/global/EnvironmentVariablesPage.cpp +++ b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp @@ -17,6 +17,7 @@ */ #include +#include #include #include "EnvironmentVariablesPage.h" @@ -24,10 +25,16 @@ EnvironmentVariablesPage::EnvironmentVariablesPage(QWidget* parent) : QWidget(parent) { auto verticalLayout = new QVBoxLayout(this); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); verticalLayout->setContentsMargins(0, 0, 0, 0); + + auto tabWidget = new QTabWidget(this); + tabWidget->setObjectName(QStringLiteral("tabWidget")); variables = new EnvironmentVariables(this); variables->setContentsMargins(6, 6, 6, 6); - verticalLayout->addWidget(variables); + tabWidget->addTab(variables, "Foo"); + tabWidget->tabBar()->hide(); + verticalLayout->addWidget(tabWidget); variables->initialize(false, false, APPLICATION->settings()->get("Env").toMap()); } From 364cb4ff6afccb2d9696a5a2363df0623beee0da Mon Sep 17 00:00:00 2001 From: IThundxr Date: Sat, 28 Oct 2023 07:39:32 -0400 Subject: [PATCH 12/36] chore: remove windows 7/8 support With 8.0 windows legacy support was dropped, this just removes it from the manifest Signed-off-by: IThundxr --- program_info/prismlauncher.manifest.in | 6 ------ 1 file changed, 6 deletions(-) diff --git a/program_info/prismlauncher.manifest.in b/program_info/prismlauncher.manifest.in index 6f4467c7d..fb28afc17 100644 --- a/program_info/prismlauncher.manifest.in +++ b/program_info/prismlauncher.manifest.in @@ -16,12 +16,6 @@ Custom Minecraft launcher for managing multiple installs. - - - - - - From 9dcb7e975921374274740e67632ca44dc0fe09da Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 28 Oct 2023 16:03:11 +0000 Subject: [PATCH 13/36] chore(deps): update korthout/backport-action action to v2 --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index c705ff7b0..f9cf4fb7d 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -24,7 +24,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - name: Create backport PRs - uses: korthout/backport-action@v1.4.0 + uses: korthout/backport-action@v2.0.0 with: # Config README: https://github.com/korthout/backport-action#backport-action pull_description: |- From 54305397e45ec9f2c14b84eb782b541633b9dc3d Mon Sep 17 00:00:00 2001 From: LocalSpook <56512186+LocalSpook@users.noreply.github.com> Date: Sat, 28 Oct 2023 12:50:40 -0700 Subject: [PATCH 14/36] Localize sorting options for resource and shader packs Signed-off-by: LocalSpook <56512186+LocalSpook@users.noreply.github.com> --- launcher/modplatform/flame/FlameAPI.cpp | 20 +++++++++---------- launcher/modplatform/modrinth/ModrinthAPI.cpp | 14 ++++++------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/launcher/modplatform/flame/FlameAPI.cpp b/launcher/modplatform/flame/FlameAPI.cpp index e99ce3a56..bb4f18983 100644 --- a/launcher/modplatform/flame/FlameAPI.cpp +++ b/launcher/modplatform/flame/FlameAPI.cpp @@ -208,17 +208,15 @@ Task::Ptr FlameAPI::getFile(const QString& addonId, const QString& fileId, std:: return netJob; } -// https://docs.curseforge.com/?python#tocS_ModsSearchSortField -static QList s_sorts = { { 1, "Featured", QObject::tr("Sort by Featured") }, - { 2, "Popularity", QObject::tr("Sort by Popularity") }, - { 3, "LastUpdated", QObject::tr("Sort by Last Updated") }, - { 4, "Name", QObject::tr("Sort by Name") }, - { 5, "Author", QObject::tr("Sort by Author") }, - { 6, "TotalDownloads", QObject::tr("Sort by Downloads") }, - { 7, "Category", QObject::tr("Sort by Category") }, - { 8, "GameVersion", QObject::tr("Sort by Game Version") } }; - QList FlameAPI::getSortingMethods() const { - return s_sorts; + // https://docs.curseforge.com/?python#tocS_ModsSearchSortField + return { { 1, "Featured", QObject::tr("Sort by Featured") }, + { 2, "Popularity", QObject::tr("Sort by Popularity") }, + { 3, "LastUpdated", QObject::tr("Sort by Last Updated") }, + { 4, "Name", QObject::tr("Sort by Name") }, + { 5, "Author", QObject::tr("Sort by Author") }, + { 6, "TotalDownloads", QObject::tr("Sort by Downloads") }, + { 7, "Category", QObject::tr("Sort by Category") }, + { 8, "GameVersion", QObject::tr("Sort by Game Version") } }; } diff --git a/launcher/modplatform/modrinth/ModrinthAPI.cpp b/launcher/modplatform/modrinth/ModrinthAPI.cpp index f453f5cb9..8be963ecf 100644 --- a/launcher/modplatform/modrinth/ModrinthAPI.cpp +++ b/launcher/modplatform/modrinth/ModrinthAPI.cpp @@ -111,14 +111,12 @@ Task::Ptr ModrinthAPI::getProjects(QStringList addonIds, std::shared_ptr s_sorts = { { 1, "relevance", QObject::tr("Sort by Relevance") }, - { 2, "downloads", QObject::tr("Sort by Downloads") }, - { 3, "follows", QObject::tr("Sort by Follows") }, - { 4, "newest", QObject::tr("Sort by Last Updated") }, - { 5, "updated", QObject::tr("Sort by Newest") } }; - QList ModrinthAPI::getSortingMethods() const { - return s_sorts; + // https://docs.modrinth.com/api-spec/#tag/projects/operation/searchProjects + return { { 1, "relevance", QObject::tr("Sort by Relevance") }, + { 2, "downloads", QObject::tr("Sort by Downloads") }, + { 3, "follows", QObject::tr("Sort by Follows") }, + { 4, "newest", QObject::tr("Sort by Last Updated") }, + { 5, "updated", QObject::tr("Sort by Newest") } }; } From 55ac17c45b40f678f831b189a6d25a1f5344f73e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 29 Oct 2023 00:18:11 +0000 Subject: [PATCH 15/36] chore(nix): update lockfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nixpkgs': 'github:nixos/nixpkgs/44881e03af1c730cbb1d72a4d41274a2c957813a' (2023-10-21) → 'github:nixos/nixpkgs/808c0d8c53c7ae50f82aca8e7df263225cf235bf' (2023-10-26) • Updated input 'pre-commit-hooks': 'github:cachix/pre-commit-hooks.nix/8cc349bfd082da8782b989cad2158c9ad5bd70fd' (2023-10-19) → 'github:cachix/pre-commit-hooks.nix/bd38df3d508dfcdff52cd243d297f218ed2257bf' (2023-10-25) --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index d71403358..7cf901f77 100644 --- a/flake.lock +++ b/flake.lock @@ -106,11 +106,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1697886341, - "narHash": "sha256-AdE67xPty9M9wn36nPVp6aDntIdigrs7UbyaGv1VAaM=", + "lastModified": 1698336494, + "narHash": "sha256-sO72WDBKyijYD1GcKPlGsycKbMBiTJMBCnmOxLAs880=", "owner": "nixos", "repo": "nixpkgs", - "rev": "44881e03af1c730cbb1d72a4d41274a2c957813a", + "rev": "808c0d8c53c7ae50f82aca8e7df263225cf235bf", "type": "github" }, "original": { @@ -153,11 +153,11 @@ ] }, "locked": { - "lastModified": 1697746376, - "narHash": "sha256-gu77VkgdfaHgNCVufeb6WP9oqFLjwK4jHcoPZmBVF3E=", + "lastModified": 1698227354, + "narHash": "sha256-Fi5H9jbaQLmLw9qBi/mkR33CoFjNbobo5xWdX4tKz1Q=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "8cc349bfd082da8782b989cad2158c9ad5bd70fd", + "rev": "bd38df3d508dfcdff52cd243d297f218ed2257bf", "type": "github" }, "original": { From 5a54d80c6ee2ec05bcca0044d3936d5fa0e8d13d Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 30 Oct 2023 09:26:38 +0000 Subject: [PATCH 16/36] Fix group issues Signed-off-by: TheKodeToad --- launcher/InstanceList.cpp | 11 ++++++----- launcher/InstanceList.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp index 756ff93dd..111f8d8a4 100644 --- a/launcher/InstanceList.cpp +++ b/launcher/InstanceList.cpp @@ -290,8 +290,7 @@ void InstanceList::deleteGroup(const GroupId& name) qDebug() << "Remove" << instID << "from group" << name; removed = true; auto idx = getInstIndex(instance.get()); - if (idx > 0) - emit dataChanged(index(idx), index(idx), { GroupRole }); + emit dataChanged(index(idx), index(idx), { GroupRole }); } } if (removed) @@ -315,8 +314,7 @@ void InstanceList::renameGroup(const QString& src, const QString& dst) qDebug() << "Set" << instID << "group to" << dst; modified = true; auto idx = getInstIndex(instance.get()); - if (idx > 0) - emit dataChanged(index(idx), index(idx), { GroupRole }); + emit dataChanged(index(idx), index(idx), { GroupRole }); } } if (modified) @@ -947,9 +945,12 @@ QString InstanceList::getStagedInstancePath() bool InstanceList::commitStagedInstance(const QString& path, InstanceName const& instanceName, - const QString& groupName, + QString groupName, InstanceTask const& commiting) { + if (groupName.isEmpty() && !groupName.isNull()) + groupName = QString(); + QDir dir; QString instID; InstancePtr inst; diff --git a/launcher/InstanceList.h b/launcher/InstanceList.h index 6b0bcd810..5ddddee95 100644 --- a/launcher/InstanceList.h +++ b/launcher/InstanceList.h @@ -130,7 +130,7 @@ class InstanceList : public QAbstractListModel { * should_override is used when another similar instance already exists, and we want to override it * - for instance, when updating it. */ - bool commitStagedInstance(const QString& keyPath, const InstanceName& instanceName, const QString& groupName, const InstanceTask&); + bool commitStagedInstance(const QString& keyPath, const InstanceName& instanceName, QString groupName, const InstanceTask&); /** * Destroy a previously created staging area given by @keyPath - used when creation fails. From 2526275c5e124996b7a6b0465bad8b2bc9a1dffe Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 30 Oct 2023 09:51:37 +0000 Subject: [PATCH 17/36] Better check Signed-off-by: TheKodeToad --- launcher/InstanceList.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp index 111f8d8a4..2b8f34293 100644 --- a/launcher/InstanceList.cpp +++ b/launcher/InstanceList.cpp @@ -290,7 +290,8 @@ void InstanceList::deleteGroup(const GroupId& name) qDebug() << "Remove" << instID << "from group" << name; removed = true; auto idx = getInstIndex(instance.get()); - emit dataChanged(index(idx), index(idx), { GroupRole }); + if (idx >= 0) + emit dataChanged(index(idx), index(idx), { GroupRole }); } } if (removed) @@ -314,7 +315,8 @@ void InstanceList::renameGroup(const QString& src, const QString& dst) qDebug() << "Set" << instID << "group to" << dst; modified = true; auto idx = getInstIndex(instance.get()); - emit dataChanged(index(idx), index(idx), { GroupRole }); + if (idx >= 0) + emit dataChanged(index(idx), index(idx), { GroupRole }); } } if (modified) From 2349f29be01e1f6777f60a0397eab69650454c0d Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 2 Nov 2023 01:19:18 +0200 Subject: [PATCH 18/36] jsut a overflow protection Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index 1a3e52160..a14882097 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -113,7 +113,13 @@ class PixmapCache final : public QObject { if (m_consecutive_fast_evicitons >= m_consecutive_fast_evicitons_threshold) { // double the cache size auto newSize = _cacheLimit() * 2; - qDebug() << m_consecutive_fast_evicitons << "pixmap cache misses by eviction happened too fast, doubling cache size to" + if (newSize <= 0) { // double it until you overflow :D + qDebug() << m_consecutive_fast_evicitons + << tr("pixmap cache misses by eviction happened too fast, doing nothing as the cache size reached it's limit"); + m_consecutive_fast_evicitons = 0; + return true; + } + qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doubling cache size to") << newSize; _setCacheLimit(newSize); m_consecutive_fast_evicitons = 0; From 220a1de99a564602b9d043732b83b5d7c5545c25 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 2 Nov 2023 22:41:56 +0200 Subject: [PATCH 19/36] made sure that we do not relay for undefined behavior Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index a14882097..5f8212d74 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -5,6 +5,7 @@ #include #include #include +#include #define GET_TYPE() \ Qt::ConnectionType type; \ @@ -112,16 +113,16 @@ class PixmapCache final : public QObject { m_last_cache_miss_by_eviciton = now; if (m_consecutive_fast_evicitons >= m_consecutive_fast_evicitons_threshold) { // double the cache size - auto newSize = _cacheLimit() * 2; - if (newSize <= 0) { // double it until you overflow :D + auto newSize = _cacheLimit() * 2.L; + if (newSize >= std::numeric_limits::max()) { // double it until you overflow :D + newSize = std::numeric_limits::max(); qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doing nothing as the cache size reached it's limit"); - m_consecutive_fast_evicitons = 0; - return true; + } else { + qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doubling cache size to") + << static_cast(newSize); } - qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doubling cache size to") - << newSize; - _setCacheLimit(newSize); + _setCacheLimit(static_cast(newSize)); m_consecutive_fast_evicitons = 0; return true; } From 127a31ba3a468f8ad9fcedc29befea78ad381657 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 3 Nov 2023 10:31:40 +0200 Subject: [PATCH 20/36] Added warning for remove account Signed-off-by: Trial97 --- launcher/ui/pages/global/AccountListPage.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index 50f3ff2b6..6fd6112d4 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -42,22 +42,17 @@ #include -#include "net/NetJob.h" - #include "ui/dialogs/CustomMessageBox.h" #include "ui/dialogs/MSALoginDialog.h" #include "ui/dialogs/OfflineLoginDialog.h" #include "ui/dialogs/ProgressDialog.h" #include "ui/dialogs/SkinUploadDialog.h" -#include "minecraft/auth/AccountTask.h" #include "minecraft/services/SkinDelete.h" #include "tasks/Task.h" #include "Application.h" -#include "BuildConfig.h" - AccountListPage::AccountListPage(QWidget* parent) : QMainWindow(parent), ui(new Ui::AccountListPage) { ui->setupUi(this); @@ -172,6 +167,12 @@ void AccountListPage::on_actionAddOffline_triggered() void AccountListPage::on_actionRemove_triggered() { + auto response = CustomMessageBox::selectable(this, tr("Remove account?"), tr("Do you realy want to delete this account?"), + QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) + ->exec(); + if (response != QMessageBox::Yes) { + return; + } QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); if (selection.size() > 0) { QModelIndex selected = selection.first(); From b18082376ddc90eab4176ff88a10683d3b38ecff Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 3 Nov 2023 11:04:13 +0200 Subject: [PATCH 21/36] Fixed visual bug with Modlist export Signed-off-by: Trial97 --- launcher/ui/dialogs/ExportToModListDialog.cpp | 7 +++--- launcher/ui/dialogs/ExportToModListDialog.ui | 23 +++++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/launcher/ui/dialogs/ExportToModListDialog.cpp b/launcher/ui/dialogs/ExportToModListDialog.cpp index c811bfe6a..a343f555a 100644 --- a/launcher/ui/dialogs/ExportToModListDialog.cpp +++ b/launcher/ui/dialogs/ExportToModListDialog.cpp @@ -214,10 +214,11 @@ void ExportToModListDialog::addExtra(ExportToModList::OptionalData option) void ExportToModListDialog::enableCustom(bool enabled) { ui->authorsCheckBox->setHidden(enabled); - ui->versionCheckBox->setHidden(enabled); - ui->urlCheckBox->setHidden(enabled); - ui->authorsButton->setHidden(!enabled); + + ui->versionCheckBox->setHidden(enabled); ui->versionButton->setHidden(!enabled); + + ui->urlCheckBox->setHidden(enabled); ui->urlButton->setHidden(!enabled); } diff --git a/launcher/ui/dialogs/ExportToModListDialog.ui b/launcher/ui/dialogs/ExportToModListDialog.ui index 25eb43429..4f8ab52b5 100644 --- a/launcher/ui/dialogs/ExportToModListDialog.ui +++ b/launcher/ui/dialogs/ExportToModListDialog.ui @@ -7,7 +7,7 @@ 0 0 650 - 446 + 522 @@ -61,18 +61,37 @@ + + + 0 + 0 + + Template - + + + + 0 + 0 + + + + + + 0 + 0 + + Optional Info From 1bd69ecbb286df9d14a76d2dcb8a635d7895f154 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Fri, 3 Nov 2023 11:42:40 +0200 Subject: [PATCH 22/36] Update launcher/ui/pages/global/AccountListPage.cpp Co-authored-by: TheKodeToad Signed-off-by: Alexandru Ionut Tripon --- launcher/ui/pages/global/AccountListPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index 6fd6112d4..3a21cdd9b 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -167,7 +167,7 @@ void AccountListPage::on_actionAddOffline_triggered() void AccountListPage::on_actionRemove_triggered() { - auto response = CustomMessageBox::selectable(this, tr("Remove account?"), tr("Do you realy want to delete this account?"), + auto response = CustomMessageBox::selectable(this, tr("Remove account?"), tr("Do you really want to delete this account?"), QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ->exec(); if (response != QMessageBox::Yes) { From 0f95bf1e424e3ebd7f1450461d554f54c71c5f33 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sat, 4 Nov 2023 12:08:49 +0200 Subject: [PATCH 23/36] Updated readme Signed-off-by: Trial97 --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 61bf4c20b..e3457c7ed 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,18 @@ - All downloads and instructions for Prism Launcher can be found on our [Website](https://prismlauncher.org/download). -- Last build status can be found in the [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions). +- Last build status can be found in the [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) (this also includes the pull requests status). ### Development Builds -There are development builds available [here](https://github.com/PrismLauncher/PrismLauncher/actions). These have debug information in the binaries, so their file sizes are relatively larger. +Please understand that these builds are not intended for most users. There may be bugs, and other instabilities. You have been warned. + +There are development builds available on: + +- [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) includes builds from pull requests opened by contribuitors. +- [nightly.link](https://nightly.link/PrismLauncher/PrismLauncher/workflows/trigger_builds/develop) this will allways point only to the latest develop. + +These have debug information in the binaries, so their file sizes are relatively larger. Prebuilt Development builds are provided for **Linux**, **Windows** and **macOS**. From 40ebae394afe7ba426a67615e7a658f07ea76297 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 5 Nov 2023 00:18:56 +0000 Subject: [PATCH 24/36] chore(nix): update lockfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'flake-parts': 'github:hercules-ci/flake-parts/c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4' (2023-10-03) → 'github:hercules-ci/flake-parts/8c9fa2545007b49a5db5f650ae91f227672c3877' (2023-11-01) • Updated input 'flake-parts/nixpkgs-lib': 'github:NixOS/nixpkgs/f5892ddac112a1e9b3612c39af1b72987ee5783a?dir=lib' (2023-09-29) → 'github:NixOS/nixpkgs/0cbe9f69c234a7700596e943bfae7ef27a31b735?dir=lib' (2023-10-29) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/808c0d8c53c7ae50f82aca8e7df263225cf235bf' (2023-10-26) → 'github:nixos/nixpkgs/9d5d25bbfe8c0297ebe85324addcb5020ed1a454' (2023-11-04) • Updated input 'pre-commit-hooks': 'github:cachix/pre-commit-hooks.nix/bd38df3d508dfcdff52cd243d297f218ed2257bf' (2023-10-25) → 'github:cachix/pre-commit-hooks.nix/dec10399e5b56aa95fcd530e0338be72ad6462a0' (2023-11-01) --- flake.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index 7cf901f77..a520c27e5 100644 --- a/flake.lock +++ b/flake.lock @@ -21,11 +21,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1696343447, - "narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=", + "lastModified": 1698882062, + "narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4", + "rev": "8c9fa2545007b49a5db5f650ae91f227672c3877", "type": "github" }, "original": { @@ -106,11 +106,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1698336494, - "narHash": "sha256-sO72WDBKyijYD1GcKPlGsycKbMBiTJMBCnmOxLAs880=", + "lastModified": 1699094435, + "narHash": "sha256-YLZ5/KKZ1PyLrm2MO8UxRe4H3M0/oaYqNhSlq6FDeeA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "808c0d8c53c7ae50f82aca8e7df263225cf235bf", + "rev": "9d5d25bbfe8c0297ebe85324addcb5020ed1a454", "type": "github" }, "original": { @@ -123,11 +123,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1696019113, - "narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=", + "lastModified": 1698611440, + "narHash": "sha256-jPjHjrerhYDy3q9+s5EAsuhyhuknNfowY6yt6pjn9pc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a", + "rev": "0cbe9f69c234a7700596e943bfae7ef27a31b735", "type": "github" }, "original": { @@ -153,11 +153,11 @@ ] }, "locked": { - "lastModified": 1698227354, - "narHash": "sha256-Fi5H9jbaQLmLw9qBi/mkR33CoFjNbobo5xWdX4tKz1Q=", + "lastModified": 1698852633, + "narHash": "sha256-Hsc/cCHud8ZXLvmm8pxrXpuaPEeNaaUttaCvtdX/Wug=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "bd38df3d508dfcdff52cd243d297f218ed2257bf", + "rev": "dec10399e5b56aa95fcd530e0338be72ad6462a0", "type": "github" }, "original": { From cf4144cb5022db62c97d35b9917ade9947110d16 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 4 Nov 2023 15:22:43 -0400 Subject: [PATCH 25/36] Fixed link to Fulmine's website Signed-off-by: Alex --- launcher/ui/dialogs/AboutDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp index f5eaff7a1..cee01e821 100644 --- a/launcher/ui/dialogs/AboutDialog.cpp +++ b/launcher/ui/dialogs/AboutDialog.cpp @@ -101,7 +101,7 @@ QString getCreditsHtml() stream << "

" << QObject::tr("With thanks to", "About Credits") << "

\n"; stream << QString("

Boba %1

\n").arg(getWebsite("https://bobaonline.neocities.org/")); stream << QString("

Davi Rafael %1

\n").arg(getWebsite("https://auti.one/")); - stream << QString("

Fulmine %1

\n").arg(getWebsite("https://www.fulmine.xyz/")); + stream << QString("

Fulmine %1

\n").arg(getWebsite("https://fulmine.xyz/")); stream << QString("

ely %1

\n").arg(getGitHub("elyrodso")); stream << QString("

gon sawa %1

\n").arg(getGitHub("gonsawa")); stream << QString("

Pankakes

\n"); From 64bbcb2834a7974d2c329180add799a728a856f9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 15:57:06 +0000 Subject: [PATCH 26/36] chore(deps): update korthout/backport-action action to v2.1.0 --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index f9cf4fb7d..6f2025551 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -24,7 +24,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - name: Create backport PRs - uses: korthout/backport-action@v2.0.0 + uses: korthout/backport-action@v2.1.0 with: # Config README: https://github.com/korthout/backport-action#backport-action pull_description: |- From d2a85cb580f47ab181d65d13d18de2a96e297471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgars=20C=C4=ABrulis?= Date: Sun, 5 Nov 2023 17:41:53 +0000 Subject: [PATCH 27/36] visual: Fix spacing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Edgars Cīrulis --- launcher/LaunchController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index 9fb385777..f59cdeda8 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -89,7 +89,7 @@ void LaunchController::decideAccount() // Tell the user they need to log in at least one account in order to play. auto reply = CustomMessageBox::selectable(m_parentWidget, tr("No Accounts"), tr("In order to play Minecraft, you must have at least one Microsoft " - "account which owns Minecraft logged in." + "account which owns Minecraft logged in. " "Would you like to open the account manager to add an account now?"), QMessageBox::Information, QMessageBox::Yes | QMessageBox::No) ->exec(); From 710a48fcafdfd70c13077ea26a57dfb1aa375079 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 5 Nov 2023 21:41:10 +0200 Subject: [PATCH 28/36] changed type form double long to long long Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index 5f8212d74..a1447fd5a 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -113,7 +113,7 @@ class PixmapCache final : public QObject { m_last_cache_miss_by_eviciton = now; if (m_consecutive_fast_evicitons >= m_consecutive_fast_evicitons_threshold) { // double the cache size - auto newSize = _cacheLimit() * 2.L; + auto newSize = _cacheLimit() * 2ll; if (newSize >= std::numeric_limits::max()) { // double it until you overflow :D newSize = std::numeric_limits::max(); qDebug() << m_consecutive_fast_evicitons From 9a8667e99cdfd9608f8aa543b432bacc672a45e4 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 5 Nov 2023 22:22:49 +0200 Subject: [PATCH 29/36] Added Global Dependenicies toggle Signed-off-by: Trial97 --- launcher/Application.cpp | 1 + launcher/ui/dialogs/ModUpdateDialog.cpp | 2 +- launcher/ui/dialogs/ResourceDownloadDialog.cpp | 14 ++++++++------ launcher/ui/pages/global/LauncherPage.cpp | 2 ++ launcher/ui/pages/global/LauncherPage.ui | 10 ++++++++++ launcher/ui/pages/instance/ModFolderPage.cpp | 4 ++++ 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 661c6c5be..be252f1c5 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -644,6 +644,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) // Minecraft mods m_settings->registerSetting("ModMetadataDisabled", false); + m_settings->registerSetting("ModDependenciesDisabled", false); // Minecraft offline player name m_settings->registerSetting("LastOfflinePlayerName", ""); diff --git a/launcher/ui/dialogs/ModUpdateDialog.cpp b/launcher/ui/dialogs/ModUpdateDialog.cpp index 1a70ea59a..298bdad97 100644 --- a/launcher/ui/dialogs/ModUpdateDialog.cpp +++ b/launcher/ui/dialogs/ModUpdateDialog.cpp @@ -186,7 +186,7 @@ void ModUpdateDialog::checkCandidates() } } - { // dependencies + if (!APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies auto depTask = makeShared(this, m_instance, m_mod_model.get(), selectedVers); connect(depTask.get(), &Task::failed, this, diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index dc7cfff06..1431ea92c 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -270,13 +270,15 @@ QList ModDownloadDialog::getPages() GetModDependenciesTask::Ptr ModDownloadDialog::getModDependenciesTask() { - if (auto model = dynamic_cast(getBaseModel().get()); model) { - QList> selectedVers; - for (auto& selected : getTasks()) { - selectedVers.append(std::make_shared(selected->getPack(), selected->getVersion())); - } + if (!APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies + if (auto model = dynamic_cast(getBaseModel().get()); model) { + QList> selectedVers; + for (auto& selected : getTasks()) { + selectedVers.append(std::make_shared(selected->getPack(), selected->getVersion())); + } - return makeShared(this, m_instance, model, selectedVers); + return makeShared(this, m_instance, model, selectedVers); + } } return nullptr; } diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index 6d8c65ec5..d15883db5 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -223,6 +223,7 @@ void LauncherPage::applySettings() // Mods s->set("ModMetadataDisabled", ui->metadataDisableBtn->isChecked()); + s->set("ModDependenciesDisabled", ui->dependenciesDisableBtn->isChecked()); } void LauncherPage::loadSettings() { @@ -278,6 +279,7 @@ void LauncherPage::loadSettings() // Mods ui->metadataDisableBtn->setChecked(s->get("ModMetadataDisabled").toBool()); ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked()); + ui->dependenciesDisableBtn->setChecked(s->get("ModDependenciesDisabled").toBool()); } void LauncherPage::refreshFontPreview() diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 250a8bc88..637b2cd81 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -186,6 +186,16 @@
+ + + + Disable mod dependencies checking. + + + Disable mod dependencies checking + + +
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 625d37933..8d99256b9 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -214,6 +214,10 @@ void ModFolderPage::updateMods() 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("The mod update is disabled when the metadata is disabled!")); + return; + } auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); auto mods_list = m_model->selectedMods(selection); From bd9d5e09907071d2a2576add9c99314e6c52ed20 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sun, 5 Nov 2023 20:31:48 +0000 Subject: [PATCH 30/36] Reword Signed-off-by: TheKodeToad --- launcher/ui/pages/global/LauncherPage.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 637b2cd81..32d89ee51 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -189,10 +189,10 @@ - Disable mod dependencies checking. + Disable automatically checking and installation of mod dependencies. - Disable mod dependencies checking + Do not install mod dependencies From 902e861fc68b658d999476f273f4a15fe4207672 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Sun, 5 Nov 2023 23:41:26 +0200 Subject: [PATCH 31/36] Apply suggestions from code review Co-authored-by: seth Signed-off-by: Alexandru Ionut Tripon --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e3457c7ed..b32132d49 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,16 @@ - All downloads and instructions for Prism Launcher can be found on our [Website](https://prismlauncher.org/download). -- Last build status can be found in the [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) (this also includes the pull requests status). +- Last build status can be found in the [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) tab (this also includes the pull requests status). ### Development Builds Please understand that these builds are not intended for most users. There may be bugs, and other instabilities. You have been warned. -There are development builds available on: +There are development builds available through: -- [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) includes builds from pull requests opened by contribuitors. -- [nightly.link](https://nightly.link/PrismLauncher/PrismLauncher/workflows/trigger_builds/develop) this will allways point only to the latest develop. +- [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) (includes builds from pull requests opened by contribuitors) +- [nightly.link](https://nightly.link/PrismLauncher/PrismLauncher/workflows/trigger_builds/develop) (this will always point only to the latest version of develop) These have debug information in the binaries, so their file sizes are relatively larger. From 3e7f9083cab97489aab958d3bbc649b24d58abb6 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Sun, 5 Nov 2023 23:41:54 +0200 Subject: [PATCH 32/36] Update launcher/ui/pages/instance/ModFolderPage.cpp Co-authored-by: seth Signed-off-by: Alexandru Ionut Tripon --- launcher/ui/pages/instance/ModFolderPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 8d99256b9..f45f8b4b3 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -215,7 +215,7 @@ void ModFolderPage::updateMods() return; } if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) { - QMessageBox::critical(this, tr("Error"), tr("The mod update is disabled when the metadata is disabled!")); + 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(); From 867e6223ce5601ea32e8fc471d5dc3e13e32e276 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 5 Nov 2023 23:48:26 +0200 Subject: [PATCH 33/36] Fixed mangoHub loading Signed-off-by: Trial97 --- launcher/minecraft/MinecraftInstance.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 170561f11..7cb4100ea 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -575,15 +575,20 @@ QProcessEnvironment MinecraftInstance::createLaunchEnvironment() #ifdef Q_OS_LINUX if (settings()->get("EnableMangoHud").toBool() && APPLICATION->capabilities() & Application::SupportsMangoHud) { - auto preloadList = env.value("LD_PRELOAD").split(QLatin1String(":")); - auto libPaths = env.value("LD_LIBRARY_PATH").split(QLatin1String(":")); + QStringList preloadList; + if (auto value = env.value("LD_PRELOAD"); !value.isEmpty()) + preloadList = value.split(QLatin1String(":")); + QStringList libPaths; + if (auto value = env.value("LD_LIBRARY_PATH"); !value.isEmpty()) + libPaths = value.split(QLatin1String(":")); auto mangoHudLibString = MangoHud::getLibraryString(); if (!mangoHudLibString.isEmpty()) { QFileInfo mangoHudLib(mangoHudLibString); // dlsym variant is only needed for OpenGL and not included in the vulkan layer - preloadList << "libMangoHud_dlsym.so" << mangoHudLib.fileName(); + preloadList << "libMangoHud_dlsym.so" + << "libMangoHud_opengl.so" << mangoHudLib.fileName(); libPaths << mangoHudLib.absolutePath(); } From cc291219f9c937ec69402f7b88b79d1f33927ba3 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 6 Nov 2023 10:51:34 +0200 Subject: [PATCH 34/36] apply suggested changes Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index a1447fd5a..da9500788 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -101,10 +101,14 @@ class PixmapCache final : public QObject { */ bool _markCacheMissByEviciton() { + static constexpr int maxInt = std::numeric_limits::max(); + static constexpr uint oneMB = 1000; + static constexpr int oneSecond = 1000; + auto now = QTime::currentTime(); if (!m_last_cache_miss_by_eviciton.isNull()) { auto diff = m_last_cache_miss_by_eviciton.msecsTo(now); - if (diff < 1000) { // less than a second ago + if (diff < oneSecond) { // less than a second ago ++m_consecutive_fast_evicitons; } else { m_consecutive_fast_evicitons = 0; @@ -112,10 +116,10 @@ class PixmapCache final : public QObject { } m_last_cache_miss_by_eviciton = now; if (m_consecutive_fast_evicitons >= m_consecutive_fast_evicitons_threshold) { - // double the cache size - auto newSize = _cacheLimit() * 2ll; - if (newSize >= std::numeric_limits::max()) { // double it until you overflow :D - newSize = std::numeric_limits::max(); + // increase the cache size + uint newSize = _cacheLimit() + oneMB; + if (newSize >= maxInt) { // increase it until you overflow :D + newSize = maxInt; qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doing nothing as the cache size reached it's limit"); } else { From 670e91cb6072d42f74e501cfaeadbb49a8f171b4 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 6 Nov 2023 11:08:18 +0200 Subject: [PATCH 35/36] Increased the step to around 10MB Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index da9500788..eab6a70ec 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -102,7 +102,7 @@ class PixmapCache final : public QObject { bool _markCacheMissByEviciton() { static constexpr int maxInt = std::numeric_limits::max(); - static constexpr uint oneMB = 1000; + static constexpr uint step = 10240; static constexpr int oneSecond = 1000; auto now = QTime::currentTime(); @@ -117,7 +117,7 @@ class PixmapCache final : public QObject { m_last_cache_miss_by_eviciton = now; if (m_consecutive_fast_evicitons >= m_consecutive_fast_evicitons_threshold) { // increase the cache size - uint newSize = _cacheLimit() + oneMB; + uint newSize = _cacheLimit() + step; if (newSize >= maxInt) { // increase it until you overflow :D newSize = maxInt; qDebug() << m_consecutive_fast_evicitons From ca226d2ab5c3fb88d2e4a69ae94d2393960e9713 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 6 Nov 2023 11:24:19 +0200 Subject: [PATCH 36/36] Fixed comparation warning Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index eab6a70ec..b6bd13045 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -101,7 +101,7 @@ class PixmapCache final : public QObject { */ bool _markCacheMissByEviciton() { - static constexpr int maxInt = std::numeric_limits::max(); + static constexpr uint maxInt = static_cast(std::numeric_limits::max()); static constexpr uint step = 10240; static constexpr int oneSecond = 1000; @@ -123,8 +123,8 @@ class PixmapCache final : public QObject { qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doing nothing as the cache size reached it's limit"); } else { - qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doubling cache size to") - << static_cast(newSize); + qDebug() << m_consecutive_fast_evicitons + << tr("pixmap cache misses by eviction happened too fast, increasing cache size to") << static_cast(newSize); } _setCacheLimit(static_cast(newSize)); m_consecutive_fast_evicitons = 0;