ScummVM API documentation
shape.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 ULTIMA8_GFX_SHAPE_H
23#define ULTIMA8_GFX_SHAPE_H
24
25#include "common/array.h"
26#include "common/stream.h"
27
28namespace Ultima {
29namespace Ultima8 {
30
31class ShapeFrame;
32class RawShapeFrame;
33class Palette;
34struct ConvertShapeFormat;
35
36class Shape {
37public:
38 // Parse data, create frames.
39 // NB: Shape uses data without copying it. It is deleted on destruction
40 // If format is not specified it will be autodetected
41 Shape(const uint8 *data, uint32 size, const ConvertShapeFormat *format,
42 const uint16 flexId, const uint32 shapenum);
44 virtual ~Shape();
45 void setPalette(const Palette *pal) {
46 _palette = pal;
47 }
48 const Palette *getPalette() const {
49 return _palette;
50 }
51
52 uint32 frameCount() const {
53 return static_cast<uint32>(_frames.size());
54 }
55
59 void getTotalDimensions(int32 &w, int32 &h, int32 &x, int32 &y) const;
60
61 const ShapeFrame *getFrame(unsigned int frame) const;
62
63 void getShapeId(uint16 &flexId, uint32 &shapenum) const;
64
65 // This will detect the format of a shape
66 static const ConvertShapeFormat *DetectShapeFormat(const uint8 *data, uint32 size);
67 static const ConvertShapeFormat *DetectShapeFormat(Common::SeekableReadStream &ds, uint32 size);
68
69private:
70 void loadFrames(const uint8 *data, uint32 size, const ConvertShapeFormat *format);
71
72 // This will load a u8 style shape 'optimized'.
73 static Common::Array<RawShapeFrame *> loadU8Format(const uint8 *data, uint32 size, const ConvertShapeFormat *format);
74
75 // This will load a pentagram style shape 'optimized'.
76 static Common::Array<RawShapeFrame *> loadPentagramFormat(const uint8 *data, uint32 size, const ConvertShapeFormat *format);
77
78 // This will load any sort of shape via a ConvertShapeFormat struct
79 // Crusader shapes must be loaded this way
80 static Common::Array<RawShapeFrame *> loadGenericFormat(const uint8 *data, uint32 size, const ConvertShapeFormat *format);
81
83
84 const Palette *_palette;
85
86 const uint16 _flexId;
87 const uint32 _shapeNum;
88};
89
90} // End of namespace Ultima8
91} // End of namespace Ultima
92
93#endif
Definition: array.h:52
Definition: stream.h:745
Definition: atari-screen.h:42
Definition: palette.h:36
Definition: shape_frame.h:33
Definition: shape.h:36
void getTotalDimensions(int32 &w, int32 &h, int32 &x, int32 &y) const
Definition: convert_shape.h:35