NOISSUE hack it together enough to get launching back
Meta index will now always return valid objects. They just might never load if they don't exist on the server.
This commit is contained in:
parent
e46aba9da5
commit
2660418d58
@ -137,4 +137,13 @@ void Meta::BaseEntity::load()
|
|||||||
m_updateTask->start();
|
m_updateTask->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shared_qobject_ptr<Task> Meta::BaseEntity::getCurrentTask()
|
||||||
|
{
|
||||||
|
if(m_updateStatus == UpdateStatus::InProgress)
|
||||||
|
{
|
||||||
|
return m_updateTask;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
#include "BaseEntity.moc"
|
#include "BaseEntity.moc"
|
||||||
|
@ -61,6 +61,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
|
shared_qobject_ptr<Task> getCurrentTask();
|
||||||
|
|
||||||
protected: /* methods */
|
protected: /* methods */
|
||||||
bool loadLocalFile();
|
bool loadLocalFile();
|
||||||
|
@ -83,17 +83,19 @@ bool Index::hasUid(const QString &uid) const
|
|||||||
|
|
||||||
VersionListPtr Index::get(const QString &uid)
|
VersionListPtr Index::get(const QString &uid)
|
||||||
{
|
{
|
||||||
return m_uids.value(uid, nullptr);
|
VersionListPtr out = m_uids.value(uid, nullptr);
|
||||||
|
if(!out)
|
||||||
|
{
|
||||||
|
out = std::make_shared<VersionList>(uid);
|
||||||
|
m_uids[uid] = out;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
VersionPtr Index::get(const QString &uid, const QString &version)
|
VersionPtr Index::get(const QString &uid, const QString &version)
|
||||||
{
|
{
|
||||||
auto list = get(uid);
|
auto list = get(uid);
|
||||||
if(list)
|
return list->getVersion(version);
|
||||||
{
|
|
||||||
return list->getVersion(version);
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Index::parse(const QJsonObject& obj)
|
void Index::parse(const QJsonObject& obj)
|
||||||
|
@ -68,3 +68,4 @@ private:
|
|||||||
void connectVersionList(const int row, const VersionListPtr &list);
|
void connectVersionList(const int row, const VersionListPtr &list);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,38 +18,45 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
#include "JsonFormat.h"
|
#include "JsonFormat.h"
|
||||||
|
#include "minecraft/MinecraftProfile.h"
|
||||||
|
|
||||||
namespace Meta
|
void Meta::Version::applyTo(MinecraftProfile* profile)
|
||||||
{
|
{
|
||||||
Version::Version(const QString &uid, const QString &version)
|
if(m_data)
|
||||||
|
{
|
||||||
|
m_data->applyTo(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Meta::Version::Version(const QString &uid, const QString &version)
|
||||||
: BaseVersion(), m_uid(uid), m_version(version)
|
: BaseVersion(), m_uid(uid), m_version(version)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Version::descriptor()
|
QString Meta::Version::descriptor()
|
||||||
{
|
{
|
||||||
return m_version;
|
return m_version;
|
||||||
}
|
}
|
||||||
QString Version::name()
|
QString Meta::Version::name()
|
||||||
{
|
{
|
||||||
return m_version;
|
return m_version;
|
||||||
}
|
}
|
||||||
QString Version::typeString() const
|
QString Meta::Version::typeString() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime Version::time() const
|
QDateTime Meta::Version::time() const
|
||||||
{
|
{
|
||||||
return QDateTime::fromMSecsSinceEpoch(m_time * 1000, Qt::UTC);
|
return QDateTime::fromMSecsSinceEpoch(m_time * 1000, Qt::UTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Version::parse(const QJsonObject& obj)
|
void Meta::Version::parse(const QJsonObject& obj)
|
||||||
{
|
{
|
||||||
parseVersion(obj, this);
|
parseVersion(obj, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Version::merge(const std::shared_ptr<BaseEntity> &other)
|
void Meta::Version::merge(const std::shared_ptr<BaseEntity> &other)
|
||||||
{
|
{
|
||||||
VersionPtr version = std::dynamic_pointer_cast<Version>(other);
|
VersionPtr version = std::dynamic_pointer_cast<Version>(other);
|
||||||
if (m_type != version->m_type)
|
if (m_type != version->m_type)
|
||||||
@ -68,28 +75,28 @@ void Version::merge(const std::shared_ptr<BaseEntity> &other)
|
|||||||
setData(version->m_data);
|
setData(version->m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Version::localFilename() const
|
QString Meta::Version::localFilename() const
|
||||||
{
|
{
|
||||||
return m_uid + '/' + m_version + ".json";
|
return m_uid + '/' + m_version + ".json";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Version::setType(const QString &type)
|
void Meta::Version::setType(const QString &type)
|
||||||
{
|
{
|
||||||
m_type = type;
|
m_type = type;
|
||||||
emit typeChanged();
|
emit typeChanged();
|
||||||
}
|
}
|
||||||
void Version::setTime(const qint64 time)
|
void Meta::Version::setTime(const qint64 time)
|
||||||
{
|
{
|
||||||
m_time = time;
|
m_time = time;
|
||||||
emit timeChanged();
|
emit timeChanged();
|
||||||
}
|
}
|
||||||
void Version::setRequires(const QVector<Reference> &requires)
|
void Meta::Version::setRequires(const QVector<Reference> &requires)
|
||||||
{
|
{
|
||||||
m_requires = requires;
|
m_requires = requires;
|
||||||
emit requiresChanged();
|
emit requiresChanged();
|
||||||
}
|
}
|
||||||
void Version::setData(const VersionFilePtr &data)
|
void Meta::Version::setData(const VersionFilePtr &data)
|
||||||
{
|
{
|
||||||
m_data = data;
|
m_data = data;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -33,7 +33,7 @@ namespace Meta
|
|||||||
{
|
{
|
||||||
using VersionPtr = std::shared_ptr<class Version>;
|
using VersionPtr = std::shared_ptr<class Version>;
|
||||||
|
|
||||||
class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public BaseEntity
|
class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public BaseEntity, public ProfilePatch
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString uid READ uid CONSTANT)
|
Q_PROPERTY(QString uid READ uid CONSTANT)
|
||||||
@ -41,9 +41,89 @@ class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public
|
|||||||
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
|
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
|
||||||
Q_PROPERTY(QDateTime time READ time NOTIFY timeChanged)
|
Q_PROPERTY(QDateTime time READ time NOTIFY timeChanged)
|
||||||
Q_PROPERTY(QVector<Reference> requires READ requires NOTIFY requiresChanged)
|
Q_PROPERTY(QVector<Reference> requires READ requires NOTIFY requiresChanged)
|
||||||
public:
|
|
||||||
|
public: /* con/des */
|
||||||
explicit Version(const QString &uid, const QString &version);
|
explicit Version(const QString &uid, const QString &version);
|
||||||
|
|
||||||
|
// FIXME: none of this belongs here...
|
||||||
|
public: /* ProfilePatch overrides */
|
||||||
|
QString getFilename() override
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
QString getID() override
|
||||||
|
{
|
||||||
|
return m_uid;
|
||||||
|
}
|
||||||
|
QList<JarmodPtr> getJarMods() override
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
QString getName() override
|
||||||
|
{
|
||||||
|
return name();
|
||||||
|
}
|
||||||
|
QDateTime getReleaseDateTime() override
|
||||||
|
{
|
||||||
|
return time();
|
||||||
|
}
|
||||||
|
QString getVersion() override
|
||||||
|
{
|
||||||
|
return m_version;
|
||||||
|
}
|
||||||
|
std::shared_ptr<class VersionFile> getVersionFile() override
|
||||||
|
{
|
||||||
|
return m_data;
|
||||||
|
}
|
||||||
|
int getOrder() override
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
VersionSource getVersionSource() override
|
||||||
|
{
|
||||||
|
return VersionSource::Local;
|
||||||
|
}
|
||||||
|
bool isVersionChangeable() override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool isRevertible() override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool isRemovable() override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool isCustom() override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool isCustomizable() override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool isMoveable() override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool isEditable() override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void setOrder(int) override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
bool hasJarMods() override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool isMinecraftVersion() override
|
||||||
|
{
|
||||||
|
return m_uid == "net.minecraft";
|
||||||
|
}
|
||||||
|
void applyTo(MinecraftProfile * profile) override;
|
||||||
|
|
||||||
QString descriptor() override;
|
QString descriptor() override;
|
||||||
QString name() override;
|
QString name() override;
|
||||||
QString typeString() const override;
|
QString typeString() const override;
|
||||||
|
@ -125,13 +125,15 @@ QString VersionList::humanReadable() const
|
|||||||
return m_name.isEmpty() ? m_uid : m_name;
|
return m_name.isEmpty() ? m_uid : m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VersionList::hasVersion(const QString &version) const
|
VersionPtr VersionList::getVersion(const QString &version)
|
||||||
{
|
{
|
||||||
return m_lookup.contains(version);
|
VersionPtr out = m_lookup.value(version, nullptr);
|
||||||
}
|
if(!out)
|
||||||
VersionPtr VersionList::getVersion(const QString &version) const
|
{
|
||||||
{
|
out = std::make_shared<Version>(m_uid, version);
|
||||||
return m_lookup.value(version);
|
m_lookup[version] = out;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionList::setName(const QString &name)
|
void VersionList::setName(const QString &name)
|
||||||
|
@ -60,8 +60,7 @@ public:
|
|||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
QString humanReadable() const;
|
QString humanReadable() const;
|
||||||
|
|
||||||
bool hasVersion(const QString &version) const;
|
VersionPtr getVersion(const QString &version);
|
||||||
VersionPtr getVersion(const QString &version) const;
|
|
||||||
|
|
||||||
QVector<VersionPtr> versions() const { return m_versions; }
|
QVector<VersionPtr> versions() const { return m_versions; }
|
||||||
|
|
||||||
|
@ -92,10 +92,6 @@ public:
|
|||||||
{
|
{
|
||||||
return m_problemSeverity;
|
return m_problemSeverity;
|
||||||
}
|
}
|
||||||
virtual bool hasFailed()
|
|
||||||
{
|
|
||||||
return getProblemSeverity() == PROBLEM_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<PatchProblem> m_problems;
|
QList<PatchProblem> m_problems;
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QSaveFile>
|
#include <QSaveFile>
|
||||||
#include <QResource>
|
#include <QResource>
|
||||||
|
#include <meta/Index.h>
|
||||||
|
#include <meta/Version.h>
|
||||||
|
|
||||||
OneSixProfileStrategy::OneSixProfileStrategy(OneSixInstance* instance)
|
OneSixProfileStrategy::OneSixProfileStrategy(OneSixInstance* instance)
|
||||||
{
|
{
|
||||||
@ -98,7 +100,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto mcversion = ENV.getVersion("net.minecraft", m_instance->intendedVersionId());
|
auto mcversion = ENV.metadataIndex()->get("net.minecraft", m_instance->intendedVersionId());
|
||||||
minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(mcversion);
|
minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(mcversion);
|
||||||
}
|
}
|
||||||
if (!minecraftPatch)
|
if (!minecraftPatch)
|
||||||
@ -121,7 +123,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto lwjglversion = ENV.getVersion("org.lwjgl", "2.9.1" /*m_instance->intendedVersionId()*/);
|
auto lwjglversion = ENV.metadataIndex()->get("org.lwjgl", "2.9.1");
|
||||||
lwjglPatch = std::dynamic_pointer_cast<ProfilePatch>(lwjglversion);
|
lwjglPatch = std::dynamic_pointer_cast<ProfilePatch>(lwjglversion);
|
||||||
}
|
}
|
||||||
if (!lwjglPatch)
|
if (!lwjglPatch)
|
||||||
|
@ -34,6 +34,9 @@
|
|||||||
#include "update/FMLLibrariesTask.h"
|
#include "update/FMLLibrariesTask.h"
|
||||||
#include "update/AssetUpdateTask.h"
|
#include "update/AssetUpdateTask.h"
|
||||||
|
|
||||||
|
#include <meta/Index.h>
|
||||||
|
#include <meta/Version.h>
|
||||||
|
|
||||||
OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
|
OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
|
||||||
{
|
{
|
||||||
// create folders
|
// create folders
|
||||||
@ -44,30 +47,22 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
|
|||||||
// add a version update task, if necessary
|
// add a version update task, if necessary
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
auto list = std::dynamic_pointer_cast<MinecraftVersionList>(ENV.getVersionList("net.minecraft"));
|
* FIXME: there are some corner cases here that remain unhandled:
|
||||||
auto version = std::dynamic_pointer_cast<MinecraftVersion>(list->findVersion(m_inst->intendedVersionId()));
|
* what if local load succeeds but remote fails? The version is still usable...
|
||||||
if (version == nullptr)
|
*/
|
||||||
|
// FIXME: derive this from the actual list of version patches...
|
||||||
|
auto loadVersion = [&](const QString & uid, const QString & version)
|
||||||
{
|
{
|
||||||
// don't do anything if it was invalid
|
auto obj = ENV.metadataIndex()->get(uid, version);
|
||||||
m_preFailure = tr("The specified Minecraft version is invalid. Choose a different one.");
|
obj->load();
|
||||||
}
|
auto task = obj->getCurrentTask();
|
||||||
else if (m_inst->providesVersionFile() || !version->needsUpdate())
|
if(task)
|
||||||
{
|
|
||||||
qDebug() << "Instance either provides a version file or doesn't need an update.";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto versionUpdateTask = list->createUpdateTask(m_inst->intendedVersionId());
|
|
||||||
if (!versionUpdateTask)
|
|
||||||
{
|
{
|
||||||
qDebug() << "Didn't spawn an update task.";
|
m_tasks.append(task.unwrap());
|
||||||
}
|
}
|
||||||
else
|
};
|
||||||
{
|
loadVersion("org.lwjgl", "2.9.1");
|
||||||
m_tasks.append(versionUpdateTask);
|
loadVersion("net.minecraft", m_inst->intendedVersionId());
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// libraries download
|
// libraries download
|
||||||
@ -118,11 +113,20 @@ void OneSixUpdate::next()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto task = m_tasks[m_currentTask];
|
auto task = m_tasks[m_currentTask];
|
||||||
|
// if the task is already finished by the time we look at it, skip it
|
||||||
|
if(task->isFinished())
|
||||||
|
{
|
||||||
|
next();
|
||||||
|
}
|
||||||
connect(task.get(), &Task::succeeded, this, &OneSixUpdate::subtaskSucceeded);
|
connect(task.get(), &Task::succeeded, this, &OneSixUpdate::subtaskSucceeded);
|
||||||
connect(task.get(), &Task::failed, this, &OneSixUpdate::subtaskFailed);
|
connect(task.get(), &Task::failed, this, &OneSixUpdate::subtaskFailed);
|
||||||
connect(task.get(), &Task::progress, this, &OneSixUpdate::progress);
|
connect(task.get(), &Task::progress, this, &OneSixUpdate::progress);
|
||||||
connect(task.get(), &Task::status, this, &OneSixUpdate::setStatus);
|
connect(task.get(), &Task::status, this, &OneSixUpdate::setStatus);
|
||||||
task->start();
|
// if the task is already running, do not start it again
|
||||||
|
if(!task->isRunning())
|
||||||
|
{
|
||||||
|
task->start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixUpdate::subtaskSucceeded()
|
void OneSixUpdate::subtaskSucceeded()
|
||||||
|
@ -320,6 +320,7 @@ 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...
|
||||||
VersionSelectDialog vselect(m_inst->versionList().get(), tr("Change Minecraft version"),
|
VersionSelectDialog vselect(m_inst->versionList().get(), tr("Change Minecraft version"),
|
||||||
this);
|
this);
|
||||||
if (!vselect.exec() || !vselect.selectedVersion())
|
if (!vselect.exec() || !vselect.selectedVersion())
|
||||||
|
Loading…
Reference in New Issue
Block a user