Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TerrainProperties.h
Go to the documentation of this file.
1 /* Copyright (C) 2012 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19 ///////////////////////////////////////////////
20  CTerrainProperties
21 
22  Basically represents a set of terrain attributes loaded from XML. These
23  objects are organized in an inheritance tree, determined at load time.
24 
25 */
26 
27 #ifndef INCLUDED_TERRAINPROPERTIES
28 #define INCLUDED_TERRAINPROPERTIES
29 
30 #include "ps/CStr.h"
31 #include "lib/file/vfs/vfs_path.h"
32 #include <boost/shared_ptr.hpp>
33 
34 class CTerrainGroup;
35 class XMBElement;
36 class CXeromyces;
38 
39 typedef shared_ptr<CTerrainProperties> CTerrainPropertiesPtr;
40 
42 {
43 public:
44  typedef std::vector<CTerrainGroup *> GroupVector;
45 
46 private:
48 
49  // BGRA color of topmost mipmap level, for coloring minimap, or a color
50  // manually specified in the Terrain XML (or by any parent)
51  // ..Valid is true if the base color is specified in this terrain XML
52  // No caching here, since ideally, a saved XML file of an object should
53  // produce be equivalent to the source file
56 
58 
59  // Orientation of texture (in radians) (default pi/4 = 45 degrees)
61 
62  // Size of texture in metres (default 32m = 8 tiles)
64 
65  // All terrain type groups we're a member of
67 
68 public:
70 
71  // Create a new object and load the XML file specified. Returns NULL upon
72  // failure
73  // The parent pointer may be NULL, for the "root" terrainproperties object.
74  static CTerrainPropertiesPtr FromXML(const CTerrainPropertiesPtr& parent, const VfsPath& pathname);
75 
76  void LoadXml(XMBElement node, CXeromyces *pFile, const VfsPath& pathname);
77 
78  // Save the object to an XML file. Implement when needed! ;-)
79  // bool WriteXML(const CStr& path);
80 
82  {
83  return m_pParent;
84  }
85 
86  // Return true if this property object or any of its parents has a basecolor
87  // override (mmap attribute in the XML file)
88  bool HasBaseColor();
89  // Return the minimap color specified in this property object or in any of
90  // its parents. If no minimap color is specified, return garbage.
91  // Use HasBaseColor() to see if the value is valid.
92  // The color value is in BGRA format
93  u32 GetBaseColor();
94 
96  {
97  return m_TextureAngle;
98  }
99 
101  {
102  return m_TextureSize;
103  }
104 
105  CStr GetMovementClass() const
106  {
107  return m_MovementClass;
108  }
109 
110  const GroupVector &GetGroups() const
111  {
112  return m_Groups;
113  }
114 };
115 
116 #endif
shared_ptr< CTerrainProperties > CTerrainPropertiesPtr
CTerrainPropertiesPtr m_pParent
std::vector< CTerrainGroup * > GroupVector
void LoadXml(XMBElement node, CXeromyces *pFile, const VfsPath &pathname)
static CTerrainPropertiesPtr FromXML(const CTerrainPropertiesPtr &parent, const VfsPath &pathname)
CTerrainProperties(CTerrainPropertiesPtr parent)
Definition: path.h:75
#define u32
Definition: types.h:41
CStr GetMovementClass() const
const GroupVector & GetGroups() const
CTerrainPropertiesPtr GetParent() const