LCOV - code coverage report
Current view: top level - source/graphics - TerrainProperties.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 7 0.0 %
Date: 2023-01-19 00:18:29 Functions: 0 4 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2022 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 <memory>
      31             : 
      32             : #include "ps/CStr.h"
      33             : #include "lib/file/vfs/vfs_path.h"
      34             : 
      35             : class CTerrainGroup;
      36             : class XMBElement;
      37             : class CXeromyces;
      38             : class CTerrainProperties;
      39             : 
      40             : typedef std::shared_ptr<CTerrainProperties> CTerrainPropertiesPtr;
      41             : 
      42           0 : class CTerrainProperties
      43             : {
      44             : public:
      45             :     typedef std::vector<CTerrainGroup *> GroupVector;
      46             : 
      47             : private:
      48             :     CTerrainPropertiesPtr m_pParent;
      49             : 
      50             :     // BGRA color of topmost mipmap level, for coloring minimap, or a color
      51             :     // manually specified in the Terrain XML (or by any parent)
      52             :     // ..Valid is true if the base color is specified in this terrain XML
      53             :     // No caching here, since ideally, a saved XML file of an object should
      54             :     // produce be equivalent to the source file
      55             :     u32 m_BaseColor;
      56             :     bool m_HasBaseColor;
      57             : 
      58             :     // Orientation of texture (in radians) (default pi/4 = 45 degrees)
      59             :     float m_TextureAngle;
      60             : 
      61             :     // Size of texture in metres (default 32m = 8 tiles)
      62             :     float m_TextureSize;
      63             : 
      64             :     // All terrain type groups we're a member of
      65             :     GroupVector m_Groups;
      66             : 
      67             : public:
      68             :     CTerrainProperties(CTerrainPropertiesPtr parent);
      69             : 
      70             :     // Create a new object and load the XML file specified. Returns NULL upon
      71             :     // failure
      72             :     // The parent pointer may be NULL, for the "root" terrainproperties object.
      73             :     static CTerrainPropertiesPtr FromXML(const CTerrainPropertiesPtr& parent, const VfsPath& pathname);
      74             : 
      75             :     void LoadXml(XMBElement node, CXeromyces *pFile, const VfsPath& pathname);
      76             : 
      77             :     // Save the object to an XML file. Implement when needed! ;-)
      78             :     // bool WriteXML(const CStr& path);
      79             : 
      80             :     inline CTerrainPropertiesPtr GetParent() const
      81             :     {
      82             :         return m_pParent;
      83             :     }
      84             : 
      85             :     // Return true if this property object or any of its parents has a basecolor
      86             :     // override (mmap attribute in the XML file)
      87             :     bool HasBaseColor();
      88             :     // Return the minimap color specified in this property object or in any of
      89             :     // its parents. If no minimap color is specified, return garbage.
      90             :     // Use HasBaseColor() to see if the value is valid.
      91             :     // The color value is in BGRA format
      92             :     u32 GetBaseColor();
      93             : 
      94           0 :     float GetTextureAngle()
      95             :     {
      96           0 :         return m_TextureAngle;
      97             :     }
      98             : 
      99           0 :     float GetTextureSize()
     100             :     {
     101           0 :         return m_TextureSize;
     102             :     }
     103             : 
     104           0 :     const GroupVector &GetGroups() const
     105             :     {
     106           0 :         return m_Groups;
     107             :     }
     108             : };
     109             : 
     110             : #endif

Generated by: LCOV version 1.13