summaryrefslogtreecommitdiffstats
path: root/libmultimc/include
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-07-28 08:40:15 +0200
committerPetr Mrázek <peterix@gmail.com>2013-07-28 08:40:15 +0200
commit9d99b539bfaabe45a43948edf37e900401288f65 (patch)
treeb583a7649dfa59597f352a41ed641b373f130436 /libmultimc/include
parenta7a84d4dbb58565f108cb0886da6cb786e34d10d (diff)
downloadMultiMC-9d99b539bfaabe45a43948edf37e900401288f65.tar
MultiMC-9d99b539bfaabe45a43948edf37e900401288f65.tar.gz
MultiMC-9d99b539bfaabe45a43948edf37e900401288f65.tar.lz
MultiMC-9d99b539bfaabe45a43948edf37e900401288f65.tar.xz
MultiMC-9d99b539bfaabe45a43948edf37e900401288f65.zip
Parsing the version files, part IV
Also, start of big refactors.
Diffstat (limited to 'libmultimc/include')
-rw-r--r--libmultimc/include/fullversion.h73
-rw-r--r--libmultimc/include/instance.h1
-rw-r--r--libmultimc/include/instancelist.h6
-rw-r--r--libmultimc/include/instanceloader.h32
-rw-r--r--libmultimc/include/instancetypeinterface.h94
-rw-r--r--libmultimc/include/library.h81
6 files changed, 95 insertions, 192 deletions
diff --git a/libmultimc/include/fullversion.h b/libmultimc/include/fullversion.h
index 523ac87c..8547960f 100644
--- a/libmultimc/include/fullversion.h
+++ b/libmultimc/include/fullversion.h
@@ -6,64 +6,71 @@ class Library;
class FullVersion
{
public:
- FullVersion()
- {
- minimumLauncherVersion = 0xDEADBEEF;
- isLegacy = false;
- }
- // the ID - determines which jar to use! ACTUALLY IMPORTANT!
+ /// the ID - determines which jar to use! ACTUALLY IMPORTANT!
QString id;
- // do we actually care about parsing this?
+ /// Last updated time - as a string
QString time;
- // I don't think we do.
+ /// Release time - as a string
QString releaseTime;
- // eh, not caring - "release" or "snapshot"
+ /// Release type - "release" or "snapshot"
QString type;
- /*
+ /**
* DEPRECATED: Old versions of the new vanilla launcher used this
* ex: "username_session_version"
*/
QString processArguments;
- /*
+ /**
* arguments that should be used for launching minecraft
*
* ex: "--username ${auth_player_name} --session ${auth_session}
* --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}"
*/
QString minecraftArguments;
- /*
+ /**
* the minimum launcher version required by this version ... current is 4 (at point of writing)
*/
int minimumLauncherVersion;
- /*
+ /**
* The main class to load first
*/
QString mainClass;
- // the list of libs. just the names for now. expand to full-blown strutures!
+ /// the list of libs - both active and inactive, native and java
QList<QSharedPointer<Library> > libraries;
- // is this actually a legacy version? if so, none of the other stuff here will be ever used.
- // added by FullVersionFactory
+ /**
+ * is this actually a legacy version? if so, none of the other stuff here will be ever used.
+ * added by FullVersionFactory
+ */
bool isLegacy;
-/*
-FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
+ /*
+ FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
- "rules": [
- {
- "action": "allow"
- },
- {
- "action": "disallow",
- "os": {
- "name": "osx",
- "version": "^10\\.5\\.\\d$"
- }
- }
- ],
- "incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX 10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!"
-}
-*/
+ "rules": [
+ {
+ "action": "allow"
+ },
+ {
+ "action": "disallow",
+ "os": {
+ "name": "osx",
+ "version": "^10\\.5\\.\\d$"
+ }
+ }
+ ],
+ "incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX 10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!"
+ }
+ */
// QList<Rule> rules;
+
+public:
+ FullVersion()
+ {
+ minimumLauncherVersion = 0xDEADBEEF;
+ isLegacy = false;
+ }
+
+ QList<QSharedPointer<Library> > getActiveNormalLibs();
+ QList<QSharedPointer<Library> > getActiveNativeLibs();
}; \ No newline at end of file
diff --git a/libmultimc/include/instance.h b/libmultimc/include/instance.h
index f6857cd8..36db7ffb 100644
--- a/libmultimc/include/instance.h
+++ b/libmultimc/include/instance.h
@@ -22,7 +22,6 @@
#include <settingsobject.h>
#include "inifile.h"
-#include "instancetypeinterface.h"
#include "instversionlist.h"
#include "libmmc_config.h"
diff --git a/libmultimc/include/instancelist.h b/libmultimc/include/instancelist.h
index a0d8788a..bd8d0627 100644
--- a/libmultimc/include/instancelist.h
+++ b/libmultimc/include/instancelist.h
@@ -27,6 +27,12 @@ class Instance;
class LIBMULTIMC_EXPORT InstanceList : public QObject
{
Q_OBJECT
+private:
+ /*!
+ * \brief Get the instance groups
+ */
+ void loadGroupList(QMap<QString, QString> & groupList);
+
public:
explicit InstanceList(const QString &instDir, QObject *parent = 0);
diff --git a/libmultimc/include/instanceloader.h b/libmultimc/include/instanceloader.h
index fd6d04d6..af5bf92d 100644
--- a/libmultimc/include/instanceloader.h
+++ b/libmultimc/include/instanceloader.h
@@ -36,22 +36,18 @@ public:
*/
static InstanceLoader &get() { return loader; }
- /*!
- * \brief Error codes returned by functions in the InstanceLoader and InstanceType classes.
- *
- * - NoError indicates that no error occurred.
- * - OtherError indicates that an unspecified error occurred.
- * - InstExists is returned by createInstance() if the given instance directory is already an instance.
- * - NotAnInstance is returned by loadInstance() if the given instance directory is not a valid instance.
- * - CantCreateDir is returned by createInstance( if the given instance directory can't be created.)
- */
- enum InstLoaderError
+ enum InstLoadError
+ {
+ NoLoadError = 0,
+ UnknownLoadError,
+ NotAnInstance
+ };
+
+ enum InstCreateError
{
- NoError = 0,
- OtherError,
-
+ NoCreateError = 0,
+ UnknownCreateError,
InstExists,
- NotAnInstance,
CantCreateDir
};
@@ -61,21 +57,21 @@ public:
* \param inst Pointer to store the created instance in.
* \param type The type of instance to create.
* \param instDir The instance's directory.
- * \return An InstLoaderError error code.
+ * \return An InstCreateError error code.
* - InstExists if the given instance directory is already an instance.
* - CantCreateDir if the given instance directory cannot be created.
*/
- InstLoaderError createInstance(Instance *&inst, const QString &instDir);
+ InstCreateError createInstance(Instance *&inst, const QString &instDir);
/*!
* \brief Loads an instance from the given directory.
* Checks the instance's INI file to figure out what the instance's type is first.
* \param inst Pointer to store the loaded instance in.
* \param instDir The instance's directory.
- * \return An InstLoaderError error code.
+ * \return An InstLoadError error code.
* - NotAnInstance if the given instance directory isn't a valid instance.
*/
- InstLoaderError loadInstance(Instance *&inst, const QString &instDir);
+ InstLoadError loadInstance(Instance *&inst, const QString &instDir);
private:
InstanceLoader();
diff --git a/libmultimc/include/instancetypeinterface.h b/libmultimc/include/instancetypeinterface.h
deleted file mode 100644
index 4fbc2593..00000000
--- a/libmultimc/include/instancetypeinterface.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef INSTANCETYPE_H
-#define INSTANCETYPE_H
-
-#include <QObject>
-
-#include "instanceloader.h"
-
-class InstVersionList;
-
-//! The InstanceTypeInterface's interface ID.
-#define InstanceTypeInterface_IID "net.forkk.MultiMC.InstanceTypeInterface/0.1"
-
-/*!
- * \brief The InstanceType class is an interface for all instance types.
- * InstanceTypes are usually provided by plugins.
- * It handles loading and creating instances of a certain type. There should be
- * one of these for each type of instance and they should be registered with the
- * InstanceLoader.
- * To create an instance, the InstanceLoader calls the type's createInstance()
- * function. Loading is done through the loadInstance() function.
- */
-class InstanceTypeInterface
-{
-public:
- friend class InstanceLoader;
-
- /*!
- * \brief Gets the ID for this instance type.
- * The type ID should be unique as it is used to identify the type
- * of instances when they are loaded.
- * Changing this value at runtime results in undefined behavior.
- * \return This instance type's ID string.
- */
- virtual QString typeID() const = 0;
-
- /*!
- * \brief Gets the name of this instance type as it is displayed to the user.
- * \return The instance type's display name.
- */
- virtual QString displayName() const = 0;
-
- /*!
- * \brief Gets a longer, more detailed description of this instance type.
- * \return The instance type's description.
- */
- virtual QString description() const = 0;
-
- /*!
- * \brief Gets the version list for this instance type.
- * \return A pointer to this instance type's version list.
- */
- virtual InstVersionList *versionList() const = 0;
-
-protected:
- /*!
- * \brief Creates an instance and stores it in inst.
- * \param inst Pointer to store the created instance in.
- * \param instDir The instance's directory.
- * \return An InstTypeError error code.
- * TypeNotRegistered if the given type is not registered with the InstanceLoader.
- * InstExists if the given instance directory is already an instance.
- */
- virtual InstanceLoader::InstLoaderError createInstance(Instance *&inst, const QString &instDir) const = 0;
-
- /*!
- * \brief Loads an instance from the given directory.
- * \param inst Pointer to store the loaded instance in.
- * \param instDir The instance's directory.
- * \return An InstTypeError error code.
- * TypeNotRegistered if the given type is not registered with the InstanceLoader.
- * NotAnInstance if the given instance directory isn't a valid instance.
- * WrongInstType if the given instance directory's type isn't an instance of this type.
- */
- virtual InstanceLoader::InstLoaderError loadInstance(Instance *&inst, const QString &instDir) const = 0;
-};
-
-Q_DECLARE_INTERFACE(InstanceTypeInterface, InstanceTypeInterface_IID)
-
-#endif // INSTANCETYPE_H
diff --git a/libmultimc/include/library.h b/libmultimc/include/library.h
index 8d97b4a6..ed377ddd 100644
--- a/libmultimc/include/library.h
+++ b/libmultimc/include/library.h
@@ -133,51 +133,7 @@ public:
QStringList extract_excludes;
public:
- /// finalize the library, processing the input values into derived values and state
- void finalize()
- {
- QStringList parts = m_name.split(':');
- QString relative = parts[0];
- relative.replace('.','/');
- relative += '/' + parts[1] + '/' + parts[2] + '/' + parts[1] + '-' + parts[2];
- if(!m_is_native)
- relative += ".jar";
- else
- {
- if(m_native_suffixes.contains(currentSystem))
- {
- relative += "-" + m_native_suffixes[currentSystem] + ".jar";
- }
- else
- {
- // really, bad.
- relative += ".jar";
- }
- }
- m_storage_path = relative;
- m_download_path = m_base_url + relative;
-
- if(m_rules.empty())
- {
- m_is_active = true;
- }
- else
- {
- RuleAction result = Disallow;
- for(auto rule: m_rules)
- {
- RuleAction temp = rule->apply( this );
- if(temp != Defer)
- result = temp;
- }
- m_is_active = (result == Allow);
- }
- if(m_is_native)
- {
- m_is_active = m_is_active && m_native_suffixes.contains(currentSystem);
- }
- };
-
+ /// Constructor
Library(QString name)
{
m_is_native = false;
@@ -186,34 +142,67 @@ public:
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)
{
m_name = name;
}
+ /**
+ * Set the url base for downloads
+ */
void setBaseUrl(QString base_url)
{
m_base_url = base_url;
}
+ /**
+ * Call this to mark the library as 'native' (it's a zip archive with DLLs)
+ */
void setIsNative()
{
m_is_native = true;
}
+ /**
+ * Attach a name suffix to the specified OS native
+ */
void addNative(OpSys os, QString suffix)
{
m_is_native = true;
m_native_suffixes[os] = suffix;
}
+ /**
+ * Set the load rules
+ */
void setRules(QList<QSharedPointer<Rule> > rules)
{
m_rules = rules;
}
- bool applies()
+ /**
+ * Returns true if the library should be loaded (or extracted, in case of natives)
+ */
+ bool getIsActive()
{
return m_is_active;
}
+ /**
+ * Returns true if the library is native
+ */
+ bool getIsNative()
+ {
+ return m_is_native;
+ }
};