diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-03-07 02:01:28 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-03-07 02:03:36 +0100 |
commit | d4eacb56b30baaef801f42545398a4f29755fadf (patch) | |
tree | 0a185b0841f12c5af431cdedeb8695691ac0bce9 /logic/minecraft/MojangDownloadInfo.h | |
parent | 3d8728f52f220845fc4079d34b97458a122ac031 (diff) | |
download | MultiMC-d4eacb56b30baaef801f42545398a4f29755fadf.tar MultiMC-d4eacb56b30baaef801f42545398a4f29755fadf.tar.gz MultiMC-d4eacb56b30baaef801f42545398a4f29755fadf.tar.lz MultiMC-d4eacb56b30baaef801f42545398a4f29755fadf.tar.xz MultiMC-d4eacb56b30baaef801f42545398a4f29755fadf.zip |
NOISSUE make new Mojang version format pass through MultiMC structures
Not yet used effectively, but it is read and written properly
Diffstat (limited to 'logic/minecraft/MojangDownloadInfo.h')
-rw-r--r-- | logic/minecraft/MojangDownloadInfo.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/logic/minecraft/MojangDownloadInfo.h b/logic/minecraft/MojangDownloadInfo.h new file mode 100644 index 00000000..780318b8 --- /dev/null +++ b/logic/minecraft/MojangDownloadInfo.h @@ -0,0 +1,92 @@ +#pragma once +#include <QString> +#include <memory> + +class MojangDownloadInfo +{ + friend class MojangVersionFormat; +public: + QString getUrl() + { + return m_url; + } + + QString getSha1() + { + return m_sha1; + } + + int getSize() + { + return m_size; + } + +protected: + /// Local filesystem path. WARNING: not used, only here so we can pass through mojang files unmolested! + QString m_path; + /// absolute URL of this file + QString m_url; + /// sha-1 checksum of the file + QString m_sha1; + /// size of the file in bytes + int m_size; +}; + +typedef std::shared_ptr<MojangDownloadInfo> MojangDownloadInfoPtr; + +class MojangLibraryDownloadInfo +{ + friend class MojangVersionFormat; +public: + MojangDownloadInfo *getDownloadInfo(QString classifier) + { + if (classifier.isNull()) + { + return artifact.get(); + } + + return classifiers[classifier].get(); + } +private: + MojangDownloadInfoPtr artifact; + QMap<QString, MojangDownloadInfoPtr> classifiers; +}; + +typedef std::shared_ptr<MojangLibraryDownloadInfo> MojangLibraryDownloadInfoPtr; + +class MojangAssetIndexInfo : public MojangDownloadInfo +{ + friend class MojangVersionFormat; +public: + MojangAssetIndexInfo() + { + } + + MojangAssetIndexInfo(QString id) + { + m_id = id; + m_url = "https://s3.amazonaws.com/Minecraft.Download/indexes/" + id + ".json"; + m_known = false; + } + + int getTotalSize() + { + return m_totalSize; + } + + QString getId() + { + return m_id; + } + + bool sizeAndHashKnown() + { + return m_known; + } + +protected: + int m_totalSize; + QString m_id; + bool m_known = true; +}; +typedef std::shared_ptr<MojangAssetIndexInfo> MojangAssetIndexInfoPtr; |