From 5180536cc3a96ab2e6894fb1a8a5922dae6bcd21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 10 Sep 2020 23:10:17 +0200 Subject: [PATCH] NOISSUE add a way to use native system versions of OpenAL and GLFW If your OS comes with patched/fixed/newer versions of those, you can now check the checkboxes and stop using the old ones shipped by Mojang. --- api/logic/minecraft/MinecraftInstance.cpp | 5 ++ api/logic/minecraft/launch/ExtractNatives.cpp | 15 ++++- application/MultiMC.cpp | 4 ++ application/pages/global/MinecraftPage.cpp | 7 +++ application/pages/global/MinecraftPage.ui | 29 ++++++++- .../pages/instance/InstanceSettingsPage.cpp | 19 ++++++ .../pages/instance/InstanceSettingsPage.ui | 59 ++++++++++++++++++- 7 files changed, 132 insertions(+), 6 deletions(-) diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp index db259395..5fda2f4b 100644 --- a/api/logic/minecraft/MinecraftInstance.cpp +++ b/api/logic/minecraft/MinecraftInstance.cpp @@ -100,6 +100,11 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO auto launchMethodOverride = m_settings->registerSetting("OverrideMCLaunchMethod", false); m_settings->registerOverride(globalSettings->getSetting("MCLaunchMethod"), launchMethodOverride); + // Native library workarounds + auto nativeLibraryWorkaroundsOverride = m_settings->registerSetting("OverrideNativeWorkarounds", false); + m_settings->registerOverride(globalSettings->getSetting("UseNativeOpenAL"), nativeLibraryWorkaroundsOverride); + m_settings->registerOverride(globalSettings->getSetting("UseNativeGLFW"), nativeLibraryWorkaroundsOverride); + // DEPRECATED: Read what versions the user configuration thinks should be used m_settings->registerSetting({"IntendedVersion", "MinecraftVersion"}, ""); m_settings->registerSetting("LWJGLVersion", ""); diff --git a/api/logic/minecraft/launch/ExtractNatives.cpp b/api/logic/minecraft/launch/ExtractNatives.cpp index 253d13bc..31fd01f8 100644 --- a/api/logic/minecraft/launch/ExtractNatives.cpp +++ b/api/logic/minecraft/launch/ExtractNatives.cpp @@ -33,7 +33,7 @@ static QString replaceSuffix (QString target, const QString &suffix, const QStri return target + replacement; } -static bool unzipNatives(QString source, QString targetFolder, bool applyJnilibHack) +static bool unzipNatives(QString source, QString targetFolder, bool applyJnilibHack, bool nativeOpenAL, bool nativeGLFW) { QuaZip zip(source); if(!zip.open(QuaZip::mdUnzip)) @@ -48,6 +48,13 @@ static bool unzipNatives(QString source, QString targetFolder, bool applyJnilibH do { QString name = zip.getCurrentFileName(); + auto lowercase = name.toLower(); + if (nativeGLFW && name.contains("glfw")) { + continue; + } + if (nativeOpenAL && name.contains("openal")) { + continue; + } if(applyJnilibHack) { name = replaceSuffix(name, ".jnilib", ".dylib"); @@ -76,12 +83,16 @@ void ExtractNatives::executeTask() emitSucceeded(); return; } + auto settings = minecraftInstance->settings(); + bool nativeOpenAL = settings->get("UseNativeOpenAL").toBool(); + bool nativeGLFW = settings->get("UseNativeGLFW").toBool(); + auto outputPath = minecraftInstance->getNativePath(); auto javaVersion = minecraftInstance->getJavaVersion(); bool jniHackEnabled = javaVersion.major() >= 8; for(const auto &source: toExtract) { - if(!unzipNatives(source, outputPath, jniHackEnabled)) + if(!unzipNatives(source, outputPath, jniHackEnabled, nativeOpenAL, nativeGLFW)) { auto reason = tr("Couldn't extract native jar '%1' to destination '%2'").arg(source, outputPath); emit logLine(reason, MessageLevel::Fatal); diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 8e2557d4..bca922ed 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -509,6 +509,10 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) m_settings->registerSetting("LastHostname", ""); m_settings->registerSetting("JvmArgs", ""); + // Native library workarounds + m_settings->registerSetting("UseNativeOpenAL", false); + m_settings->registerSetting("UseNativeGLFW", false); + // Minecraft launch method m_settings->registerSetting("MCLaunchMethod", "LauncherPart"); diff --git a/application/pages/global/MinecraftPage.cpp b/application/pages/global/MinecraftPage.cpp index 1d7042ad..7a8e8a49 100644 --- a/application/pages/global/MinecraftPage.cpp +++ b/application/pages/global/MinecraftPage.cpp @@ -63,6 +63,10 @@ void MinecraftPage::applySettings() s->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); s->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); s->set("MinecraftWinHeight", ui->windowHeightSpinBox->value()); + + // Native library workarounds + s->set("UseNativeOpenAL", ui->useNativeOpenALCheck->isChecked()); + s->set("UseNativeGLFW", ui->useNativeGLFWCheck->isChecked()); } void MinecraftPage::loadSettings() @@ -73,4 +77,7 @@ void MinecraftPage::loadSettings() ui->maximizedCheckBox->setChecked(s->get("LaunchMaximized").toBool()); ui->windowWidthSpinBox->setValue(s->get("MinecraftWinWidth").toInt()); ui->windowHeightSpinBox->setValue(s->get("MinecraftWinHeight").toInt()); + + ui->useNativeOpenALCheck->setChecked(s->get("UseNativeOpenAL").toBool()); + ui->useNativeGLFWCheck->setChecked(s->get("UseNativeGLFW").toBool()); } diff --git a/application/pages/global/MinecraftPage.ui b/application/pages/global/MinecraftPage.ui index 9a18927a..c096c969 100644 --- a/application/pages/global/MinecraftPage.ui +++ b/application/pages/global/MinecraftPage.ui @@ -6,8 +6,8 @@ 0 0 - 545 - 195 + 936 + 1134 @@ -111,6 +111,29 @@ + + + + Native library workarounds + + + + + + Use system installation of GLFW + + + + + + + Use system installation of OpenAL + + + + + + @@ -135,6 +158,8 @@ maximizedCheckBox windowWidthSpinBox windowHeightSpinBox + useNativeGLFWCheck + useNativeOpenALCheck diff --git a/application/pages/instance/InstanceSettingsPage.cpp b/application/pages/instance/InstanceSettingsPage.cpp index b7b0a863..9a39b034 100644 --- a/application/pages/instance/InstanceSettingsPage.cpp +++ b/application/pages/instance/InstanceSettingsPage.cpp @@ -163,6 +163,20 @@ void InstanceSettingsPage::applySettings() m_settings->reset("WrapperCommand"); m_settings->reset("PostExitCommand"); } + + // Workarounds + bool workarounds = ui->nativeWorkaroundsGroupBox->isChecked(); + m_settings->set("OverrideNativeWorkarounds", workarounds); + if(workarounds) + { + m_settings->set("UseNativeOpenAL", ui->useNativeOpenALCheck->isChecked()); + m_settings->set("UseNativeGLFW", ui->useNativeGLFWCheck->isChecked()); + } + else + { + m_settings->reset("UseNativeOpenAL"); + m_settings->reset("UseNativeGLFW"); + } } void InstanceSettingsPage::loadSettings() @@ -219,6 +233,11 @@ void InstanceSettingsPage::loadSettings() m_settings->get("WrapperCommand").toString(), m_settings->get("PostExitCommand").toString() ); + + // Workarounds + ui->nativeWorkaroundsGroupBox->setChecked(m_settings->get("OverrideNativeWorkarounds").toBool()); + ui->useNativeGLFWCheck->setChecked(m_settings->get("UseNativeGLFW").toBool()); + ui->useNativeOpenALCheck->setChecked(m_settings->get("UseNativeOpenAL").toBool()); } void InstanceSettingsPage::on_javaDetectBtn_clicked() diff --git a/application/pages/instance/InstanceSettingsPage.ui b/application/pages/instance/InstanceSettingsPage.ui index d6de53ee..c91570c6 100644 --- a/application/pages/instance/InstanceSettingsPage.ui +++ b/application/pages/instance/InstanceSettingsPage.ui @@ -6,8 +6,8 @@ 0 0 - 738 - 804 + 691 + 581 @@ -364,6 +364,58 @@ + + + Workarounds + + + + + + true + + + Native libraries + + + true + + + false + + + + + + Use system installation of GLFW + + + + + + + Use system installation of OpenAL + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + @@ -398,6 +450,9 @@ showConsoleCheck autoCloseConsoleCheck showConsoleErrorCheck + nativeWorkaroundsGroupBox + useNativeGLFWCheck + useNativeOpenALCheck