NOISSUE stuff and things happened. Maybe.
This commit is contained in:
parent
2660418d58
commit
f557c13679
@ -22,6 +22,7 @@
|
||||
#include "BaseVersion.h"
|
||||
#include "tasks/Task.h"
|
||||
#include "multimc_logic_export.h"
|
||||
#include "QObjectPtr.h"
|
||||
|
||||
/*!
|
||||
* \brief Class that each instance type's version list derives from.
|
||||
@ -63,7 +64,7 @@ public:
|
||||
* The task returned by this function should reset the model when it's done.
|
||||
* \return A pointer to a task that reloads the version list.
|
||||
*/
|
||||
virtual Task *getLoadTask() = 0;
|
||||
virtual shared_qobject_ptr<Task> getLoadTask() = 0;
|
||||
|
||||
//! Checks whether or not the list is loaded. If this returns false, the list should be
|
||||
//loaded.
|
||||
@ -76,17 +77,17 @@ public:
|
||||
virtual int count() const = 0;
|
||||
|
||||
//////// List Model Functions ////////
|
||||
virtual QVariant data(const QModelIndex &index, int role) const;
|
||||
virtual int rowCount(const QModelIndex &parent) const;
|
||||
virtual int columnCount(const QModelIndex &parent) const;
|
||||
virtual QHash<int, QByteArray> roleNames() const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
int columnCount(const QModelIndex &parent) const override;
|
||||
virtual QHash<int, QByteArray> roleNames() const;
|
||||
|
||||
//! which roles are provided by this version list?
|
||||
virtual RoleList providesRoles() const;
|
||||
|
||||
/*!
|
||||
* \brief Finds a version by its descriptor.
|
||||
* \param The descriptor of the version to find.
|
||||
* \param descriptor The descriptor of the version to find.
|
||||
* \return A const pointer to the version with the given descriptor. NULL if
|
||||
* one doesn't exist.
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ JavaInstallList::JavaInstallList(QObject *parent) : BaseVersionList(parent)
|
||||
{
|
||||
}
|
||||
|
||||
Task *JavaInstallList::getLoadTask()
|
||||
shared_qobject_ptr<Task> JavaInstallList::getLoadTask()
|
||||
{
|
||||
return new JavaListLoadTask(this);
|
||||
}
|
||||
|
@ -34,17 +34,17 @@ class MULTIMC_LOGIC_EXPORT JavaInstallList : public BaseVersionList
|
||||
public:
|
||||
explicit JavaInstallList(QObject *parent = 0);
|
||||
|
||||
virtual Task *getLoadTask() override;
|
||||
virtual bool isLoaded() override;
|
||||
virtual const BaseVersionPtr at(int i) const override;
|
||||
virtual int count() const override;
|
||||
virtual void sortVersions() override;
|
||||
shared_qobject_ptr<Task> getLoadTask() override;
|
||||
bool isLoaded() override;
|
||||
const BaseVersionPtr at(int i) const override;
|
||||
int count() const override;
|
||||
void sortVersions() override;
|
||||
|
||||
virtual QVariant data(const QModelIndex &index, int role) const override;
|
||||
virtual RoleList providesRoles() const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
RoleList providesRoles() const override;
|
||||
|
||||
public slots:
|
||||
virtual void updateListData(QList<BaseVersionPtr> versions) override;
|
||||
void updateListData(QList<BaseVersionPtr> versions) override;
|
||||
|
||||
protected:
|
||||
QList<BaseVersionPtr> m_vlist;
|
||||
@ -60,7 +60,7 @@ public:
|
||||
explicit JavaListLoadTask(JavaInstallList *vlist);
|
||||
~JavaListLoadTask();
|
||||
|
||||
virtual void executeTask();
|
||||
void executeTask() override;
|
||||
public slots:
|
||||
void javaCheckerFinished(QList<JavaCheckResult> results);
|
||||
|
||||
|
@ -101,16 +101,20 @@ bool Meta::BaseEntity::loadLocalFile()
|
||||
|
||||
void Meta::BaseEntity::load()
|
||||
{
|
||||
// load local file if nothing is loaded yet
|
||||
if(!isLoaded())
|
||||
{
|
||||
loadLocalFile();
|
||||
if(loadLocalFile())
|
||||
{
|
||||
m_loadStatus = LoadStatus::Local;
|
||||
}
|
||||
}
|
||||
// if we need remote update, run the update task
|
||||
if(!shouldStartRemoteUpdate())
|
||||
{
|
||||
return;
|
||||
}
|
||||
NetJob *job = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename()));
|
||||
|
||||
auto url = this->url();
|
||||
auto entry = ENV.metacache()->resolveEntry("meta", localFilename());
|
||||
entry->setStale(true);
|
||||
|
@ -23,7 +23,7 @@ slots:
|
||||
QVERIFY(!windex.hasUid("asdf"));
|
||||
QVERIFY(windex.get("list2") != nullptr);
|
||||
QCOMPARE(windex.get("list2")->uid(), QString("list2"));
|
||||
QVERIFY(windex.get("adsf") == nullptr);
|
||||
QVERIFY(windex.get("adsf") != nullptr);
|
||||
}
|
||||
|
||||
void test_merge()
|
||||
|
@ -20,14 +20,6 @@
|
||||
#include "JsonFormat.h"
|
||||
#include "minecraft/MinecraftProfile.h"
|
||||
|
||||
void Meta::Version::applyTo(MinecraftProfile* profile)
|
||||
{
|
||||
if(m_data)
|
||||
{
|
||||
m_data->applyTo(profile);
|
||||
}
|
||||
}
|
||||
|
||||
Meta::Version::Version(const QString &uid, const QString &version)
|
||||
: BaseVersion(), m_uid(uid), m_version(version)
|
||||
{
|
||||
@ -39,7 +31,9 @@ QString Meta::Version::descriptor()
|
||||
}
|
||||
QString Meta::Version::name()
|
||||
{
|
||||
return m_version;
|
||||
if(m_data)
|
||||
return m_data->getName();
|
||||
return m_uid;
|
||||
}
|
||||
QString Meta::Version::typeString() const
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace Meta
|
||||
{
|
||||
using VersionPtr = std::shared_ptr<class Version>;
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public BaseEntity, public ProfilePatch
|
||||
class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public BaseEntity
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString uid READ uid CONSTANT)
|
||||
@ -45,85 +45,6 @@ class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, 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;
|
||||
@ -153,6 +74,7 @@ signals:
|
||||
void requiresChanged();
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_uid;
|
||||
QString m_version;
|
||||
QString m_type;
|
||||
|
@ -29,15 +29,15 @@ VersionList::VersionList(const QString &uid, QObject *parent)
|
||||
setObjectName("Version list: " + uid);
|
||||
}
|
||||
|
||||
Task *VersionList::getLoadTask()
|
||||
shared_qobject_ptr<Task> VersionList::getLoadTask()
|
||||
{
|
||||
// TODO: create a wrapper task that will chain from root to here.
|
||||
return nullptr;
|
||||
load();
|
||||
return getCurrentTask();
|
||||
}
|
||||
|
||||
bool VersionList::isLoaded()
|
||||
{
|
||||
return isLoaded();
|
||||
return BaseEntity::isLoaded();
|
||||
}
|
||||
|
||||
const BaseVersionPtr VersionList::at(int i) const
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
VersionPtrRole
|
||||
};
|
||||
|
||||
Task *getLoadTask() override;
|
||||
shared_qobject_ptr<Task> getLoadTask() override;
|
||||
bool isLoaded() override;
|
||||
const BaseVersionPtr at(int i) const override;
|
||||
int count() const override;
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "minecraft/launch/ModMinecraftJar.h"
|
||||
#include "minecraft/launch/ClaimAccount.h"
|
||||
#include "java/launch/CheckJava.h"
|
||||
#include <meta/Index.h>
|
||||
#include <meta/VersionList.h>
|
||||
|
||||
#include <icons/IIconList.h>
|
||||
|
||||
@ -105,7 +107,7 @@ QString MinecraftInstance::binRoot() const
|
||||
|
||||
std::shared_ptr< BaseVersionList > MinecraftInstance::versionList() const
|
||||
{
|
||||
return ENV.getVersionList("net.minecraft");
|
||||
return ENV.metadataIndex()->get("net.minecraft");
|
||||
}
|
||||
|
||||
QStringList MinecraftInstance::javaArguments() const
|
||||
|
@ -210,7 +210,7 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
||||
readVersionProperties(root, out.get());
|
||||
|
||||
out->name = "Minecraft";
|
||||
out->fileId = "net.minecraft";
|
||||
out->uid = "net.minecraft";
|
||||
out->version = out->minecraftVersion;
|
||||
out->filename = filename;
|
||||
|
||||
|
@ -51,8 +51,6 @@ public:
|
||||
virtual void applyTo(MinecraftProfile *profile) = 0;
|
||||
|
||||
virtual bool isMinecraftVersion() = 0;
|
||||
virtual bool hasJarMods() = 0;
|
||||
virtual QList<JarmodPtr> getJarMods() = 0;
|
||||
|
||||
virtual bool isMoveable() = 0;
|
||||
virtual bool isCustomizable() = 0;
|
||||
|
@ -102,7 +102,7 @@ bool readOverrideOrders(QString path, PatchOrder &order)
|
||||
static VersionFilePtr createErrorVersionFile(QString fileId, QString filepath, QString error)
|
||||
{
|
||||
auto outError = std::make_shared<VersionFile>();
|
||||
outError->fileId = outError->name = fileId;
|
||||
outError->uid = outError->name = fileId;
|
||||
outError->filename = filepath;
|
||||
outError->addProblem(PROBLEM_ERROR, error);
|
||||
return outError;
|
||||
|
@ -14,12 +14,7 @@
|
||||
|
||||
bool VersionFile::isMinecraftVersion()
|
||||
{
|
||||
return fileId == "net.minecraft";
|
||||
}
|
||||
|
||||
bool VersionFile::hasJarMods()
|
||||
{
|
||||
return !jarMods.isEmpty();
|
||||
return uid == "net.minecraft";
|
||||
}
|
||||
|
||||
void VersionFile::applyTo(MinecraftProfile *profile)
|
||||
@ -29,7 +24,7 @@ void VersionFile::applyTo(MinecraftProfile *profile)
|
||||
{
|
||||
if (QRegExp(dependsOnMinecraftVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(theirVersion) == -1)
|
||||
{
|
||||
throw MinecraftVersionMismatch(fileId, dependsOnMinecraftVersion, theirVersion);
|
||||
throw MinecraftVersionMismatch(uid, dependsOnMinecraftVersion, theirVersion);
|
||||
}
|
||||
}
|
||||
profile->applyMinecraftVersion(minecraftVersion);
|
||||
|
@ -25,7 +25,6 @@ class VersionFile : public ProfilePatch
|
||||
public: /* methods */
|
||||
virtual void applyTo(MinecraftProfile *profile) override;
|
||||
virtual bool isMinecraftVersion() override;
|
||||
virtual bool hasJarMods() override;
|
||||
virtual int getOrder() override
|
||||
{
|
||||
return order;
|
||||
@ -34,13 +33,9 @@ public: /* methods */
|
||||
{
|
||||
this->order = order;
|
||||
}
|
||||
virtual QList<JarmodPtr> getJarMods() override
|
||||
{
|
||||
return jarMods;
|
||||
}
|
||||
virtual QString getID() override
|
||||
{
|
||||
return fileId;
|
||||
return uid;
|
||||
}
|
||||
virtual QString getName() override
|
||||
{
|
||||
@ -120,9 +115,6 @@ public: /* methods */
|
||||
|
||||
|
||||
public: /* data */
|
||||
/// MultiMC: order hint for this version file if no explicit order is set
|
||||
int order = 0;
|
||||
|
||||
// Flags for UI and version file manipulation in general
|
||||
bool m_isVanilla = false;
|
||||
bool m_isRemovable = false;
|
||||
@ -130,6 +122,9 @@ public: /* data */
|
||||
bool m_isCustomizable = false;
|
||||
bool m_isMovable = false;
|
||||
|
||||
/// MultiMC: order hint for this version file if no explicit order is set
|
||||
int order = 0;
|
||||
|
||||
/// MultiMC: filename of the file this was loaded from
|
||||
QString filename;
|
||||
|
||||
@ -137,7 +132,7 @@ public: /* data */
|
||||
QString name;
|
||||
|
||||
/// MultiMC: package ID of this package
|
||||
QString fileId;
|
||||
QString uid;
|
||||
|
||||
/// MultiMC: version of this package
|
||||
QString version;
|
||||
@ -191,5 +186,3 @@ public:
|
||||
// Mojang: extended asset index download information
|
||||
std::shared_ptr<MojangAssetIndexInfo> mojangAssetIndex;
|
||||
};
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
||||
if(QFile::exists(mcJson))
|
||||
{
|
||||
auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false);
|
||||
file->fileId = "net.minecraft";
|
||||
file->uid = "net.minecraft";
|
||||
file->name = QObject::tr("Minecraft (tracked)");
|
||||
file->setVanilla(true);
|
||||
if(file->version.isEmpty())
|
||||
@ -64,7 +64,7 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
||||
addLib->setHint("local");
|
||||
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
||||
}
|
||||
file->fileId = "org.multimc.ftb.pack";
|
||||
file->uid = "org.multimc.ftb.pack";
|
||||
file->setVanilla(true);
|
||||
file->name = QObject::tr("%1 (FTB pack)").arg(m_instance->name());
|
||||
if(file->version.isEmpty())
|
||||
|
@ -99,6 +99,7 @@ inline QDomElement getDomElementByTagName(QDomElement parent, QString tagname)
|
||||
|
||||
void LWJGLVersionList::rssFailed(const QString& reason)
|
||||
{
|
||||
m_rssDLJob.reset();
|
||||
m_loading = false;
|
||||
qWarning() << "Failed to load LWJGL list. Network error: " + reason;
|
||||
}
|
||||
@ -116,8 +117,9 @@ void LWJGLVersionList::rssSucceeded()
|
||||
if (!doc.setContent(m_rssData, false, &xmlErrorMsg, &errorLine))
|
||||
{
|
||||
qWarning() << "Failed to load LWJGL list. XML error: " + xmlErrorMsg + " at line " + QString::number(errorLine);
|
||||
m_loading = false;
|
||||
m_rssDLJob.reset();
|
||||
m_rssData.clear();
|
||||
m_loading = false;
|
||||
return;
|
||||
}
|
||||
m_rssData.clear();
|
||||
@ -162,5 +164,6 @@ void LWJGLVersionList::rssSucceeded()
|
||||
endResetModel();
|
||||
|
||||
qDebug() << "Loaded LWJGL list.";
|
||||
m_rssDLJob.reset();
|
||||
m_loading = false;
|
||||
}
|
||||
|
@ -78,9 +78,9 @@ public:
|
||||
return m_vlist[i];
|
||||
}
|
||||
|
||||
virtual Task* getLoadTask() override
|
||||
virtual shared_qobject_ptr<Task> getLoadTask() override
|
||||
{
|
||||
return nullptr;
|
||||
return m_rssDLJob;
|
||||
}
|
||||
|
||||
virtual void sortVersions() override {};
|
||||
|
@ -56,7 +56,7 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles()
|
||||
}
|
||||
auto file = ProfileUtils::parseJsonFile(QFileInfo(sourceFile), false);
|
||||
ProfileUtils::removeLwjglFromPatch(file);
|
||||
file->fileId = "net.minecraft";
|
||||
file->uid = "net.minecraft";
|
||||
file->version = file->minecraftVersion;
|
||||
file->name = "Minecraft";
|
||||
auto data = OneSixVersionFormat::versionFileToJson(file, false).toJson();
|
||||
@ -81,6 +81,107 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles()
|
||||
}
|
||||
}
|
||||
|
||||
class MetaPatchProvider : public ProfilePatch
|
||||
{
|
||||
public: /* con/des */
|
||||
MetaPatchProvider(std::shared_ptr<Meta::Version> data)
|
||||
:m_version(data)
|
||||
{
|
||||
}
|
||||
public:
|
||||
QString getFilename() override
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
QString getID() override
|
||||
{
|
||||
return m_version->uid();
|
||||
}
|
||||
QString getName() override
|
||||
{
|
||||
auto vfile = getFile();
|
||||
if(vfile)
|
||||
{
|
||||
return vfile->getName();
|
||||
}
|
||||
return m_version->name();
|
||||
}
|
||||
QDateTime getReleaseDateTime() override
|
||||
{
|
||||
return m_version->time();
|
||||
}
|
||||
QString getVersion() override
|
||||
{
|
||||
return m_version->version();
|
||||
}
|
||||
std::shared_ptr<class VersionFile> getVersionFile() override
|
||||
{
|
||||
return m_version->data();
|
||||
}
|
||||
void setOrder(int) override
|
||||
{
|
||||
}
|
||||
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;
|
||||
}
|
||||
bool isMinecraftVersion() override
|
||||
{
|
||||
return getID() == "net.minecraft";
|
||||
}
|
||||
void applyTo(MinecraftProfile * profile) override
|
||||
{
|
||||
auto vfile = getFile();
|
||||
if(vfile)
|
||||
{
|
||||
vfile->applyTo(profile);
|
||||
}
|
||||
}
|
||||
private:
|
||||
VersionFilePtr getFile()
|
||||
{
|
||||
if(!m_version->isLoaded())
|
||||
{
|
||||
m_version->load();
|
||||
}
|
||||
return m_version->data();
|
||||
}
|
||||
private:
|
||||
std::shared_ptr<Meta::Version> m_version;
|
||||
};
|
||||
|
||||
void OneSixProfileStrategy::loadDefaultBuiltinPatches()
|
||||
{
|
||||
{
|
||||
@ -101,7 +202,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
|
||||
else
|
||||
{
|
||||
auto mcversion = ENV.metadataIndex()->get("net.minecraft", m_instance->intendedVersionId());
|
||||
minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(mcversion);
|
||||
minecraftPatch = std::make_shared<MetaPatchProvider>(mcversion);
|
||||
}
|
||||
if (!minecraftPatch)
|
||||
{
|
||||
@ -124,7 +225,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
|
||||
else
|
||||
{
|
||||
auto lwjglversion = ENV.metadataIndex()->get("org.lwjgl", "2.9.1");
|
||||
lwjglPatch = std::dynamic_pointer_cast<ProfilePatch>(lwjglversion);
|
||||
lwjglPatch = std::make_shared<MetaPatchProvider>(lwjglversion);
|
||||
}
|
||||
if (!lwjglPatch)
|
||||
{
|
||||
@ -162,10 +263,10 @@ void OneSixProfileStrategy::loadUserPatches()
|
||||
qDebug() << "Reading" << filename << "by user order";
|
||||
VersionFilePtr file = ProfileUtils::parseJsonFile(finfo, false);
|
||||
// sanity check. prevent tampering with files.
|
||||
if (file->fileId != id)
|
||||
if (file->uid != id)
|
||||
{
|
||||
file->addProblem(PROBLEM_WARNING, QObject::tr("load id %1 does not match internal id %2").arg(id, file->fileId));
|
||||
seen_extra.insert(file->fileId);
|
||||
file->addProblem(PROBLEM_WARNING, QObject::tr("load id %1 does not match internal id %2").arg(id, file->uid));
|
||||
seen_extra.insert(file->uid);
|
||||
}
|
||||
file->setRemovable(true);
|
||||
file->setMovable(true);
|
||||
@ -185,15 +286,15 @@ void OneSixProfileStrategy::loadUserPatches()
|
||||
qDebug() << "Reading" << info.fileName();
|
||||
auto file = ProfileUtils::parseJsonFile(info, true);
|
||||
// ignore builtins
|
||||
if (file->fileId == "net.minecraft")
|
||||
if (file->uid == "net.minecraft")
|
||||
continue;
|
||||
if (file->fileId == "org.lwjgl")
|
||||
if (file->uid == "org.lwjgl")
|
||||
continue;
|
||||
// do not load versions with broken IDs twice
|
||||
if(seen_extra.contains(file->fileId))
|
||||
if(seen_extra.contains(file->uid))
|
||||
continue;
|
||||
// do not load what we already loaded in the first pass
|
||||
if (userOrder.contains(file->fileId))
|
||||
if (userOrder.contains(file->uid))
|
||||
continue;
|
||||
file->setRemovable(true);
|
||||
file->setMovable(true);
|
||||
@ -203,7 +304,7 @@ void OneSixProfileStrategy::loadUserPatches()
|
||||
file->assets = QString();
|
||||
file->mojangAssetIndex.reset();
|
||||
// HACK
|
||||
files.insert(file->order, file);
|
||||
files.insert(file->getOrder(), file);
|
||||
}
|
||||
QSet<int> seen;
|
||||
for (auto order : files.keys())
|
||||
@ -284,7 +385,8 @@ bool OneSixProfileStrategy::removePatch(ProfilePatchPtr patch)
|
||||
return true;
|
||||
};
|
||||
|
||||
for(auto &jarmod: patch->getJarMods())
|
||||
auto &jarMods = patch->getVersionFile()->jarMods;
|
||||
for(auto &jarmod: jarMods)
|
||||
{
|
||||
ok &= preRemoveJarMod(jarmod);
|
||||
}
|
||||
@ -404,8 +506,8 @@ bool OneSixProfileStrategy::installJarMods(QStringList filepaths)
|
||||
jarMod->originalName = sourceInfo.completeBaseName();
|
||||
f->jarMods.append(jarMod);
|
||||
f->name = target_name;
|
||||
f->fileId = target_id;
|
||||
f->order = profile->getFreeOrderNumber();
|
||||
f->uid = target_id;
|
||||
f->setOrder(profile->getFreeOrderNumber());
|
||||
QString patchFileName = FS::PathCombine(patchDir, target_id + ".json");
|
||||
f->filename = patchFileName;
|
||||
f->setMovable(true);
|
||||
|
@ -51,7 +51,7 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
||||
{
|
||||
if (root.contains("order"))
|
||||
{
|
||||
out->order = requireInteger(root.value("order"));
|
||||
out->setOrder(requireInteger(root.value("order")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -61,7 +61,16 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
||||
}
|
||||
|
||||
out->name = root.value("name").toString();
|
||||
out->fileId = root.value("fileId").toString();
|
||||
|
||||
if(root.contains("uid"))
|
||||
{
|
||||
out->uid = root.value("uid").toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
out->uid = root.value("fileId").toString();
|
||||
}
|
||||
|
||||
out->version = root.value("version").toString();
|
||||
out->dependsOnMinecraftVersion = root.value("mcVersion").toString();
|
||||
out->filename = filename;
|
||||
@ -161,10 +170,13 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch
|
||||
QJsonObject root;
|
||||
if (saveOrder)
|
||||
{
|
||||
root.insert("order", patch->order);
|
||||
root.insert("order", patch->getOrder());
|
||||
}
|
||||
writeString(root, "name", patch->name);
|
||||
writeString(root, "fileId", patch->fileId);
|
||||
|
||||
writeString(root, "uid", patch->uid);
|
||||
writeString(root, "fileId", patch->uid);
|
||||
|
||||
writeString(root, "version", patch->version);
|
||||
writeString(root, "mcVersion", patch->dependsOnMinecraftVersion);
|
||||
|
||||
|
@ -487,22 +487,16 @@ int VersionPage::currentRow()
|
||||
|
||||
void VersionPage::on_customizeBtn_clicked()
|
||||
{
|
||||
// TODO: implement
|
||||
/*
|
||||
auto version = currentRow();
|
||||
if(version == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//HACK HACK remove, this is dumb
|
||||
auto patch = m_profile->versionPatch(version);
|
||||
auto mc = std::dynamic_pointer_cast<MinecraftVersion>(patch);
|
||||
if(mc && mc->needsUpdate())
|
||||
if(!patch->getVersionFile())
|
||||
{
|
||||
if(!doUpdate())
|
||||
{
|
||||
return;
|
||||
}
|
||||
// TODO: wait for the update task to finish here...
|
||||
return;
|
||||
}
|
||||
if(!m_profile->customize(version))
|
||||
{
|
||||
@ -510,7 +504,6 @@ void VersionPage::on_customizeBtn_clicked()
|
||||
}
|
||||
updateButtons();
|
||||
preselect(currentIdx);
|
||||
*/
|
||||
}
|
||||
|
||||
void VersionPage::on_editBtn_clicked()
|
||||
@ -531,22 +524,11 @@ void VersionPage::on_editBtn_clicked()
|
||||
|
||||
void VersionPage::on_revertBtn_clicked()
|
||||
{
|
||||
// TODO: implement
|
||||
/*
|
||||
auto version = currentRow();
|
||||
if(version == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto mcraw = MMC->minecraftlist()->findVersion(m_inst->intendedVersionId());
|
||||
auto mc = std::dynamic_pointer_cast<MinecraftVersion>(mcraw);
|
||||
if(mc && mc->needsUpdate())
|
||||
{
|
||||
if(!doUpdate())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!m_profile->revertToBase(version))
|
||||
{
|
||||
// TODO: some error box here
|
||||
@ -554,7 +536,6 @@ void VersionPage::on_revertBtn_clicked()
|
||||
updateButtons();
|
||||
preselect(currentIdx);
|
||||
m_container->refreshContainer();
|
||||
*/
|
||||
}
|
||||
|
||||
#include "VersionPage.moc"
|
||||
|
@ -80,52 +80,42 @@ void VersionSelectWidget::initialize()
|
||||
|
||||
void VersionSelectWidget::closeEvent(QCloseEvent * event)
|
||||
{
|
||||
if(loadTask)
|
||||
{
|
||||
loadTask->abort();
|
||||
loadTask->deleteLater();
|
||||
loadTask = nullptr;
|
||||
}
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
void VersionSelectWidget::loadList()
|
||||
{
|
||||
if(loadTask)
|
||||
auto newTask = m_vlist->getLoadTask();
|
||||
if (!newTask)
|
||||
{
|
||||
return;
|
||||
}
|
||||
loadTask = m_vlist->getLoadTask();
|
||||
if (!loadTask)
|
||||
{
|
||||
return;
|
||||
}
|
||||
connect(loadTask, &Task::finished, this, &VersionSelectWidget::onTaskFinished);
|
||||
loadTask = newTask.get();
|
||||
connect(loadTask, &Task::succeeded, this, &VersionSelectWidget::onTaskSucceeded);
|
||||
connect(loadTask, &Task::failed, this, &VersionSelectWidget::onTaskFailed);
|
||||
connect(loadTask, &Task::progress, this, &VersionSelectWidget::changeProgress);
|
||||
loadTask->start();
|
||||
if(!loadTask->isRunning())
|
||||
{
|
||||
loadTask->start();
|
||||
}
|
||||
sneakyProgressBar->setHidden(false);
|
||||
}
|
||||
|
||||
void VersionSelectWidget::onTaskFinished()
|
||||
void VersionSelectWidget::onTaskSucceeded()
|
||||
{
|
||||
if (!loadTask->successful())
|
||||
{
|
||||
CustomMessageBox::selectable(this, tr("Error"),
|
||||
tr("List update failed:\n%1").arg(loadTask->failReason()),
|
||||
QMessageBox::Warning)->show();
|
||||
if (m_proxyModel->rowCount() == 0)
|
||||
{
|
||||
listView->setEmptyMode(VersionListView::ErrorString);
|
||||
}
|
||||
}
|
||||
else if (m_proxyModel->rowCount() == 0)
|
||||
if (m_proxyModel->rowCount() == 0)
|
||||
{
|
||||
listView->setEmptyMode(VersionListView::String);
|
||||
}
|
||||
sneakyProgressBar->setHidden(true);
|
||||
loadTask->deleteLater();
|
||||
loadTask = nullptr;
|
||||
preselect();
|
||||
loadTask = nullptr;
|
||||
}
|
||||
|
||||
void VersionSelectWidget::onTaskFailed(const QString& reason)
|
||||
{
|
||||
CustomMessageBox::selectable(this, tr("Error"), tr("List update failed:\n%1").arg(reason), QMessageBox::Warning)->show();
|
||||
onTaskSucceeded();
|
||||
}
|
||||
|
||||
void VersionSelectWidget::changeProgress(qint64 current, qint64 total)
|
||||
|
@ -55,7 +55,8 @@ protected:
|
||||
virtual void closeEvent ( QCloseEvent* );
|
||||
|
||||
private slots:
|
||||
void onTaskFinished();
|
||||
void onTaskSucceeded();
|
||||
void onTaskFailed(const QString &reason);
|
||||
void changeProgress(qint64 current, qint64 total);
|
||||
void currentRowChanged(const QModelIndex ¤t, const QModelIndex &);
|
||||
|
||||
@ -66,7 +67,7 @@ private:
|
||||
BaseVersionList *m_vlist = nullptr;
|
||||
VersionProxyModel *m_proxyModel = nullptr;
|
||||
int resizeOnColumn = 0;
|
||||
Task * loadTask = nullptr;
|
||||
Task * loadTask;
|
||||
bool preselectedAlready = false;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user