diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-03-30 01:05:58 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-04-07 00:20:02 +0200 |
commit | 2ac0edbbdb27e12bae00c4779da135582bde89f5 (patch) | |
tree | 0870890a8f00bb958a679175691724da727df580 | |
parent | 53188386b807f1f1ca5eebcd08303633ca4a13fb (diff) | |
download | MultiMC-2ac0edbbdb27e12bae00c4779da135582bde89f5.tar MultiMC-2ac0edbbdb27e12bae00c4779da135582bde89f5.tar.gz MultiMC-2ac0edbbdb27e12bae00c4779da135582bde89f5.tar.lz MultiMC-2ac0edbbdb27e12bae00c4779da135582bde89f5.tar.xz MultiMC-2ac0edbbdb27e12bae00c4779da135582bde89f5.zip |
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.
-rw-r--r-- | api/logic/ProblemProvider.h | 17 | ||||
-rw-r--r-- | api/logic/minecraft/Library.cpp | 10 | ||||
-rw-r--r-- | api/logic/minecraft/ProfilePatch.cpp | 41 | ||||
-rw-r--r-- | api/logic/minecraft/ProfilePatch.h | 8 | ||||
-rw-r--r-- | api/logic/minecraft/VersionFile.h | 2 | ||||
-rw-r--r-- | api/logic/minecraft/onesix/OneSixInstance.cpp | 44 | ||||
-rw-r--r-- | api/logic/minecraft/onesix/OneSixInstance.h | 4 | ||||
-rw-r--r-- | api/logic/minecraft/onesix/OneSixProfileStrategy.cpp | 4 | ||||
-rw-r--r-- | api/logic/minecraft/onesix/OneSixUpdate.cpp | 4 | ||||
-rw-r--r-- | application/pages/VersionPage.cpp | 47 |
10 files changed, 144 insertions, 37 deletions
diff --git a/api/logic/ProblemProvider.h b/api/logic/ProblemProvider.h index 64a31c59..b30e1776 100644 --- a/api/logic/ProblemProvider.h +++ b/api/logic/ProblemProvider.h @@ -31,10 +31,21 @@ private: class ProblemProvider { public: - virtual const QList<PatchProblem>& getProblems() + virtual const QList<PatchProblem> getProblems() = 0; + virtual ProblemSeverity getProblemSeverity() = 0; +}; + +class ProblemContainer : public ProblemProvider +{ +public: + const QList<PatchProblem> getProblems() override { return m_problems; } + ProblemSeverity getProblemSeverity() override + { + return m_problemSeverity; + } virtual void addProblem(ProblemSeverity severity, const QString &description) { if(severity > m_problemSeverity) @@ -43,10 +54,6 @@ public: } m_problems.append(PatchProblem(severity, description)); } - virtual ProblemSeverity getProblemSeverity() - { - return m_problemSeverity; - } private: QList<PatchProblem> m_problems; 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 <meta/VersionList.h> +#include <meta/Index.h> +#include <Env.h> #include "ProfilePatch.h" #include "meta/Version.h" @@ -35,6 +38,15 @@ std::shared_ptr<class VersionFile> ProfilePatch::getVersionFile() return m_file; } +std::shared_ptr<class Meta::VersionList> 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<PatchProblem> 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<class VersionFile> getVersionFile(); + virtual std::shared_ptr<class Meta::VersionList> getVersionList(); void setVanilla (bool state); void setRemovable (bool state); void setRevertible (bool state); - void setCustomizable (bool state); void setMovable (bool state); + + const QList<PatchProblem> 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<VersionFile> 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<WorldList> 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<Mod> 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 diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp index 5a0b2243..94068786 100644 --- a/application/pages/VersionPage.cpp +++ b/application/pages/VersionPage.cpp @@ -323,9 +323,20 @@ void VersionPage::on_moveDownBtn_clicked() void VersionPage::on_changeVersionBtn_clicked() { - // FIXME: this is hilariously broken because it assumes m_inst->versionList() is a sensible thing... - VersionSelectDialog vselect(m_inst->versionList().get(), tr("Change Minecraft version"), - this); + auto versionRow = currentRow(); + if(versionRow == -1) + { + return; + } + auto patch = m_profile->versionPatch(versionRow); + auto name = patch->getName(); + auto list = patch->getVersionList(); + if(!list) + { + return; + } + auto uid = list->uid(); + VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); if (!vselect.exec() || !vselect.selectedVersion()) return; @@ -339,21 +350,25 @@ void VersionPage::on_changeVersionBtn_clicked() return; } - if (!m_profile->isVanilla()) + qDebug() << "Change" << uid << "to" << vselect.selectedVersion()->descriptor(); + if(uid == "net.minecraft") { - auto result = CustomMessageBox::selectable( - this, tr("Are you sure?"), - tr("This will remove any library/version customization you did previously. " - "This includes things like Forge install and similar."), - QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Abort, - QMessageBox::Abort)->exec(); - - if (result != QMessageBox::Ok) - return; - m_profile->revertToVanilla(); - reloadMinecraftProfile(); + if (!m_profile->isVanilla()) + { + auto result = CustomMessageBox::selectable( + this, tr("Are you sure?"), + tr("This will remove any library/version customization you did previously. " + "This includes things like Forge install and similar."), + QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Abort, + QMessageBox::Abort)->exec(); + + if (result != QMessageBox::Ok) + return; + m_profile->revertToVanilla(); + reloadMinecraftProfile(); + } } - m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor()); + m_inst->setComponentVersion(uid, vselect.selectedVersion()->descriptor()); doUpdate(); m_container->refreshContainer(); } |