1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef QDENGINE_SYSTEM_GRAPHICS_GR_TILE_ANIMATION_H
#define QDENGINE_SYSTEM_GRAPHICS_GR_TILE_ANIMATION_H
#include "common/path.h"
#include "qdengine/xmath.h"
#include "qdengine/system/graphics/gr_tile_sprite.h"
namespace Common {
class SeekableReadStream;
}
namespace Graphics {
class ManagedSurface;
}
namespace QDEngine {
typedef void (*CompressionProgressHandler)(int percents_loaded, void *context);
class grTileAnimation {
public:
grTileAnimation();
bool isEmpty() const {
return !_frameCount;
}
void clear();
int frameCount() const {
return _frameCount;
}
const Vect2i &frameSize() const {
return _frameSize;
}
const Vect2i &frameTileSize() const {
return _frameTileSize;
}
int tileCount() const {
return _tileOffsets.size() - 1;
}
void init(int frame_count, const Vect2i &frame_size, bool alpha_flag);
void compact();
bool compress(grTileCompressionMethod method);
grTileSprite getTile(int tile_index) const;
grTileSprite getFrameTile(int frame_number, int tile_index) const;
void addFrame(const uint32 *frame_data);
bool load(Common::SeekableReadStream *fh, int version);
void drawFrame(const Vect2i &position, int32 frame_index, int32 mode, int closest_scale) const;
void drawFrame(const Vect2i &position, int frame_index, float angle, int mode = 0) const;
void drawFrame(const Vect2i &position, int frame_index, float angle, const Vect2f &scale, int mode) const;
void drawFrame_scale(const Vect2i &position, int frame_index, float scale, int mode) const;
void drawMask(const Vect2i &position, int frame_index, uint32 mask_color, int mask_alpha, int mode, int closest_scale) const;
void drawMask_scale(const Vect2i &pos, int frame_index, uint32 mask_colour, int mask_alpha, float scale, int mode) const;
void drawMask_rot(const Vect2i &pos, int frame_index, uint32 mask_colour, int mask_alpha, float angle, int mode) const;
void drawMask_rot(const Vect2i &pos, int frame_index, uint32 mask_colour, int mask_alpha, float angle, Vect2f scale, int mode) const;
void drawContour(const Vect2i &position, int frame_index, uint32 color, int mode, int closest_scale) const;
void drawContour(const Vect2i &position, int frame_index, uint32 color, float scale, int mode) const;
bool hit(int frame_number, Vect2i &pos) const;
static void setProgressHandler(CompressionProgressHandler handler, void *context) {
_progressHandler = handler;
_progressHandlerContext = context;
}
void addScale(int i, float scale);
byte *decode_frame_data(int frame_index, int closest_scale) const;
int find_closest_scale(float *scale) const;
bool wasFrameSizeChanged(int frame_index, int scaleIdx, float scale) const;
Graphics::ManagedSurface *dumpTiles(int tilesPerRow) const;
void dumpTiles(Common::Path baseName, int tilesPerRow) const;
Graphics::ManagedSurface *dumpFrameTiles(int frame_index, float scale) const;
private:
grTileCompressionMethod _compression;
/// true если есть альфа-канал
bool _hasAlpha;
/// размеры кадра в пикселах
/// могут быть невыровненными по рамерам тайла
Vect2i _frameSize;
/// размеры кадра в тайлах
Vect2i _frameTileSize;
/// количество кадров
int _frameCount;
typedef Std::vector<uint32> FrameIndex;
struct ScaleArray {
float _scale;
Vect2i _frameSize;
Vect2i _frameTileSize;
int _frameStart;
};
Std::vector<ScaleArray> _scaleArray;
/// индекс кадров - номера тайлов, из которых состоят кадры
/// _frameTileSize.x * _frameTileSize.y на кадр
FrameIndex _frameIndex;
typedef Std::vector<uint32> TileOffsets;
/// смещения до данных каждого тайла
TileOffsets _tileOffsets;
typedef Std::vector<uint32> TileData;
/// данные тайлов
TileData _tileData;
Std::vector<Vect2i> _frameSizeArray;
static CompressionProgressHandler _progressHandler;
static void *_progressHandlerContext;
};
} // namespace QDEngine
#endif // QDENGINE_SYSTEM_GRAPHICS_GR_TILE_ANIMATION_H
|