1 // _________ __ __ 2 // / _____// |_____________ _/ |______ ____ __ __ ______ 3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 6 // \/ \/ \//_____/ \/ 7 // ______________________ ______________________ 8 // T H E W A R B E G I N S 9 // Stratagus - A free fantasy real time strategy game engine 10 // 11 /**@name construct.h - The constructions headerfile. */ 12 // 13 // (c) Copyright 1998-2006 by Lutz Sammer and Jimmy Salmon 14 // 15 // This program is free software; you can redistribute it and/or modify 16 // it under the terms of the GNU General Public License as published by 17 // the Free Software Foundation; only version 2 of the License. 18 // 19 // This program is distributed in the hope that it will be useful, 20 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 // GNU General Public License for more details. 23 // 24 // You should have received a copy of the GNU General Public License 25 // along with this program; if not, write to the Free Software 26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 27 // 02111-1307, USA. 28 // 29 30 #ifndef __CONSTRUCT_H__ 31 #define __CONSTRUCT_H__ 32 33 //@{ 34 35 /*---------------------------------------------------------------------------- 36 -- Documentation 37 ----------------------------------------------------------------------------*/ 38 39 /** 40 ** @class CConstruction construct.h 41 ** 42 ** \#include "construct.h" 43 ** 44 ** Each building perhaps also units can have its own construction 45 ** frames. This construction frames are currently not animated, 46 ** this is planned for the future. What construction frames a 47 ** building has, is handled by UnitType::Construction. 48 ** 49 ** The construction structure members: 50 ** 51 ** CConstruction::Ident 52 ** 53 ** Unique identifier of the construction, used to reference it in 54 ** the config files and during startup. As convention they start 55 ** with "construction-" fe. "construction-land". 56 ** @note Don't use this member in game, use instead the pointer 57 ** to this structure. See ConstructionByIdent(). 58 ** 59 ** CConstruction::File 60 ** 61 ** Path file name of the sprite file. 62 ** 63 ** CConstruction::ShadowFile 64 ** 65 ** Path file name of shadow sprite file. 66 ** 67 ** CConstruction::Frames 68 ** 69 ** Frames of the construction sequence. 70 ** 71 ** CConstruction::Sprite 72 ** 73 ** Sprite image. 74 ** 75 ** CConstruction::Width CConstruction::Height 76 ** 77 ** Size of a sprite frame in pixels. All frames of a sprite have 78 ** the same size. Also all sprites (tilesets) must have the same 79 ** size. 80 ** 81 ** CConstruction::ShadowSprite 82 ** 83 ** Shadow sprite image. 84 ** 85 ** CConstruction::ShadowWidth CConstruction::ShadowHeight 86 ** 87 ** Size of a shadow sprite frame in pixels. All frames of a sprite 88 ** have the same size. Also all sprites (tilesets) must have the 89 ** same size. 90 ** 91 ** @todo 92 ** Need ::TilesetByName, ... 93 ** Only fixed number of constructions supported, more than 94 ** a single construction frame is not supported, animated 95 ** constructions aren't supported. 96 */ 97 98 /*---------------------------------------------------------------------------- 99 -- Declarations 100 ----------------------------------------------------------------------------*/ 101 102 class CGraphic; 103 class CPlayerColorGraphic; 104 105 106 enum ConstructionFileType { 107 ConstructionFileConstruction, 108 ConstructionFileMain 109 }; 110 111 /// Construction frame 112 class CConstructionFrame 113 { 114 public: CConstructionFrame()115 CConstructionFrame() : Percent(0), File(ConstructionFileConstruction), 116 Frame(0), Next(nullptr) {} 117 118 int Percent; /// Percent complete 119 ConstructionFileType File; /// Graphic to use 120 int Frame; /// Frame number 121 CConstructionFrame *Next; /// Next pointer 122 }; 123 124 /// Construction shown during construction of a building 125 class CConstruction 126 { 127 public: CConstruction()128 CConstruction() : Frames(nullptr), Sprite(nullptr), Width(0), 129 Height(0), ShadowSprite(nullptr), ShadowWidth(0), ShadowHeight(0) 130 { 131 File.Width = 0; 132 File.Height = 0; 133 ShadowFile.Width = 0; 134 ShadowFile.Height = 0; 135 } 136 ~CConstruction(); 137 void Clean(); 138 void Load(); 139 140 public: 141 std::string Ident; /// construction identifier 142 struct { 143 std::string File;/// sprite file 144 int Width; /// sprite width 145 int Height; /// sprite height 146 } File, ShadowFile; 147 CConstructionFrame *Frames; /// construction frames 148 149 // --- FILLED UP --- 150 151 CPlayerColorGraphic *Sprite;/// construction sprite image 152 int Width; /// sprite width 153 int Height; /// sprite height 154 CGraphic *ShadowSprite; /// construction shadow sprite image 155 int ShadowWidth; /// shadow sprite width 156 int ShadowHeight; /// shadow sprite height 157 }; 158 159 /*---------------------------------------------------------------------------- 160 -- Macros 161 ----------------------------------------------------------------------------*/ 162 163 /*---------------------------------------------------------------------------- 164 -- Variables 165 ----------------------------------------------------------------------------*/ 166 167 /*---------------------------------------------------------------------------- 168 -- Functions 169 ----------------------------------------------------------------------------*/ 170 171 /// Initialize the constructions module 172 extern void InitConstructions(); 173 /// Load the graphics for constructions 174 extern void LoadConstructions(); 175 /// Count the amount of constructions to load 176 extern int GetConstructionsCount(); 177 /// Clean up the constructions module 178 extern void CleanConstructions(); 179 /// Get construction by identifier 180 extern CConstruction *ConstructionByIdent(const std::string &ident); 181 182 /// Register ccl features 183 extern void ConstructionCclRegister(); 184 185 //@} 186 187 #endif // !__CONSTRUCT_H__ 188