_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          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 
77 };
78 
79 //Modify types
81  modSet = 0,
91 };
92 
94 {
95 public:
96  CAnimation(AnimationType type) : Type(type), Next(NULL) {}
97 
98  virtual ~CAnimation() {}
99 
100  virtual void Action(CUnit &unit, int &move, int scale) const = 0;
101  virtual void Init(const char *s, lua_State *l = NULL) {}
102 
105 };
106 
108 {
109 public:
110  CAnimations() : Attack(NULL), Build(NULL), Move(NULL), Repair(NULL),
111  Research(NULL), SpellCast(NULL), Start(NULL), Still(NULL),
112  Train(NULL), Upgrade(NULL)
113  {
114  memset(Death, 0, sizeof(Death));
115  memset(Harvest, 0, sizeof(Harvest));
116  }
117 
119  {
120  delete Attack;
121  delete Build;
122  for (int i = 0; i < ANIMATIONS_DEATHTYPES + 1; ++i) {
123  delete Death[i];
124  }
125  for (int i = 0; i < MaxCosts; ++i) {
126  delete Harvest[i];
127  }
128  delete Move;
129  delete Repair;
130  delete Research;
131  delete SpellCast;
132  delete Start;
133  delete Still;
134  delete Train;
135  delete Upgrade;
136  }
137 
138  static void SaveUnitAnim(CFile &file, const CUnit &unit);
139  static void LoadUnitAnim(lua_State *l, CUnit &unit, int luaIndex);
140  static void LoadWaitUnitAnim(lua_State *l, CUnit &unit, int luaIndex);
141 
142 public:
155 };
156 
157 
158 /*----------------------------------------------------------------------------
159 -- Functions
160 ----------------------------------------------------------------------------*/
161 
163 extern CAnimations *AnimationsByIdent(const std::string &ident);
164 
165 extern void AnimationCclRegister();
166 
168 extern int UnitShowAnimationScaled(CUnit &unit, const CAnimation *anim, int scale);
170 extern int UnitShowAnimation(CUnit &unit, const CAnimation *anim);
171 
172 
173 extern int ParseAnimInt(const CUnit &unit, const char *parseint);
174 extern int ParseAnimFlags(const CUnit &unit, const char *parseflag);
175 
176 extern void FindLabelLater(CAnimation **anim, const std::string &name);
177 
178 extern void FreeAnimations();
179 
181 
182 #endif // !__ANIMATIONS_H__
CAnimation * Build
Definition: animation.h:144
int UnitShowAnimationScaled(CUnit &unit, const CAnimation *anim, int scale)
Handle the animation of a unit.
Definition: animation.cpp:332
Definition: animation.h:68
CAnimations()
Definition: animation.h:110
Definition: animation.h:107
CAnimation * Death[ANIMATIONS_DEATHTYPES+1]
Definition: animation.h:145
resource 6
Definition: upgrade_structs.h:70
void AnimationCclRegister()
Definition: animation.cpp:745
CAnimations * AnimationsByIdent(const std::string &ident)
Get the animations structure by ident.
Definition: animation.cpp:376
Definition: animation.h:75
CAnimation * Harvest[MaxCosts]
Definition: animation.h:146
Bitwise AND.
Definition: animation.h:88
AnimationType
Definition: animation.h:54
static void LoadUnitAnim(lua_State *l, CUnit &unit, int luaIndex)
Definition: animation.cpp:453
Definition: animation.h:74
Definition: animation.h:93
Definition: animation.h:57
The big unit structure.
Definition: unit.h:119
static void SaveUnitAnim(CFile &file, const CUnit &unit)
Definition: animation.cpp:412
void FindLabelLater(CAnimation **anim, const std::string &name)
Definition: animation.cpp:538
CAnimation * SpellCast
Definition: animation.h:150
Definition: animation.h:73
Definition: animation.h:60
int ParseAnimInt(const CUnit &unit, const char *parseint)
Definition: animation.cpp:137
Set value to this.
Definition: animation.h:82
Division.
Definition: animation.h:86
std::string ExtraDeathTypes[ANIMATIONS_DEATHTYPES]
Definition: unittype.cpp:585
CAnimation * Attack
Definition: animation.h:143
Definition: iolib.h:101
Definition: animation.h:76
Definition: animation.h:59
SetVar_ModifyTypes
Definition: animation.h:80
CAnimation * Move
Definition: animation.h:147
const AnimationType Type
Definition: animation.h:103
CAnimation(AnimationType type)
Definition: animation.h:96
Definition: animation.h:67
Definition: animation.h:62
int UnitShowAnimation(CUnit &unit, const CAnimation *anim)
Handle the animation of a unit.
Definition: animation.cpp:105
Definition: animation.h:70
Definition: animation.h:56
CAnimation * Research
Definition: animation.h:149
Multiplication.
Definition: animation.h:85
Addition.
Definition: animation.h:83
CAnimation * Next
Definition: animation.h:104
#define ANIMATIONS_DEATHTYPES
Definition: animation.h:39
Definition: animation.h:64
Modulo.
Definition: animation.h:87
int ParseAnimFlags(const CUnit &unit, const char *parseflag)
Definition: animation.cpp:270
Definition: animation.h:63
CAnimation * Train
Definition: animation.h:153
CAnimation * Repair
Definition: animation.h:148
Subtraction.
Definition: animation.h:84
static void LoadWaitUnitAnim(lua_State *l, CUnit &unit, int luaIndex)
Definition: animation.cpp:481
void FreeAnimations()
Definition: animation.cpp:385
Definition: animation.h:72
CAnimation * Still
Definition: animation.h:152
Definition: animation.h:58
Definition: animation.h:61
Definition: animation.h:81
Definition: animation.h:66
CAnimation * Upgrade
Definition: animation.h:154
Definition: animation.h:71
virtual void Action(CUnit &unit, int &move, int scale) const =0
Bitwise OR.
Definition: animation.h:89
Definition: animation.h:69
virtual ~CAnimation()
Definition: animation.h:98
virtual void Init(const char *s, lua_State *l=NULL)
Definition: animation.h:101
Bitwise XOR.
Definition: animation.h:90
~CAnimations()
Definition: animation.h:118
Definition: animation.h:65
Definition: animation.h:55
CAnimation * Start
Definition: animation.h:151
(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.