$treeview $search $mathjax
Stratagus
2.2.6
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 // _________ __ __ 00002 // / _____// |_____________ _/ |______ ____ __ __ ______ 00003 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 00004 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 00005 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 00006 // \/ \/ \//_____/ \/ 00007 // ______________________ ______________________ 00008 // T H E W A R B E G I N S 00009 // Stratagus - A free fantasy real time strategy game engine 00010 // 00012 // 00013 // (c) Copyright 2005-2007 by Jimmy Salmon 00014 // 00015 // This program is free software; you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation; only version 2 of the License. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00029 00030 #ifndef __ANIMATIONS_H__ 00031 #define __ANIMATIONS_H__ 00032 00034 00035 #include <string> 00036 #include <map> 00037 00038 #define ANIMATIONS_MAXANIM 1024 00039 #define ANIMATIONS_DEATHTYPES 40 00040 00041 /*---------------------------------------------------------------------------- 00042 -- Declarations 00043 ----------------------------------------------------------------------------*/ 00044 00048 extern std::string ExtraDeathTypes[ANIMATIONS_DEATHTYPES]; 00049 00050 enum AnimationType { 00051 AnimationNone, 00052 AnimationFrame, 00053 AnimationExactFrame, 00054 AnimationWait, 00055 AnimationRandomWait, 00056 AnimationSound, 00057 AnimationRandomSound, 00058 AnimationAttack, 00059 AnimationRotate, 00060 AnimationRandomRotate, 00061 AnimationMove, 00062 AnimationUnbreakable, 00063 AnimationLabel, 00064 AnimationGoto, 00065 AnimationRandomGoto, 00066 AnimationSpawnMissile 00067 }; 00068 00069 class CAnimation { 00070 public: 00071 CAnimation() : Type(AnimationNone), Next(NULL) { 00072 memset(&D, 0, sizeof(D)); 00073 } 00074 00075 ~CAnimation() { 00076 if (Type == AnimationSound) 00077 delete[] D.Sound.Name; 00078 else if (Type == AnimationSpawnMissile) 00079 delete[] D.SpawnMissile.Missile; 00080 else if (Type == AnimationRandomSound) { 00081 for (unsigned int i = 0; i < D.RandomSound.NumSounds; ++i) { 00082 delete[] D.RandomSound.Name[i]; 00083 } 00084 delete[] D.RandomSound.Name; 00085 delete[] D.RandomSound.Sound; 00086 } 00087 } 00088 00089 AnimationType Type; 00090 union { 00091 struct { 00092 int Frame; 00093 } Frame; 00094 struct { 00095 int Wait; 00096 } Wait; 00097 struct { 00098 int MinWait; 00099 int MaxWait; 00100 } RandomWait; 00101 struct { 00102 const char *Name; 00103 CSound *Sound; 00104 } Sound; 00105 struct { 00106 const char **Name; 00107 CSound **Sound; 00108 unsigned int NumSounds; 00109 } RandomSound; 00110 struct { 00111 int Rotate; 00112 } Rotate; 00113 struct { 00114 int Move; 00115 } Move; 00116 struct { 00117 int Begin; 00118 } Unbreakable; 00119 struct { 00120 CAnimation *Goto; 00121 } Goto; 00122 struct { 00123 int Random; 00124 CAnimation *Goto; 00125 } RandomGoto; 00126 struct { 00127 const char *Missile; 00128 } SpawnMissile; 00129 } D; 00130 CAnimation *Next; 00131 }; 00132 00133 class CAnimations { 00134 public: 00135 CAnimations() : Start(NULL), 00136 Repair(NULL), Train(NULL), Research(NULL), 00137 Upgrade(NULL), Build(NULL) 00138 { 00139 memset(Still, 0, sizeof(Still)); 00140 memset(Move, 0, sizeof(Move)); 00141 memset(Attack, 0, sizeof(Attack)); 00142 memset(Harvest, 0, sizeof(Harvest)); 00143 memset(Death, 0, sizeof(Death)); 00144 } 00145 00146 ~CAnimations() { 00147 delete[] Start; 00148 delete[] Repair; 00149 delete[] Train; 00150 delete[] Research; 00151 delete[] Upgrade; 00152 delete[] Build; 00153 for ( int i = 0; i< MaxCosts; ++i) { 00154 delete[] Harvest[i]; 00155 } 00156 for ( int i = 0; i< ANIMATIONS_DEATHTYPES+1; ++i) { 00157 delete[] Death[i]; 00158 } 00159 for ( int i = 0; i< 100; ++i) { 00160 delete[] Still[i]; 00161 delete[] Move[i]; 00162 delete[] Attack[i]; 00163 } 00164 00165 } 00166 00167 CAnimation *Start; 00168 CAnimation *Still[100]; 00169 CAnimation *Death[ANIMATIONS_DEATHTYPES+1]; 00170 CAnimation *Attack[100]; 00171 CAnimation *Move[100]; 00172 CAnimation *Repair; 00173 CAnimation *Train; 00174 CAnimation *Research; 00175 CAnimation *Upgrade; 00176 CAnimation *Build; 00177 CAnimation *Harvest[MaxCosts]; 00178 }; 00179 00180 00181 00182 00183 extern CAnimation *AnimationsArray[ANIMATIONS_MAXANIM]; 00184 extern int NumAnimations; 00185 00187 extern std::map<std::string, CAnimations *> AnimationMap; 00188 00189 00190 /*---------------------------------------------------------------------------- 00191 -- Functions 00192 ----------------------------------------------------------------------------*/ 00193 00195 extern CAnimations *AnimationsByIdent(const std::string &ident); 00196 00197 00199 00200 #endif // !__ANIMATIONS_H__