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 HOLLYWOOD_RUNAWAY_ANIMATION_H
23#define HOLLYWOOD_RUNAWAY_ANIMATION_H
24
25#include "common/array.h"
26#include "common/random.h"
27#include "common/ustr.h"
28
29namespace Hollywood {
30
31// The room actor, inventory portrait and other speakers share the original
32// text-derived mouth shapes (0..5), with a closed-eye set at 6..11.
34public:
35 // Pass the voice sample ID for retail recordings; zero keeps demo text-derived animation.
36 void start(const Common::U32String &text, uint32 now, uint32 duration, Common::RandomSource &random, uint16 sample = 0);
37 void stop() { _frames.clear(); }
38 byte frame(uint32 now) const;
39 uint frameDuration() const { return _frameDuration; }
40
41private:
42 bool loadRecording(uint16 sample);
43 Common::Array<byte> _frames;
44 uint32 _started = 0, _duration = 0, _frameDuration = 80;
45};
46
48public:
49 void reset(uint32 now);
50 void pause(uint32 elapsed);
51 void update(uint32 now, bool enabled, uint blinkInterval, Common::RandomSource &random);
52 byte frame() const { return _frame; }
53
54private:
55 uint32 _turnTick = 0, _blinkTick = 0;
56 byte _step = 6, _target = 6, _frame = 0;
57 bool _blink = false, _active = false;
58};
59
61public:
62 void update(uint32 now, bool talking, Common::RandomSource &random);
63 uint frame(byte mouth = 0) const;
64 bool holdsGlass() const { return _state == kDrinking && _step >= 15 && _step < 44; }
65
66private:
67 enum State { kBreathing, kWaiting, kDrinking, kTurning, kTalking, kReturning };
68 State _state = kBreathing;
69 uint32 _tick = 0;
70 uint _step = 0, _wait = 0;
71};
72
73} // End of namespace Hollywood
74
75#endif // HOLLYWOOD_RUNAWAY_ANIMATION_H
void clear()
Definition: array.h:321
Definition: random.h:44
Definition: ustr.h:57
Definition: animation.h:60
Definition: animation.h:47
Definition: animation.h:33