From 13b1b98f7cf8a3b3b2c15dd42f96537b02c00711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 3 Aug 2013 15:57:33 +0200 Subject: WTF, I don't even... --- backend/InstanceFactory.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'backend/InstanceFactory.cpp') diff --git a/backend/InstanceFactory.cpp b/backend/InstanceFactory.cpp index 318650ae..ee582d3f 100644 --- a/backend/InstanceFactory.cpp +++ b/backend/InstanceFactory.cpp @@ -19,8 +19,12 @@ #include #include "BaseInstance.h" +#include "LegacyInstance.h" +#include "OneSixInstance.h" #include "inifile.h" +#include +#include #include "pathutils.h" @@ -34,12 +38,25 @@ InstanceFactory::InstanceFactory() : InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst, const QString &instDir) { - BaseInstance *loadedInst = new BaseInstance(instDir, this); + auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg")); - // TODO: Sanity checks to verify that the instance is valid. + m_settings->registerSetting(new Setting("InstanceType", "Legacy")); - inst = loadedInst; + QString inst_type = m_settings->get("InstanceType").toString(); + //FIXME: replace with a map lookup, where instance classes register their types + if(inst_type == "Legacy") + { + inst = new LegacyInstance(instDir, m_settings, this); + } + else if(inst_type == "OneSix") + { + inst = new OneSixInstance(instDir, m_settings, this); + } + else + { + return InstanceFactory::UnknownLoadError; + } return NoLoadError; } @@ -53,8 +70,8 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *& { return InstanceFactory::CantCreateDir; } - - inst = new BaseInstance(instDir, this); + return InstanceFactory::UnknownCreateError; + //inst = new BaseInstance(instDir, this); //FIXME: really, how do you even know? return InstanceFactory::NoCreateError; -- cgit v1.2.3