GH-1021 make builtin versions not customizable

They use attributes not defined in the OneSix format.
This commit is contained in:
Petr Mrázek 2015-05-31 19:24:39 +02:00
parent ff64b6cf1d
commit b9e06b5da0
3 changed files with 34 additions and 8 deletions

View File

@ -53,17 +53,29 @@ bool MinecraftVersion::isMinecraftVersion()
return true;
}
// 1. assume the local file is good. load, check. If it's good, apply.
// 2. if discrepancies are found, fall out and fail (impossible to apply incomplete version).
void MinecraftVersion::applyFileTo(MinecraftProfile *version)
{
if(m_versionSource == Local && getVersionFile())
{
getVersionFile()->applyTo(version);
}
else
{
throw VersionIncomplete(QObject::tr("Can't apply incomplete/builtin Minecraft version %1").arg(m_name));
}
}
QJsonDocument MinecraftVersion::toJson(bool saveOrder)
{
if(m_versionSource == Local && getVersionFile())
{
return getVersionFile()->toJson(saveOrder);
}
else
{
throw VersionIncomplete(QObject::tr("Can't write incomplete/builtin Minecraft version %1").arg(m_name));
}
}
VersionFilePtr MinecraftVersion::getVersionFile()
{
@ -76,6 +88,22 @@ VersionFilePtr MinecraftVersion::getVersionFile()
return loadedVersionFile;
}
bool MinecraftVersion::isCustomizable()
{
switch(m_versionSource)
{
case Local:
case Remote:
// locally cached file, or a remote file that we can acquire can be customized
return true;
case Builtin:
// builtins do not follow the normal OneSix format. They are not customizable.
default:
// Everything else is undefined and therefore not customizable.
return false;
}
return false;
}
void MinecraftVersion::applyTo(MinecraftProfile *version)
{

View File

@ -52,10 +52,7 @@ public: /* methods */
{
return false;
}
virtual bool isCustomizable() override
{
return true;
}
virtual bool isCustomizable() override;
virtual bool isRemovable() override
{
return false;

View File

@ -224,6 +224,7 @@ bool RawLibrary::filesExist(const QDir &base) const
}
return true;
}
QString RawLibrary::url() const
{
if (!m_absolute_url.isEmpty())