ScummVM API documentation
livingbooks_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 MOHAWK_LIVINGBOOKS_ANIMATION_H
23#define MOHAWK_LIVINGBOOKS_ANIMATION_H
24
25#include "mohawk/livingbooks_constants.h"
26#include "mohawk/livingbooks_item.h"
27#include "mohawk/sound.h"
28
29#include "common/array.h"
30#include "common/rect.h"
31
32namespace Mohawk {
33
34class MohawkEngine_LivingBooks;
35class LBPage;
36class LBAnimation;
37
39 byte opcode;
40 byte size;
41 byte *data;
42};
43
45public:
46 LBAnimationNode(MohawkEngine_LivingBooks *vm, LBAnimation *parent, uint16 scriptResourceId);
48
49 void draw(const Common::Rect &_bounds);
50 void reset();
51 NodeState update(bool seeking = false);
52 bool transparentAt(int x, int y);
53
54protected:
56 LBAnimation *_parent;
57
58 void loadScript(uint16 resourceId);
59 uint _currentEntry;
61
62 uint _currentCel;
63 int16 _xPos, _yPos;
64 uint32 _delay;
65};
66
67class LBAnimationItem;
68
70public:
71 LBAnimation(MohawkEngine_LivingBooks *vm, LBAnimationItem *parent, uint16 resourceId);
73
74 void draw();
75 bool update();
76
77 void start();
78 void seek(uint16 pos);
79 void seekToTime(uint32 time);
80 void stop();
81
82 void playSound(uint16 resourceId);
83 bool soundPlaying(uint16 resourceId, const Common::String &cue);
84
85 bool transparentAt(int x, int y);
86
87 void setTempo(uint16 tempo);
88
89 uint getNumResources() { return _shapeResources.size(); }
90 uint16 getResource(uint num) { return _shapeResources[num]; }
91 Common::Point getOffset(uint num) { return _shapeOffsets[num]; }
92
93 uint32 getCurrentFrame() { return _currentFrame; }
94
95 uint16 getParentId();
96
97protected:
99 LBAnimationItem *_parent;
100
101 Common::Rect _bounds, _clip;
103
104 uint16 _tempo;
105
106 uint16 _currentSound;
107 CueList _cueList;
108
109 uint32 _lastTime, _currentFrame;
110 bool _running;
111
112 void loadShape(uint16 resourceId);
113 Common::Array<uint16> _shapeResources;
114 Common::Array<Common::Point> _shapeOffsets;
115};
116
117class LBAnimationItem : public LBItem {
118public:
120 ~LBAnimationItem() override;
121
122 void setEnabled(bool enabled) override;
123 bool contains(Common::Point point) override;
124 void update() override;
125 void draw() override;
126 bool togglePlaying(bool playing, bool restart) override;
127 void done(bool onlyNotify) override;
128 void init() override;
129 void seek(uint16 pos) override;
130 void seekToTime(uint32 time) override;
131 void startPhase(uint phase) override;
132 void stop() override;
133
134protected:
135 LBItem *createClone() override;
136
137 LBAnimation *_anim;
138 bool _running;
139};
140
141} // End of namespace Mohawk
142
143#endif
Definition: array.h:52
size_type size() const
Definition: array.h:316
Definition: str.h:59
Definition: livingbooks_animation.h:69
Definition: livingbooks_animation.h:117
Definition: livingbooks_animation.h:44
Definition: livingbooks_item.h:45
Definition: livingbooks_page.h:34
Definition: livingbooks.h:84
Definition: bitmap.h:32
Definition: rect.h:144
Definition: rect.h:536
Definition: sound.h:119
Definition: livingbooks_animation.h:38