ScummVM API documentation
gr_tile_animation.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 
23 #ifndef QDENGINE_SYSTEM_GRAPHICS_GR_TILE_ANIMATION_H
24 #define QDENGINE_SYSTEM_GRAPHICS_GR_TILE_ANIMATION_H
25 
26 #include "common/hashmap.h"
27 #include "common/path.h"
28 
29 #include "qdengine/xmath.h"
30 #include "qdengine/system/graphics/gr_tile_sprite.h"
31 
32 namespace Common {
33 class SeekableReadStream;
34 }
35 
36 namespace Graphics {
37 class ManagedSurface;
38 }
39 
40 namespace QDEngine {
41 
42 typedef void (*CompressionProgressHandler)(int percents_loaded, void *context);
43 
45 public:
47 
48  bool isEmpty() const {
49  return !_frameCount;
50  }
51 
52  void clear();
53 
54  int frameCount() const {
55  return _frameCount;
56  }
57  const Vect2i &frameSize() const {
58  return _frameSize;
59  }
60  const Vect2i &frameTileSize() const {
61  return _frameTileSize;
62  }
63  int tileCount() const {
64  return _tileOffsets.size() - 1;
65  }
66 
67  void init(int frame_count, const Vect2i &frame_size, bool alpha_flag);
68 
69  void compact();
70 
71  bool compress(grTileCompressionMethod method);
72 
73  grTileSprite getTile(int tile_index) const;
74  grTileSprite getFrameTile(int frame_number, int tile_index) const;
75 
76  void addFrame(const uint32 *frame_data);
77 
78  bool load(Common::SeekableReadStream *fh, int version);
79 
80  void drawFrame(const Vect2i &position, int32 frame_index, int32 mode, int closest_scale) const;
81  void drawFrame(const Vect2i &position, int frame_index, float angle, int mode = 0) const;
82  void drawFrame(const Vect2i &position, int frame_index, float angle, const Vect2f &scale, int mode) const;
83 
84  void drawFrame_scale(const Vect2i &position, int frame_index, float scale, int mode) const;
85 
86  void drawMask(const Vect2i &position, int frame_index, uint32 mask_color, int mask_alpha, int mode, int closest_scale) const;
87  void drawMask_scale(const Vect2i &pos, int frame_index, uint32 mask_colour, int mask_alpha, float scale, int mode) const;
88  void drawMask_rot(const Vect2i &pos, int frame_index, uint32 mask_colour, int mask_alpha, float angle, int mode) const;
89  void drawMask_rot(const Vect2i &pos, int frame_index, uint32 mask_colour, int mask_alpha, float angle, Vect2f scale, int mode) const;
90 
91  void drawContour(const Vect2i &position, int frame_index, uint32 color, int mode, int closest_scale) const;
92  void drawContour(const Vect2i &position, int frame_index, uint32 color, float scale, int mode) const;
93 
94  bool hit(int frame_number, Vect2i &pos) const;
95 
96  static void setProgressHandler(CompressionProgressHandler handler, void *context) {
97  _progressHandler = handler;
98  _progressHandlerContext = context;
99  }
100 
101  void addScale(int i, float scale);
102  byte *decode_frame_data(int frame_index, int closest_scale) const;
103  int find_closest_scale(float *scale) const;
104  bool wasFrameSizeChanged(int frame_index, int scaleIdx, float scale) const;
105 
106  Graphics::ManagedSurface *dumpTiles(int tilesPerRow) const;
107  void dumpTiles(Common::Path baseName, int tilesPerRow) const;
108 
109  Graphics::ManagedSurface *dumpFrameTiles(int frame_index, float scale) const;
110 
111 private:
112 
113  grTileCompressionMethod _compression;
114 
116  bool _hasAlpha;
117 
120  Vect2i _frameSize;
121 
123  Vect2i _frameTileSize;
124 
126  int _frameCount;
127 
129 
130  struct ScaleArray {
131  float _scale;
132  Vect2i _frameSize;
133  Vect2i _frameTileSize;
134  int _frameStart;
135  };
136 
137  Std::vector<ScaleArray> _scaleArray;
138 
141  FrameIndex _frameIndex;
142 
145  TileOffsets _tileOffsets;
148  TileData _tileData;
149 
150  mutable Common::HashMap<uint32, grTileSprite> _decompressedTiles;
151 
152  Std::vector<Vect2i> _frameSizeArray;
153 
154  static CompressionProgressHandler _progressHandler;
155  static void *_progressHandlerContext;
156 };
157 
158 } // namespace QDEngine
159 
160 #endif // QDENGINE_SYSTEM_GRAPHICS_GR_TILE_ANIMATION_H
Definition: managed_surface.h:51
Definition: xmath.h:117
Definition: path.h:52
Definition: stream.h:745
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: hashmap.h:85
Базовый класс для игровых ресурсов.
Definition: console.h:28
Definition: xmath.h:268
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: gr_tile_animation.h:44
Тайл-спрайт
Definition: gr_tile_sprite.h:44