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