diff options
author | Hugues Ross <hugues.ross@gmail.com> | 2020-04-14 14:41:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-14 20:41:29 +0200 |
commit | 5cf6318117edcae6bf30d829d9e9dd9dbf1d4bf7 (patch) | |
tree | de590965f9f1cf68a4b6ee7ca802aaa5c0b987ee /src/itemdef.cpp | |
parent | 7e21b3cd4883eb8b9eb7e9ca49e50f6f0c7bc0d6 (diff) | |
download | minetest-5cf6318117edcae6bf30d829d9e9dd9dbf1d4bf7.tar.gz minetest-5cf6318117edcae6bf30d829d9e9dd9dbf1d4bf7.tar.bz2 minetest-5cf6318117edcae6bf30d829d9e9dd9dbf1d4bf7.zip |
Refactor texture overrides and add new features (#9600)
* Refactor texture overrides, and add new features:
- Texture overrides can support multiple targets in one line
- Texture override files can have comment lines
- Item images/wield images can be overridden
* Formatting changes
* Address soime feedback
- Pass vectors by const reference
- Log syntax errors as warnings
- Remove 'C' prefix from TextureOverrideSource
* Simplify override target checks with an inline helper function
* make linter happy
* Apply feedback suggestions
Co-Authored-By: rubenwardy <rw@rubenwardy.com>
* Remove remaining != 0 checks
* Update copyright notice
Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: rubenwardy <rw@rubenwardy.com>
Diffstat (limited to 'src/itemdef.cpp')
-rw-r--r-- | src/itemdef.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/itemdef.cpp b/src/itemdef.cpp index ba7bd6a0b..a13b3f7d4 100644 --- a/src/itemdef.cpp +++ b/src/itemdef.cpp @@ -422,6 +422,25 @@ public: return get(stack.name).color; } #endif + void applyTextureOverrides(const std::vector<TextureOverride> &overrides) + { + infostream << "ItemDefManager::applyTextureOverrides(): Applying " + "overrides to textures" << std::endl; + + for (const TextureOverride& texture_override : overrides) { + if (m_item_definitions.find(texture_override.id) == m_item_definitions.end()) { + continue; // Ignore unknown item + } + + ItemDefinition* itemdef = m_item_definitions[texture_override.id]; + + if (texture_override.hasTarget(OverrideTarget::INVENTORY)) + itemdef->inventory_image = texture_override.texture; + + if (texture_override.hasTarget(OverrideTarget::WIELD)) + itemdef->wield_image = texture_override.texture; + } + } void clear() { for(std::map<std::string, ItemDefinition*>::const_iterator |