summaryrefslogtreecommitdiffstats
path: root/logic/lists
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-04-23 02:27:40 +0200
committerPetr Mrázek <peterix@gmail.com>2014-06-09 01:38:29 +0200
commitaade36860c373268857ca821c14a13f38c880b1a (patch)
tree464b804216c7eadc00941daa33a1713c8071a088 /logic/lists
parent3a0cdf2d3dde6192694ca34429ab277608357c2a (diff)
downloadMultiMC-aade36860c373268857ca821c14a13f38c880b1a.tar
MultiMC-aade36860c373268857ca821c14a13f38c880b1a.tar.gz
MultiMC-aade36860c373268857ca821c14a13f38c880b1a.tar.lz
MultiMC-aade36860c373268857ca821c14a13f38c880b1a.tar.xz
MultiMC-aade36860c373268857ca821c14a13f38c880b1a.zip
Begin the transformation!
Nuke all the things.
Diffstat (limited to 'logic/lists')
-rw-r--r--logic/lists/ForgeVersionList.cpp439
-rw-r--r--logic/lists/ForgeVersionList.h128
-rw-r--r--logic/lists/LiteLoaderVersionList.cpp223
-rw-r--r--logic/lists/LiteLoaderVersionList.h112
-rw-r--r--logic/lists/MinecraftVersionList.cpp16
5 files changed, 7 insertions, 911 deletions
diff --git a/logic/lists/ForgeVersionList.cpp b/logic/lists/ForgeVersionList.cpp
deleted file mode 100644
index 4902dc64..00000000
--- a/logic/lists/ForgeVersionList.cpp
+++ /dev/null
@@ -1,439 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ForgeVersionList.h"
-#include <logic/net/NetJob.h>
-#include <logic/net/URLConstants.h>
-#include "MultiMC.h"
-
-#include <QtNetwork>
-#include <QtXml>
-#include <QRegExp>
-
-#include "logger/QsLog.h"
-
-ForgeVersionList::ForgeVersionList(QObject *parent) : BaseVersionList(parent)
-{
-}
-
-Task *ForgeVersionList::getLoadTask()
-{
- return new ForgeListLoadTask(this);
-}
-
-bool ForgeVersionList::isLoaded()
-{
- return m_loaded;
-}
-
-const BaseVersionPtr ForgeVersionList::at(int i) const
-{
- return m_vlist.at(i);
-}
-
-int ForgeVersionList::count() const
-{
- return m_vlist.count();
-}
-
-int ForgeVersionList::columnCount(const QModelIndex &parent) const
-{
- return 3;
-}
-
-QVariant ForgeVersionList::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (index.row() > count())
- return QVariant();
-
- auto version = std::dynamic_pointer_cast<ForgeVersion>(m_vlist[index.row()]);
- switch (role)
- {
- case Qt::DisplayRole:
- switch (index.column())
- {
- case 0:
- return version->name();
-
- case 1:
- return version->mcver;
-
- case 2:
- return version->typeString();
- default:
- return QVariant();
- }
-
- case Qt::ToolTipRole:
- return version->descriptor();
-
- case VersionPointerRole:
- return qVariantFromValue(m_vlist[index.row()]);
-
- default:
- return QVariant();
- }
-}
-
-QVariant ForgeVersionList::headerData(int section, Qt::Orientation orientation, int role) const
-{
- switch (role)
- {
- case Qt::DisplayRole:
- switch (section)
- {
- case 0:
- return "Version";
-
- case 1:
- return "Minecraft";
-
- case 2:
- return "Type";
-
- default:
- return QVariant();
- }
-
- case Qt::ToolTipRole:
- switch (section)
- {
- case 0:
- return "The name of the version.";
-
- case 1:
- return "Minecraft version";
-
- case 2:
- return "The version's type.";
-
- default:
- return QVariant();
- }
-
- default:
- return QVariant();
- }
-}
-
-BaseVersionPtr ForgeVersionList::getLatestStable() const
-{
- return BaseVersionPtr();
-}
-
-void ForgeVersionList::updateListData(QList<BaseVersionPtr> versions)
-{
- beginResetModel();
- m_vlist = versions;
- m_loaded = true;
- endResetModel();
- // NOW SORT!!
- // sort();
-}
-
-void ForgeVersionList::sort()
-{
- // NO-OP for now
-}
-
-ForgeListLoadTask::ForgeListLoadTask(ForgeVersionList *vlist) : Task()
-{
- m_list = vlist;
-}
-
-void ForgeListLoadTask::executeTask()
-{
- setStatus(tr("Fetching Forge version lists..."));
- auto job = new NetJob("Version index");
- // we do not care if the version is stale or not.
- auto forgeListEntry = MMC->metacache()->resolveEntry("minecraftforge", "list.json");
- auto gradleForgeListEntry = MMC->metacache()->resolveEntry("minecraftforge", "json");
-
- // verify by poking the server.
- forgeListEntry->stale = true;
- gradleForgeListEntry->stale = true;
-
- job->addNetAction(listDownload = CacheDownload::make(QUrl(URLConstants::FORGE_LEGACY_URL),
- forgeListEntry));
- job->addNetAction(gradleListDownload = CacheDownload::make(
- QUrl(URLConstants::FORGE_GRADLE_URL), gradleForgeListEntry));
-
- connect(listDownload.get(), SIGNAL(failed(int)), SLOT(listFailed()));
- connect(gradleListDownload.get(), SIGNAL(failed(int)), SLOT(gradleListFailed()));
-
- listJob.reset(job);
- connect(listJob.get(), SIGNAL(succeeded()), SLOT(listDownloaded()));
- connect(listJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
- listJob->start();
-}
-
-bool ForgeListLoadTask::parseForgeList(QList<BaseVersionPtr> &out)
-{
- QByteArray data;
- {
- auto dlJob = listDownload;
- auto filename = std::dynamic_pointer_cast<CacheDownload>(dlJob)->getTargetFilepath();
- QFile listFile(filename);
- if (!listFile.open(QIODevice::ReadOnly))
- {
- return false;
- }
- data = listFile.readAll();
- dlJob.reset();
- }
-
- QJsonParseError jsonError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
-
- if (jsonError.error != QJsonParseError::NoError)
- {
- emitFailed("Error parsing version list JSON:" + jsonError.errorString());
- return false;
- }
-
- if (!jsonDoc.isObject())
- {
- emitFailed("Error parsing version list JSON: JSON root is not an object");
- return false;
- }
-
- QJsonObject root = jsonDoc.object();
-
- // Now, get the array of versions.
- if (!root.value("builds").isArray())
- {
- emitFailed(
- "Error parsing version list JSON: version list object is missing 'builds' array");
- return false;
- }
- QJsonArray builds = root.value("builds").toArray();
-
- for (int i = 0; i < builds.count(); i++)
- {
- // Load the version info.
- if (!builds[i].isObject())
- {
- // FIXME: log this somewhere
- continue;
- }
- QJsonObject obj = builds[i].toObject();
- int build_nr = obj.value("build").toDouble(0);
- if (!build_nr)
- continue;
- QJsonArray files = obj.value("files").toArray();
- QString url, jobbuildver, mcver, buildtype, filename;
- QString changelog_url, installer_url;
- QString installer_filename;
- bool valid = false;
- for (int j = 0; j < files.count(); j++)
- {
- if (!files[j].isObject())
- {
- continue;
- }
- QJsonObject file = files[j].toObject();
- buildtype = file.value("buildtype").toString();
- if ((buildtype == "client" || buildtype == "universal") && !valid)
- {
- mcver = file.value("mcver").toString();
- url = file.value("url").toString();
- jobbuildver = file.value("jobbuildver").toString();
- int lastSlash = url.lastIndexOf('/');
- filename = url.mid(lastSlash + 1);
- valid = true;
- }
- else if (buildtype == "changelog")
- {
- QString ext = file.value("ext").toString();
- if (ext.isEmpty())
- {
- continue;
- }
- changelog_url = file.value("url").toString();
- }
- else if (buildtype == "installer")
- {
- installer_url = file.value("url").toString();
- int lastSlash = installer_url.lastIndexOf('/');
- installer_filename = installer_url.mid(lastSlash + 1);
- }
- }
- if (valid)
- {
- // Now, we construct the version object and add it to the list.
- std::shared_ptr<ForgeVersion> fVersion(new ForgeVersion());
- fVersion->universal_url = url;
- fVersion->changelog_url = changelog_url;
- fVersion->installer_url = installer_url;
- fVersion->jobbuildver = jobbuildver;
- fVersion->mcver = mcver;
- if (installer_filename.isEmpty())
- {
- fVersion->filename = filename;
- }
- else
- {
- fVersion->filename = installer_filename;
- }
- fVersion->m_buildnr = build_nr;
- out.append(fVersion);
- }
- }
-
- return true;
-}
-
-bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
-{
- QByteArray data;
- {
- auto dlJob = gradleListDownload;
- auto filename = std::dynamic_pointer_cast<CacheDownload>(dlJob)->getTargetFilepath();
- QFile listFile(filename);
- if (!listFile.open(QIODevice::ReadOnly))
- {
- return false;
- }
- data = listFile.readAll();
- dlJob.reset();
- }
-
- QJsonParseError jsonError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
-
- if (jsonError.error != QJsonParseError::NoError)
- {
- emitFailed("Error parsing gradle version list JSON:" + jsonError.errorString());
- return false;
- }
-
- if (!jsonDoc.isObject())
- {
- emitFailed("Error parsing gradle version list JSON: JSON root is not an object");
- return false;
- }
-
- QJsonObject root = jsonDoc.object();
-
- // we probably could hard code these, but it might still be worth doing it this way
- const QString webpath = root.value("webpath").toString();
- const QString artifact = root.value("artifact").toString();
-
- QJsonObject numbers = root.value("number").toObject();
- for (auto it = numbers.begin(); it != numbers.end(); ++it)
- {
- QJsonObject number = it.value().toObject();
- std::shared_ptr<ForgeVersion> fVersion(new ForgeVersion());
- fVersion->m_buildnr = number.value("build").toDouble();
- fVersion->jobbuildver = number.value("version").toString();
- fVersion->mcver = number.value("mcversion").toString();
- fVersion->filename = "";
- QString filename, installer_filename;
- QJsonArray files = number.value("files").toArray();
- for (auto fIt = files.begin(); fIt != files.end(); ++fIt)
- {
- // TODO with gradle we also get checksums, use them
- QJsonArray file = (*fIt).toArray();
- if (file.size() < 3)
- {
- continue;
- }
- if (file.at(1).toString() == "installer")
- {
- fVersion->installer_url = QString("%1/%2-%3/%4-%2-%3-installer.%5").arg(
- webpath, fVersion->mcver, fVersion->jobbuildver, artifact,
- file.at(0).toString());
- installer_filename = QString("%1-%2-%3-installer.%4").arg(
- artifact, fVersion->mcver, fVersion->jobbuildver, file.at(0).toString());
- }
- else if (file.at(1).toString() == "universal")
- {
- fVersion->universal_url = QString("%1/%2-%3/%4-%2-%3-universal.%5").arg(
- webpath, fVersion->mcver, fVersion->jobbuildver, artifact,
- file.at(0).toString());
- filename = QString("%1-%2-%3-universal.%4").arg(
- artifact, fVersion->mcver, fVersion->jobbuildver, file.at(0).toString());
- }
- else if (file.at(1).toString() == "changelog")
- {
- fVersion->changelog_url = QString("%1/%2-%3/%4-%2-%3-changelog.%5").arg(
- webpath, fVersion->mcver, fVersion->jobbuildver, artifact,
- file.at(0).toString());
- }
- }
- if (fVersion->installer_url.isEmpty() && fVersion->universal_url.isEmpty())
- {
- continue;
- }
- fVersion->filename = fVersion->installer_url.isEmpty() ? filename : installer_filename;
- out.append(fVersion);
- }
-
- return true;
-}
-
-void ForgeListLoadTask::listDownloaded()
-{
- QList<BaseVersionPtr> list;
- bool ret = true;
- if (!parseForgeList(list))
- {
- ret = false;
- }
- if (!parseForgeGradleList(list))
- {
- ret = false;
- }
-
- if (!ret)
- {
- return;
- }
- std::sort(list.begin(), list.end(), [](const BaseVersionPtr & l, const BaseVersionPtr & r)
- { return (*l > *r); });
-
- m_list->updateListData(list);
-
- emitSucceeded();
- return;
-}
-
-void ForgeListLoadTask::listFailed()
-{
- auto reply = listDownload->m_reply;
- if (reply)
- {
- QLOG_ERROR() << "Getting forge version list failed: " << reply->errorString();
- }
- else
- {
- QLOG_ERROR() << "Getting forge version list failed for reasons unknown.";
- }
-}
-void ForgeListLoadTask::gradleListFailed()
-{
- auto reply = gradleListDownload->m_reply;
- if (reply)
- {
- QLOG_ERROR() << "Getting forge version list failed: " << reply->errorString();
- }
- else
- {
- QLOG_ERROR() << "Getting forge version list failed for reasons unknown.";
- }
-}
diff --git a/logic/lists/ForgeVersionList.h b/logic/lists/ForgeVersionList.h
deleted file mode 100644
index b19d3f56..00000000
--- a/logic/lists/ForgeVersionList.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <QObject>
-#include <QAbstractListModel>
-#include <QUrl>
-
-#include <QNetworkReply>
-#include "BaseVersionList.h"
-#include "logic/tasks/Task.h"
-#include "logic/net/NetJob.h"
-
-class ForgeVersion;
-typedef std::shared_ptr<ForgeVersion> ForgeVersionPtr;
-
-struct ForgeVersion : public BaseVersion
-{
- virtual QString descriptor() override
- {
- return filename;
- }
- ;
- virtual QString name() override
- {
- return "Forge " + jobbuildver;
- }
- ;
- virtual QString typeString() const override
- {
- if (installer_url.isEmpty())
- return "Universal";
- else
- return "Installer";
- }
-
- virtual bool operator<(BaseVersion &a) override
- {
- ForgeVersion *pa = dynamic_cast<ForgeVersion *>(&a);
- if(!pa)
- return true;
- return m_buildnr < pa->m_buildnr;
- }
- virtual bool operator>(BaseVersion &a) override
- {
- ForgeVersion *pa = dynamic_cast<ForgeVersion *>(&a);
- if(!pa)
- return false;
- return m_buildnr > pa->m_buildnr;
- }
- int m_buildnr = 0;
- QString universal_url;
- QString changelog_url;
- QString installer_url;
- QString jobbuildver;
- QString mcver;
- QString filename;
-};
-
-class ForgeVersionList : public BaseVersionList
-{
- Q_OBJECT
-public:
- friend class ForgeListLoadTask;
-
- explicit ForgeVersionList(QObject *parent = 0);
-
- virtual Task *getLoadTask();
- virtual bool isLoaded();
- virtual const BaseVersionPtr at(int i) const;
- virtual int count() const;
- virtual void sort();
-
- virtual BaseVersionPtr getLatestStable() const;
-
- virtual QVariant data(const QModelIndex &index, int role) const;
- virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- virtual int columnCount(const QModelIndex &parent) const;
-
-protected:
- QList<BaseVersionPtr> m_vlist;
-
- bool m_loaded = false;
-
-protected
-slots:
- virtual void updateListData(QList<BaseVersionPtr> versions);
-};
-
-class ForgeListLoadTask : public Task
-{
- Q_OBJECT
-
-public:
- explicit ForgeListLoadTask(ForgeVersionList *vlist);
-
- virtual void executeTask();
-
-protected
-slots:
- void listDownloaded();
- void listFailed();
- void gradleListFailed();
-
-protected:
- NetJobPtr listJob;
- ForgeVersionList *m_list;
-
- CacheDownloadPtr listDownload;
- CacheDownloadPtr gradleListDownload;
-
-private:
- bool parseForgeList(QList<BaseVersionPtr> &out);
- bool parseForgeGradleList(QList<BaseVersionPtr> &out);
-};
diff --git a/logic/lists/LiteLoaderVersionList.cpp b/logic/lists/LiteLoaderVersionList.cpp
deleted file mode 100644
index ef95eefd..00000000
--- a/logic/lists/LiteLoaderVersionList.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "LiteLoaderVersionList.h"
-#include "MultiMC.h"
-#include "logic/net/URLConstants.h"
-
-#include <QtXml>
-
-#include <QJsonDocument>
-#include <QJsonObject>
-#include <QJsonArray>
-#include <QJsonValue>
-#include <QJsonParseError>
-
-#include <QtAlgorithms>
-
-#include <QtNetwork>
-
-LiteLoaderVersionList::LiteLoaderVersionList(QObject *parent) : BaseVersionList(parent)
-{
-}
-
-Task *LiteLoaderVersionList::getLoadTask()
-{
- return new LLListLoadTask(this);
-}
-
-bool LiteLoaderVersionList::isLoaded()
-{
- return m_loaded;
-}
-
-const BaseVersionPtr LiteLoaderVersionList::at(int i) const
-{
- return m_vlist.at(i);
-}
-
-int LiteLoaderVersionList::count() const
-{
- return m_vlist.count();
-}
-
-static bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second)
-{
- auto left = std::dynamic_pointer_cast<LiteLoaderVersion>(first);
- auto right = std::dynamic_pointer_cast<LiteLoaderVersion>(second);
- return left->timestamp > right->timestamp;
-}
-
-void LiteLoaderVersionList::sort()
-{
- beginResetModel();
- qSort(m_vlist.begin(), m_vlist.end(), cmpVersions);
- endResetModel();
-}
-
-BaseVersionPtr LiteLoaderVersionList::getLatestStable() const
-{
- for (int i = 0; i < m_vlist.length(); i++)
- {
- auto ver = std::dynamic_pointer_cast<LiteLoaderVersion>(m_vlist.at(i));
- if (ver->isLatest)
- {
- return m_vlist.at(i);
- }
- }
- return BaseVersionPtr();
-}
-
-void LiteLoaderVersionList::updateListData(QList<BaseVersionPtr> versions)
-{
- beginResetModel();
- m_vlist = versions;
- m_loaded = true;
- qSort(m_vlist.begin(), m_vlist.end(), cmpVersions);
- endResetModel();
-}
-
-LLListLoadTask::LLListLoadTask(LiteLoaderVersionList *vlist)
-{
- m_list = vlist;
-}
-
-LLListLoadTask::~LLListLoadTask()
-{
-}
-
-void LLListLoadTask::executeTask()
-{
- setStatus(tr("Loading LiteLoader version list..."));
- auto job = new NetJob("Version index");
- // we do not care if the version is stale or not.
- auto liteloaderEntry = MMC->metacache()->resolveEntry("liteloader", "versions.json");
-
- // verify by poking the server.
- liteloaderEntry->stale = true;
-
- job->addNetAction(listDownload = CacheDownload::make(QUrl(URLConstants::LITELOADER_URL),
- liteloaderEntry));
-
- connect(listDownload.get(), SIGNAL(failed(int)), SLOT(listFailed()));
-
- listJob.reset(job);
- connect(listJob.get(), SIGNAL(succeeded()), SLOT(listDownloaded()));
- connect(listJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
- listJob->start();
-}
-
-void LLListLoadTask::listFailed()
-{
- emitFailed("Failed to load LiteLoader version list.");
- return;
-}
-
-void LLListLoadTask::listDownloaded()
-{
- QByteArray data;
- {
- auto dlJob = listDownload;
- auto filename = std::dynamic_pointer_cast<CacheDownload>(dlJob)->getTargetFilepath();
- QFile listFile(filename);
- if (!listFile.open(QIODevice::ReadOnly))
- {
- emitFailed("Failed to open the LiteLoader version list.");
- return;
- }
- data = listFile.readAll();
- listFile.close();
- dlJob.reset();
- }
-
- QJsonParseError jsonError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
-
- if (jsonError.error != QJsonParseError::NoError)
- {
- emitFailed("Error parsing version list JSON:" + jsonError.errorString());
- return;
- }
-
- if (!jsonDoc.isObject())
- {
- emitFailed("Error parsing version list JSON: jsonDoc is not an object");
- return;
- }
-
- const QJsonObject root = jsonDoc.object();
-
- // Now, get the array of versions.
- if (!root.value("versions").isObject())
- {
- emitFailed("Error parsing version list JSON: missing 'versions' object");
- return;
- }
-
- auto meta = root.value("meta").toObject();
- QString description = meta.value("description").toString(tr("This is a lightweight loader for mods that don't change game mechanics."));
- QString defaultUrl = meta.value("url").toString("http://dl.liteloader.com");
- QString authors = meta.value("authors").toString("Mumfrey");
- auto versions = root.value("versions").toObject();
-
- QList<BaseVersionPtr> tempList;
- for (auto vIt = versions.begin(); vIt != versions.end(); ++vIt)
- {
- const QString mcVersion = vIt.key();
- QString latest;
- const QJsonObject artefacts = vIt.value()
- .toObject()
- .value("artefacts")
- .toObject()
- .value("com.mumfrey:liteloader")
- .toObject();
- QList<BaseVersionPtr> perMcVersionList;
- for (auto aIt = artefacts.begin(); aIt != artefacts.end(); ++aIt)
- {
- const QString identifier = aIt.key();
- const QJsonObject artefact = aIt.value().toObject();
- if (identifier == "latest")
- {
- latest = artefact.value("version").toString();
- continue;
- }
- LiteLoaderVersionPtr version(new LiteLoaderVersion());
- version->version = artefact.value("version").toString();
- version->file = artefact.value("file").toString();
- version->mcVersion = mcVersion;
- version->md5 = artefact.value("md5").toString();
- version->timestamp = artefact.value("timestamp").toDouble();
- version->tweakClass = artefact.value("tweakClass").toString();
- version->authors = authors;
- version->description = description;
- version->defaultUrl = defaultUrl;
- const QJsonArray libs = artefact.value("libraries").toArray();
- for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt)
- {
- version->libraries.append((*lIt).toObject().value("name").toString());
- }
- perMcVersionList.append(version);
- }
- for (auto version : perMcVersionList)
- {
- auto v = std::dynamic_pointer_cast<LiteLoaderVersion>(version);
- v->isLatest = v->version == latest;
- }
- tempList.append(perMcVersionList);
- }
- m_list->updateListData(tempList);
-
- emitSucceeded();
-}
diff --git a/logic/lists/LiteLoaderVersionList.h b/logic/lists/LiteLoaderVersionList.h
deleted file mode 100644
index bfc913e5..00000000
--- a/logic/lists/LiteLoaderVersionList.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <QObject>
-
-#include <QString>
-#include <QStringList>
-#include "BaseVersionList.h"
-#include "logic/tasks/Task.h"
-#include "logic/BaseVersion.h"
-#include <logic/net/NetJob.h>
-
-class LLListLoadTask;
-class QNetworkReply;
-
-class LiteLoaderVersion : public BaseVersion
-{
-public:
- QString descriptor() override
- {
- if (isLatest)
- {
- return QObject::tr("Latest");
- }
- return QString();
- }
- QString typeString() const override
- {
- return mcVersion;
- }
- QString name() override
- {
- return version;
- }
-
- // important info
- QString version;
- QString file;
- QString mcVersion;
- QString md5;
- int timestamp;
- bool isLatest;
- QString tweakClass;
- QStringList libraries;
-
- // meta
- QString defaultUrl;
- QString description;
- QString authors;
-};
-typedef std::shared_ptr<LiteLoaderVersion> LiteLoaderVersionPtr;
-
-class LiteLoaderVersionList : public BaseVersionList
-{
- Q_OBJECT
-public:
- friend class LLListLoadTask;
-
- explicit LiteLoaderVersionList(QObject *parent = 0);
-
- virtual Task *getLoadTask();
- virtual bool isLoaded();
- virtual const BaseVersionPtr at(int i) const;
- virtual int count() const;
- virtual void sort();
-
- virtual BaseVersionPtr getLatestStable() const;
-
-protected:
- QList<BaseVersionPtr> m_vlist;
-
- bool m_loaded = false;
-
-protected
-slots:
- virtual void updateListData(QList<BaseVersionPtr> versions);
-};
-
-class LLListLoadTask : public Task
-{
- Q_OBJECT
-
-public:
- explicit LLListLoadTask(LiteLoaderVersionList *vlist);
- ~LLListLoadTask();
-
- virtual void executeTask();
-
-protected
-slots:
- void listDownloaded();
- void listFailed();
-
-protected:
- NetJobPtr listJob;
- CacheDownloadPtr listDownload;
- LiteLoaderVersionList *m_list;
-};
diff --git a/logic/lists/MinecraftVersionList.cpp b/logic/lists/MinecraftVersionList.cpp
index b9d60c61..ec2f2d21 100644
--- a/logic/lists/MinecraftVersionList.cpp
+++ b/logic/lists/MinecraftVersionList.cpp
@@ -212,6 +212,7 @@ void MCVListLoadTask::list_downloaded()
{
bool is_snapshot = false;
bool is_latest = false;
+ bool legacyLaunch = false;
// Load the version info.
if (!versions[i].isObject())
@@ -236,32 +237,28 @@ void MCVListLoadTask::list_downloaded()
// FIXME: log this somewhere
continue;
}
- // Parse the type.
- MinecraftVersion::VersionType versionType;
// OneSix or Legacy. use filter to determine type
if (versionTypeStr == "release")
{
- versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
- : MinecraftVersion::OneSix;
+ legacyLaunch = legacyWhitelist.contains(versionID);
is_latest = (versionID == latestReleaseID);
is_snapshot = false;
}
else if (versionTypeStr == "snapshot") // It's a snapshot... yay
{
- versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
- : MinecraftVersion::OneSix;
+ legacyLaunch = legacyWhitelist.contains(versionID);
is_latest = (versionID == latestSnapshotID);
is_snapshot = true;
}
else if (versionTypeStr == "old_alpha")
{
- versionType = MinecraftVersion::Nostalgia;
+ legacyLaunch = false;
is_latest = false;
is_snapshot = false;
}
else if (versionTypeStr == "old_beta")
{
- versionType = MinecraftVersion::Legacy;
+ legacyLaunch = true;
is_latest = false;
is_snapshot = false;
}
@@ -280,7 +277,8 @@ void MCVListLoadTask::list_downloaded()
mcVersion->download_url = dlUrl;
mcVersion->is_latest = is_latest;
mcVersion->is_snapshot = is_snapshot;
- mcVersion->type = versionType;
+ if(legacyLaunch)
+ mcVersion->features.insert("legacy");
tempList.append(mcVersion);
}
m_list->updateListData(tempList);