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