diff options
Diffstat (limited to 'logic/minecraft')
-rw-r--r-- | logic/minecraft/MinecraftVersion.cpp | 16 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersion.h | 3 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersionList.cpp | 28 |
3 files changed, 40 insertions, 7 deletions
diff --git a/logic/minecraft/MinecraftVersion.cpp b/logic/minecraft/MinecraftVersion.cpp index e0cbce8d..b66b9768 100644 --- a/logic/minecraft/MinecraftVersion.cpp +++ b/logic/minecraft/MinecraftVersion.cpp @@ -20,14 +20,26 @@ QString MinecraftVersion::name() QString MinecraftVersion::typeString() const { - if (is_snapshot) + if(m_type == "snapshot") { return QObject::tr("Snapshot"); } - else + else if (m_type == "release") { return QObject::tr("Regular release"); } + else if (m_type == "old_alpha") + { + return QObject::tr("Alpha"); + } + else if (m_type == "old_beta") + { + return QObject::tr("Beta"); + } + else + { + return QString(); + } } bool MinecraftVersion::hasJarMods() diff --git a/logic/minecraft/MinecraftVersion.h b/logic/minecraft/MinecraftVersion.h index 02afd709..422b4cea 100644 --- a/logic/minecraft/MinecraftVersion.h +++ b/logic/minecraft/MinecraftVersion.h @@ -61,9 +61,6 @@ public: /* data */ /// The URL that this version will be downloaded from. maybe. QString download_url; - /// is this a snapshot? - bool is_snapshot = false; - VersionSource m_versionSource = Builtin; /// the human readable version name diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp index 26a17c73..e012330e 100644 --- a/logic/minecraft/MinecraftVersionList.cpp +++ b/logic/minecraft/MinecraftVersionList.cpp @@ -154,6 +154,7 @@ void MinecraftVersionList::loadBuiltinList() "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + versionID + "/"; mcVersion->m_versionSource = Builtin; + mcVersion->m_type = versionTypeStr; mcVersion->m_appletClass = versionObj.value("appletClass").toString(""); mcVersion->m_mainClass = versionObj.value("mainClass").toString(""); mcVersion->m_processArguments = versionObj.value("processArguments").toString("legacy"); @@ -293,10 +294,13 @@ void MinecraftVersionList::loadMojangList(QByteArray data, VersionSource source) continue; } mcVersion->m_type = versionTypeStr; - mcVersion->is_snapshot = is_snapshot; tempList.append(mcVersion); } updateListData(tempList); + if(source == Remote) + { + m_loaded = true; + } } void MinecraftVersionList::sort() @@ -322,6 +326,7 @@ void MinecraftVersionList::updateListData(QList<BaseVersionPtr> versions) if (!m_lookup.contains(descr)) { + m_lookup[version->descriptor()] = version; m_vlist.append(version); continue; } @@ -343,7 +348,6 @@ void MinecraftVersionList::updateListData(QList<BaseVersionPtr> versions) // alright, it's an update. put it inside the original, for further processing. orig->upstreamUpdate = added; } - m_loaded = true; sortInternal(); endResetModel(); } @@ -528,6 +532,26 @@ void MinecraftVersionList::saveCachedList() entriesArr.append(entryObj); } toplevel.insert("versions", entriesArr); + + { + bool someLatest = false; + QJsonObject latestObj; + if(!m_latestReleaseID.isNull()) + { + latestObj.insert("release", m_latestReleaseID); + someLatest = true; + } + if(!m_latestSnapshotID.isNull()) + { + latestObj.insert("snapshot", m_latestSnapshotID); + someLatest = true; + } + if(someLatest) + { + toplevel.insert("latest", latestObj); + } + } + QJsonDocument doc(toplevel); QByteArray jsonData = doc.toJson(); qint64 result = tfile.write(jsonData); |