00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00027 #ifndef _EFFECT_H
00028 #define _EFFECT_H
00029
00030 #include <stdexcept>
00031 #include <memory>
00032 #include <vector>
00033
00034 #include "animation.h"
00035 #include "bitmap.h"
00036 #include "lib.h"
00037 #include "rve.h"
00038
00052 class Effect {
00053 public:
00054 Effect(): _maxtime(0) { _fps = global_fps; }
00055 virtual ~Effect() {}
00056
00061 virtual void run() = 0;
00062
00064 int get_time() const { return _maxtime; }
00066 void set_time(int maxtime) { _maxtime = maxtime; }
00068 int get_fps() const { return _fps; }
00070 void set_fps(int fps) { _fps = fps; }
00071
00072 protected:
00080 void animate(int from, int to, int maxtime = 0);
00081
00087 virtual void step(int value) = 0;
00088
00089 int _maxtime, _fps;
00090 int _oldval;
00091 };
00092
00099 class Effect_move_animation: public Effect {
00100 public:
00101 virtual void run();
00109 void param(int x1, int y1, int x2, int y2, Animation &anim, int alpha = 0) {
00110 _x1 = x1; _y1 = y1; _x2 = x2; _y2 = y2;
00111 _anim = &anim;
00112 _alpha = alpha;
00113 }
00114
00115 protected:
00116 virtual void step(int value);
00117
00118 int _x1, _y1, _x2, _y2;
00119 int _distance, _alpha;
00120 Animation *_anim;
00121 };
00122
00129 class Effect_move: public Effect {
00130 public:
00131 virtual void run();
00139 void param(int x1, int y1, int x2, int y2, const Bitmap &bitmap) {
00140 _x1 = x1; _y1 = y1; _x2 = x2; _y2 = y2;
00141 _orig_bitmap.reset(bitmap.clone());
00142 }
00143
00144 protected:
00145 virtual void step(int value);
00146
00147 int _x1, _y1, _x2, _y2;
00148 int _distance, _left, _top;
00149 std::auto_ptr<Bitmap> _orig_bitmap;
00150 std::auto_ptr<Bitmap> _used_bitmap;
00151 };
00152
00160 class Effect_changealpha: public Effect {
00161 public:
00167 void param(int from, int to, int width, int height, int xpos, int ypos) {
00168 _from = from; _to = to;
00169 _width = width; _height = height; _xpos = xpos; _ypos = ypos;
00170 }
00171
00172 protected:
00173 int _from, _to;
00174 int _width, _height, _xpos, _ypos;
00175 };
00176
00178 class Effect_fade: public Effect_changealpha {
00179 public:
00180 virtual void run() { animate(_from, _to); }
00181
00182 protected:
00183 virtual void step(int value) {
00184 set_alpha(_width, _height, _xpos, _ypos, value);
00185 }
00186 };
00187
00190 class Effect_tile: public Effect_changealpha {
00191 public:
00192 virtual void run();
00193
00194 protected:
00195 virtual void step(int value);
00196
00197 int _length, _per_row, _numtiles;
00198 std::vector<int> _sequence;
00199 };
00200
00203 class Effect_counter: public Effect {
00204 public:
00205 Effect_counter(): _text(NULL) {}
00206
00207 virtual void run();
00208
00210 void param(int xpos, int ypos, int from, int digits, int groupspacing = 5,
00211 RGBA *background = NULL, int marginx = 0, int marginy = 0,
00212 int shift = 0, int digitsize = 0, char *text = NULL) {
00213 _xpos = xpos; _ypos = ypos; _from = from; _text = text;
00214 _anim.param(_fps, from, digits, groupspacing, background, marginx,
00215 marginy, shift, digitsize);
00216 }
00217
00218 protected:
00219 virtual void step(int value);
00220 void Effect_counter::anim_part(int state, int frames);
00221
00222 int _xpos, _ypos, _from;
00223 char *_text;
00224
00225 int _state, _xfrom, _textxfrom, _textx, _texty, _countery, _canvasy;
00226 RollCount _anim;
00227 RGBA _textbm, _canvas;
00228
00229 static const int _speed = 20;
00230 };
00231
00233 class Effect_movebars: public Effect {
00234 public:
00235 class Bar {
00236 public:
00237 int oldheight, newheight, xpos;
00238 };
00239
00240 virtual void run();
00241 void param(std::vector<Bar> &bars, int barypos, int barwidth,
00242 int barheight, int valpha, int halpha) {
00243 _bars = &bars;
00244 _barypos = barypos; _barwidth = barwidth; _barheight = barheight;
00245 _valpha = valpha; _halpha = halpha;
00246 }
00247
00248 protected:
00249 virtual void step(int value);
00250
00251 std::vector<Bar> *_bars;
00252 int _barypos, _barwidth, _barheight;
00253 int _valpha, _halpha;
00254 int _maxdelta;
00255 };
00256
00257 #endif