NOISSUE Add NullInstance for instances that can't be loaded

This commit is contained in:
Petr Mrázek 2015-02-11 19:56:55 +01:00
parent d4d8cb4891
commit 234f57b8e6
3 changed files with 64 additions and 1 deletions

View File

@ -13,6 +13,7 @@ SET(LOGIC_SOURCES
BaseProcess.cpp
BaseInstance.h
BaseInstance.cpp
NullInstance.h
MMCError.h
# WARNING: globals live here

View File

@ -37,6 +37,7 @@
#include "minecraft/MinecraftVersion.h"
#include "settings/INISettingsObject.h"
#include "ftb/FTBPlugin.h"
#include "NullInstance.h"
const static int GROUP_FILE_FORMAT_VERSION = 1;
@ -454,7 +455,7 @@ InstanceList::loadInstance(InstancePtr &inst, const QString &instDir)
}
else
{
return InstanceList::UnknownLoadError;
inst.reset(new NullInstance(m_globalSettings, instanceSettings, instDir));
}
inst->init();
return NoLoadError;

61
logic/NullInstance.h Normal file
View File

@ -0,0 +1,61 @@
#include "BaseInstance.h"
class NullInstance: public BaseInstance
{
public:
NullInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir)
:BaseInstance(globalSettings, settings, rootDir)
{
setFlag(BaseInstance::VersionBrokenFlag);
}
virtual ~NullInstance() {};
virtual bool setIntendedVersionId(QString) override
{
return false;
}
virtual void cleanupAfterRun() override
{
}
virtual QString currentVersionId() const
{
return "Null";
};
virtual QString intendedVersionId() const
{
return "Null";
};
virtual void init() override
{
};
virtual QString getStatusbarDescription() override
{
return tr("Unknown instance type");
};
virtual bool shouldUpdate() const override
{
return false;
};
virtual QSet< QString > traits()
{
return {};
};
virtual QString instanceConfigFolder() const
{
return instanceRoot();
};
virtual BaseProcess* prepareForLaunch(AuthSessionPtr)
{
return nullptr;
}
virtual std::shared_ptr< Task > doUpdate()
{
return nullptr;
}
virtual void setShouldUpdate(bool)
{
};
virtual std::shared_ptr< BaseVersionList > versionList() const
{
return nullptr;
};
};