From 27b1de0d6d196d9d0f6c284e0cb772c077688c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 23 Jun 2013 22:10:32 +0200 Subject: Implement some bits and pieces, disable dead buttons. --- libmultimc/include/instversion.h | 13 ------ libmultimc/include/minecraftversion.h | 40 ++++++++---------- libmultimc/src/gameupdatetask.cpp | 3 +- libmultimc/src/instversion.cpp | 6 --- libmultimc/src/minecraftversion.cpp | 73 ++++++--------------------------- libmultimc/src/minecraftversionlist.cpp | 14 +++++-- 6 files changed, 42 insertions(+), 107 deletions(-) (limited to 'libmultimc') diff --git a/libmultimc/include/instversion.h b/libmultimc/include/instversion.h index 009bd412..af632939 100644 --- a/libmultimc/include/instversion.h +++ b/libmultimc/include/instversion.h @@ -49,18 +49,6 @@ class LIBMULTIMC_EXPORT InstVersion : public QObject */ Q_PROPERTY(QString typeName READ typeName) - /*! - * Whether or not this is a meta version. - * Meta versions are not real versions, merely versions that act as aliases - * for other versions. - * For example: There could be a meta version called "Latest" that always - * points to the latest version. The user would pick this version and when - * a new version came out, it would point to the new one and update the instance - * automatically. - */ - Q_PROPERTY(bool isMeta READ isMeta) - - /*! * Gets the version's timestamp. * This is primarily used for sorting versions in a list. @@ -93,7 +81,6 @@ public: virtual QString name() const; virtual QString typeName() const = 0; virtual qint64 timestamp() const; - virtual bool isMeta() const; virtual InstVersionList *versionList() const; diff --git a/libmultimc/include/minecraftversion.h b/libmultimc/include/minecraftversion.h index fd11b316..6f9b7879 100644 --- a/libmultimc/include/minecraftversion.h +++ b/libmultimc/include/minecraftversion.h @@ -29,6 +29,11 @@ class LIBMULTIMC_EXPORT MinecraftVersion : public InstVersion */ Q_PROPERTY(VersionType versionType READ versionType WRITE setVersionType) + /*! + * This version's launcher. Used to identify the launcher version this is intended for. + */ + Q_PROPERTY(LauncherVersion versionType READ launcherVersion WRITE setLauncherVersion) + /*! * The URL that this version will be downloaded from. */ @@ -39,10 +44,6 @@ class LIBMULTIMC_EXPORT MinecraftVersion : public InstVersion */ Q_PROPERTY(QString etag READ etag) - /*! - * True if this is a version from the new Minecraft launcher's version list. - */ - Q_PROPERTY(bool isForNewLauncher READ isForNewLauncher WRITE setIsForNewLauncher) public: explicit MinecraftVersion(QString descriptor, @@ -52,15 +53,6 @@ public: QString etag, InstVersionList *parent = 0); - /*! - * Creates a meta version that links to the given version. - * This is *NOT* a copy constructor. - * \param linkedVersion the version that the meta version will link to. - */ - explicit MinecraftVersion(const MinecraftVersion *linkedVersion); - - MinecraftVersion(const MinecraftVersion &other, QObject *parent); - static InstVersion *mcnVersion(QString rawName, QString niceName); enum VersionType @@ -69,10 +61,14 @@ public: Stable, CurrentStable, Snapshot, - MCNostalgia, - MetaCustom, - MetaLatestSnapshot, - MetaLatestStable + MCNostalgia + }; + + enum LauncherVersion + { + Unknown = -1, + Legacy = 0, // the legacy launcher that's been around since ... forever + Launcher16 = 1, // current launcher as of 26/06/2013 }; virtual QString descriptor() const; @@ -80,24 +76,22 @@ public: virtual QString typeName() const; virtual qint64 timestamp() const; - virtual bool isForNewLauncher() const; - virtual void setIsForNewLauncher(bool val); - virtual VersionType versionType() const; virtual void setVersionType(VersionType typeName); + virtual LauncherVersion launcherVersion() const; + virtual void setLauncherVersion(LauncherVersion launcherVersion); + virtual QString downloadURL() const; virtual QString etag() const; - virtual bool isMeta() const; virtual InstVersion *copyVersion(InstVersionList *newParent) const; private: - InstVersion *m_linkedVersion; - QString m_dlUrl; QString m_etag; VersionType m_type; + LauncherVersion m_launcherVersion; bool m_isNewLauncherVersion; }; diff --git a/libmultimc/src/gameupdatetask.cpp b/libmultimc/src/gameupdatetask.cpp index 114f4ede..c718ce71 100644 --- a/libmultimc/src/gameupdatetask.cpp +++ b/libmultimc/src/gameupdatetask.cpp @@ -73,7 +73,8 @@ void GameUpdateTask::executeTask() // we're downloading from. QString jarFilename = "minecraft"; - if (targetVersion->isForNewLauncher()) + // FIXME: this is NOT enough + if (targetVersion->launcherVersion() == MinecraftVersion::Launcher16) jarFilename = targetVersion->descriptor(); QUrl mcJarURL = targetVersion->downloadURL() + jarFilename + ".jar"; diff --git a/libmultimc/src/instversion.cpp b/libmultimc/src/instversion.cpp index ebd76c7a..4e42c364 100644 --- a/libmultimc/src/instversion.cpp +++ b/libmultimc/src/instversion.cpp @@ -51,12 +51,6 @@ bool InstVersion::isGreaterThan(const InstVersion &other) const return timestamp() > other.timestamp(); } -bool InstVersion::isMeta() const -{ - return false; -} - - QString InstVersion::descriptor() const { return m_descriptor; diff --git a/libmultimc/src/minecraftversion.cpp b/libmultimc/src/minecraftversion.cpp index 7dee802f..36ba87f8 100644 --- a/libmultimc/src/minecraftversion.cpp +++ b/libmultimc/src/minecraftversion.cpp @@ -23,29 +23,9 @@ MinecraftVersion::MinecraftVersion(QString descriptor, InstVersionList *parent) : InstVersion(descriptor, name, timestamp, parent), m_dlUrl(dlUrl), m_etag(etag) { - m_linkedVersion = NULL; m_isNewLauncherVersion = false; } -MinecraftVersion::MinecraftVersion(const MinecraftVersion *linkedVersion) : - InstVersion(linkedVersion->descriptor(), linkedVersion->name(), linkedVersion->timestamp(), - linkedVersion->versionList()) -{ - m_linkedVersion = (MinecraftVersion *)linkedVersion; -} - -MinecraftVersion::MinecraftVersion(const MinecraftVersion &other, QObject *parent) : - InstVersion(other, parent) -{ - if (other.m_linkedVersion) - m_linkedVersion = other.m_linkedVersion; - else - { - m_dlUrl = other.downloadURL(); - m_etag = other.etag(); - } -} - QString MinecraftVersion::descriptor() const { return m_descriptor; @@ -58,9 +38,6 @@ QString MinecraftVersion::name() const QString MinecraftVersion::typeName() const { - if (m_linkedVersion) - return m_linkedVersion->typeName(); - switch (versionType()) { case OldSnapshot: @@ -78,17 +55,6 @@ QString MinecraftVersion::typeName() const case MCNostalgia: return "MCNostalgia"; - case MetaCustom: - // Not really sure what this does, but it was in the code for v4, - // so it must be important... Right? - return "Custom Meta Version"; - - case MetaLatestSnapshot: - return "Latest Snapshot"; - - case MetaLatestStable: - return "Latest Stable"; - default: return QString("Unknown Type %1").arg(versionType()); } @@ -99,16 +65,6 @@ qint64 MinecraftVersion::timestamp() const return m_timestamp; } -bool MinecraftVersion::isForNewLauncher() const -{ - return m_isNewLauncherVersion; -} - -void MinecraftVersion::setIsForNewLauncher(bool val) -{ - m_isNewLauncherVersion = val; -} - MinecraftVersion::VersionType MinecraftVersion::versionType() const { return m_type; @@ -129,26 +85,21 @@ QString MinecraftVersion::etag() const return m_etag; } -bool MinecraftVersion::isMeta() const +MinecraftVersion::LauncherVersion MinecraftVersion::launcherVersion() const { - return versionType() == MetaCustom || - versionType() == MetaLatestSnapshot || - versionType() == MetaLatestStable; + return m_launcherVersion; +}; + +void MinecraftVersion::setLauncherVersion(LauncherVersion launcherVersion) +{ + m_launcherVersion = launcherVersion; } InstVersion *MinecraftVersion::copyVersion(InstVersionList *newParent) const { - if (isMeta()) - { - MinecraftVersion *version = new MinecraftVersion((MinecraftVersion *)m_linkedVersion); - return version; - } - else - { - MinecraftVersion *version = new MinecraftVersion( - descriptor(), name(), timestamp(), downloadURL(), etag(), newParent); - version->setVersionType(versionType()); - version->setIsForNewLauncher(isForNewLauncher()); - return version; - } + MinecraftVersion *version = new MinecraftVersion( + descriptor(), name(), timestamp(), downloadURL(), etag(), newParent); + version->setVersionType(versionType()); + version->setLauncherVersion(launcherVersion()); + return version; } diff --git a/libmultimc/src/minecraftversionlist.cpp b/libmultimc/src/minecraftversionlist.cpp index 71deb471..17737b1e 100644 --- a/libmultimc/src/minecraftversionlist.cpp +++ b/libmultimc/src/minecraftversionlist.cpp @@ -200,6 +200,7 @@ void MCVListLoadTask::setSubStatus(const QString msg) setStatus("Loading instance version list: " + msg); } +// FIXME: we should have a local cache of the version list and a local cache of version data bool MCVListLoadTask::loadFromVList() { QNetworkReply *vlistReply = netMgr->get(QNetworkRequest(QUrl(QString(MCVLIST_URLBASE) + @@ -276,10 +277,15 @@ bool MCVListLoadTask::loadFromVList() else versionType = MinecraftVersion::Stable; } - else + else if(versionTypeStr == "snapshot") { versionType = MinecraftVersion::Snapshot; } + else + { + // we don't know what to do with this... + continue; + } // Get the download URL. QString dlUrl = QString(MCVLIST_URLBASE) + versionID + "/"; @@ -289,7 +295,7 @@ bool MCVListLoadTask::loadFromVList() MinecraftVersion *mcVersion = new MinecraftVersion( versionID, versionID, versionTime.toMSecsSinceEpoch(), dlUrl, ""); - mcVersion->setIsForNewLauncher(true); + mcVersion->setLauncherVersion(MinecraftVersion::Launcher16); mcVersion->setVersionType(versionType); tempList.append(mcVersion); } @@ -340,7 +346,7 @@ bool MCVListLoadTask::loadFromAssets() QDomNodeList contents = doc.elementsByTagName("Contents"); QRegExp mcRegex("/minecraft.jar$"); - QRegExp snapshotRegex("[0-9][0-9]w[0-9][0-9][a-z]|pre|rc"); + QRegExp snapshotRegex("[0-9][0-9]w[0-9][0-9][a-z]?|pre|rc"); for (int i = 0; i < contents.length(); i++) { @@ -443,6 +449,8 @@ bool MCVListLoadTask::loadMCNostalgia() { QNetworkReply *mcnReply = netMgr->get(QNetworkRequest(QUrl(QString(MCN_URLBASE) + "?pversion=1&list=True"))); NetUtils::waitForNetRequest(mcnReply); + processedMCNReply = true; + updateStuff(); return true; } -- cgit v1.2.3