Split MultiMC up into a few separate libraries.
Fixed plugin system. Tons of other stuff...
This commit is contained in:
@ -1,40 +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.
|
||||
*/
|
||||
|
||||
#include "appsettings.h"
|
||||
|
||||
AppSettings* settings;
|
||||
|
||||
SettingsBase::SettingsBase(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AppSettings::AppSettings(QObject *parent) :
|
||||
SettingsBase(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVariant AppSettings::getValue(const QString& name, QVariant defVal) const
|
||||
{
|
||||
return config.value(name, defVal);
|
||||
}
|
||||
|
||||
void AppSettings::setValue(const QString& name, QVariant val)
|
||||
{
|
||||
config.setValue(name, val);
|
||||
}
|
@ -1,116 +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 APPSETTINGS_H
|
||||
#define APPSETTINGS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
#include <QColor>
|
||||
#include <QPoint>
|
||||
|
||||
#include "util/apputils.h"
|
||||
#include "util/osutils.h"
|
||||
|
||||
#if WINDOWS
|
||||
#define JPATHKEY "JavaPathWindows"
|
||||
#elif OSX
|
||||
#define JPATHKEY "JavaPathOSX"
|
||||
#else
|
||||
#define JPATHKEY "JavaPathLinux"
|
||||
#endif
|
||||
|
||||
#define DEFINE_SETTING_ADVANCED(funcName, name, valType, defVal) \
|
||||
virtual valType get ## funcName() const { return getValue(name, defVal).value<valType>(); } \
|
||||
virtual void set ## funcName(valType value) { setValue(name, value); }
|
||||
|
||||
#define DEFINE_SETTING(name, valType, defVal) \
|
||||
DEFINE_SETTING_ADVANCED(name, STR_VAL(name), valType, defVal)
|
||||
|
||||
|
||||
class SettingsBase : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SettingsBase(QObject *parent = 0);
|
||||
|
||||
// Updates
|
||||
DEFINE_SETTING(UseDevBuilds, bool, false)
|
||||
DEFINE_SETTING(AutoUpdate, bool, true)
|
||||
|
||||
// Folders
|
||||
DEFINE_SETTING(InstanceDir, QString, "instances")
|
||||
DEFINE_SETTING(CentralModsDir, QString, "mods")
|
||||
DEFINE_SETTING(LWJGLDir, QString, "lwjgl")
|
||||
|
||||
// Console
|
||||
DEFINE_SETTING(ShowConsole, bool, true)
|
||||
DEFINE_SETTING(AutoCloseConsole, bool, true)
|
||||
|
||||
// Toolbar settings
|
||||
DEFINE_SETTING(InstanceToolbarVisible, bool, true)
|
||||
DEFINE_SETTING(InstanceToolbarPosition, QPoint, QPoint())
|
||||
|
||||
// Console Colors
|
||||
DEFINE_SETTING(SysMessageColor, QColor, QColor(Qt::blue))
|
||||
DEFINE_SETTING(StdOutColor, QColor, QColor(Qt::black))
|
||||
DEFINE_SETTING(StdErrColor, QColor, QColor(Qt::red))
|
||||
|
||||
// Window Size
|
||||
DEFINE_SETTING(LaunchCompatMode, bool, false)
|
||||
DEFINE_SETTING(LaunchMaximized, bool, false)
|
||||
DEFINE_SETTING(MinecraftWinWidth, int, 854)
|
||||
DEFINE_SETTING(MinecraftWinHeight, int, 480)
|
||||
|
||||
// Auto login
|
||||
DEFINE_SETTING(AutoLogin, bool, false)
|
||||
|
||||
// Memory
|
||||
DEFINE_SETTING(MinMemAlloc, int, 512)
|
||||
DEFINE_SETTING(MaxMemAlloc, int, 1024)
|
||||
|
||||
// Java Settings
|
||||
DEFINE_SETTING_ADVANCED(JavaPath, JPATHKEY, QString, "java")
|
||||
DEFINE_SETTING(JvmArgs, QString, "")
|
||||
|
||||
// Custom Commands
|
||||
DEFINE_SETTING(PreLaunchCommand, QString, "")
|
||||
DEFINE_SETTING(PostExitCommand, QString, "")
|
||||
|
||||
virtual QVariant getValue(const QString& name, QVariant defVal = QVariant()) const = 0;
|
||||
virtual void setValue(const QString& name, QVariant val) = 0;
|
||||
};
|
||||
|
||||
class AppSettings : public SettingsBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppSettings(QObject *parent = 0);
|
||||
|
||||
QSettings& getConfig() { return config; }
|
||||
|
||||
virtual QVariant getValue(const QString &name, QVariant defVal = QVariant()) const;
|
||||
virtual void setValue(const QString& name, QVariant val);
|
||||
|
||||
protected:
|
||||
QSettings config;
|
||||
};
|
||||
|
||||
#undef DEFINE_SETTING_ADVANCED
|
||||
#undef DEFINE_SETTING
|
||||
|
||||
extern AppSettings* settings;
|
||||
|
||||
#endif // APPSETTINGS_H
|
@ -1,86 +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.
|
||||
*/
|
||||
|
||||
#include "inifile.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QStringList>
|
||||
|
||||
INIFile::INIFile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool INIFile::saveFile(QString fileName)
|
||||
{
|
||||
// TODO Handle errors.
|
||||
QFile file(fileName);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
QTextStream out(&file);
|
||||
|
||||
for (Iterator iter = begin(); iter != end(); iter++)
|
||||
{
|
||||
out << iter.key() << "=" << iter.value().toString() << "\n";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool INIFile::loadFile(QString fileName)
|
||||
{
|
||||
// TODO Handle errors.
|
||||
QFile file(fileName);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QTextStream in(&file);
|
||||
|
||||
QStringList lines = in.readAll().split('\n');
|
||||
for (int i = 0; i < lines.count(); i++)
|
||||
{
|
||||
QString & lineRaw = lines[i];
|
||||
// Ignore comments.
|
||||
QString line = lineRaw.left(lineRaw.indexOf('#')).trimmed();
|
||||
|
||||
int eqPos = line.indexOf('=');
|
||||
if(eqPos == -1)
|
||||
continue;
|
||||
QString key = line.left(eqPos).trimmed();
|
||||
QString valueStr = line.right(line.length() - eqPos - 1).trimmed();
|
||||
|
||||
QVariant value(valueStr);
|
||||
/*
|
||||
QString dbg = key;
|
||||
dbg += " = ";
|
||||
dbg += valueStr;
|
||||
qDebug(dbg.toLocal8Bit());
|
||||
*/
|
||||
this->operator [](key) = value;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant INIFile::get(QString key, QVariant def) const
|
||||
{
|
||||
if (!this->contains(key))
|
||||
return def;
|
||||
else
|
||||
return this->operator [](key);
|
||||
}
|
||||
|
||||
void INIFile::set(QString key, QVariant val)
|
||||
{
|
||||
this->operator [](key) = val;
|
||||
}
|
@ -1,36 +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 INIFILE_H
|
||||
#define INIFILE_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
// Sectionless INI parser (for instance config files)
|
||||
class INIFile : public QMap<QString, QVariant>
|
||||
{
|
||||
public:
|
||||
explicit INIFile();
|
||||
|
||||
bool loadFile(QString fileName);
|
||||
bool saveFile(QString fileName);
|
||||
|
||||
QVariant get(QString key, QVariant def) const;
|
||||
void set(QString key, QVariant val);
|
||||
};
|
||||
|
||||
#endif // INIFILE_H
|
@ -1,110 +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.
|
||||
*/
|
||||
|
||||
#include "instance.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "util/pathutils.h"
|
||||
|
||||
Instance::Instance(const QString &rootDir, QObject *parent) :
|
||||
SettingsBase(parent)
|
||||
{
|
||||
m_rootDir = rootDir;
|
||||
config.loadFile(PathCombine(rootDir, "instance.cfg"));
|
||||
}
|
||||
|
||||
QString Instance::id()
|
||||
{
|
||||
return QFileInfo(rootDir()).baseName();
|
||||
}
|
||||
|
||||
QString Instance::rootDir()
|
||||
{
|
||||
return m_rootDir;
|
||||
}
|
||||
|
||||
InstanceList *Instance::instList()
|
||||
{
|
||||
if (parent()->inherits("InstanceList"))
|
||||
return (InstanceList *)parent();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QString Instance::minecraftDir() const
|
||||
{
|
||||
QFileInfo mcDir(PathCombine(rootDir(), "minecraft"));
|
||||
QFileInfo dotMCDir(PathCombine(rootDir(), ".minecraft"));
|
||||
|
||||
if (dotMCDir.exists() && !mcDir.exists())
|
||||
{
|
||||
return dotMCDir.path();
|
||||
}
|
||||
else
|
||||
{
|
||||
return mcDir.path();
|
||||
}
|
||||
}
|
||||
|
||||
QString Instance::binDir() const
|
||||
{
|
||||
return PathCombine(minecraftDir(), "bin");
|
||||
}
|
||||
|
||||
QString Instance::savesDir() const
|
||||
{
|
||||
return PathCombine(minecraftDir(), "saves");
|
||||
}
|
||||
|
||||
QString Instance::mlModsDir() const
|
||||
{
|
||||
return PathCombine(minecraftDir(), "mods");
|
||||
}
|
||||
|
||||
QString Instance::coreModsDir() const
|
||||
{
|
||||
return PathCombine(minecraftDir(), "coremods");
|
||||
}
|
||||
|
||||
QString Instance::resourceDir() const
|
||||
{
|
||||
return PathCombine(minecraftDir(), "resources");
|
||||
}
|
||||
|
||||
QString Instance::screenshotsDir() const
|
||||
{
|
||||
return PathCombine(minecraftDir(), "screenshots");
|
||||
}
|
||||
|
||||
QString Instance::texturePacksDir() const
|
||||
{
|
||||
return PathCombine(minecraftDir(), "texturepacks");
|
||||
}
|
||||
|
||||
QString Instance::mcJar() const
|
||||
{
|
||||
return PathCombine(binDir(), "minecraft.jar");
|
||||
}
|
||||
|
||||
QVariant Instance::getField(const QString &name, QVariant defVal) const
|
||||
{
|
||||
return config.get(name, defVal);
|
||||
}
|
||||
|
||||
void Instance::setField(const QString &name, QVariant val)
|
||||
{
|
||||
config.set(name, val);
|
||||
}
|
@ -1,340 +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 INSTANCE_H
|
||||
#define INSTANCE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "data/appsettings.h"
|
||||
#include "data/inifile.h"
|
||||
|
||||
#define DEFINE_OVERRIDDEN_SETTING_ADVANCED(funcName, cfgEntryName, typeName) \
|
||||
typeName get ## funcName() const { return getField(cfgEntryName, settings->get ## funcName()).value<typeName>(); }
|
||||
|
||||
#define DEFINE_OVERRIDDEN_SETTING(funcName, typeName) \
|
||||
DEFINE_OVERRIDDEN_SETTING_ADVANCED(funcName, STR_VAL(funcName), typeName)
|
||||
|
||||
class InstanceList;
|
||||
|
||||
/*!
|
||||
* \brief Base class for instances.
|
||||
* This class implements many functions that are common between instances and
|
||||
* provides a standard interface for all instances.
|
||||
*
|
||||
* To create a new instance type, create a new class inheriting from this class
|
||||
* and implement the pure virtual functions.
|
||||
*/
|
||||
class Instance : public SettingsBase
|
||||
{
|
||||
Q_OBJECT
|
||||
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.
|
||||
|
||||
|
||||
//////// 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();
|
||||
|
||||
/*!
|
||||
* \brief Gets the path to the instance's root directory.
|
||||
* \return The path to the instance's root directory.
|
||||
*/
|
||||
virtual QString rootDir();
|
||||
|
||||
/*!
|
||||
* \brief Gets the instance list that this instance is a part of.
|
||||
* Returns NULL if this instance is not in a list
|
||||
* (the parent is not an InstanceList).
|
||||
* \return A pointer to the InstanceList containing this instance.
|
||||
*/
|
||||
virtual InstanceList *instList();
|
||||
|
||||
|
||||
//////// FIELDS AND SETTINGS ////////
|
||||
// Fields are options stored in the instance's config file that are specific
|
||||
// to instances (not a part of SettingsBase). Settings are things overridden
|
||||
// from SettingsBase.
|
||||
|
||||
|
||||
////// Fields //////
|
||||
|
||||
//// 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 getField("name", "Unnamed Instance").value<QString>(); }
|
||||
|
||||
/*!
|
||||
* \brief Sets the instance's name
|
||||
* \param val The instance's new name.
|
||||
*/
|
||||
virtual void setName(QString val) { setField("name", val); }
|
||||
|
||||
/*!
|
||||
* \brief Gets the instance's icon key.
|
||||
* \return The instance's icon key.
|
||||
* \sa setIconKey()
|
||||
*/
|
||||
virtual QString iconKey() const { return getField("iconKey", "default").value<QString>(); }
|
||||
|
||||
/*!
|
||||
* \brief Sets the instance's icon key.
|
||||
* \param val The new icon key.
|
||||
*/
|
||||
virtual void setIconKey(QString val) { setField("iconKey", val); }
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Gets the instance's notes.
|
||||
* \return The instances notes.
|
||||
*/
|
||||
virtual QString notes() const { return getField("notes", "").value<QString>(); }
|
||||
|
||||
/*!
|
||||
* \brief Sets the instance's notes.
|
||||
* \param val The instance's new notes.
|
||||
*/
|
||||
virtual void setNotes(QString val) { setField("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 getField("NeedsRebuild", false).value<bool>(); }
|
||||
|
||||
/*!
|
||||
* \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) { setField("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 getField("JarVersion", "Unknown").value<QString>(); }
|
||||
|
||||
/*!
|
||||
* \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) { setField("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 getField("LwjglVersion", "Mojang").value<QString>(); }
|
||||
|
||||
/*!
|
||||
* \brief Sets the version of LWJGL that this instance should use.
|
||||
* \param val The LWJGL version to use
|
||||
*/
|
||||
virtual void setLWJGLVersion(QString val) { setField("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 getField("IntendedJarVersion", currentVersion()).value<QString>(); }
|
||||
|
||||
/*!
|
||||
* \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) { setField("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 getField("lastLaunchTime", 0).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())
|
||||
{ setField("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;
|
||||
|
||||
////// Settings //////
|
||||
|
||||
//// Java Settings ////
|
||||
DEFINE_OVERRIDDEN_SETTING_ADVANCED(JavaPath, JPATHKEY, QString)
|
||||
DEFINE_OVERRIDDEN_SETTING(JvmArgs, QString)
|
||||
|
||||
//// Custom Commands ////
|
||||
DEFINE_OVERRIDDEN_SETTING(PreLaunchCommand, QString)
|
||||
DEFINE_OVERRIDDEN_SETTING(PostExitCommand, QString)
|
||||
|
||||
//// Memory ////
|
||||
DEFINE_OVERRIDDEN_SETTING(MinMemAlloc, int)
|
||||
DEFINE_OVERRIDDEN_SETTING(MaxMemAlloc, int)
|
||||
|
||||
//// Auto login ////
|
||||
DEFINE_OVERRIDDEN_SETTING(AutoLogin, bool)
|
||||
|
||||
// This little guy here is to keep Qt Creator from being a dumbass and
|
||||
// auto-indenting the lines below the macros. Seriously, it's really annoying.
|
||||
;
|
||||
|
||||
|
||||
//////// OTHER FUNCTIONS ////////
|
||||
|
||||
//// Version System ////
|
||||
|
||||
/*!
|
||||
* \brief Checks whether or not the currentVersion of the instance needs to be updated.
|
||||
* If this returns true, updateCurrentVersion is called. In the
|
||||
* standard instance, this is determined by checking a timestamp
|
||||
* stored in the instance config file against the last modified time of Minecraft.jar.
|
||||
* \return True if updateCurrentVersion() should be called.
|
||||
*/
|
||||
virtual bool shouldUpdateCurrentVersion() = 0;
|
||||
|
||||
/*!
|
||||
* \brief Updates the current version.
|
||||
* This function should first set the current version timestamp
|
||||
* (setCurrentVersionTimestamp()) to the current time. Next, if
|
||||
* keepCurrent is false, this function should check what the
|
||||
* instance's current version is and call setCurrentVersion() to
|
||||
* update it. This function will automatically be called when the
|
||||
* instance is loaded if shouldUpdateCurrentVersion returns true.
|
||||
* \param keepCurrent If true, only the version timestamp will be updated.
|
||||
*/
|
||||
virtual void updateCurrentVersion(bool keepCurrent = false) = 0;
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief Gets the value of the given field in the instance's config file.
|
||||
* If the value isn't in the config file, defVal is returned instead.
|
||||
* \param name The name of the field in the config file.
|
||||
* \param defVal The default value.
|
||||
* \return The value of the given field or defVal if the field doesn't exist.
|
||||
* \sa setField()
|
||||
*/
|
||||
virtual QVariant getField(const QString &name, QVariant defVal = QVariant()) const;
|
||||
|
||||
/*!
|
||||
* \brief Sets the value of the given field in the config file.
|
||||
* \param name The name of the field in the config file.
|
||||
* \param val The value to set the field to.
|
||||
* \sa getField()
|
||||
*/
|
||||
virtual void setField(const QString &name, QVariant val);
|
||||
|
||||
// Overrides for SettingBase stuff.
|
||||
virtual QVariant getValue(const QString &name, QVariant defVal = QVariant()) const
|
||||
{ return settings->getValue(name, defVal); }
|
||||
virtual void setValue(const QString &name, QVariant val)
|
||||
{ setField(name, val); }
|
||||
|
||||
INIFile config;
|
||||
|
||||
private:
|
||||
QString m_rootDir;
|
||||
};
|
||||
|
||||
#endif // INSTANCE_H
|
@ -1,78 +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.
|
||||
*/
|
||||
|
||||
#include "instancelist.h"
|
||||
|
||||
#include "data/siglist_impl.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QDirIterator>
|
||||
|
||||
#include "instance.h"
|
||||
#include "instanceloader.h"
|
||||
|
||||
#include "util/pathutils.h"
|
||||
|
||||
|
||||
InstanceList::InstanceList(const QString &instDir, QObject *parent) :
|
||||
QObject(parent), m_instDir(instDir)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
InstanceList::InstListError InstanceList::loadList()
|
||||
{
|
||||
QDir dir(m_instDir);
|
||||
QDirIterator iter(dir);
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
QString subDir = iter.next();
|
||||
if (QFileInfo(PathCombine(subDir, "instance.cfg")).exists())
|
||||
{
|
||||
QSharedPointer<Instance> inst;
|
||||
InstanceLoader::InstTypeError error = InstanceLoader::loader.
|
||||
loadInstance(inst.data(), subDir);
|
||||
|
||||
if (inst.data() && error == InstanceLoader::NoError)
|
||||
{
|
||||
qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8());
|
||||
inst->setParent(this);
|
||||
append(QSharedPointer<Instance>(inst));
|
||||
}
|
||||
else if (error != InstanceLoader::NotAnInstance)
|
||||
{
|
||||
QString errorMsg = QString("Failed to load instance %1: ").
|
||||
arg(QFileInfo(subDir).baseName()).toUtf8();
|
||||
|
||||
switch (error)
|
||||
{
|
||||
case InstanceLoader::TypeNotRegistered:
|
||||
errorMsg += "Instance type not found.";
|
||||
break;
|
||||
}
|
||||
qDebug(errorMsg.toUtf8());
|
||||
}
|
||||
else if (!inst.data())
|
||||
{
|
||||
qDebug(QString("Error loading instance %1. Instance loader returned null.").
|
||||
arg(QFileInfo(subDir).baseName()).toUtf8());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NoError;
|
||||
}
|
@ -1,57 +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 INSTANCELIST_H
|
||||
#define INSTANCELIST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "data/siglist.h"
|
||||
|
||||
class Instance;
|
||||
|
||||
class InstanceList : public QObject, public SigList<QSharedPointer<Instance>>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InstanceList(const QString &instDir, QObject *parent = 0);
|
||||
|
||||
/*!
|
||||
* \brief Error codes returned by functions in the InstanceList class.
|
||||
* NoError Indicates that no error occurred.
|
||||
* UnknownError indicates that an unspecified error occurred.
|
||||
*/
|
||||
enum InstListError
|
||||
{
|
||||
NoError = 0,
|
||||
UnknownError
|
||||
};
|
||||
|
||||
QString instDir() const { return m_instDir; }
|
||||
|
||||
/*!
|
||||
* \brief Loads the instance list.
|
||||
*/
|
||||
InstListError loadList();
|
||||
|
||||
DEFINE_SIGLIST_SIGNALS(QSharedPointer<Instance>);
|
||||
SETUP_SIGLIST_SIGNALS(QSharedPointer<Instance>);
|
||||
protected:
|
||||
QString m_instDir;
|
||||
};
|
||||
|
||||
#endif // INSTANCELIST_H
|
@ -1,106 +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.
|
||||
*/
|
||||
|
||||
#include "instanceloader.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "instancetype.h"
|
||||
|
||||
#include "data/inifile.h"
|
||||
|
||||
#include "util/pathutils.h"
|
||||
|
||||
InstanceLoader InstanceLoader::loader;
|
||||
|
||||
InstanceLoader::InstanceLoader() :
|
||||
QObject(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
InstanceLoader::InstTypeError InstanceLoader::registerInstanceType(InstanceType *type)
|
||||
{
|
||||
// Check to see if the type ID exists.
|
||||
if (m_typeMap.contains(type->typeID()))
|
||||
return TypeIDExists;
|
||||
|
||||
// Set the parent to this.
|
||||
type->setParent(this);
|
||||
|
||||
// Add it to the map.
|
||||
m_typeMap.insert(type->typeID(), type);
|
||||
return NoError;
|
||||
}
|
||||
|
||||
InstanceLoader::InstTypeError InstanceLoader::createInstance(Instance *inst,
|
||||
const InstanceType *type,
|
||||
const QString &instDir)
|
||||
{
|
||||
// Check if the type is registered.
|
||||
if (!type || findType(type->typeID()) != type)
|
||||
return TypeNotRegistered;
|
||||
|
||||
// Create the instance.
|
||||
return type->createInstance(inst, instDir);
|
||||
}
|
||||
|
||||
InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *inst,
|
||||
const InstanceType *type,
|
||||
const QString &instDir)
|
||||
{
|
||||
// Check if the type is registered.
|
||||
if (!type || findType(type->typeID()) != type)
|
||||
return TypeNotRegistered;
|
||||
|
||||
return type->loadInstance(inst, instDir);
|
||||
}
|
||||
|
||||
InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *inst,
|
||||
const QString &instDir)
|
||||
{
|
||||
QFileInfo instConfig(PathCombine(instDir, "instance.cfg"));
|
||||
|
||||
if (!instConfig.exists())
|
||||
return NotAnInstance;
|
||||
|
||||
INIFile ini;
|
||||
ini.loadFile(instConfig.path());
|
||||
QString typeName = ini.get("type", "StdInstance").toString();
|
||||
const InstanceType *type = findType(typeName);
|
||||
|
||||
return loadInstance(inst, type, instDir);
|
||||
}
|
||||
|
||||
const InstanceType *InstanceLoader::findType(const QString &id)
|
||||
{
|
||||
if (!m_typeMap.contains(id))
|
||||
return NULL;
|
||||
else
|
||||
return m_typeMap[id];
|
||||
}
|
||||
|
||||
InstTypeList InstanceLoader::typeList()
|
||||
{
|
||||
InstTypeList typeList;
|
||||
|
||||
for (auto iter = m_typeMap.begin(); iter != m_typeMap.end(); iter++)
|
||||
{
|
||||
typeList.append(*iter);
|
||||
}
|
||||
|
||||
return typeList;
|
||||
}
|
@ -1,133 +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 INSTANCELOADER_H
|
||||
#define INSTANCELOADER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
|
||||
class InstanceType;
|
||||
class Instance;
|
||||
|
||||
typedef QList<const InstanceType *> InstTypeList;
|
||||
|
||||
/*!
|
||||
* \brief The InstanceLoader is a singleton that manages all of the instance types and handles loading and creating instances.
|
||||
* Instance types are registered with the instance loader through its registerInstType() function.
|
||||
* Creating instances is done through the InstanceLoader's createInstance() function. This function takes
|
||||
*/
|
||||
class InstanceLoader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static InstanceLoader 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.
|
||||
* - TypeIDExists is returned by registerInstanceType() if the ID of the type being registered already exists.
|
||||
* - TypeNotRegistered is returned by createInstance() and loadInstance() when the given type is not registered.
|
||||
* - 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.
|
||||
* - WrongInstType is returned by loadInstance() if the given instance directory's type doesn't match the given type.
|
||||
*/
|
||||
enum InstTypeError
|
||||
{
|
||||
NoError = 0,
|
||||
OtherError,
|
||||
|
||||
TypeIDExists,
|
||||
|
||||
TypeNotRegistered,
|
||||
InstExists,
|
||||
NotAnInstance,
|
||||
WrongInstType
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Registers the given InstanceType with the instance loader.
|
||||
* This causes the instance loader to take ownership of the given
|
||||
* instance type (meaning the instance type's parent will be set to
|
||||
* the instance loader).
|
||||
*
|
||||
* \param type The InstanceType to register.
|
||||
* \return An InstTypeError error code.
|
||||
* - TypeIDExists if the given type's is already registered to another instance type.
|
||||
*/
|
||||
InstTypeError registerInstanceType(InstanceType *type);
|
||||
|
||||
/*!
|
||||
* \brief Creates an instance with the given type and stores it in inst.
|
||||
*
|
||||
* \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 InstTypeError error code.
|
||||
* - TypeNotRegistered if the given type is not registered with the InstanceLoader.
|
||||
* - InstExists if the given instance directory is already an instance.
|
||||
*/
|
||||
InstTypeError createInstance(Instance *inst, const InstanceType *type, const QString &instDir);
|
||||
|
||||
/*!
|
||||
* \brief Loads an instance from the given directory.
|
||||
*
|
||||
* \param inst Pointer to store the loaded instance in.
|
||||
* \param type The type of instance to load.
|
||||
* \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 the same as the given type.
|
||||
*/
|
||||
InstTypeError loadInstance(Instance *inst, const InstanceType *type, 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 InstTypeError error code.
|
||||
* - TypeNotRegistered if the instance's type is not registered with the InstanceLoader.
|
||||
* - NotAnInstance if the given instance directory isn't a valid instance.
|
||||
*/
|
||||
InstTypeError loadInstance(Instance *inst, const QString &instDir);
|
||||
|
||||
/*!
|
||||
* \brief Finds an instance type with the given ID.
|
||||
* If one cannot be found, returns NULL.
|
||||
*
|
||||
* \param id The ID of the type to find.
|
||||
* \return The type with the given ID. NULL if none were found.
|
||||
*/
|
||||
const InstanceType *findType(const QString &id);
|
||||
|
||||
/*!
|
||||
* \brief Gets a list of the registered instance types.
|
||||
*
|
||||
* \return A list of instance types.
|
||||
*/
|
||||
InstTypeList typeList();
|
||||
|
||||
private:
|
||||
InstanceLoader();
|
||||
|
||||
QMap<QString, InstanceType *> m_typeMap;
|
||||
};
|
||||
|
||||
#endif // INSTANCELOADER_H
|
@ -1,21 +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.
|
||||
*/
|
||||
|
||||
#include "instancetype.h"
|
||||
|
||||
InstanceType::InstanceType(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
@ -1,83 +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"
|
||||
|
||||
/*!
|
||||
* \brief The InstanceType class is a base class for all instance types.
|
||||
* 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 InstanceType : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InstanceType(QObject *parent = 0);
|
||||
|
||||
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;
|
||||
|
||||
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::InstTypeError 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::InstTypeError loadInstance(Instance *inst, const QString &instDir) const = 0;
|
||||
};
|
||||
|
||||
#endif // INSTANCETYPE_H
|
@ -1,41 +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 INSTANCETYPEPLUGIN_H
|
||||
#define INSTANCETYPEPLUGIN_H
|
||||
|
||||
#include <QList>
|
||||
|
||||
#include "data/inst/instancetype.h"
|
||||
|
||||
/*!
|
||||
* \brief Interface for plugins that want to provide custom instance types.
|
||||
*/
|
||||
class InstanceTypePlugin
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Gets a QList containing the instance types that this plugin provides.
|
||||
* These instance types are then registered with the InstanceLoader.
|
||||
* The InstanceType objects should \e not be deleted by the plugin. Once they
|
||||
* are registered, they belong to the InstanceLoader.
|
||||
* \return A QList containing this plugin's instance types.
|
||||
*/
|
||||
virtual QList<InstanceType *> getInstanceTypes() = 0;
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(InstanceTypePlugin, "net.forkk.MultiMC.InstanceTypePlugin/0.1")
|
||||
|
||||
#endif // INSTANCETYPEPLUGIN_H
|
@ -18,10 +18,17 @@
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
#include <QVariant>
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
#include "data/plugin/instancetypeplugin.h"
|
||||
#include "instancetypeinterface.h"
|
||||
|
||||
// MultiMC's API version. This must match the "api" field in each plugin's
|
||||
// metadata or MultiMC won't consider them valid MultiMC plugin.
|
||||
#define MMC_API_VERSION "MultiMC5-API-1"
|
||||
|
||||
PluginManager PluginManager::manager;
|
||||
|
||||
@ -33,8 +40,16 @@ PluginManager::PluginManager() :
|
||||
|
||||
bool PluginManager::loadPlugins(QString pluginDir)
|
||||
{
|
||||
// Delete the loaded plugins and clear the list.
|
||||
for (int i = 0; i < m_plugins.count(); i++)
|
||||
{
|
||||
delete m_plugins[i];
|
||||
}
|
||||
m_plugins.clear();
|
||||
|
||||
qDebug(QString("Loading plugins from directory: %1").
|
||||
arg(pluginDir).toUtf8());
|
||||
|
||||
QDir dir(pluginDir);
|
||||
QDirIterator iter(dir);
|
||||
|
||||
@ -44,53 +59,47 @@ bool PluginManager::loadPlugins(QString pluginDir)
|
||||
|
||||
if (pluginFile.exists() && pluginFile.isFile())
|
||||
{
|
||||
QPluginLoader pluginLoader(pluginFile.absoluteFilePath());
|
||||
pluginLoader.load();
|
||||
QObject *plugin = pluginLoader.instance();
|
||||
if (plugin)
|
||||
{
|
||||
qDebug(QString("Loaded plugin %1.").
|
||||
arg(pluginFile.baseName()).toUtf8());
|
||||
m_plugins.push_back(plugin);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning(QString("Error loading plugin %1. Not a valid plugin.").
|
||||
arg(pluginFile.baseName()).toUtf8());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PluginManager::initInstanceTypes()
|
||||
{
|
||||
for (int i = 0; i < m_plugins.count(); i++)
|
||||
{
|
||||
InstanceTypePlugin *plugin = qobject_cast<InstanceTypePlugin *>(m_plugins[i]);
|
||||
if (plugin)
|
||||
{
|
||||
QList<InstanceType *> instanceTypes = plugin->getInstanceTypes();
|
||||
qDebug(QString("Attempting to load plugin: %1").
|
||||
arg(pluginFile.canonicalFilePath()).toUtf8());
|
||||
|
||||
for (int i = 0; i < instanceTypes.count(); i++)
|
||||
QPluginLoader *pluginLoader = new QPluginLoader(pluginFile.absoluteFilePath());
|
||||
|
||||
QJsonObject pluginInfo = pluginLoader->metaData();
|
||||
QJsonObject pluginMetadata = pluginInfo.value("MetaData").toObject();
|
||||
|
||||
if (pluginMetadata.value("api").toString("") != MMC_API_VERSION)
|
||||
{
|
||||
InstanceLoader::InstTypeError error =
|
||||
InstanceLoader::loader.registerInstanceType(instanceTypes[i]);
|
||||
switch (error)
|
||||
{
|
||||
case InstanceLoader::TypeIDExists:
|
||||
qWarning(QString("Instance type %1 already registered.").
|
||||
arg(instanceTypes[i]->typeID()).toUtf8());
|
||||
}
|
||||
// If "api" is not specified, it's not a MultiMC plugin.
|
||||
qDebug(QString("Not loading plugin %1. Not a valid MultiMC plugin. "
|
||||
"API: %2").
|
||||
arg(pluginFile.canonicalFilePath(), pluginMetadata.value("api").toString("")).toUtf8());
|
||||
continue;
|
||||
}
|
||||
|
||||
qDebug(QString("Loaded plugin: %1").
|
||||
arg(pluginInfo.value("IID").toString()).toUtf8());
|
||||
m_plugins.push_back(pluginLoader);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QObject *PluginManager::getPlugin(int index)
|
||||
QPluginLoader *PluginManager::getPlugin(int index)
|
||||
{
|
||||
return m_plugins[index];
|
||||
}
|
||||
|
||||
void PluginManager::initInstanceTypes()
|
||||
{
|
||||
for (int i = 0; i < m_plugins.count(); i++)
|
||||
{
|
||||
InstanceTypeInterface *instType = qobject_cast<InstanceTypeInterface *>(m_plugins[i]->instance());
|
||||
|
||||
if (instType)
|
||||
{
|
||||
// TODO: Handle errors
|
||||
InstanceLoader::get().registerInstanceType(instType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,12 +41,6 @@ public:
|
||||
*/
|
||||
bool loadPlugins(QString pluginDir);
|
||||
|
||||
/*!
|
||||
* \brief Initializes the instance type plugins.
|
||||
* \return True if successful. False on failure.
|
||||
*/
|
||||
bool initInstanceTypes();
|
||||
|
||||
/*!
|
||||
* \brief Checks how many plugins are loaded.
|
||||
* \return The number of plugins.
|
||||
@ -58,12 +52,19 @@ public:
|
||||
* \param index The index of the plugin to get.
|
||||
* \return The plugin at the given index.
|
||||
*/
|
||||
QObject *getPlugin(int index);
|
||||
QPluginLoader *getPlugin(int index);
|
||||
|
||||
/*!
|
||||
* \brief Initializes and registers all the instance types.
|
||||
* This is done by going through the plugin list and registering all of the
|
||||
* plugins that derive from the InstanceTypeInterface with the InstanceLoader.
|
||||
*/
|
||||
void initInstanceTypes();
|
||||
|
||||
private:
|
||||
PluginManager();
|
||||
|
||||
QList<QObject *> m_plugins;
|
||||
QList<QPluginLoader *> m_plugins;
|
||||
|
||||
static PluginManager manager;
|
||||
};
|
||||
|
130
data/siglist.h
130
data/siglist.h
@ -1,130 +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 SIGLIST_H
|
||||
#define SIGLIST_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
|
||||
// A QList that allows emitting signals when the list changes.
|
||||
// Since QObject doesn't support templates, to use this class with a
|
||||
// certain type, you should create a class deriving from SigList<T> and then
|
||||
// call the DEFINE_SIGLIST_SIGNALS(T) and SETUP_SIGLIST_SIGNALS(T) macros.
|
||||
template <typename T>
|
||||
class SigList : public QList<T>
|
||||
{
|
||||
|
||||
public:
|
||||
explicit SigList() : QList<T>() {}
|
||||
|
||||
virtual void append(const T &value);
|
||||
virtual void append(const QList<T> &other);
|
||||
|
||||
virtual void clear();
|
||||
|
||||
virtual void erase(iterator pos);
|
||||
virtual void erase(iterator first, iterator last);
|
||||
|
||||
virtual void insert(int i, const T &t);
|
||||
virtual void insert(iterator before, const T &t);
|
||||
|
||||
virtual void move(int from, int to);
|
||||
|
||||
virtual void pop_back() { takeLast(); }
|
||||
virtual void pop_front() { takeFirst(); }
|
||||
|
||||
virtual void push_back(const T &t) { append(t); }
|
||||
virtual void push_front(const T &t) { prepend(t); }
|
||||
|
||||
virtual void prepend(const T &t);
|
||||
|
||||
virtual int removeAll(const T &t);
|
||||
virtual bool removeOne(const T &t);
|
||||
|
||||
virtual void removeAt(int i) { takeAt(i); }
|
||||
virtual void removeFirst() { takeFirst(); }
|
||||
virtual void removeLast() { takeLast(); }
|
||||
|
||||
virtual void swap(QList<T> &other);
|
||||
virtual void swap(int i, int j);
|
||||
|
||||
virtual T takeAt(int i);
|
||||
virtual T takeFirst();
|
||||
virtual T takeLast();
|
||||
|
||||
virtual QList<T> &operator +=(const QList<T> &other) { append(other); return *this; }
|
||||
virtual QList<T> &operator +=(const T &value) { append(value); return *this; }
|
||||
virtual QList<T> &operator <<(const QList<T> &other) { append(other); return *this; }
|
||||
virtual QList<T> &operator <<(const T &value) { append(value); return *this; }
|
||||
|
||||
virtual QList<T> &operator =(const QList<T> &other);
|
||||
|
||||
|
||||
// Signal emitted after an item is added to the list.
|
||||
// Contains a reference to item and the item's new index.
|
||||
virtual void onItemAdded(const T &item, int index) = 0;
|
||||
|
||||
// Signal emitted after multiple items are added to the list at once.
|
||||
// The items parameter is a const reference to a QList of the items that
|
||||
// were added.
|
||||
// The firstIndex parameter is the new index of the first item added.
|
||||
virtual void onItemsAdded(const QList<T> &items, int firstIndex) = 0;
|
||||
|
||||
// Signal emitted after an item is removed to the list.
|
||||
// Contains a reference to the item and the item's old index.
|
||||
virtual void onItemRemoved(const T &item, int index) = 0;
|
||||
|
||||
// Signal emitted after multiple items are removed from the list at once.
|
||||
// The items parameter is a const reference to a QList of the items that
|
||||
// were added.
|
||||
// The firstIndex parameter is the new index of the first item added.
|
||||
virtual void onItemsRemoved(const QList<T> &items, int firstIndex) = 0;
|
||||
|
||||
// Signal emitted after an item is moved to another index.
|
||||
// Contains the item, the old index, and the new index.
|
||||
virtual void onItemMoved(const T &item, int oldIndex, int newIndex) = 0;
|
||||
|
||||
// Signal emitted after an operation that changes the whole list occurs.
|
||||
// This signal should be treated as if all data in the entire list was cleared
|
||||
// and new data added in its place.
|
||||
virtual void onInvalidated() = 0;
|
||||
};
|
||||
|
||||
// Defines the signals for a SigList
|
||||
#define DEFINE_SIGLIST_SIGNALS(TYPE) \
|
||||
Q_SIGNAL void itemAdded(TYPE const &item, int index);\
|
||||
Q_SIGNAL void itemsAdded(const QList<TYPE> &items, int firstIndex);\
|
||||
Q_SIGNAL void itemRemoved(TYPE const &item, int index);\
|
||||
Q_SIGNAL void itemsRemoved(const QList<TYPE> &items, int firstIndex);\
|
||||
Q_SIGNAL void itemMoved(TYPE const &item, int oldIndex, int newIndex);\
|
||||
Q_SIGNAL void invalidated();
|
||||
|
||||
// Overrides the onItem* functions and causes them to emit their corresponding
|
||||
// signals.
|
||||
#define SETUP_SIGLIST_SIGNALS(TYPE) \
|
||||
virtual void onItemAdded(TYPE const &item, int index)\
|
||||
{ emit itemAdded(item, index); }\
|
||||
virtual void onItemsAdded(const QList<TYPE> &items, int firstIndex)\
|
||||
{ emit itemsAdded(items, firstIndex); }\
|
||||
virtual void onItemRemoved(TYPE const &item, int index)\
|
||||
{ emit itemRemoved(item, index); }\
|
||||
virtual void onItemsRemoved(const QList<TYPE> &items, int firstIndex)\
|
||||
{ emit itemsRemoved(items, firstIndex); }\
|
||||
virtual void onItemMoved(TYPE const &item, int oldIndex, int newIndex)\
|
||||
{ emit itemMoved(item, oldIndex, newIndex); }\
|
||||
virtual void onInvalidated() { emit invalidated(); }
|
||||
|
||||
#endif // SIGLIST_H
|
@ -1,156 +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.
|
||||
*/
|
||||
|
||||
#include "siglist.h"
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::append(const T &value)
|
||||
{
|
||||
QList<T>::append(value);
|
||||
onItemAdded(value, length() - 1);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::prepend(const T &value)
|
||||
{
|
||||
QList<T>::prepend(value);
|
||||
onItemAdded(value, 0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::append(const QList<T> &other)
|
||||
{
|
||||
int index = length();
|
||||
QList<T>::append(other);
|
||||
onItemsAdded(other, index);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::clear()
|
||||
{
|
||||
QList<T>::clear();
|
||||
onInvalidated();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::erase(QList<T>::iterator pos)
|
||||
{
|
||||
T value = *pos;
|
||||
int index = indexOf(*pos);
|
||||
QList<T>::erase(pos);
|
||||
onItemRemoved(value, index);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::erase(QList<T>::iterator first, QList<T>::iterator last)
|
||||
{
|
||||
QList<T> removedValues;
|
||||
int firstIndex = indexOf(*first);
|
||||
|
||||
for (QList<T>::iterator iter = first; iter < last; iter++)
|
||||
{
|
||||
removedValues << *iter;
|
||||
QList<T>::erase(iter);
|
||||
}
|
||||
|
||||
onItemsRemoved(removedValues, firstIndex);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::insert(int i, const T &t)
|
||||
{
|
||||
QList<T>::insert(i, t);
|
||||
onItemAdded(t, i);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::insert(QList<T>::iterator before, const T &t)
|
||||
{
|
||||
QList<T>::insert(before, t);
|
||||
onItemAdded(t, indexOf(t));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::move(int from, int to)
|
||||
{
|
||||
const T &item = at(from);
|
||||
QList<T>::move(from, to);
|
||||
onItemMoved(item, from, to);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int SigList<T>::removeAll(const T &t)
|
||||
{
|
||||
int retVal = QList<T>::removeAll(t);
|
||||
onInvalidated();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool SigList<T>::removeOne(const T &t)
|
||||
{
|
||||
int index = indexOf(t);
|
||||
if (QList<T>::removeOne(t))
|
||||
{
|
||||
onItemRemoved(t, index);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::swap(QList<T> &other)
|
||||
{
|
||||
QList<T>::swap(other);
|
||||
onInvalidated();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SigList<T>::swap(int i, int j)
|
||||
{
|
||||
const T &item1 = at(i);
|
||||
const T &item2 = at(j);
|
||||
QList<T>::swap(i, j);
|
||||
onItemMoved(item1, i, j);
|
||||
onItemMoved(item2, j, i);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T SigList<T>::takeAt(int i)
|
||||
{
|
||||
T val = QList<T>::takeAt(i);
|
||||
onItemRemoved(val, i);
|
||||
return val;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T SigList<T>::takeFirst()
|
||||
{
|
||||
return takeAt(0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T SigList<T>::takeLast()
|
||||
{
|
||||
return takeAt(length() - 1);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QList<T> &SigList<T>::operator =(const QList<T> &other)
|
||||
{
|
||||
QList<T>::operator =(other);
|
||||
onInvalidated();
|
||||
return *this;
|
||||
}
|
@ -1,32 +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.
|
||||
*/
|
||||
|
||||
#include "instversion.h"
|
||||
#include "instversionlist.h"
|
||||
|
||||
InstVersion::InstVersion(InstVersionList *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
InstVersionList *InstVersion::versionList() const
|
||||
{
|
||||
// Parent should *always* be an InstVersionList
|
||||
if (!parent() || !parent()->inherits("InstVersionList"))
|
||||
return NULL;
|
||||
else
|
||||
return (InstVersionList *)parent();
|
||||
}
|
@ -1,51 +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 INSTVERSION_H
|
||||
#define INSTVERSION_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class InstVersionList;
|
||||
|
||||
class 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.
|
||||
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;
|
||||
|
||||
// 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.
|
||||
virtual QString type() const = 0;
|
||||
|
||||
// Returns the version list that this InstVersion is a part of.
|
||||
virtual InstVersionList *versionList() const;
|
||||
};
|
||||
|
||||
#endif // INSTVERSION_H
|
@ -1,21 +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.
|
||||
*/
|
||||
|
||||
#include "instversionlist.h"
|
||||
|
||||
InstVersionList::InstVersionList() :
|
||||
QObject(NULL)
|
||||
{
|
||||
}
|
@ -1,43 +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 INSTVERSIONLIST_H
|
||||
#define INSTVERSIONLIST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class InstVersion;
|
||||
|
||||
// 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.
|
||||
class InstVersionList : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InstVersionList();
|
||||
|
||||
// Reloads the version list.
|
||||
virtual void loadVersionList() = 0;
|
||||
|
||||
// Gets the version at the given index.
|
||||
virtual const InstVersion *at(int i) const = 0;
|
||||
|
||||
// Returns the number of versions in the list.
|
||||
virtual int count() const = 0;
|
||||
};
|
||||
|
||||
#endif // INSTVERSIONLIST_H
|
Reference in New Issue
Block a user