ScummVM API documentation
animation.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 ANIMATION_H
23 #define ANIMATION_H
24 
25 #include "common/ptr.h"
26 #include "common/rect.h"
27 #include "common/scummsys.h"
28 #include "common/str.h"
29 
30 namespace Common {
31 class SeekableReadStream;
32 }
33 namespace Graphics {
34 struct Surface;
35 class ManagedSurface;
36 } // namespace Graphics
37 namespace Video {
38 class FlicDecoder;
39 }
40 
41 namespace AGDS {
42 
43 class AGDSEngine;
44 class Object;
45 
46 class Animation {
49 
50  AGDSEngine *_engine;
51  Common::String _name;
52  FlicPtr _flic;
53  ManagedSurfacePtr _frame;
54  ManagedSurfacePtr _scaledFrame;
55  int _frames;
56  Common::Point _position;
57  Common::String _process;
58  Common::String _phaseVar;
59  bool _loop;
60  int _cycles;
61  bool _phaseVarControlled;
62  int _phase;
63  bool _paused;
64  int _speed;
65  int _z;
66  int _rotation;
67  int _delay;
68  int _random;
69  float _scale;
70  bool _onScreen;
71  uint _visibleHeight;
72  uint _visibleCenter;
73 
74 public:
75  Animation(AGDSEngine *engine, const Common::String &name);
76  ~Animation();
77 
78  bool hasFrame() const {
79  return _frame != nullptr;
80  }
81 
82  int frames() const {
83  return _frames;
84  }
85  bool ended() const {
86  return _phase >= _frames;
87  }
88 
89  const Common::Point &position() const {
90  return _position;
91  }
92 
93  void position(Common::Point position) {
94  _position = position;
95  }
96 
97  const Common::String &phaseVar() const {
98  return _phaseVar;
99  }
100 
101  void phaseVar(const Common::String &phaseVar) {
102  _phaseVar = phaseVar;
103  }
104 
105  const Common::String &process() const {
106  return _process;
107  }
108 
109  void process(const Common::String &process) {
110  _process = process;
111  }
112 
113  void loop(bool loop) {
114  _loop = loop;
115  }
116 
117  void cycles(int cycles) {
118  _cycles = cycles;
119  }
120 
121  void delay(int delay) {
122  _delay = delay;
123  }
124 
125  void setRandom(int value) { // can't declare random() because of stupid macro
126  _random = value;
127  }
128 
129  void phaseVarControlled(bool controlled) {
130  _phaseVarControlled = controlled;
131  _onScreen = !controlled;
132  }
133 
134  bool paused() const {
135  return _paused;
136  }
137 
138  void pause() {
139  _paused = true;
140  }
141 
142  void resume() {
143  _paused = false;
144  }
145 
146  void rewind();
147 
148  void speed(int speed) {
149  _speed = speed;
150  }
151 
152  void z(int z) {
153  _z = z;
154  }
155 
156  int z() const {
157  return _z;
158  }
159 
160  void rotate(int rotation) {
161  if (_rotation == rotation)
162  return;
163 
164  _rotation = rotation;
165  rescaleCurrentFrame();
166  }
167 
168  void scale(float scale);
169  float scale() const {
170  return _scale;
171  }
172 
173  int phase() const {
174  return _phase;
175  }
176 
177  void onScreen(bool onScreen);
178 
179  bool load(Common::SeekableReadStream *stream, const Common::String &fname);
180  void paint(Graphics::Surface &backbuffer, Common::Point dst, Graphics::ManagedSurface *mask = nullptr, int maskAlpha = 0) const;
181  uint width() const;
182  uint height() const;
183  uint visibleHeight() const {
184  return _visibleHeight;
185  }
186  uint visibleCenter() const {
187  return _visibleCenter;
188  }
189  bool tick();
190 
191  void decodeNextFrame();
192 
193 private:
194  void rescaleCurrentFrame();
195  void freeFrame();
196  void freeScaledFrame();
197 };
198 
199 } // End of namespace AGDS
200 
201 #endif /* AGDS_ANIMATION_H */
Definition: managed_surface.h:51
Definition: str.h:59
Definition: surface.h:67
Definition: stream.h:745
Definition: agds.h:58
Definition: animation.h:46
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: rect.h:144
Definition: animation.h:37
Definition: agds.h:81