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
25 #include "AnimationFactory.h"
29 #include "SpriteCover.h"
30 #include "System/DataStream.h"
32 //scripted animation flags
33 #define S_ANI_PLAYONCE 8 //(same as area animation)
35 #define IE_VVC_TRANSPARENT 0x00000002
36 #define IE_VVC_BLENDED 0x00000008
37 #define IE_VVC_MIRRORX 0x00000010
38 #define IE_VVC_MIRRORY 0x00000020
39 #define IE_VVC_TINT 0x00030000 //2 bits need to be set for tint
40 #define IE_VVC_GREYSCALE 0x00080000
41 #define IE_VVC_DARKEN 0x00100000 //this is unsure
42 #define IE_VVC_GLOWING 0x00200000
43 #define IE_VVC_RED_TINT 0x02000000
45 #define IE_VVC_LOOP 0x00000001
46 #define IE_VVC_BAM 0x00000008
47 #define IE_VVC_NOCOVER 0x00000040
49 #define IE_VVC_UNUSED 0xe0000000U
52 #define P_NOTINITED -1
57 class GEM_EXPORT ScriptedAnimation
{
60 ~ScriptedAnimation(void);
61 ScriptedAnimation(DataStream
* stream
, bool autoFree
= true);
63 void LoadAnimationFactory(AnimationFactory
*af
, int gettwin
= 0);
64 void Override(ScriptedAnimation
*templ
);
65 //there are 3 phases: start, hold, release
66 //it will usually cycle in the 2. phase
67 //the anims could also be used 'orientation based' if FaceTarget is
69 Animation
* anims
[3*MAX_ORIENT
];
70 //there is only one palette
77 ieDword SequenceFlags
;
89 ScriptedAnimation
*twin
;
92 Holder
<SoundHandle
> sound_handle
;
94 //draws the next frame of the videocell
95 bool Draw(const Region
&screen
, const Point
&Pos
, const Color
&tint
, Map
*area
, int dither
, int orientation
);
97 void SetPhase(int arg
);
98 //sets sound for phase (p_onset, p_hold, p_release)
99 void SetSound(int arg
, const ieResRef sound
);
100 //sets the animation to play only once
102 //sets gradient colour slot to gradient
103 void SetPalette(int gradient
, int start
=-1);
104 //sets complete palette to ResRef
105 void SetFullPalette(const ieResRef PaletteResRef
);
106 //sets complete palette to own name+index
107 void SetFullPalette(int idx
);
109 void SetSpriteCover(SpriteCover
* c
) { delete cover
; cover
= c
; }
110 /* get stored SpriteCover */
111 SpriteCover
* GetSpriteCover() const { return cover
; }
112 int GetCurrentFrame();
113 ieDword
GetSequenceDuration(ieDword multiplier
);
114 /* sets default duration if it wasn't set yet */
115 void SetDefaultDuration(unsigned int duration
);
116 /* sets up the direction of the vvc */
117 void SetOrientation(int orientation
);
118 /* transforms vvc to blended */
120 /* sets fade effect at end of animation (pst feature) */
121 void SetFade(ieByte initial
, int speed
);
122 /* alters palette with rgb factor */
123 void AlterPalette(const RGBModifier
&rgb
);
124 /* returns possible twin after altering it to become underlay */
125 ScriptedAnimation
*DetachTwin();
127 void PrepareAnimation(Animation
*anim
, ieDword Transparency
);
128 void PreparePalette();
129 bool HandlePhase(Sprite2D
*&frame
);
130 void GetPaletteCopy();