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.
This commit is contained in:
Petr Mrázek 2020-09-10 23:10:17 +02:00
parent 27e43d037e
commit 5180536cc3
7 changed files with 132 additions and 6 deletions

View File

@ -100,6 +100,11 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO
auto launchMethodOverride = m_settings->registerSetting("OverrideMCLaunchMethod", false); auto launchMethodOverride = m_settings->registerSetting("OverrideMCLaunchMethod", false);
m_settings->registerOverride(globalSettings->getSetting("MCLaunchMethod"), launchMethodOverride); 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 // DEPRECATED: Read what versions the user configuration thinks should be used
m_settings->registerSetting({"IntendedVersion", "MinecraftVersion"}, ""); m_settings->registerSetting({"IntendedVersion", "MinecraftVersion"}, "");
m_settings->registerSetting("LWJGLVersion", ""); m_settings->registerSetting("LWJGLVersion", "");

View File

@ -33,7 +33,7 @@ static QString replaceSuffix (QString target, const QString &suffix, const QStri
return target + replacement; 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); QuaZip zip(source);
if(!zip.open(QuaZip::mdUnzip)) if(!zip.open(QuaZip::mdUnzip))
@ -48,6 +48,13 @@ static bool unzipNatives(QString source, QString targetFolder, bool applyJnilibH
do do
{ {
QString name = zip.getCurrentFileName(); QString name = zip.getCurrentFileName();
auto lowercase = name.toLower();
if (nativeGLFW && name.contains("glfw")) {
continue;
}
if (nativeOpenAL && name.contains("openal")) {
continue;
}
if(applyJnilibHack) if(applyJnilibHack)
{ {
name = replaceSuffix(name, ".jnilib", ".dylib"); name = replaceSuffix(name, ".jnilib", ".dylib");
@ -76,12 +83,16 @@ void ExtractNatives::executeTask()
emitSucceeded(); emitSucceeded();
return; return;
} }
auto settings = minecraftInstance->settings();
bool nativeOpenAL = settings->get("UseNativeOpenAL").toBool();
bool nativeGLFW = settings->get("UseNativeGLFW").toBool();
auto outputPath = minecraftInstance->getNativePath(); auto outputPath = minecraftInstance->getNativePath();
auto javaVersion = minecraftInstance->getJavaVersion(); auto javaVersion = minecraftInstance->getJavaVersion();
bool jniHackEnabled = javaVersion.major() >= 8; bool jniHackEnabled = javaVersion.major() >= 8;
for(const auto &source: toExtract) 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); auto reason = tr("Couldn't extract native jar '%1' to destination '%2'").arg(source, outputPath);
emit logLine(reason, MessageLevel::Fatal); emit logLine(reason, MessageLevel::Fatal);

View File

@ -509,6 +509,10 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
m_settings->registerSetting("LastHostname", ""); m_settings->registerSetting("LastHostname", "");
m_settings->registerSetting("JvmArgs", ""); m_settings->registerSetting("JvmArgs", "");
// Native library workarounds
m_settings->registerSetting("UseNativeOpenAL", false);
m_settings->registerSetting("UseNativeGLFW", false);
// Minecraft launch method // Minecraft launch method
m_settings->registerSetting("MCLaunchMethod", "LauncherPart"); m_settings->registerSetting("MCLaunchMethod", "LauncherPart");

View File

@ -63,6 +63,10 @@ void MinecraftPage::applySettings()
s->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); s->set("LaunchMaximized", ui->maximizedCheckBox->isChecked());
s->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); s->set("MinecraftWinWidth", ui->windowWidthSpinBox->value());
s->set("MinecraftWinHeight", ui->windowHeightSpinBox->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() void MinecraftPage::loadSettings()
@ -73,4 +77,7 @@ void MinecraftPage::loadSettings()
ui->maximizedCheckBox->setChecked(s->get("LaunchMaximized").toBool()); ui->maximizedCheckBox->setChecked(s->get("LaunchMaximized").toBool());
ui->windowWidthSpinBox->setValue(s->get("MinecraftWinWidth").toInt()); ui->windowWidthSpinBox->setValue(s->get("MinecraftWinWidth").toInt());
ui->windowHeightSpinBox->setValue(s->get("MinecraftWinHeight").toInt()); ui->windowHeightSpinBox->setValue(s->get("MinecraftWinHeight").toInt());
ui->useNativeOpenALCheck->setChecked(s->get("UseNativeOpenAL").toBool());
ui->useNativeGLFWCheck->setChecked(s->get("UseNativeGLFW").toBool());
} }

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>545</width> <width>936</width>
<height>195</height> <height>1134</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -111,6 +111,29 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="nativeLibWorkaroundGroupBox">
<property name="title">
<string>Native library workarounds</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QCheckBox" name="useNativeGLFWCheck">
<property name="text">
<string>Use system installation of GLFW</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useNativeOpenALCheck">
<property name="text">
<string>Use system installation of OpenAL</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacerMinecraft"> <spacer name="verticalSpacerMinecraft">
<property name="orientation"> <property name="orientation">
@ -135,6 +158,8 @@
<tabstop>maximizedCheckBox</tabstop> <tabstop>maximizedCheckBox</tabstop>
<tabstop>windowWidthSpinBox</tabstop> <tabstop>windowWidthSpinBox</tabstop>
<tabstop>windowHeightSpinBox</tabstop> <tabstop>windowHeightSpinBox</tabstop>
<tabstop>useNativeGLFWCheck</tabstop>
<tabstop>useNativeOpenALCheck</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -163,6 +163,20 @@ void InstanceSettingsPage::applySettings()
m_settings->reset("WrapperCommand"); m_settings->reset("WrapperCommand");
m_settings->reset("PostExitCommand"); 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() void InstanceSettingsPage::loadSettings()
@ -219,6 +233,11 @@ void InstanceSettingsPage::loadSettings()
m_settings->get("WrapperCommand").toString(), m_settings->get("WrapperCommand").toString(),
m_settings->get("PostExitCommand").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() void InstanceSettingsPage::on_javaDetectBtn_clicked()

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>738</width> <width>691</width>
<height>804</height> <height>581</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -364,6 +364,58 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="workaroundsPage">
<attribute name="title">
<string>Workarounds</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QGroupBox" name="nativeWorkaroundsGroupBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Native libraries</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QCheckBox" name="useNativeGLFWCheck">
<property name="text">
<string>Use system installation of GLFW</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useNativeOpenALCheck">
<property name="text">
<string>Use system installation of OpenAL</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -398,6 +450,9 @@
<tabstop>showConsoleCheck</tabstop> <tabstop>showConsoleCheck</tabstop>
<tabstop>autoCloseConsoleCheck</tabstop> <tabstop>autoCloseConsoleCheck</tabstop>
<tabstop>showConsoleErrorCheck</tabstop> <tabstop>showConsoleErrorCheck</tabstop>
<tabstop>nativeWorkaroundsGroupBox</tabstop>
<tabstop>useNativeGLFWCheck</tabstop>
<tabstop>useNativeOpenALCheck</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>