ScummVM API documentation
anifile.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_ANIFILE_H
29 #define GOB_ANIFILE_H
30 
31 #include "common/system.h"
32 #include "common/str.h"
33 #include "common/array.h"
34 #include "common/list.h"
35 
36 namespace Common {
37  class SeekableReadStreamEndian;
38 }
39 
40 namespace Gob {
41 
42 class GobEngine;
43 class Surface;
44 class CMPFile;
45 
53 class ANIFile {
54 public:
56  struct FrameArea {
57  int16 left;
58  int16 top;
59  int16 right;
60  int16 bottom;
61  };
62 
64  struct Animation {
66 
67  uint16 frameCount;
68 
69  int16 x;
70  int16 y;
71  bool transp;
72 
73  int16 deltaX;
74  int16 deltaY;
75 
78 
79  uint16 width;
80  uint16 height;
81  };
82 
83 
84  ANIFile(GobEngine *vm, const Common::String &fileName,
85  uint16 width = 320, uint8 bpp = 1);
86  ~ANIFile();
87 
89  uint16 getAnimationCount() const;
90 
92  void getMaxSize(uint16 &width, uint16 &height) const;
93 
95  const Animation &getAnimationInfo(uint16 animation) const;
96 
98  void draw(Surface &dest, uint16 animation, uint16 frame, int16 x, int16 y) const;
99 
101  void recolor(uint8 from, uint8 to);
102 
103 private:
106 
108  struct AnimationChunk {
109  int16 x;
110  int16 y;
111 
112  uint16 layer;
113  uint16 part;
114  };
115 
119 
120 
121  GobEngine *_vm;
122 
123  uint16 _width;
124  uint8 _bpp;
125 
126  byte _hasPadding;
127 
128  LayerArray _layers;
129  AnimationArray _animations;
130  AnimationFrameArray _frames;
131 
132  uint16 _maxWidth;
133  uint16 _maxHeight;
134 
135 
136  // Loading helpers
137 
138  void load(Common::SeekableReadStreamEndian &ani, const Common::String &fileName);
139 
140  CMPFile *loadLayer(Common::SeekableReadStreamEndian &ani);
141 
142  void loadAnimation(Animation &animation, FrameArray &frames,
144  void loadFrames(FrameArray &frames, Common::SeekableReadStreamEndian &ani);
145 
146  // Drawing helpers
147 
148  bool getCoordinates(uint16 layer, uint16 part,
149  uint16 &left, uint16 &top, uint16 &right, uint16 &bottom) const;
150 
151  void drawLayer(Surface &dest, uint16 layer, uint16 part,
152  int16 x, int16 y, int32 transp) const;
153 };
154 
155 } // End of namespace Gob
156 
157 #endif // GOB_ANIFILE_H
Common::Array< FrameArea > frameAreas
Definition: anifile.h:77
Definition: gob.h:163
Definition: str.h:59
uint16 height
The maximum height of this animation&#39;s frames.
Definition: anifile.h:80
Definition: anifile.h:64
uint16 frameCount
The number of frames in this animation.
Definition: anifile.h:67
Common::String name
The name of the animation.
Definition: anifile.h:65
Definition: anifile.h:56
Definition: array.h:52
Definition: list.h:44
Definition: anifile.h:40
Definition: cmpfile.h:49
Definition: algorithm.h:29
Definition: surface.h:100
Definition: stream.h:944
Definition: anifile.h:53
bool transp
Should the animation frames be drawn with transparency?
Definition: anifile.h:71
int16 x
The default x position for this animation.
Definition: anifile.h:69
int16 deltaY
of pixels to advance in Y direction after each cycle.
Definition: anifile.h:74
int16 deltaX
of pixels to advance in X direction after each cycle.
Definition: anifile.h:73
int16 y
The default y position for this animation.
Definition: anifile.h:70
uint16 width
The maximum width of this animation&#39;s frames.
Definition: anifile.h:79