From 7721c57e5e1093a3d8597b6b6f30c97d2aa3d8a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 11 Sep 2013 23:43:17 +0200 Subject: Split OneSixVersion into parts. --- logic/OneSixVersion.h | 153 ++------------------------------------------------ 1 file changed, 4 insertions(+), 149 deletions(-) (limited to 'logic/OneSixVersion.h') diff --git a/logic/OneSixVersion.h b/logic/OneSixVersion.h index 89b7c911..8f01f82d 100644 --- a/logic/OneSixVersion.h +++ b/logic/OneSixVersion.h @@ -1,151 +1,6 @@ #pragma once #include - -class Library; - -enum OpSys -{ - Os_Windows, - Os_Linux, - Os_OSX, - Os_Other -}; - -OpSys OpSys_fromString(QString); - -#ifdef Q_OS_WIN32 - #define currentSystem Os_Windows -#else - #ifdef Q_OS_MAC - #define currentSystem Os_OSX - #else - #define currentSystem Os_Linux - #endif -#endif -enum RuleAction -{ - Allow, - Disallow, - Defer -}; - -RuleAction RuleAction_fromString(QString); - -class Rule -{ -protected: - RuleAction m_result; - virtual bool applies(Library * parent) = 0; -public: - Rule(RuleAction result) - :m_result(result) {} - virtual ~Rule(){}; - RuleAction apply(Library * parent) - { - if(applies(parent)) - return m_result; - else - return Defer; - }; -}; - -class OsRule : public Rule -{ -private: - // the OS - OpSys m_system; - // the OS version regexp - QString m_version_regexp; -protected: - virtual bool applies ( Library* ) - { - return (m_system == currentSystem); - } - OsRule(RuleAction result, OpSys system, QString version_regexp) - : Rule(result), m_system(system), m_version_regexp(version_regexp) {} -public: - static QSharedPointer create(RuleAction result, OpSys system, QString version_regexp) - { - return QSharedPointer (new OsRule(result, system, version_regexp)); - } -}; - -class ImplicitRule : public Rule -{ -protected: - virtual bool applies ( Library* ) - { - return true; - } - ImplicitRule(RuleAction result) - : Rule(result) {} -public: - static QSharedPointer create(RuleAction result) - { - return QSharedPointer (new ImplicitRule(result)); - } -}; - -class Library -{ -private: - // basic values used internally (so far) - QString m_name; - QString m_base_url; - QList > m_rules; - - // derived values used for real things - /// where to store the lib locally - QString m_storage_path; - /// where to download the lib from - QString m_download_path; - /// is this lib actually active on the current OS? - bool m_is_active; - /// is the library a native? - bool m_is_native; - /// native suffixes per OS - QMap m_native_suffixes; -public: - QStringList extract_excludes; - -public: - /// Constructor - Library(QString name) - { - m_is_native = false; - m_is_native = false; - m_name = name; - m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/"; - } - - /** - * finalize the library, processing the input values into derived values and state - * - * This SHALL be called after all the values are parsed or after any further change. - */ - void finalize(); - - /// Set the library composite name - void setName(QString name); - /// Set the url base for downloads - void setBaseUrl(QString base_url); - /// Call this to mark the library as 'native' (it's a zip archive with DLLs) - void setIsNative(); - /// Attach a name suffix to the specified OS native - void addNative(OpSys os, QString suffix); - /// Set the load rules - void setRules(QList > rules); - - /// Returns true if the library should be loaded (or extracted, in case of natives) - bool isActive(); - /// Returns true if the library is native - bool isNative(); - /// Get the URL to download the library from - QString downloadPath(); - /// Get the relative path where the library should be saved - QString storagePath(); -}; - +class OneSixLibrary; class OneSixVersion { @@ -180,7 +35,7 @@ public: QString mainClass; /// the list of libs - both active and inactive, native and java - QList > libraries; + QList > libraries; /* FIXME: add support for those rules here? Looks like a pile of quick hacks to me though. @@ -208,6 +63,6 @@ public: minimumLauncherVersion = 0xDEADBEEF; } - QList > getActiveNormalLibs(); - QList > getActiveNativeLibs(); + QList > getActiveNormalLibs(); + QList > getActiveNativeLibs(); }; \ No newline at end of file -- cgit v1.2.3 From d38b90530b3ba3a49c4eb072eb344ae2b0836913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 16 Sep 2013 00:54:39 +0200 Subject: Forge version list implementation. Needs integration and testing. --- logic/OneSixVersion.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'logic/OneSixVersion.h') diff --git a/logic/OneSixVersion.h b/logic/OneSixVersion.h index 8f01f82d..6a6a5b4b 100644 --- a/logic/OneSixVersion.h +++ b/logic/OneSixVersion.h @@ -2,8 +2,14 @@ #include class OneSixLibrary; -class OneSixVersion +class OneSixVersion : public QAbstractListModel { +public: + virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; + virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const; + virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; + virtual int columnCount ( const QModelIndex& parent ) const; + virtual Qt::ItemFlags flags(const QModelIndex& index) const; public: /// the ID - determines which jar to use! ACTUALLY IMPORTANT! QString id; @@ -58,6 +64,7 @@ public: // QList rules; public: + OneSixVersion() { minimumLauncherVersion = 0xDEADBEEF; @@ -65,4 +72,4 @@ public: QList > getActiveNormalLibs(); QList > getActiveNativeLibs(); -}; \ No newline at end of file +}; -- cgit v1.2.3