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();
|
||||
}
|
||||
|
||||
shared_qobject_ptr<Task> Meta::BaseEntity::getCurrentTask()
|
||||
{
|
||||
if(m_updateStatus == UpdateStatus::InProgress)
|
||||
{
|
||||
return m_updateTask;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#include "BaseEntity.moc"
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
}
|
||||
|
||||
void load();
|
||||
shared_qobject_ptr<Task> getCurrentTask();
|
||||
|
||||
protected: /* methods */
|
||||
bool loadLocalFile();
|
||||
|
@ -83,18 +83,20 @@ bool Index::hasUid(const QString &uid) const
|
||||
|
||||
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)
|
||||
{
|
||||
auto list = get(uid);
|
||||
if(list)
|
||||
{
|
||||
return list->getVersion(version);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Index::parse(const QJsonObject& obj)
|
||||
{
|
||||
|
@ -68,3 +68,4 @@ private:
|
||||
void connectVersionList(const int row, const VersionListPtr &list);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -18,38 +18,45 @@
|
||||
#include <QDateTime>
|
||||
|
||||
#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)
|
||||
{
|
||||
}
|
||||
|
||||
QString Version::descriptor()
|
||||
QString Meta::Version::descriptor()
|
||||
{
|
||||
return m_version;
|
||||
}
|
||||
QString Version::name()
|
||||
QString Meta::Version::name()
|
||||
{
|
||||
return m_version;
|
||||
}
|
||||
QString Version::typeString() const
|
||||
QString Meta::Version::typeString() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
QDateTime Version::time() const
|
||||
QDateTime Meta::Version::time() const
|
||||
{
|
||||
return QDateTime::fromMSecsSinceEpoch(m_time * 1000, Qt::UTC);
|
||||
}
|
||||
|
||||
void Version::parse(const QJsonObject& obj)
|
||||
void Meta::Version::parse(const QJsonObject& obj)
|
||||
{
|
||||
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);
|
||||
if (m_type != version->m_type)
|
||||
@ -68,28 +75,28 @@ void Version::merge(const std::shared_ptr<BaseEntity> &other)
|
||||
setData(version->m_data);
|
||||
}
|
||||
|
||||
QString Version::localFilename() const
|
||||
QString Meta::Version::localFilename() const
|
||||
{
|
||||
return m_uid + '/' + m_version + ".json";
|
||||
}
|
||||
|
||||
void Version::setType(const QString &type)
|
||||
void Meta::Version::setType(const QString &type)
|
||||
{
|
||||
m_type = type;
|
||||
emit typeChanged();
|
||||
}
|
||||
void Version::setTime(const qint64 time)
|
||||
void Meta::Version::setTime(const qint64 time)
|
||||
{
|
||||
m_time = time;
|
||||
emit timeChanged();
|
||||
}
|
||||
void Version::setRequires(const QVector<Reference> &requires)
|
||||
void Meta::Version::setRequires(const QVector<Reference> &requires)
|
||||
{
|
||||
m_requires = requires;
|
||||
emit requiresChanged();
|
||||
}
|
||||
void Version::setData(const VersionFilePtr &data)
|
||||
void Meta::Version::setData(const VersionFilePtr &data)
|
||||
{
|
||||
m_data = data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace Meta
|
||||
{
|
||||
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_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(QDateTime time READ time NOTIFY timeChanged)
|
||||
Q_PROPERTY(QVector<Reference> requires READ requires NOTIFY requiresChanged)
|
||||
public:
|
||||
|
||||
public: /* con/des */
|
||||
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 name() override;
|
||||
QString typeString() const override;
|
||||
|
@ -125,13 +125,15 @@ QString VersionList::humanReadable() const
|
||||
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)
|
||||
{
|
||||
out = std::make_shared<Version>(m_uid, version);
|
||||
m_lookup[version] = out;
|
||||
}
|
||||
VersionPtr VersionList::getVersion(const QString &version) const
|
||||
{
|
||||
return m_lookup.value(version);
|
||||
return out;
|
||||
}
|
||||
|
||||
void VersionList::setName(const QString &name)
|
||||
|
@ -60,8 +60,7 @@ public:
|
||||
QString name() const { return m_name; }
|
||||
QString humanReadable() const;
|
||||
|
||||
bool hasVersion(const QString &version) const;
|
||||
VersionPtr getVersion(const QString &version) const;
|
||||
VersionPtr getVersion(const QString &version);
|
||||
|
||||
QVector<VersionPtr> versions() const { return m_versions; }
|
||||
|
||||
|
@ -92,10 +92,6 @@ public:
|
||||
{
|
||||
return m_problemSeverity;
|
||||
}
|
||||
virtual bool hasFailed()
|
||||
{
|
||||
return getProblemSeverity() == PROBLEM_ERROR;
|
||||
}
|
||||
|
||||
protected:
|
||||
QList<PatchProblem> m_problems;
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <QJsonArray>
|
||||
#include <QSaveFile>
|
||||
#include <QResource>
|
||||
#include <meta/Index.h>
|
||||
#include <meta/Version.h>
|
||||
|
||||
OneSixProfileStrategy::OneSixProfileStrategy(OneSixInstance* instance)
|
||||
{
|
||||
@ -98,7 +100,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (!minecraftPatch)
|
||||
@ -121,7 +123,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (!lwjglPatch)
|
||||
|
@ -34,6 +34,9 @@
|
||||
#include "update/FMLLibrariesTask.h"
|
||||
#include "update/AssetUpdateTask.h"
|
||||
|
||||
#include <meta/Index.h>
|
||||
#include <meta/Version.h>
|
||||
|
||||
OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
|
||||
{
|
||||
// create folders
|
||||
@ -44,30 +47,22 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
|
||||
// add a version update task, if necessary
|
||||
{
|
||||
/*
|
||||
auto list = std::dynamic_pointer_cast<MinecraftVersionList>(ENV.getVersionList("net.minecraft"));
|
||||
auto version = std::dynamic_pointer_cast<MinecraftVersion>(list->findVersion(m_inst->intendedVersionId()));
|
||||
if (version == nullptr)
|
||||
{
|
||||
// don't do anything if it was invalid
|
||||
m_preFailure = tr("The specified Minecraft version is invalid. Choose a different one.");
|
||||
}
|
||||
else if (m_inst->providesVersionFile() || !version->needsUpdate())
|
||||
{
|
||||
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.";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tasks.append(versionUpdateTask);
|
||||
}
|
||||
}
|
||||
* FIXME: there are some corner cases here that remain unhandled:
|
||||
* what if local load succeeds but remote fails? The version is still usable...
|
||||
*/
|
||||
// FIXME: derive this from the actual list of version patches...
|
||||
auto loadVersion = [&](const QString & uid, const QString & version)
|
||||
{
|
||||
auto obj = ENV.metadataIndex()->get(uid, version);
|
||||
obj->load();
|
||||
auto task = obj->getCurrentTask();
|
||||
if(task)
|
||||
{
|
||||
m_tasks.append(task.unwrap());
|
||||
}
|
||||
};
|
||||
loadVersion("org.lwjgl", "2.9.1");
|
||||
loadVersion("net.minecraft", m_inst->intendedVersionId());
|
||||
}
|
||||
|
||||
// libraries download
|
||||
@ -118,12 +113,21 @@ void OneSixUpdate::next()
|
||||
return;
|
||||
}
|
||||
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::failed, this, &OneSixUpdate::subtaskFailed);
|
||||
connect(task.get(), &Task::progress, this, &OneSixUpdate::progress);
|
||||
connect(task.get(), &Task::status, this, &OneSixUpdate::setStatus);
|
||||
// if the task is already running, do not start it again
|
||||
if(!task->isRunning())
|
||||
{
|
||||
task->start();
|
||||
}
|
||||
}
|
||||
|
||||
void OneSixUpdate::subtaskSucceeded()
|
||||
{
|
||||
|
@ -320,6 +320,7 @@ 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);
|
||||
if (!vselect.exec() || !vselect.selectedVersion())
|
||||
|
Loading…
Reference in New Issue
Block a user