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:
parent
53188386b8
commit
2ac0edbbdb
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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."))};
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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 (!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();
|
||||
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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user