mirror of
https://github.com/UltimMC/Launcher.git
synced 2026-01-01 05:06:15 +00:00
@@ -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", "");
|
||||
|
||||
@@ -138,14 +138,31 @@ void World::repath(const QFileInfo &file)
|
||||
m_folderName = file.fileName();
|
||||
if(file.isFile() && file.suffix() == "zip")
|
||||
{
|
||||
m_iconFile = QString();
|
||||
readFromZip(file);
|
||||
}
|
||||
else if(file.isDir())
|
||||
{
|
||||
QFileInfo assumedIconPath(file.absoluteFilePath() + "/icon.png");
|
||||
if(assumedIconPath.exists()) {
|
||||
m_iconFile = assumedIconPath.absoluteFilePath();
|
||||
}
|
||||
readFromFS(file);
|
||||
}
|
||||
}
|
||||
|
||||
bool World::resetIcon()
|
||||
{
|
||||
if(m_iconFile.isNull()) {
|
||||
return false;
|
||||
}
|
||||
if(QFile(m_iconFile).remove()) {
|
||||
m_iconFile = QString();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void World::readFromFS(const QFileInfo &file)
|
||||
{
|
||||
auto bytes = getLevelDatDataFromFS(file);
|
||||
|
||||
@@ -40,6 +40,10 @@ public:
|
||||
{
|
||||
return m_actualName;
|
||||
}
|
||||
QString iconFile() const
|
||||
{
|
||||
return m_iconFile;
|
||||
}
|
||||
QDateTime lastPlayed() const
|
||||
{
|
||||
return m_lastPlayed;
|
||||
@@ -70,6 +74,8 @@ public:
|
||||
bool replace(World &with);
|
||||
// change the world's filesystem path (used by world lists for *MAGIC* purposes)
|
||||
void repath(const QFileInfo &file);
|
||||
// remove the icon file, if any
|
||||
bool resetIcon();
|
||||
|
||||
bool rename(const QString &to);
|
||||
bool install(const QString &to, const QString &name= QString());
|
||||
@@ -88,6 +94,7 @@ protected:
|
||||
QString m_containerOffsetPath;
|
||||
QString m_folderName;
|
||||
QString m_actualName;
|
||||
QString m_iconFile;
|
||||
QDateTime levelDatTime;
|
||||
QDateTime m_lastPlayed;
|
||||
int64_t m_randomSeed = 0;
|
||||
|
||||
@@ -136,6 +136,19 @@ bool WorldList::deleteWorlds(int first, int last)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WorldList::resetIcon(int row)
|
||||
{
|
||||
if (row >= worlds.size() || row < 0)
|
||||
return false;
|
||||
World &m = worlds[row];
|
||||
if(m.resetIcon()) {
|
||||
emit dataChanged(index(row), index(row), {WorldList::IconFileRole});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int WorldList::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 3;
|
||||
@@ -195,6 +208,10 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
return world.lastPlayed();
|
||||
}
|
||||
case IconFileRole:
|
||||
{
|
||||
return world.iconFile();
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ public:
|
||||
SeedRole,
|
||||
NameRole,
|
||||
GameModeRole,
|
||||
LastPlayedRole
|
||||
LastPlayedRole,
|
||||
IconFileRole
|
||||
};
|
||||
|
||||
WorldList(const QString &dir);
|
||||
@@ -81,6 +82,9 @@ public:
|
||||
/// Deletes the mod at the given index.
|
||||
virtual bool deleteWorld(int index);
|
||||
|
||||
/// Removes the world icon, if any
|
||||
virtual bool resetIcon(int index);
|
||||
|
||||
/// Deletes all the selected mods
|
||||
virtual bool deleteWorlds(int first, int last);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user