Skip to content

Commit

Permalink
Refactor|Material: Relocated is-autogenerated classification to Mater…
Browse files Browse the repository at this point in the history
…ialManifest

This classification now belongs at manifest level.
  • Loading branch information
danij-deng committed Jan 23, 2013
1 parent 28425ef commit 83087c6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
3 changes: 0 additions & 3 deletions doomsday/client/include/resource/material.h
Expand Up @@ -455,9 +455,6 @@ class Material : public de::MapElement
/// Returns @c true if the material has at least one animated layer.
bool isAnimated() const;

/// Returns @c true if the material is marked as "autogenerated".
bool isAutoGenerated() const;

/// Returns @c true if the material has one or more (light) decorations.
/// Equivalent to @code decorationCount() != 0; @endcode, for convenience.
inline bool isDecorated() const { return decorationCount() != 0; }
Expand Down
7 changes: 6 additions & 1 deletion doomsday/client/include/resource/materialmanifest.h
Expand Up @@ -75,7 +75,12 @@ class MaterialManifest : public PathTree::Node

void setId(materialid_t newId);

/// @return @c true if the manifest is not derived from an original game resource.
/// @c true if the manifest was automatically produced for a game/add-on resource.
bool isAutoGenerated() const;

void setAutoGenerated(bool yes);

/// @c true if the manifest was not produced for an original game resource.
bool isCustom() const;

void setCustom(bool yes);
Expand Down
3 changes: 2 additions & 1 deletion doomsday/client/src/def_main.cpp
Expand Up @@ -1031,7 +1031,8 @@ static void updateMaterialFromDef(Material &material, ded_material_t &def)
material.setDimensions(QSize(def.width, def.height));
material.setAudioEnvironment(S_AudioEnvironmentForMaterial(def.uri));

// Update custom status.
// Update manifest classification.
manifest.setAutoGenerated(def.autoGenerated);
/// @todo This should take into account the whole definition, not just whether
/// the primary layer's first texture is custom or not.
manifest.setCustom(false);
Expand Down
6 changes: 0 additions & 6 deletions doomsday/client/src/resource/material.cpp
Expand Up @@ -256,12 +256,6 @@ bool Material::isAnimated() const
return false; // Not at all.
}

bool Material::isAutoGenerated() const
{
/// @todo fixme: We should not need a definition to determine this.
return (d->def && d->def->autoGenerated);
}

bool Material::isDetailed() const
{
/// @todo fixme: Determine this from our own configuration.
Expand Down
23 changes: 17 additions & 6 deletions doomsday/client/src/resource/materialmanifest.cpp
Expand Up @@ -37,10 +37,13 @@ struct MaterialManifest::Instance
/// Unique identifier.
materialid_t id;

/// @c true if the material is not derived from an original game resource.
/// @c true if the manifest was automatically produced for a game/add-on resource.
bool isAutoGenerated;

/// @c true if the manifest was not produced for an original game resource.
bool isCustom;

Instance() : material(0), id(0), isCustom(false)
Instance() : material(0), id(0), isAutoGenerated(false), isCustom(false)
{}
};

Expand All @@ -65,6 +68,11 @@ void MaterialManifest::setId(materialid_t id)
d->id = id;
}

void MaterialManifest::setAutoGenerated(bool yes)
{
d->isAutoGenerated = yes;
}

void MaterialManifest::setCustom(bool yes)
{
d->isCustom = yes;
Expand Down Expand Up @@ -98,10 +106,8 @@ Uri MaterialManifest::composeUri(QChar sep) const

String MaterialManifest::sourceDescription() const
{
/// @todo We should not need a material to determine this.
if(!d->material || !d->material->isValid()) return "unknown";
if(!isCustom()) return "game";
if(d->material->isAutoGenerated()) return "add-on"; // Unintuitive but correct.
if(!d->isCustom) return "game";
if(d->isAutoGenerated) return "add-on"; // Unintuitive but correct.
return "def";
}

Expand All @@ -110,6 +116,11 @@ materialid_t MaterialManifest::id() const
return d->id;
}

bool MaterialManifest::isAutoGenerated() const
{
return d->isAutoGenerated;
}

bool MaterialManifest::isCustom() const
{
return d->isCustom;
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/src/resource/materials.cpp
Expand Up @@ -524,6 +524,7 @@ Material *Materials::newFromDef(ded_material_t &def)
{
manifest = &newManifest(scheme(uri.scheme()), uri.path());
}
manifest->setAutoGenerated(CPP_BOOL(def.autoGenerated));
manifest->setCustom(tex->flags().testFlag(Texture::Custom));

// Create a material for this right away.
Expand Down

0 comments on commit 83087c6

Please sign in to comment.