diff options
Diffstat (limited to 'libmultimc/include')
-rw-r--r-- | libmultimc/include/instance.h | 263 | ||||
-rw-r--r-- | libmultimc/include/instancetypeinterface.h | 10 | ||||
-rw-r--r-- | libmultimc/include/instversion.h | 33 | ||||
-rw-r--r-- | libmultimc/include/instversionlist.h | 37 | ||||
-rw-r--r-- | libmultimc/include/task.h | 9 |
5 files changed, 192 insertions, 160 deletions
diff --git a/libmultimc/include/instance.h b/libmultimc/include/instance.h index 7de61343..c41e6718 100644 --- a/libmultimc/include/instance.h +++ b/libmultimc/include/instance.h @@ -22,6 +22,8 @@ #include <settingsobject.h> #include "inifile.h" +#include "instancetypeinterface.h" +#include "instversionlist.h" #include "libmmc_config.h" @@ -38,33 +40,124 @@ class InstanceList; class LIBMULTIMC_EXPORT Instance : public QObject { Q_OBJECT + + // Properties + /*! + * The instance's ID. + * This is a unique identifier string that is, by default, set to the + * instance's folder name. It's not always the instance's folder name, + * however, as any class deriving from Instance can override the id() + * method and change how the ID is determined. The instance's ID should + * always remain constant. Undefined behavior results if an already loaded + * instance's ID changes. + */ + Q_PROPERTY(QString id READ id STORED false) + + //! Path to the instance's root directory. + Q_PROPERTY(QString rootDir READ rootDir) + + //! The name of the instance that is displayed to the user. + Q_PROPERTY(QString name READ name WRITE setName) + + //! The instance's icon key. + Q_PROPERTY(QString iconKey READ iconKey WRITE setIconKey) + + //! The instance's notes. + Q_PROPERTY(QString notes READ notes WRITE setNotes) + + /*! + * Whether or not the instance's minecraft.jar needs to be rebuilt. + * If this is true, when the instance launches, its jar mods will be + * re-added to a fresh minecraft.jar file. + */ + Q_PROPERTY(bool shouldRebuild READ shouldRebuild WRITE setShouldRebuild) + + + /*! + * The instance's current version. + * This value represents the instance's current version. If this value is + * different from the intendedVersion, the instance should be updated. + * \warning Don't change this value unless you know what you're doing. + */ + Q_PROPERTY(QString currentVersion READ currentVersion WRITE setCurrentVersion) + + /*! + * The version that the user has set for this instance to use. + * If this is not the same as currentVersion, the instance's game updater + * will be run on launch. + */ + Q_PROPERTY(QString intendedVersion READ intendedVersion WRITE setIntendedVersion) + + //! The version of LWJGL that this instance uses. + Q_PROPERTY(QString lwjglVersion READ lwjglVersion WRITE setLWJGLVersion) + + + /*! + * Gets the time that the instance was last launched. + * Stored in milliseconds since epoch. + * This value is usually used for things like sorting instances by the time + * they were last launched. + */ + Q_PROPERTY(qint64 lastLaunch READ lastLaunch WRITE setLastLaunch) + + + + // Dirs + //! Path to the instance's .minecraft folder. + Q_PROPERTY(QString minecraftDir READ minecraftDir STORED false) + + //! Path to the instance's instMods folder. + Q_PROPERTY(QString instModsDir READ instModsDir STORED false) + + //! Path to the instance's bin folder. + Q_PROPERTY(QString binDir READ binDir STORED false) + + //! Path to the instance's saves folder. + Q_PROPERTY(QString savesDir READ savesDir STORED false) + + //! Path to the instance's mods folder (.minecraft/mods) + Q_PROPERTY(QString mlModsDir READ mlModsDir STORED false) + + //! Path to the instance's coremods folder. + Q_PROPERTY(QString coreModsDir READ coreModsDir STORED false) + + //! Path to the instance's resources folder. + Q_PROPERTY(QString resourceDir READ resourceDir STORED false) + + //! Path to the instance's screenshots folder. + Q_PROPERTY(QString screenshotsDir READ screenshotsDir STORED false) + + //! Path to the instance's texturepacks folder. + Q_PROPERTY(QString texturePacksDir READ texturePacksDir STORED false) + + + // Files + //! Path to the instance's minecraft.jar + Q_PROPERTY(QString mcJar READ mcJar STORED false) + + //! Path to the instance's mcbackup.jar + Q_PROPERTY(QString mcBackup READ mcBackup STORED false) + + //! Path to the instance's config file. + Q_PROPERTY(QString configFile READ configFile STORED false) + + //! Path to the instance's modlist file. + Q_PROPERTY(QString modListFile READ modListFile STORED false) + public: explicit Instance(const QString &rootDir, QObject *parent = 0); // Please, for the sake of my (and everyone else's) sanity, at least keep this shit // *somewhat* organized. Also, documentation is semi-important here. Please don't // leave undocumented stuff behind. + // As a side-note, doxygen processes comments for accessor functions and + // properties separately, so please document properties in the massive block of + // Q_PROPERTY declarations above rather than documenting their accessors. //////// STUFF //////// - - /*! - * \brief Get the instance's ID. - * This is a unique identifier string that is, by default, set to the - * instance's folder name. It's not always the instance's folder name, - * however, as any class deriving from Instance can override the id() - * method and change how the ID is determined. The instance's ID - * should always remain constant. Undefined behavior results if an - * already loaded instance's ID changes. - * - * \return The instance's ID. - */ virtual QString id() const; - /*! - * \brief Gets the path to the instance's root directory. - * \return The path to the instance's root directory. - */ virtual QString rootDir() const; /*! @@ -79,178 +172,76 @@ public: //////// INSTANCE INFO //////// //// General Info //// - - /*! - * \brief Gets this instance's name. - * This is the name that will be displayed to the user. - * \return The instance's name. - * \sa setName - */ virtual QString name() { return settings().get("name").toString(); } - - /*! - * \brief Sets the instance's name - * \param val The instance's new name. - */ virtual void setName(QString val) { settings().set("name", val); } - /*! - * \brief Gets the instance's icon key. - * \return The instance's icon key. - * \sa setIconKey() - */ virtual QString iconKey() const { return settings().get("iconKey").toString(); } - - /*! - * \brief Sets the instance's icon key. - * \param val The new icon key. - */ virtual void setIconKey(QString val) { settings().set("iconKey", val); } - - /*! - * \brief Gets the instance's notes. - * \return The instances notes. - */ virtual QString notes() const { return settings().get("notes").toString(); } - - /*! - * \brief Sets the instance's notes. - * \param val The instance's new notes. - */ virtual void setNotes(QString val) { settings().set("notes", val); } - - /*! - * \brief Checks if the instance's minecraft.jar needs to be rebuilt. - * If this is true, the instance's mods will be reinstalled to its - * minecraft.jar file. This value is automatically set to true when - * the jar mod list changes. - * \return Whether or not the instance's jar file should be rebuilt. - */ virtual bool shouldRebuild() const { return settings().get("NeedsRebuild").toBool(); } - - /*! - * \brief Sets whether or not the instance's minecraft.jar needs to be rebuilt. - * \param val Whether the instance's minecraft needs to be rebuilt or not. - */ virtual void setShouldRebuild(bool val) { settings().set("NeedsRebuild", val); } //// Version Stuff //// - /*! - * \brief Sets the instance's current version. - * This value represents the instance's current version. If this value - * is different from intendedVersion(), the instance should be updated. - * This value is updated by the updateCurrentVersion() function. - * \return A string representing the instance's current version. - */ virtual QString currentVersion() { return settings().get("JarVersion").toString(); } - - /*! - * \brief Sets the instance's current version. - * This is used to keep track of the instance's current version. Don't - * mess with this unless you know what you're doing. - * \param val The new value. - */ virtual void setCurrentVersion(QString val) { settings().set("JarVersion", val); } - - /*! - * \brief Gets the version of LWJGL that this instance should use. - * If no LWJGL version is specified in the instance's config file, - * defaults to "Mojang" - * \return The instance's LWJGL version. - */ virtual QString lwjglVersion() { return settings().get("LwjglVersion").toString(); } - - /*! - * \brief Sets the version of LWJGL that this instance should use. - * \param val The LWJGL version to use - */ virtual void setLWJGLVersion(QString val) { settings().set("LwjglVersion", val); } - - /*! - * \brief Gets the version that this instance should try to update to. - * If this value differs from currentVersion(), the instance will - * download the intended version when it launches. - * \return The instance's intended version. - */ virtual QString intendedVersion() { return settings().get("IntendedJarVersion").toString(); } - - /*! - * \brief Sets the version that this instance should try to update to. - * \param val The instance's new intended version. - */ virtual void setIntendedVersion(QString val) { settings().set("IntendedJarVersion", val); } //// Timestamps //// - /*! - * \brief Gets the time that the instance was last launched. - * Measured in milliseconds since epoch. QDateTime::currentMSecsSinceEpoch() - * \return The time that the instance was last launched. - */ virtual qint64 lastLaunch() { return settings().get("lastLaunchTime").value<qint64>(); } - - /*! - * \brief Sets the time that the instance was last launched. - * \param val The time to set. Defaults to QDateTime::currentMSecsSinceEpoch() - */ virtual void setLastLaunch(qint64 val = QDateTime::currentMSecsSinceEpoch()) { settings().set("lastLaunchTime", val); } ////// Directories ////// - //! Gets the path to the instance's minecraft folder. QString minecraftDir() const; - - /*! - * \brief Gets the path to the instance's instance mods folder. - * This is the folder where the jar mods are kept. - */ QString instModsDir() const; - - //! Gets the path to the instance's bin folder. QString binDir() const; - - //! Gets the path to the instance's saves folder. QString savesDir() const; - - //! Gets the path to the instance's mods folder. (.minecraft/mods) QString mlModsDir() const; - - //! Gets the path to the instance's coremods folder. QString coreModsDir() const; - - //! Gets the path to the instance's resources folder. QString resourceDir() const; - - //! Gets the path to the instance's screenshots folder. QString screenshotsDir() const; - - //! Gets the path to the instance's texture packs folder. QString texturePacksDir() const; ////// Files ////// - //! Gets the path to the instance's minecraft.jar QString mcJar() const; - - //! Gets the path to the instance's mcbackup.jar. QString mcBackup() const; - - //! Gets the path to the instance's config file. QString configFile() const; - - //! Gets the path to the instance's modlist file. QString modListFile() const; + //////// LISTS, LISTS, AND MORE LISTS //////// + /*! + * \brief Gets a pointer to this instance's version list. + * \return A pointer to the available version list for this instance. + */ + virtual InstVersionList *versionList() const = 0; + + + + //////// INSTANCE TYPE STUFF //////// + + /*! + * \brief Returns a pointer to this instance's type. + * \return A pointer to this instance's type interface. + */ + virtual const InstanceTypeInterface *instanceType() const = 0; + + //////// OTHER FUNCTIONS //////// //// Version System //// diff --git a/libmultimc/include/instancetypeinterface.h b/libmultimc/include/instancetypeinterface.h index 30a12d99..ba13f820 100644 --- a/libmultimc/include/instancetypeinterface.h +++ b/libmultimc/include/instancetypeinterface.h @@ -20,6 +20,8 @@ #include "instanceloader.h" +class InstVersionList; + //! The InstanceTypeInterface's interface ID. #define InstanceTypeInterface_IID "net.forkk.MultiMC.InstanceTypeInterface/0.1" @@ -56,7 +58,13 @@ public: * \brief Gets a longer, more detailed description of this instance type. * \return The instance type's description. */ - virtual QString description() const = 0; + 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: /*! diff --git a/libmultimc/include/instversion.h b/libmultimc/include/instversion.h index 3c6b7ac9..7de83966 100644 --- a/libmultimc/include/instversion.h +++ b/libmultimc/include/instversion.h @@ -26,27 +26,32 @@ class LIBMULTIMC_EXPORT InstVersion : public QObject { Q_OBJECT public: - // Constructs a new InstVersion with the given parent. The parent *must* - // be the InstVersionList that contains this InstVersion. The InstVersion - // should be added to the list immediately after being created as any calls - // to id() will likely fail unless the InstVersion is in a list. + /*! + * \brief Constructs a new InstVersion with the given parent. + * The parent *must* be the InstVersionList that contains this InstVersion. + * The InstVersion should be added to the list immediately after being created. + */ explicit InstVersion(InstVersionList *parent = 0); - // Returns this InstVersion's ID. This is usually just the InstVersion's index - // within its InstVersionList, but not always. - // If this InstVersion is not in an InstVersionList, returns -1. - virtual int id() const = 0; + //! Gets the string used to identify this version in config files. + virtual QString descriptor() const = 0; + + /*! + * \breif Returns this InstVersion's name. + * This is displayed to the user in the GUI and is usually just the version number ("1.4.7"), for example. + */ - // Returns this InstVersion's name. This is displayed to the user in the GUI - // and is usually just the version number ("1.4.7"), for example. virtual QString name() const = 0; - // Returns this InstVersion's name. This is usually displayed to the user - // in the GUI and specifies what kind of version this is. For example: it - // could be "Snapshot", "Latest Version", "MCNostalgia", etc. + /*! + * \brief Returns this InstVersion's name. + * This is usually displayed to the user in the GUI and specifies what + * kind of version this is. For example: it could be "Snapshot", + * "Latest Version", "MCNostalgia", etc. + */ virtual QString type() const = 0; - // Returns the version list that this InstVersion is a part of. + //! Returns the version list that this InstVersion is a part of. virtual InstVersionList *versionList() const; }; diff --git a/libmultimc/include/instversionlist.h b/libmultimc/include/instversionlist.h index d64a286f..4345aaaa 100644 --- a/libmultimc/include/instversionlist.h +++ b/libmultimc/include/instversionlist.h @@ -21,25 +21,44 @@ #include "libmmc_config.h" class InstVersion; +class Task; -// Class that each instance type's version list derives from. Version lists are -// the lists that keep track of the available game versions for that instance. -// This list will not be loaded on startup. It will be loaded when the list's -// load function is called. +/*! + * \brief Class that each instance type's version list derives from. + * Version lists are the lists that keep track of the available game versions + * for that instance. This list will not be loaded on startup. It will be loaded + * when the list's load function is called. Before using the version list, you + * should check to see if it has been loaded yet and if not, load the list. + */ class LIBMULTIMC_EXPORT InstVersionList : public QObject { Q_OBJECT public: - explicit InstVersionList(); + explicit InstVersionList(QObject *parent = 0); + + /*! + * \brief Gets a task that will reload the version list. + * Simply execute the task to load the list. + * \return A pointer to a task that reloads the version list. + */ + virtual Task *getLoadTask() = 0; - // Reloads the version list. - virtual void loadVersionList() = 0; + //! Checks whether or not the list is loaded. If this returns false, the list should be loaded. + virtual bool isLoaded() = 0; - // Gets the version at the given index. + //! Gets the version at the given index. virtual const InstVersion *at(int i) const = 0; - // Returns the number of versions in the list. + //! Returns the number of versions in the list. virtual int count() const = 0; + + /*! + * \brief Finds a version by its descriptor. + * \param The descriptor of the version to find. + * \return A const pointer to the version with the given descriptor. NULL if + * one doesn't exist. + */ + virtual const InstVersion *findVersion(const QString &descriptor); }; #endif // INSTVERSIONLIST_H diff --git a/libmultimc/include/task.h b/libmultimc/include/task.h index b1a3052d..fc5b1d25 100644 --- a/libmultimc/include/task.h +++ b/libmultimc/include/task.h @@ -34,6 +34,15 @@ public: QString getStatus() const; int getProgress() const; + /*! + * \brief Calculates and sets the task's progress based on the number of parts completed out of the total number to complete. + * This is essentially just shorthand for setProgress((parts / whole) * 100); + * \param parts The parts out of the whole completed. This parameter should + * be less than whole. If it is greater than whole, progress is set to 100. + * \param whole The total number of things that need to be completed. + */ + void calcProgress(int parts, int whole); + public slots: void setStatus(const QString& status); void setProgress(int progress); |