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

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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), RangedAttack(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 RangedAttack;
122  delete Build;
123  for (int i = 0; i < ANIMATIONS_DEATHTYPES + 1; ++i) {
124  delete Death[i];
125  }
126  for (int i = 0; i < MaxCosts; ++i) {
127  delete Harvest[i];
128  }
129  delete Move;
130  delete Repair;
131  delete Research;
132  delete SpellCast;
133  delete Start;
134  delete Still;
135  delete Train;
136  delete Upgrade;
137  }
138 
139  static void SaveUnitAnim(CFile &file, const CUnit &unit);
140  static void LoadUnitAnim(lua_State *l, CUnit &unit, int luaIndex);
141  static void LoadWaitUnitAnim(lua_State *l, CUnit &unit, int luaIndex);
142 
143 public:
157 };
158 
159 
160 /*----------------------------------------------------------------------------
161 -- Functions
162 ----------------------------------------------------------------------------*/
163 
165 extern CAnimations *AnimationsByIdent(const std::string &ident);
166 
167 extern void AnimationCclRegister();
168 
170 extern int UnitShowAnimationScaled(CUnit &unit, const CAnimation *anim, int scale);
172 extern int UnitShowAnimation(CUnit &unit, const CAnimation *anim);
173 
174 
175 extern int ParseAnimInt(const CUnit &unit, const char *parseint);
176 extern int ParseAnimFlags(const CUnit &unit, const char *parseflag);
177 
178 extern void FindLabelLater(CAnimation **anim, const std::string &name);
179 
180 extern void FreeAnimations();
181 
183 
184 #endif // !__ANIMATIONS_H__
CAnimation * Build
Definition: animation.h:146
int UnitShowAnimationScaled(CUnit &unit, const CAnimation *anim, int scale)
Handle the animation of a unit.
Definition: animation.cpp:333
Definition: animation.h:68
CAnimations()
Definition: animation.h:110
Definition: animation.h:107
CAnimation * Death[ANIMATIONS_DEATHTYPES+1]
Definition: animation.h:147
resource 6
Definition: upgrade_structs.h:70
void AnimationCclRegister()
Definition: animation.cpp:749
CAnimations * AnimationsByIdent(const std::string &ident)
Get the animations structure by ident.
Definition: animation.cpp:377
Definition: animation.h:75
CAnimation * Harvest[MaxCosts]
Definition: animation.h:148
Bitwise AND.
Definition: animation.h:88
AnimationType
Definition: animation.h:54
static void LoadUnitAnim(lua_State *l, CUnit &unit, int luaIndex)
Definition: animation.cpp:454
Definition: animation.h:74
Definition: animation.h:93
Definition: animation.h:57
CAnimation * RangedAttack
Definition: animation.h:145
The big unit structure.
Definition: unit.h:119
static void SaveUnitAnim(CFile &file, const CUnit &unit)
Definition: animation.cpp:413
void FindLabelLater(CAnimation **anim, const std::string &name)
Definition: animation.cpp:539
CAnimation * SpellCast
Definition: animation.h:152
Definition: animation.h:73
Definition: animation.h:60
int ParseAnimInt(const CUnit &unit, const char *parseint)
Definition: animation.cpp:138
Set value to this.
Definition: animation.h:82
Division.
Definition: animation.h:86
std::string ExtraDeathTypes[ANIMATIONS_DEATHTYPES]
Definition: unittype.cpp:499
CAnimation * Attack
Definition: animation.h:144
Definition: iolib.h:101
Definition: animation.h:76
Definition: animation.h:59
SetVar_ModifyTypes
Definition: animation.h:80
CAnimation * Move
Definition: animation.h:149
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:106
Definition: animation.h:70
Definition: animation.h:56
CAnimation * Research
Definition: animation.h:151
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:271
Definition: animation.h:63
CAnimation * Train
Definition: animation.h:155
CAnimation * Repair
Definition: animation.h:150
Subtraction.
Definition: animation.h:84
static void LoadWaitUnitAnim(lua_State *l, CUnit &unit, int luaIndex)
Definition: animation.cpp:482
void FreeAnimations()
Definition: animation.cpp:386
Definition: animation.h:72
CAnimation * Still
Definition: animation.h:154
Definition: animation.h:58
Definition: animation.h:61
Definition: animation.h:81
Definition: animation.h:66
CAnimation * Upgrade
Definition: animation.h:156
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:153
(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.