From 2ac0edbbdb27e12bae00c4779da135582bde89f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 30 Mar 2017 01:05:58 +0200 Subject: NOISSUE preview of LWJGL version changing It still needs work - some LWJGL versions are exclusive to macOS. This has to be encoded in the json. --- api/logic/minecraft/Library.cpp | 10 ++++- api/logic/minecraft/ProfilePatch.cpp | 41 ++++++++++++++++++++ api/logic/minecraft/ProfilePatch.h | 8 +++- api/logic/minecraft/VersionFile.h | 2 +- api/logic/minecraft/onesix/OneSixInstance.cpp | 44 ++++++++++++++++++---- api/logic/minecraft/onesix/OneSixInstance.h | 4 +- .../minecraft/onesix/OneSixProfileStrategy.cpp | 4 +- api/logic/minecraft/onesix/OneSixUpdate.cpp | 4 +- 8 files changed, 101 insertions(+), 16 deletions(-) (limited to 'api/logic/minecraft') diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp index 5a75fe79..ad0a64cf 100644 --- a/api/logic/minecraft/Library.cpp +++ b/api/logic/minecraft/Library.cpp @@ -55,7 +55,15 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na } else { - native += actualPath(m_mojangDownloads->getDownloadInfo(nativeClassifier)->path); + auto dlinfo = m_mojangDownloads->getDownloadInfo(nativeClassifier); + if(!dlinfo) + { + qWarning() << "Cannot get native for" << nativeClassifier << "while processing" << m_name; + } + else + { + native += actualPath(dlinfo->path); + } } } } diff --git a/api/logic/minecraft/ProfilePatch.cpp b/api/logic/minecraft/ProfilePatch.cpp index e0014798..6a90f64b 100644 --- a/api/logic/minecraft/ProfilePatch.cpp +++ b/api/logic/minecraft/ProfilePatch.cpp @@ -1,3 +1,6 @@ +#include +#include +#include #include "ProfilePatch.h" #include "meta/Version.h" @@ -35,6 +38,15 @@ std::shared_ptr ProfilePatch::getVersionFile() return m_file; } +std::shared_ptr ProfilePatch::getVersionList() +{ + if(m_metaVersion) + { + return ENV.metadataIndex()->get(m_metaVersion->uid()); + } + return nullptr; +} + int ProfilePatch::getOrder() { if(m_orderOverride) @@ -113,6 +125,15 @@ bool ProfilePatch::isMoveable() } bool ProfilePatch::isVersionChangeable() { + auto list = getVersionList(); + if(list) + { + if(!list->isLoaded()) + { + list->load(); + } + return list->count() != 0; + } return false; } @@ -132,3 +153,23 @@ void ProfilePatch::setMovable (bool state) { m_isMovable = state; } + +ProblemSeverity ProfilePatch::getProblemSeverity() +{ + auto file = getVersionFile(); + if(file) + { + return file->getProblemSeverity(); + } + return ProblemSeverity::Error; +} + +const QList ProfilePatch::getProblems() +{ + auto file = getVersionFile(); + if(file) + { + return file->getProblems(); + } + return {PatchProblem(ProblemSeverity::Error, QObject::tr("Patch is not loaded yet."))}; +} diff --git a/api/logic/minecraft/ProfilePatch.h b/api/logic/minecraft/ProfilePatch.h index 9e2555af..fb6b2f05 100644 --- a/api/logic/minecraft/ProfilePatch.h +++ b/api/logic/minecraft/ProfilePatch.h @@ -11,6 +11,7 @@ class MinecraftProfile; namespace Meta { class Version; + class VersionList; } class VersionFile; @@ -41,17 +42,20 @@ public: virtual QString getFilename(); virtual std::shared_ptr getVersionFile(); + virtual std::shared_ptr getVersionList(); void setVanilla (bool state); void setRemovable (bool state); void setRevertible (bool state); - void setCustomizable (bool state); void setMovable (bool state); + + const QList getProblems() override; + ProblemSeverity getProblemSeverity() override; + protected: // Properties for UI and version manipulation from UI in general bool m_isMovable = false; - bool m_isCustomizable = false; bool m_isRevertible = false; bool m_isRemovable = false; bool m_isVanilla = false; diff --git a/api/logic/minecraft/VersionFile.h b/api/logic/minecraft/VersionFile.h index a71c6228..312d0a3b 100644 --- a/api/logic/minecraft/VersionFile.h +++ b/api/logic/minecraft/VersionFile.h @@ -18,7 +18,7 @@ struct MojangDownloadInfo; struct MojangAssetIndexInfo; typedef std::shared_ptr VersionFilePtr; -class VersionFile : public ProblemProvider +class VersionFile : public ProblemContainer { friend class MojangVersionFormat; friend class OneSixVersionFormat; diff --git a/api/logic/minecraft/onesix/OneSixInstance.cpp b/api/logic/minecraft/onesix/OneSixInstance.cpp index 6e4a5bdc..d89f6f87 100644 --- a/api/logic/minecraft/onesix/OneSixInstance.cpp +++ b/api/logic/minecraft/onesix/OneSixInstance.cpp @@ -35,6 +35,7 @@ OneSixInstance::OneSixInstance(SettingsObjectPtr globalSettings, SettingsObjectP : MinecraftInstance(globalSettings, settings, rootDir) { m_settings->registerSetting({"IntendedVersion", "MinecraftVersion"}, ""); + m_settings->registerSetting("LWJGLVersion", ""); } void OneSixInstance::init() @@ -480,7 +481,24 @@ std::shared_ptr OneSixInstance::worldList() const bool OneSixInstance::setIntendedVersionId(QString version) { - settings()->set("IntendedVersion", version); + return setComponentVersion("net.minecraft", version); +} + +QString OneSixInstance::intendedVersionId() const +{ + return getComponentVersion("net.minecraft"); +} + +bool OneSixInstance::setComponentVersion(const QString& uid, const QString& version) +{ + if(uid == "net.minecraft") + { + settings()->set("IntendedVersion", version); + } + else if (uid == "org.lwjgl") + { + settings()->set("LWJGLVersion", version); + } if(getMinecraftProfile()) { clearProfile(); @@ -489,6 +507,24 @@ bool OneSixInstance::setIntendedVersionId(QString version) return true; } +QString OneSixInstance::getComponentVersion(const QString& uid) const +{ + if(uid == "net.minecraft") + { + return settings()->get("IntendedVersion").toString(); + } + else if(uid == "org.lwjgl") + { + auto version = settings()->get("LWJGLVersion").toString(); + if(version.isEmpty()) + { + return "2.9.1"; + } + return version; + } + return QString(); +} + QList< Mod > OneSixInstance::getJarMods() const { QList mods; @@ -500,12 +536,6 @@ QList< Mod > OneSixInstance::getJarMods() const return mods; } - -QString OneSixInstance::intendedVersionId() const -{ - return settings()->get("IntendedVersion").toString(); -} - void OneSixInstance::setShouldUpdate(bool) { } diff --git a/api/logic/minecraft/onesix/OneSixInstance.h b/api/logic/minecraft/onesix/OneSixInstance.h index 72c05ad7..ec8c2597 100644 --- a/api/logic/minecraft/onesix/OneSixInstance.h +++ b/api/logic/minecraft/onesix/OneSixInstance.h @@ -59,9 +59,11 @@ public: virtual QString intendedVersionId() const override; virtual bool setIntendedVersionId(QString version) override; - virtual QString currentVersionId() const override; + QString getComponentVersion(const QString &uid) const; + bool setComponentVersion(const QString &uid, const QString &version); + virtual bool shouldUpdate() const override; virtual void setShouldUpdate(bool val) override; diff --git a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp index 8125b1d6..4a56a810 100644 --- a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp +++ b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp @@ -114,8 +114,8 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches() profilePatch->setOrder(order); profile->appendPatch(profilePatch); }; - addBuiltinPatch("net.minecraft", m_instance->intendedVersionId(), -2); - addBuiltinPatch("org.lwjgl", "2.9.1", -1); + addBuiltinPatch("net.minecraft", m_instance->getComponentVersion("net.minecraft"), -2); + addBuiltinPatch("org.lwjgl", m_instance->getComponentVersion("org.lwjgl"), -1); } void OneSixProfileStrategy::loadUserPatches() diff --git a/api/logic/minecraft/onesix/OneSixUpdate.cpp b/api/logic/minecraft/onesix/OneSixUpdate.cpp index 5bc76b01..bf234189 100644 --- a/api/logic/minecraft/onesix/OneSixUpdate.cpp +++ b/api/logic/minecraft/onesix/OneSixUpdate.cpp @@ -61,8 +61,8 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent) m_tasks.append(task.unwrap()); } }; - loadVersion("org.lwjgl", "2.9.1"); - loadVersion("net.minecraft", m_inst->intendedVersionId()); + loadVersion("org.lwjgl", m_inst->getComponentVersion("org.lwjgl")); + loadVersion("net.minecraft", m_inst->getComponentVersion("net.minecraft")); } // libraries download -- cgit v1.2.3