summaryrefslogtreecommitdiffstats
path: root/logic/lists
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-01-20 01:32:38 +0100
committerPetr Mrázek <peterix@gmail.com>2014-01-20 01:32:38 +0100
commit222d3c0dc5a8b8a9e93b9368e964cda7becc7f02 (patch)
tree9ab4538f2e80847874a7c9a5c7c2dbc099cb8cae /logic/lists
parent48b587e7b6b96b5c3ac17dc8b67a7b0ab9c2c4f0 (diff)
parent3a3c9ac9515447941d383f2c4fe4b0225fdd8252 (diff)
downloadMultiMC-222d3c0dc5a8b8a9e93b9368e964cda7becc7f02.tar
MultiMC-222d3c0dc5a8b8a9e93b9368e964cda7becc7f02.tar.gz
MultiMC-222d3c0dc5a8b8a9e93b9368e964cda7becc7f02.tar.lz
MultiMC-222d3c0dc5a8b8a9e93b9368e964cda7becc7f02.tar.xz
MultiMC-222d3c0dc5a8b8a9e93b9368e964cda7becc7f02.zip
Merge branch 'release-0.2'0.2
Diffstat (limited to 'logic/lists')
-rw-r--r--logic/lists/ForgeVersionList.cpp12
-rw-r--r--logic/lists/ForgeVersionList.h21
-rw-r--r--logic/lists/InstanceList.cpp73
3 files changed, 61 insertions, 45 deletions
diff --git a/logic/lists/ForgeVersionList.cpp b/logic/lists/ForgeVersionList.cpp
index 56eca744..4902dc64 100644
--- a/logic/lists/ForgeVersionList.cpp
+++ b/logic/lists/ForgeVersionList.cpp
@@ -187,7 +187,7 @@ bool ForgeListLoadTask::parseForgeList(QList<BaseVersionPtr> &out)
QByteArray data;
{
auto dlJob = listDownload;
- auto filename = std::dynamic_pointer_cast<CacheDownload>(dlJob)->m_target_path;
+ auto filename = std::dynamic_pointer_cast<CacheDownload>(dlJob)->getTargetFilepath();
QFile listFile(filename);
if (!listFile.open(QIODevice::ReadOnly))
{
@@ -303,7 +303,7 @@ bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
QByteArray data;
{
auto dlJob = gradleListDownload;
- auto filename = std::dynamic_pointer_cast<CacheDownload>(dlJob)->m_target_path;
+ auto filename = std::dynamic_pointer_cast<CacheDownload>(dlJob)->getTargetFilepath();
QFile listFile(filename);
if (!listFile.open(QIODevice::ReadOnly))
{
@@ -404,12 +404,8 @@ void ForgeListLoadTask::listDownloaded()
{
return;
}
-
- qSort(list.begin(), list.end(), [](const BaseVersionPtr & p1, const BaseVersionPtr & p2)
- {
- // TODO better comparison (takes major/minor/build number into account)
- return p1->name() > p2->name();
- });
+ std::sort(list.begin(), list.end(), [](const BaseVersionPtr & l, const BaseVersionPtr & r)
+ { return (*l > *r); });
m_list->updateListData(list);
diff --git a/logic/lists/ForgeVersionList.h b/logic/lists/ForgeVersionList.h
index 924084ae..b19d3f56 100644
--- a/logic/lists/ForgeVersionList.h
+++ b/logic/lists/ForgeVersionList.h
@@ -29,25 +29,38 @@ typedef std::shared_ptr<ForgeVersion> ForgeVersionPtr;
struct ForgeVersion : public BaseVersion
{
- virtual QString descriptor()
+ virtual QString descriptor() override
{
return filename;
}
;
- virtual QString name()
+ virtual QString name() override
{
return "Forge " + jobbuildver;
}
;
- virtual QString typeString() const
+ 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;
diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp
index bfd183d9..0d4eab95 100644
--- a/logic/lists/InstanceList.cpp
+++ b/logic/lists/InstanceList.cpp
@@ -308,45 +308,52 @@ void InstanceList::loadForgeInstances(QMap<QString, QString> groupMap)
return;
}
dir.cd("ModPacks");
- auto fpath = dir.absoluteFilePath("modpacks.xml");
- QFile f(fpath);
- QLOG_INFO() << "Discovering FTB instances -- " << fpath;
- if (!f.open(QFile::ReadOnly))
- return;
-
- // read the FTB packs XML.
- QXmlStreamReader reader(&f);
- while (!reader.atEnd())
+ auto allFiles = dir.entryList(QDir::Readable | QDir::Files, QDir::Name);
+ for(auto filename: allFiles)
{
- switch (reader.readNext())
- {
- case QXmlStreamReader::StartElement:
+ if(!filename.endsWith(".xml"))
+ continue;
+ auto fpath = dir.absoluteFilePath(filename);
+ QFile f(fpath);
+ QLOG_INFO() << "Discovering FTB instances -- " << fpath;
+ if (!f.open(QFile::ReadOnly))
+ continue;
+
+ // read the FTB packs XML.
+ QXmlStreamReader reader(&f);
+ while (!reader.atEnd())
{
- if (reader.name() == "modpack")
+ switch (reader.readNext())
{
- QXmlStreamAttributes attrs = reader.attributes();
- FTBRecord record;
- record.dir = attrs.value("dir").toString();
- QDir test(dataDir.absoluteFilePath(record.dir));
- if(!test.exists())
- continue;
- record.name = attrs.value("name").toString();
- record.logo = attrs.value("logo").toString();
- record.mcVersion = attrs.value("mcVersion").toString();
- record.description = attrs.value("description").toString();
- records.append(record);
+ case QXmlStreamReader::StartElement:
+ {
+ if (reader.name() == "modpack")
+ {
+ QXmlStreamAttributes attrs = reader.attributes();
+ FTBRecord record;
+ record.dir = attrs.value("dir").toString();
+ QDir test(dataDir.absoluteFilePath(record.dir));
+ if(!test.exists())
+ continue;
+ record.name = attrs.value("name").toString();
+ record.logo = attrs.value("logo").toString();
+ record.mcVersion = attrs.value("mcVersion").toString();
+ record.description = attrs.value("description").toString();
+ records.append(record);
+ }
+ break;
+ }
+ case QXmlStreamReader::EndElement:
+ break;
+ case QXmlStreamReader::Characters:
+ break;
+ default:
+ break;
}
- break;
- }
- case QXmlStreamReader::EndElement:
- break;
- case QXmlStreamReader::Characters:
- break;
- default:
- break;
}
+ f.close();
}
- f.close();
+
if(!records.size())
{
QLOG_INFO() << "No FTB instances to load.";