From d4eacb56b30baaef801f42545398a4f29755fadf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 7 Mar 2016 02:01:28 +0100 Subject: NOISSUE make new Mojang version format pass through MultiMC structures Not yet used effectively, but it is read and written properly --- logic/minecraft/MojangDownloadInfo.h | 92 ++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 logic/minecraft/MojangDownloadInfo.h (limited to 'logic/minecraft/MojangDownloadInfo.h') 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 +#include + +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 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 classifiers; +}; + +typedef std::shared_ptr 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 MojangAssetIndexInfoPtr; -- cgit v1.2.3