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