fixed the last commit to set and check the target more often, thanks fuzzie
[gemrb.git] / gemrb / core / ScriptedAnimation.h
blob3e33651ffe8bb1cf0b6fa5e4153ddb0b3a48be65
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"
25 #include "AnimationFactory.h"
26 #include "Map.h"
27 #include "Palette.h"
28 #include "SpriteCover.h"
29 #include "System/DataStream.h"
31 //scripted animation flags
32 #define S_ANI_PLAYONCE 8 //(same as area animation)
34 #define IE_VVC_TRANSPARENT 0x00000002
35 #define IE_VVC_BLENDED 0x00000008
36 #define IE_VVC_MIRRORX 0x00000010
37 #define IE_VVC_MIRRORY 0x00000020
38 #define IE_VVC_TINT 0x00030000 //2 bits need to be set for tint
39 #define IE_VVC_GREYSCALE 0x00080000
40 #define IE_VVC_DARKEN 0x00100000 //this is unsure
41 #define IE_VVC_GLOWING 0x00200000
42 #define IE_VVC_RED_TINT 0x02000000
44 #define IE_VVC_LOOP 0x00000001
45 #define IE_VVC_BAM 0x00000008
46 #define IE_VVC_NOCOVER 0x00000040
48 #define IE_VVC_UNUSED 0xe0000000U
50 //phases
51 #define P_NOTINITED -1
52 #define P_ONSET 0
53 #define P_HOLD 1
54 #define P_RELEASE 2
56 class GEM_EXPORT ScriptedAnimation {
57 public:
58 ScriptedAnimation();
59 ~ScriptedAnimation(void);
60 ScriptedAnimation(DataStream* stream, bool autoFree = true);
61 void Init();
62 void LoadAnimationFactory(AnimationFactory *af, int gettwin = 0);
63 void Override(ScriptedAnimation *templ);
64 //there are 3 phases: start, hold, release
65 //it will usually cycle in the 2. phase
66 //the anims could also be used 'orientation based' if FaceTarget is
67 //set to 5, 9, 16
68 Animation* anims[3*MAX_ORIENT];
69 //there is only one palette
70 Palette *palette;
71 ieResRef sounds[3];
72 ieResRef PaletteName;
73 Color Tint;
74 int Fade;
75 ieDword Transparency;
76 ieDword SequenceFlags;
77 int Dither;
78 //these are signed
79 int XPos, YPos, ZPos;
80 ieDword FrameRate;
81 ieDword FaceTarget;
82 ieByte Orientation;
83 ieDword Duration;
84 bool justCreated;
85 ieResRef ResName;
86 int Phase;
87 SpriteCover* cover;
88 ScriptedAnimation *twin;
89 bool active;
90 bool effect_owned;
91 public:
92 //draws the next frame of the videocell
93 bool Draw(const Region &screen, const Point &Pos, const Color &tint, Map *area, int dither, int orientation);
94 //sets phase (0-2)
95 void SetPhase(int arg);
96 //sets sound for phase (p_onset, p_hold, p_release)
97 void SetSound(int arg, const ieResRef sound);
98 //sets the animation to play only once
99 void PlayOnce();
100 //sets gradient colour slot to gradient
101 void SetPalette(int gradient, int start=-1);
102 //sets complete palette to ResRef
103 void SetFullPalette(const ieResRef PaletteResRef);
104 //sets complete palette to own name+index
105 void SetFullPalette(int idx);
106 //sets spritecover
107 void SetSpriteCover(SpriteCover* c) { delete cover; cover = c; }
108 /* get stored SpriteCover */
109 SpriteCover* GetSpriteCover() const { return cover; }
110 int GetCurrentFrame();
111 ieDword GetSequenceDuration(ieDword multiplier);
112 /* sets default duration if it wasn't set yet */
113 void SetDefaultDuration(unsigned int duration);
114 /* sets up the direction of the vvc */
115 void SetOrientation(int orientation);
116 /* transforms vvc to blended */
117 void SetBlend();
118 /* sets fade effect at end of animation (pst feature) */
119 void SetFade(ieByte initial, int speed);
120 /* alters palette with rgb factor */
121 void AlterPalette(const RGBModifier &rgb);
122 /* returns possible twin after altering it to become underlay */
123 ScriptedAnimation *DetachTwin();
124 private:
125 void PrepareAnimation(Animation *anim, ieDword Transparency);
126 void PreparePalette();
127 bool HandlePhase(Sprite2D *&frame);
128 void GetPaletteCopy();
131 #endif