diff options
author | Andrew <forkk@forkk.net> | 2013-02-20 19:45:00 -0600 |
---|---|---|
committer | Andrew <forkk@forkk.net> | 2013-02-20 19:45:00 -0600 |
commit | f3b6eeeac4e1606a288c7f12fec271fbb7f120f6 (patch) | |
tree | 50885f4302d1df8386716df9423fcd3c529010ee /plugins | |
parent | dd2e836b4cf4cfa043f9ea2911f58f1d22d4e282 (diff) | |
download | MultiMC-f3b6eeeac4e1606a288c7f12fec271fbb7f120f6.tar MultiMC-f3b6eeeac4e1606a288c7f12fec271fbb7f120f6.tar.gz MultiMC-f3b6eeeac4e1606a288c7f12fec271fbb7f120f6.tar.lz MultiMC-f3b6eeeac4e1606a288c7f12fec271fbb7f120f6.tar.xz MultiMC-f3b6eeeac4e1606a288c7f12fec271fbb7f120f6.zip |
Got instance loading working.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/stdinstance/stdinstancetype.cpp | 28 | ||||
-rw-r--r-- | plugins/stdinstance/stdinstancetype.h | 4 |
2 files changed, 28 insertions, 4 deletions
diff --git a/plugins/stdinstance/stdinstancetype.cpp b/plugins/stdinstance/stdinstancetype.cpp index 9b7aa994..5a3a6649 100644 --- a/plugins/stdinstance/stdinstancetype.cpp +++ b/plugins/stdinstance/stdinstancetype.cpp @@ -15,20 +15,44 @@ #include "stdinstancetype.h" +#include <QDir> +#include <QFileInfo> + +#include "stdinstance.h" + StdInstanceType::StdInstanceType(QObject *parent) : QObject(parent) { } -InstanceLoader::InstTypeError StdInstanceType::createInstance(Instance *inst, +InstanceLoader::InstTypeError StdInstanceType::createInstance(Instance *&inst, const QString &instDir) const { + QFileInfo rootDir(instDir); + + if (!rootDir.exists() && !QDir().mkdir(rootDir.path())) + { + return InstanceLoader::CantCreateDir; + } + + StdInstance *stdInst = new StdInstance(instDir); + + // TODO: Verify that the instance is valid. + + inst = stdInst; + return InstanceLoader::NoError; } -InstanceLoader::InstTypeError StdInstanceType::loadInstance(Instance *inst, +InstanceLoader::InstTypeError StdInstanceType::loadInstance(Instance *&inst, const QString &instDir) const { + StdInstance *stdInst = new StdInstance(instDir); + + // TODO: Verify that the instance is valid. + + inst = stdInst; + return InstanceLoader::NoError; } diff --git a/plugins/stdinstance/stdinstancetype.h b/plugins/stdinstance/stdinstancetype.h index 4f659ba7..b8382a97 100644 --- a/plugins/stdinstance/stdinstancetype.h +++ b/plugins/stdinstance/stdinstancetype.h @@ -34,9 +34,9 @@ public: virtual QString description() const { return "A standard Minecraft instance."; } - virtual InstanceLoader::InstTypeError createInstance(Instance *inst, const QString &instDir) const; + virtual InstanceLoader::InstTypeError createInstance(Instance *&inst, const QString &instDir) const; - virtual InstanceLoader::InstTypeError loadInstance(Instance *inst, const QString &instDir) const; + virtual InstanceLoader::InstTypeError loadInstance(Instance *&inst, const QString &instDir) const; }; #endif // STDINSTANCETYPE_H |