_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

animation.h
Go to the documentation of this file.
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 //
12 //
13 // (c) Copyright 2005-2007 by 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 __ANIMATIONS_H__
31 #define __ANIMATIONS_H__
32 
34 
35 #include <string>
36 #include <map>
37 
38 #include "upgrade_structs.h" // MaxCost
39 #define ANIMATIONS_DEATHTYPES 40
40 
41 class CFile;
42 class CUnit;
43 struct lua_State;
44 
45 /*----------------------------------------------------------------------------
46 -- Declarations
47 ----------------------------------------------------------------------------*/
48 
52 extern std::string ExtraDeathTypes[ANIMATIONS_DEATHTYPES];
53 
78 };
79 
80 //Modify types
82  modSet = 0,
92 };
93 
95 {
96 public:
97  CAnimation(AnimationType type) : Type(type), Next(NULL) {}
98 
99  virtual ~CAnimation() {}
100 
101  virtual void Action(CUnit &unit, int &move, int scale) const = 0;
102  virtual void Init(const char *s, lua_State *l = NULL) {}
103 
106 };
107 
109 {
110 public:
111  CAnimations() : Attack(NULL), RangedAttack(NULL), Build(NULL), Move(NULL), Repair(NULL),
112  Research(NULL), SpellCast(NULL), Start(NULL), Still(NULL),
113  Train(NULL), Upgrade(NULL), hasDeathAnimation(false)
114  {
115  memset(Death, 0, sizeof(Death));
116  memset(Harvest, 0, sizeof(Harvest));
117  }
118 
120  {
121  delete Attack;
122  delete RangedAttack;
123  delete Build;
124  for (int i = 0; i < ANIMATIONS_DEATHTYPES + 1; ++i) {
125  delete Death[i];
126  }
127  for (int i = 0; i < MaxCosts; ++i) {
128  delete Harvest[i];
129  }
130  delete Move;
131  delete Repair;
132  delete Research;
133  delete SpellCast;
134  delete Start;
135  delete Still;
136  delete Train;
137  delete Upgrade;
138  }
139 
140  static void SaveUnitAnim(CFile &file, const CUnit &unit);
141  static void LoadUnitAnim(lua_State *l, CUnit &unit, int luaIndex);
142  static void LoadWaitUnitAnim(lua_State *l, CUnit &unit, int luaIndex);
143 
144 public:
159 };
160 
161 
162 /*----------------------------------------------------------------------------
163 -- Functions
164 ----------------------------------------------------------------------------*/
165 
167 extern CAnimations *AnimationsByIdent(const std::string &ident);
168 
169 extern void AnimationCclRegister();
170 
172 extern int UnitShowAnimationScaled(CUnit &unit, const CAnimation *anim, int scale);
174 extern int UnitShowAnimation(CUnit &unit, const CAnimation *anim);
175 
176 
177 extern int ParseAnimInt(const CUnit &unit, const char *parseint);
178 extern int ParseAnimFlags(const CUnit &unit, const char *parseflag);
179 
180 extern void FindLabelLater(CAnimation **anim, const std::string &name);
181 
182 extern void FreeAnimations();
183 
185 
186 #endif // !__ANIMATIONS_H__
modSub
@ modSub
Addition.
Definition: animation.h:84
CAnimations::Death
CAnimation * Death[ANIMATIONS_DEATHTYPES+1]
Definition: animation.h:149
AnimationRandomWait
@ AnimationRandomWait
Definition: animation.h:59
MaxCosts
@ MaxCosts
resource 6
Definition: upgrade_structs.h:70
CAnimations::LoadUnitAnim
static void LoadUnitAnim(lua_State *l, CUnit &unit, int luaIndex)
Definition: animation.cpp:466
AnimationSpawnMissile
@ AnimationSpawnMissile
Definition: animation.h:70
UnitShowAnimation
int UnitShowAnimation(CUnit &unit, const CAnimation *anim)
Handle the animation of a unit.
Definition: animation.cpp:108
CAnimations::RangedAttack
CAnimation * RangedAttack
Definition: animation.h:146
CAnimations::SaveUnitAnim
static void SaveUnitAnim(CFile &file, const CUnit &unit)
Definition: animation.cpp:425
CAnimations::SpellCast
CAnimation * SpellCast
Definition: animation.h:154
modAnd
@ modAnd
Modulo.
Definition: animation.h:88
AnimationRandomSound
@ AnimationRandomSound
Definition: animation.h:61
CAnimations::CAnimations
CAnimations()
Definition: animation.h:111
AnimationWait
@ AnimationWait
Definition: animation.h:58
AnimationSpawnUnit
@ AnimationSpawnUnit
Definition: animation.h:71
AnimationsByIdent
CAnimations * AnimationsByIdent(const std::string &ident)
Get the animations structure by ident.
Definition: animation.cpp:389
CAnimations::Harvest
CAnimation * Harvest[MaxCosts]
Definition: animation.h:150
modDiv
@ modDiv
Multiplication.
Definition: animation.h:86
CAnimation::Next
CAnimation * Next
Definition: animation.h:105
AnimationLabel
@ AnimationLabel
Definition: animation.h:67
AnimationAttack
@ AnimationAttack
Definition: animation.h:62
modXor
@ modXor
Bitwise OR.
Definition: animation.h:90
modNot
@ modNot
Bitwise XOR.
Definition: animation.h:91
ParseAnimInt
int ParseAnimInt(const CUnit &unit, const char *parseint)
Definition: animation.cpp:140
UnitShowAnimationScaled
int UnitShowAnimationScaled(CUnit &unit, const CAnimation *anim, int scale)
Handle the animation of a unit.
Definition: animation.cpp:345
AnimationFrame
@ AnimationFrame
Definition: animation.h:56
CAnimation::Action
virtual void Action(CUnit &unit, int &move, int scale) const =0
modMul
@ modMul
Subtraction.
Definition: animation.h:85
AnimationNone
@ AnimationNone
Definition: animation.h:55
AnimationIfVar
@ AnimationIfVar
Definition: animation.h:72
ExtraDeathTypes
std::string ExtraDeathTypes[ANIMATIONS_DEATHTYPES]
Definition: unittype.cpp:494
AnimationRandomRotate
@ AnimationRandomRotate
Definition: animation.h:64
modSet
@ modSet
Definition: animation.h:82
AnimationGoto
@ AnimationGoto
Definition: animation.h:68
AnimationRotate
@ AnimationRotate
Definition: animation.h:63
AnimationRandomGoto
@ AnimationRandomGoto
Definition: animation.h:69
CAnimation::~CAnimation
virtual ~CAnimation()
Definition: animation.h:99
CAnimations::Move
CAnimation * Move
Definition: animation.h:151
CAnimation::Init
virtual void Init(const char *s, lua_State *l=NULL)
Definition: animation.h:102
AnimationUnbreakable
@ AnimationUnbreakable
Definition: animation.h:66
AnimationType
AnimationType
Definition: animation.h:54
CAnimations
Definition: animation.h:108
AnimationMove
@ AnimationMove
Definition: animation.h:65
CAnimations::Attack
CAnimation * Attack
Definition: animation.h:145
CAnimations::Train
CAnimation * Train
Definition: animation.h:157
CAnimations::Repair
CAnimation * Repair
Definition: animation.h:152
CAnimation
Definition: animation.h:94
AnimationSetVar
@ AnimationSetVar
Definition: animation.h:73
AnimationDie
@ AnimationDie
Definition: animation.h:75
AnimationExactFrame
@ AnimationExactFrame
Definition: animation.h:57
SetVar_ModifyTypes
SetVar_ModifyTypes
Definition: animation.h:81
CAnimations::hasDeathAnimation
bool hasDeathAnimation
Definition: animation.h:148
modMod
@ modMod
Division.
Definition: animation.h:87
AnimationWiggle
@ AnimationWiggle
Definition: animation.h:77
AnimationSetPlayerVar
@ AnimationSetPlayerVar
Definition: animation.h:74
CAnimations::~CAnimations
~CAnimations()
Definition: animation.h:119
FindLabelLater
void FindLabelLater(CAnimation **anim, const std::string &name)
Definition: animation.cpp:551
CAnimations::Upgrade
CAnimation * Upgrade
Definition: animation.h:158
CAnimations::Research
CAnimation * Research
Definition: animation.h:153
AnimationCclRegister
void AnimationCclRegister()
Definition: animation.cpp:764
ParseAnimFlags
int ParseAnimFlags(const CUnit &unit, const char *parseflag)
Definition: animation.cpp:283
modOr
@ modOr
Bitwise AND.
Definition: animation.h:89
CAnimations::LoadWaitUnitAnim
static void LoadWaitUnitAnim(lua_State *l, CUnit &unit, int luaIndex)
Definition: animation.cpp:494
CAnimation::Type
const AnimationType Type
Definition: animation.h:104
CAnimations::Still
CAnimation * Still
Definition: animation.h:156
FreeAnimations
void FreeAnimations()
Definition: animation.cpp:398
upgrade_structs.h
modAdd
@ modAdd
Set value to this.
Definition: animation.h:83
CAnimation::CAnimation
CAnimation(AnimationType type)
Definition: animation.h:97
AnimationLuaCallback
@ AnimationLuaCallback
Definition: animation.h:76
CAnimations::Start
CAnimation * Start
Definition: animation.h:155
CFile
Definition: iolib.h:102
CUnit
The big unit structure.
Definition: unit.h:135
CAnimations::Build
CAnimation * Build
Definition: animation.h:147
AnimationSound
@ AnimationSound
Definition: animation.h:60
ANIMATIONS_DEATHTYPES
#define ANIMATIONS_DEATHTYPES
Definition: animation.h:39
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.