diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-04-17 22:51:30 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-04-17 22:51:30 +0200 |
commit | c4c8e99681e14e5d0e82a13cb0631107dedf96ff (patch) | |
tree | a40279027b7530b5b8ddf0bbc286d0a33dc18951 /api/logic/minecraft/Library.cpp | |
parent | fc28aacdea3e7331b0f5f4436e0dac2fd361c390 (diff) | |
download | MultiMC-c4c8e99681e14e5d0e82a13cb0631107dedf96ff.tar MultiMC-c4c8e99681e14e5d0e82a13cb0631107dedf96ff.tar.gz MultiMC-c4c8e99681e14e5d0e82a13cb0631107dedf96ff.tar.lz MultiMC-c4c8e99681e14e5d0e82a13cb0631107dedf96ff.tar.xz MultiMC-c4c8e99681e14e5d0e82a13cb0631107dedf96ff.zip |
NOISSUE jar mods as libraries, fix for customizing net.minecraft
Diffstat (limited to 'api/logic/minecraft/Library.cpp')
-rw-r--r-- | api/logic/minecraft/Library.cpp | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp index a3b5f01c..22e1bd33 100644 --- a/api/logic/minecraft/Library.cpp +++ b/api/logic/minecraft/Library.cpp @@ -11,11 +11,11 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& native, QStringList& native32, QStringList& native64, const QString &overridePath) const { - bool isLocal = (hint() == "local"); + bool local = isLocal(); auto actualPath = [&](QString relPath) { QFileInfo out(FS::PathCombine(storagePrefix(), relPath)); - if(isLocal && !overridePath.isEmpty()) + if(local && !overridePath.isEmpty()) { QString fileName = out.fileName(); auto fullPath = FS::PathCombine(overridePath, fileName); @@ -56,7 +56,7 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class { QList<NetActionPtr> out; bool isAlwaysStale = (hint() == "always-stale"); - bool isLocal = (hint() == "local"); + bool local = isLocal(); bool isForge = (hint() == "forge-pack-xz"); auto add_download = [&](QString storage, QString url, QString sha1 = QString()) @@ -68,7 +68,7 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class } if (!entry->isStale()) return true; - if(isLocal) + if(local) { if(!overridePath.isEmpty()) { @@ -228,6 +228,11 @@ bool Library::isActive() const return result; } +bool Library::isLocal() const +{ + return m_hint == "local"; +} + void Library::setStoragePrefix(QString prefix) { m_storagePrefix = prefix; @@ -247,12 +252,44 @@ QString Library::storagePrefix() const return m_storagePrefix; } +QString Library::filename(OpSys system) const +{ + if(!m_filename.isEmpty()) + { + return m_filename; + } + // non-native? use only the gradle specifier + if (!isNative()) + { + return m_name.getFileName(); + } + + // otherwise native, override classifiers. Mojang HACK! + GradleSpecifier nativeSpec = m_name; + if (m_nativeClassifiers.contains(system)) + { + nativeSpec.setClassifier(m_nativeClassifiers[system]); + } + else + { + nativeSpec.setClassifier("INVALID"); + } + return nativeSpec.getFileName(); +} + +QString Library::displayName(OpSys system) const +{ + if(!m_displayname.isEmpty()) + return m_displayname; + return filename(system); +} + QString Library::storageSuffix(OpSys system) const { // non-native? use only the gradle specifier if (!isNative()) { - return m_name.toPath(); + return m_name.toPath(m_filename); } // otherwise native, override classifiers. Mojang HACK! @@ -265,5 +302,5 @@ QString Library::storageSuffix(OpSys system) const { nativeSpec.setClassifier("INVALID"); } - return nativeSpec.toPath(); + return nativeSpec.toPath(m_filename); } |