GameScript: Move initialization out of constructor.
[gemrb.git] / gemrb / core / ScriptedAnimation.h
blobf67bb1ace7094ebacc8a3b93c9848da5ff9e45da
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef SCRIPTEDANIMATION_H
21 #define SCRIPTEDANIMATION_H
23 #include "exports.h"
24 #include "DataStream.h"
25 #include "AnimationFactory.h"
26 #include "Palette.h"
27 #include "SpriteCover.h"
28 #include "Map.h"
30 //scripted animation flags
31 #define S_ANI_PLAYONCE 8 //(same as area animation)
33 #define IE_VVC_TRANSPARENT 0x00000002
34 #define IE_VVC_BLENDED 0x00000008
35 #define IE_VVC_MIRRORX 0x00000010
36 #define IE_VVC_MIRRORY 0x00000020
37 #define IE_VVC_TINT 0x00030000 //2 bits need to be set for tint
38 #define IE_VVC_GREYSCALE 0x00080000
39 #define IE_VVC_DARKEN 0x00100000 //this is unsure
40 #define IE_VVC_GLOWING 0x00200000
41 #define IE_VVC_RED_TINT 0x02000000
43 #define IE_VVC_LOOP 0x00000001
44 #define IE_VVC_BAM 0x00000008
45 #define IE_VVC_NOCOVER 0x00000040
47 #define IE_VVC_UNUSED 0xe0000000U
49 //phases
50 #define P_NOTINITED -1
51 #define P_ONSET 0
52 #define P_HOLD 1
53 #define P_RELEASE 2
55 class GEM_EXPORT ScriptedAnimation {
56 public:
57 ScriptedAnimation();
58 ~ScriptedAnimation(void);
59 ScriptedAnimation(DataStream* stream, bool autoFree = true);
60 void Init();
61 void LoadAnimationFactory(AnimationFactory *af, int gettwin = 0);
62 void Override(ScriptedAnimation *templ);
63 //there are 3 phases: start, hold, release
64 //it will usually cycle in the 2. phase
65 //the anims could also be used 'orientation based' if FaceTarget is
66 //set to 5, 9, 16
67 Animation* anims[3*MAX_ORIENT];
68 //there is only one palette
69 Palette *palette;
70 ieResRef sounds[3];
71 ieResRef PaletteName;
72 Color Tint;
73 int Fade;
74 ieDword Transparency;
75 ieDword SequenceFlags;
76 int Dither;
77 //these are signed
78 int XPos, YPos, ZPos;
79 ieDword FrameRate;
80 ieDword FaceTarget;
81 ieByte Orientation;
82 ieDword Duration;
83 bool justCreated;
84 ieResRef ResName;
85 int Phase;
86 SpriteCover* cover;
87 ScriptedAnimation *twin;
88 public:
89 //draws the next frame of the videocell
90 bool Draw(Region &screen, Point &Pos, Color &tint, Map *area, int dither, int orientation);
91 //sets phase (0-2)
92 void SetPhase(int arg);
93 //sets sound for phase (p_onset, p_hold, p_release)
94 void SetSound(int arg, const ieResRef sound);
95 //sets the animation to play only once
96 void PlayOnce();
97 //sets gradient colour slot to gradient
98 void SetPalette(int gradient, int start=-1);
99 //sets complete palette to ResRef
100 void SetFullPalette(const ieResRef PaletteResRef);
101 //sets complete palette to own name+index
102 void SetFullPalette(int idx);
103 //sets spritecover
104 void SetSpriteCover(SpriteCover* c) { delete cover; cover = c; }
105 /* get stored SpriteCover */
106 SpriteCover* GetSpriteCover() const { return cover; }
107 int GetCurrentFrame();
108 ieDword GetSequenceDuration(ieDword multiplier);
109 /* sets default duration if it wasn't set yet */
110 void SetDefaultDuration(unsigned int duration);
111 /* sets up the direction of the vvc */
112 void SetOrientation(int orientation);
113 /* transforms vvc to blended */
114 void SetBlend();
115 /* sets fade effect at end of animation (pst feature) */
116 void SetFade(ieByte initial, int speed);
117 /* alters palette with rgb factor */
118 void AlterPalette(const RGBModifier &rgb);
119 /* returns possible twin after altering it to become underlay */
120 ScriptedAnimation *DetachTwin();
121 private:
122 void PrepareAnimation(Animation *anim, ieDword Transparency);
123 void PreparePalette();
124 bool HandlePhase(Sprite2D *&frame);
125 void GetPaletteCopy();
128 #endif