Fix FTB-related issues
This commit is contained in:
@ -174,6 +174,15 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(InstancePtr &newI
|
||||
return InstanceFactory::CantCreateDir;
|
||||
}
|
||||
|
||||
INISettingsObject settings_obj(PathCombine(instDir, "instance.cfg"));
|
||||
settings_obj.registerSetting("InstanceType", "Legacy");
|
||||
QString inst_type = settings_obj.get("InstanceType").toString();
|
||||
|
||||
if (inst_type == "OneSixFTB")
|
||||
settings_obj.set("InstanceType", "OneSix");
|
||||
if (inst_type == "LegacyFTB")
|
||||
settings_obj.set("InstanceType", "Legacy");
|
||||
|
||||
oldInstance->copy(instDir);
|
||||
|
||||
auto error = loadInstance(newInstance, instDir);
|
||||
@ -190,5 +199,4 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(InstancePtr &newI
|
||||
rootDir.removeRecursively();
|
||||
return UnknownCreateError;
|
||||
}
|
||||
return UnknownCreateError;
|
||||
}
|
||||
|
@ -320,6 +320,17 @@ bool OneSixInstance::versionIsCustom()
|
||||
|| QFile::exists(PathCombine(instanceRoot(), "user.json"));
|
||||
}
|
||||
|
||||
bool OneSixInstance::versionIsFTBPack()
|
||||
{
|
||||
I_D(const OneSixInstance);
|
||||
auto ver = d->version;
|
||||
if(ver)
|
||||
{
|
||||
return ver->hasFtbPack();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString OneSixInstance::currentVersionId() const
|
||||
{
|
||||
return intendedVersionId();
|
||||
|
@ -68,6 +68,8 @@ public:
|
||||
std::shared_ptr<VersionFinal> getVanillaVersion() const;
|
||||
/// is the current version original, or custom?
|
||||
virtual bool versionIsCustom() override;
|
||||
/// does this instance have an FTB pack patch inside?
|
||||
bool versionIsFTBPack();
|
||||
|
||||
virtual QString defaultBaseJar() const override;
|
||||
virtual QString defaultCustomBaseJar() const override;
|
||||
|
@ -70,6 +70,7 @@ bool VersionFinal::canRemove(const int index) const
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VersionFinal::remove(const int index)
|
||||
{
|
||||
if (canRemove(index) && QFile::remove(versionFiles.at(index)->filename))
|
||||
@ -83,6 +84,20 @@ bool VersionFinal::remove(const int index)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VersionFinal::remove(const QString id)
|
||||
{
|
||||
int i = 0;
|
||||
for (auto file : versionFiles)
|
||||
{
|
||||
if (file->fileId == id)
|
||||
{
|
||||
return remove(i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString VersionFinal::versionFileId(const int index) const
|
||||
{
|
||||
if (index < 0 || index >= versionFiles.size())
|
||||
@ -91,6 +106,7 @@ QString VersionFinal::versionFileId(const int index) const
|
||||
}
|
||||
return versionFiles.at(index)->fileId;
|
||||
}
|
||||
|
||||
VersionFilePtr VersionFinal::versionFile(const QString &id)
|
||||
{
|
||||
for (auto file : versionFiles)
|
||||
@ -103,6 +119,16 @@ VersionFilePtr VersionFinal::versionFile(const QString &id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VersionFinal::hasFtbPack()
|
||||
{
|
||||
return versionFile("org.multimc.ftb.pack.json") != nullptr;
|
||||
}
|
||||
|
||||
bool VersionFinal::removeFtbPack()
|
||||
{
|
||||
return remove("org.multimc.ftb.pack.json");
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<OneSixLibrary> > VersionFinal::getActiveNormalLibs()
|
||||
{
|
||||
QList<std::shared_ptr<OneSixLibrary> > output;
|
||||
|
@ -49,6 +49,11 @@ public:
|
||||
bool isCustom();
|
||||
// remove custom.json
|
||||
bool revertToBase();
|
||||
// does this instance have an FTB pack patch file?
|
||||
bool hasFtbPack();
|
||||
// remove FTB pack
|
||||
bool removeFtbPack();
|
||||
|
||||
|
||||
enum MoveDirection { MoveUp, MoveDown };
|
||||
void move(const int index, const MoveDirection direction);
|
||||
@ -61,6 +66,7 @@ public:
|
||||
public
|
||||
slots:
|
||||
bool remove(const int index);
|
||||
bool remove(const QString id);
|
||||
|
||||
public:
|
||||
QList<std::shared_ptr<OneSixLibrary>> getActiveNormalLibs();
|
||||
|
Reference in New Issue
Block a user