ScummVM API documentation
tileanim.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA4_MAP_TILEANIM_H
23 #define ULTIMA4_MAP_TILEANIM_H
24 
25 #include "ultima/ultima4/map/direction.h"
26 
27 namespace Ultima {
28 namespace Ultima4 {
29 
30 class ConfigElement;
31 class Image;
32 class Tile;
33 struct RGBA;
34 
39 public:
40  static TileAnimTransform *create(const ConfigElement &config);
41 
45  static RGBA *loadColorFromConf(const ConfigElement &conf);
46 
47  virtual void draw(Image *dest, Tile *tile, MapTile &mapTile) = 0;
48  virtual ~TileAnimTransform() {}
49  virtual bool drawsTile() const = 0;
50 
51  // Properties
52  int _random;
53 };
54 
60 public:
61  TileAnimInvertTransform(int xp, int yp, int width, int height);
62  void draw(Image *dest, Tile *tile, MapTile &mapTile) override;
63  bool drawsTile() const override;
64 
65 private:
66  int x, y, w, h;
67 };
68 
75 public:
76  TileAnimPixelTransform(int xp, int yp);
77  void draw(Image *dest, Tile *tile, MapTile &mapTile) override;
78  bool drawsTile() const override;
79 
80  int x, y;
81  Std::vector<RGBA *> _colors;
82 };
83 
89 public:
90  TileAnimScrollTransform(int increment);
91  void draw(Image *dest, Tile *tile, MapTile &mapTile) override;
92  bool drawsTile() const override;
93 private:
94  int _increment, _current, _lastOffset;
95 };
96 
102 public:
103  TileAnimFrameTransform() : _currentFrame(0) {
104  }
105  void draw(Image *dest, Tile *tile, MapTile &mapTile) override;
106 
110  bool drawsTile() const override;
111 protected:
112  int _currentFrame;
113 };
114 
121 public:
122  TileAnimPixelColorTransform(int xp, int yp, int width, int height);
123  ~TileAnimPixelColorTransform() override;
124 
125  void draw(Image *dest, Tile *tile, MapTile &mapTile) override;
126  bool drawsTile() const override;
127 
128  int x, y, w, h;
129  RGBA *_start, *_end;
130 };
131 
136 public:
138  typedef enum {
139  FRAME,
140  DIR
141  } Type;
142 
146  static TileAnimContext *create(const ConfigElement &config);
147 
151  void add(TileAnimTransform *);
152  virtual bool isInContext(Tile *t, MapTile &mapTile, Direction d) = 0;
153  TileAnimTransformList &getTransforms() {
154  return _animTransforms;
155  }
156  virtual ~TileAnimContext() {}
157 private:
158 
159  TileAnimTransformList _animTransforms;
160 };
161 
166 public:
170  TileAnimFrameContext(int frame);
171  bool isInContext(Tile *t, MapTile &mapTile, Direction d) override;
172 
173 private:
174  int _frame;
175 };
176 
181 public:
185  TileAnimPlayerDirContext(Direction dir);
186  bool isInContext(Tile *t, MapTile &mapTile, Direction d) override;
187 
188 private:
189  Direction _dir;
190 };
191 
197 class TileAnim {
198 public:
199  TileAnim(const ConfigElement &conf);
200  ~TileAnim();
201 
202  Common::String _name;
205 
206  /* returns the frame to set the mapTile to (only relevant if persistent) */
207  void draw(Image *dest, Tile *tile, MapTile &mapTile, Direction dir);
208 
209  int _random; /* true if the tile animation occurs randomely */
210 };
211 
216 class TileAnimSet {
218 
219 public:
220  TileAnimSet(const ConfigElement &conf);
221  ~TileAnimSet();
222 
226  TileAnim *getByName(const Common::String &name);
227 
228  Common::String _name;
229  TileAnimMap _tileAnims;
230 };
231 
232 } // End of namespace Ultima4
233 } // End of namespace Ultima
234 
235 #endif
Definition: str.h:59
Definition: image.h:36
Definition: config.h:127
TileAnimTransformList & getTransforms()
Definition: tileanim.h:153
Definition: tileanim.h:135
Definition: tileanim.h:101
Definition: tileanim.h:216
Type
Definition: log.h:33
Definition: detection.h:27
Definition: map_tile.h:34
Definition: tileanim.h:165
Definition: tileanim.h:197
static RGBA * loadColorFromConf(const ConfigElement &conf)
Definition: tile.h:65
Definition: movie_decoder.h:32
Definition: containers.h:38
Definition: tileanim.h:38