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.
This commit is contained in:
Petr Mrázek 2017-03-30 01:05:58 +02:00
parent 53188386b8
commit 2ac0edbbdb
10 changed files with 143 additions and 36 deletions

View File

@ -31,10 +31,21 @@ private:
class ProblemProvider class ProblemProvider
{ {
public: 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; return m_problems;
} }
ProblemSeverity getProblemSeverity() override
{
return m_problemSeverity;
}
virtual void addProblem(ProblemSeverity severity, const QString &description) virtual void addProblem(ProblemSeverity severity, const QString &description)
{ {
if(severity > m_problemSeverity) if(severity > m_problemSeverity)
@ -43,10 +54,6 @@ public:
} }
m_problems.append(PatchProblem(severity, description)); m_problems.append(PatchProblem(severity, description));
} }
virtual ProblemSeverity getProblemSeverity()
{
return m_problemSeverity;
}
private: private:
QList<PatchProblem> m_problems; QList<PatchProblem> m_problems;

View File

@ -55,7 +55,15 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na
} }
else 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);
}
} }
} }
} }

View File

@ -1,3 +1,6 @@
#include <meta/VersionList.h>
#include <meta/Index.h>
#include <Env.h>
#include "ProfilePatch.h" #include "ProfilePatch.h"
#include "meta/Version.h" #include "meta/Version.h"
@ -35,6 +38,15 @@ std::shared_ptr<class VersionFile> ProfilePatch::getVersionFile()
return m_file; 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() int ProfilePatch::getOrder()
{ {
if(m_orderOverride) if(m_orderOverride)
@ -113,6 +125,15 @@ bool ProfilePatch::isMoveable()
} }
bool ProfilePatch::isVersionChangeable() bool ProfilePatch::isVersionChangeable()
{ {
auto list = getVersionList();
if(list)
{
if(!list->isLoaded())
{
list->load();
}
return list->count() != 0;
}
return false; return false;
} }
@ -132,3 +153,23 @@ void ProfilePatch::setMovable (bool state)
{ {
m_isMovable = 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."))};
}

View File

@ -11,6 +11,7 @@ class MinecraftProfile;
namespace Meta namespace Meta
{ {
class Version; class Version;
class VersionList;
} }
class VersionFile; class VersionFile;
@ -41,17 +42,20 @@ public:
virtual QString getFilename(); virtual QString getFilename();
virtual std::shared_ptr<class VersionFile> getVersionFile(); virtual std::shared_ptr<class VersionFile> getVersionFile();
virtual std::shared_ptr<class Meta::VersionList> getVersionList();
void setVanilla (bool state); void setVanilla (bool state);
void setRemovable (bool state); void setRemovable (bool state);
void setRevertible (bool state); void setRevertible (bool state);
void setCustomizable (bool state);
void setMovable (bool state); void setMovable (bool state);
const QList<PatchProblem> getProblems() override;
ProblemSeverity getProblemSeverity() override;
protected: protected:
// Properties for UI and version manipulation from UI in general // Properties for UI and version manipulation from UI in general
bool m_isMovable = false; bool m_isMovable = false;
bool m_isCustomizable = false;
bool m_isRevertible = false; bool m_isRevertible = false;
bool m_isRemovable = false; bool m_isRemovable = false;
bool m_isVanilla = false; bool m_isVanilla = false;

View File

@ -18,7 +18,7 @@ struct MojangDownloadInfo;
struct MojangAssetIndexInfo; struct MojangAssetIndexInfo;
typedef std::shared_ptr<VersionFile> VersionFilePtr; typedef std::shared_ptr<VersionFile> VersionFilePtr;
class VersionFile : public ProblemProvider class VersionFile : public ProblemContainer
{ {
friend class MojangVersionFormat; friend class MojangVersionFormat;
friend class OneSixVersionFormat; friend class OneSixVersionFormat;

View File

@ -35,6 +35,7 @@ OneSixInstance::OneSixInstance(SettingsObjectPtr globalSettings, SettingsObjectP
: MinecraftInstance(globalSettings, settings, rootDir) : MinecraftInstance(globalSettings, settings, rootDir)
{ {
m_settings->registerSetting({"IntendedVersion", "MinecraftVersion"}, ""); m_settings->registerSetting({"IntendedVersion", "MinecraftVersion"}, "");
m_settings->registerSetting("LWJGLVersion", "");
} }
void OneSixInstance::init() void OneSixInstance::init()
@ -480,7 +481,24 @@ std::shared_ptr<WorldList> OneSixInstance::worldList() const
bool OneSixInstance::setIntendedVersionId(QString version) 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()) if(getMinecraftProfile())
{ {
clearProfile(); clearProfile();
@ -489,6 +507,24 @@ bool OneSixInstance::setIntendedVersionId(QString version)
return true; 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 > OneSixInstance::getJarMods() const
{ {
QList<Mod> mods; QList<Mod> mods;
@ -500,12 +536,6 @@ QList< Mod > OneSixInstance::getJarMods() const
return mods; return mods;
} }
QString OneSixInstance::intendedVersionId() const
{
return settings()->get("IntendedVersion").toString();
}
void OneSixInstance::setShouldUpdate(bool) void OneSixInstance::setShouldUpdate(bool)
{ {
} }

View File

@ -59,9 +59,11 @@ public:
virtual QString intendedVersionId() const override; virtual QString intendedVersionId() const override;
virtual bool setIntendedVersionId(QString version) override; virtual bool setIntendedVersionId(QString version) override;
virtual QString currentVersionId() const 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 bool shouldUpdate() const override;
virtual void setShouldUpdate(bool val) override; virtual void setShouldUpdate(bool val) override;

View File

@ -114,8 +114,8 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
profilePatch->setOrder(order); profilePatch->setOrder(order);
profile->appendPatch(profilePatch); profile->appendPatch(profilePatch);
}; };
addBuiltinPatch("net.minecraft", m_instance->intendedVersionId(), -2); addBuiltinPatch("net.minecraft", m_instance->getComponentVersion("net.minecraft"), -2);
addBuiltinPatch("org.lwjgl", "2.9.1", -1); addBuiltinPatch("org.lwjgl", m_instance->getComponentVersion("org.lwjgl"), -1);
} }
void OneSixProfileStrategy::loadUserPatches() void OneSixProfileStrategy::loadUserPatches()

View File

@ -61,8 +61,8 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
m_tasks.append(task.unwrap()); m_tasks.append(task.unwrap());
} }
}; };
loadVersion("org.lwjgl", "2.9.1"); loadVersion("org.lwjgl", m_inst->getComponentVersion("org.lwjgl"));
loadVersion("net.minecraft", m_inst->intendedVersionId()); loadVersion("net.minecraft", m_inst->getComponentVersion("net.minecraft"));
} }
// libraries download // libraries download

