ScummVM API documentation
head.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 DGDS_HEAD_H
23#define DGDS_HEAD_H
24
25#include "common/str.h"
26#include "common/types.h"
27#include "common/ptr.h"
28#include "common/array.h"
29
30#include "graphics/managed_surface.h"
31
32#include "dgds/dgds_rect.h"
33#include "dgds/image.h"
34#include "dgds/ttm.h"
35
36// Classes related to talking heads and conversations.
37
38namespace Dgds {
39
40class Image;
41class SoundRaw;
42class Dialog;
43
45public:
46 TalkDataHeadFrame() : _xoff(0), _yoff(0), _frameNo(0), _flipFlags(0) {}
47 Common::String dump(const Common::String &indent) const;
48
49 uint16 _frameNo;
50 int16 _xoff;
51 int16 _yoff;
52 uint16 _flipFlags;
53};
54
55enum HeadFlags {
56 kHeadFlagNone = 0,
57 kHeadFlagFinished = 1,
58 kHeadFlag2 = 2,
59 kHeadFlag4 = 4,
60 kHeadFlag8 = 8,
61 kHeadFlag10 = 0x10,
62 kHeadFlagVisible = 0x20,
63 kHeadFlagOpening = 0x40,
64 kHeadFlag80 = 0x80,
65};
66
67class TalkData;
68
70public:
71 TalkDataHead() : _num(0), _drawType(0), _drawCol(0), _flags(kHeadFlagNone) {}
72 Common::String dump(const Common::String &indent) const;
73
74 void clearHead();
75
76 void drawHead(Graphics::ManagedSurface &dst, const TalkData &data) const;
77 void drawHeadType1(Graphics::ManagedSurface &dst, const Image &img) const;
78 void drawHeadType2(Graphics::ManagedSurface &dst, const Image &img) const;
79 void drawHeadType3(Graphics::ManagedSurface &dst, const Image &img) const;
80 void drawHeadType3Beamish(Graphics::ManagedSurface &dst, const TalkData &data) const;
81
82 uint16 _num;
83 uint16 _drawType;
84 uint16 _drawCol;
85 DgdsRect _rect;
87 Common::String _bmpFile;
88 HeadFlags _flags;
90};
91
93class TalkData {
94public:
95 TalkData() : _num(0), _val(0) {}
96 Common::String dump(const Common::String &indent) const;
97
98 uint16 _num;
101 uint16 _val;
102 Common::String _bmpFile;
103
104 void clearVisibleHeads();
105 void drawAndUpdateVisibleHeads(Graphics::ManagedSurface &dst);
106 bool hasVisibleHead() const;
107};
108
109
115public:
117
118 Graphics::ManagedSurface &getStoredAreaBuffer() { return _storedAreaBuffer; }
119
120protected:
121 virtual void handleOperation(TTMEnviro &env, TTMSeq &seq, uint16 op, byte count, const int16 *ivals, const Common::String &sval, const Common::Array<Common::Point> &pts) override;
122
123 Graphics::ManagedSurface _storedAreaBuffer;
124};
125
126class CDSTTMEnviro : public TTMEnviro {
127public:
128 CDSTTMEnviro() : _cdsPlayedSound(false), _cdsFrame(-1), _cdsJumped(false), _cdsDelay(0),
129 _cdsDidStoreArea(false), TTMEnviro()
130 {}
131
132 bool _cdsPlayedSound;
133 int16 _cdsFrame; // The GOTO target to use in the CDS script (Willy Beamish talkie)
134 int16 _cdsDelay;
135 bool _cdsJumped;
136 bool _cdsDidStoreArea;
137 DgdsRect _storedAreaRect;
138};
139
142public:
143 Conversation() : _thisFrameMs(0), _nextExecMs(0), _runTempFrame(-1), _tempFrameNum(0), _stopScript(false), _loadState(0),
144 _dlgNum(-1), _dlgFileNum(-1), _subNum(-1), _finished(false), _haveHeadData(false) {}
146
147 void unloadData();
148 void runScript(bool exclusive);
149 void loadData(uint16 num, uint16 num2, int16 sub, bool haveHeadData);
150 bool isForDlg(const Dialog *dlg) const;
151 bool isFinished() const { return _finished; }
152 void clear();
153
154 DgdsRect _drawRect;
155
156 static enum ImageFlipMode _lastHeadFrameFlipMode;
157 static int16 _lastHeadFrameX;
158 static int16 _lastHeadFrameY;
159
160private:
163 CDSTTMEnviro _ttmEnv;
164 uint32 _nextExecMs;
165
166 bool runScriptFrame(int16 frameNum);
167 void checkAndRunScript(bool updateDelay);
168 void incrementFrame();
169 bool isScriptRunning();
170 void pumpMessages();
171
172 void runScriptExclusive();
173 void runScriptStep();
174
175 int16 _runTempFrame;
176 int16 _tempFrameNum;
177
178 uint32 _thisFrameMs;
179 bool _stopScript;
180 int16 _loadState;
181 int16 _dlgNum;
182 int16 _dlgFileNum;
183 int16 _subNum;
184 bool _finished;
185 bool _haveHeadData;
186};
187
188
189} // end namespace Dgds
190
191#endif // DGDS_HEAD_H
Definition: array.h:52
Definition: ptr.h:159
Definition: str.h:59
Definition: head.h:126
Definition: head.h:114
Definition: head.h:141
Definition: dgds.h:120
Definition: dgds_rect.h:32
Definition: dialog.h:101
Definition: image.h:51
Definition: ttm.h:40
Definition: ttm.h:119
Definition: head.h:44
Definition: head.h:69
Definition: head.h:93
Definition: managed_surface.h:51
Definition: ttm.h:82