Minetest  5.4.0
texture_override.h
Go to the documentation of this file.
1 /*
2 Minetest
3 Copyright (C) 2020 Hugues Ross <hugues.ross@gmail.com>
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #pragma once
21 
22 #include "irrlichttypes.h"
23 #include <string>
24 #include <vector>
25 
26 typedef u16 override_t;
27 
30 {
31  INVALID = 0,
32  TOP = 1 << 0,
33  BOTTOM = 1 << 1,
34  LEFT = 1 << 2,
35  RIGHT = 1 << 3,
36  FRONT = 1 << 4,
37  BACK = 1 << 5,
38  INVENTORY = 1 << 6,
39  WIELD = 1 << 7,
40  SPECIAL_1 = 1 << 8,
41  SPECIAL_2 = 1 << 9,
42  SPECIAL_3 = 1 << 10,
43  SPECIAL_4 = 1 << 11,
44  SPECIAL_5 = 1 << 12,
45  SPECIAL_6 = 1 << 13,
46 
47  // clang-format off
48  SIDES = LEFT | RIGHT | FRONT | BACK,
49  ALL_FACES = TOP | BOTTOM | SIDES,
53  // clang-format on
54 };
55 
57 {
58  std::string id;
59  std::string texture;
61 
62  // Helper function for checking if an OverrideTarget is found in
63  // a TextureOverride without casting
64  inline bool hasTarget(OverrideTarget overrideTarget) const
65  {
66  return (target & static_cast<override_t>(overrideTarget)) != 0;
67  }
68 };
69 
72 {
73 public:
74  TextureOverrideSource(std::string filepath);
75 
77  std::vector<TextureOverride> getItemTextureOverrides();
78 
80  std::vector<TextureOverride> getNodeTileOverrides();
81 
82 private:
83  std::vector<TextureOverride> m_overrides;
84 };
Class that provides texture override information from a texture pack.
Definition: texture_override.h:72
TextureOverrideSource(std::string filepath)
Definition: texture_override.cpp:29
std::vector< TextureOverride > getItemTextureOverrides()
Get all overrides that apply to item definitions.
Definition: texture_override.cpp:111
std::vector< TextureOverride > getNodeTileOverrides()
Get all overrides that apply to node definitions.
Definition: texture_override.cpp:124
std::vector< TextureOverride > m_overrides
Definition: texture_override.h:83
Definition: texture_override.h:57
bool hasTarget(OverrideTarget overrideTarget) const
Definition: texture_override.h:64
std::string texture
Definition: texture_override.h:59
std::string id
Definition: texture_override.h:58
override_t target
Definition: texture_override.h:60
OverrideTarget
Bitmask enum specifying what a texture override should apply to.
Definition: texture_override.h:30
u16 override_t
Definition: texture_override.h:26