View File

@ -323,9 +323,20 @@ void VersionPage::on_moveDownBtn_clicked()
void VersionPage::on_changeVersionBtn_clicked() void VersionPage::on_changeVersionBtn_clicked()
{ {
// FIXME: this is hilariously broken because it assumes m_inst->versionList() is a sensible thing... auto versionRow = currentRow();
VersionSelectDialog vselect(m_inst->versionList().get(), tr("Change Minecraft version"), if(versionRow == -1)
this); {
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()) if (!vselect.exec() || !vselect.selectedVersion())
return; return;
@ -339,21 +350,25 @@ void VersionPage::on_changeVersionBtn_clicked()
return; return;
} }
if (!m_profile->isVanilla()) qDebug() << "Change" << uid << "to" << vselect.selectedVersion()->descriptor();
if(uid == "net.minecraft")
{ {
auto result = CustomMessageBox::selectable( if (!m_profile->isVanilla())
this, tr("Are you sure?"), {
tr("This will remove any library/version customization you did previously. " auto result = CustomMessageBox::selectable(
"This includes things like Forge install and similar."), this, tr("Are you sure?"),
QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Abort, tr("This will remove any library/version customization you did previously. "
QMessageBox::Abort)->exec(); "This includes things like Forge install and similar."),
QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Abort,
QMessageBox::Abort)->exec();
if (result != QMessageBox::Ok) if (result != QMessageBox::Ok)
return; return;
m_profile->revertToVanilla(); m_profile->revertToVanilla();
reloadMinecraftProfile(); reloadMinecraftProfile();
}
} }
m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor()); m_inst->setComponentVersion(uid, vselect.selectedVersion()->descriptor());
doUpdate(); doUpdate();
m_container->refreshContainer(); m_container->refreshContainer();
} }