ScummVM API documentation
scene5030.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_SCENE5030_H
23#define HOLLYWOOD_RUNAWAY_SCENE5030_H
24
25#include "common/random.h"
26#include "common/ustr.h"
27#include "hollywood/resource.h"
28#include "hollywood/runaway/animation.h"
29#include "hollywood/runaway/audio.h"
30#include "hollywood/runaway/graphics.h"
31#include "hollywood/runaway/inventory.h"
32#include "hollywood/runaway/presentation.h"
33#include "hollywood/runaway/scene.h"
34#include "hollywood/runaway/video.h"
35#include "hollywood/scene_text_store.h"
36
37namespace Hollywood {
38namespace Runaway {
39
40// The demos and retail chapter three share the shack, its room resources, actor,
41// interactions and audio; RunawayEngine owns the backend and event loop.
42class Scene5030 : public RunawayScene {
43public:
44 enum {
45 kScreenWidth = kRunawayScreenWidth, kScreenHeight = kRunawayScreenHeight,
46 kRoomWidth = 1376, kRoomHeight = kRunawayViewportHeight, kRoomTop = kRunawayViewportTop
47 };
48
49 Scene5030(Audio::Mixer *mixer, RunawayAudio &audio, RunawayInventory &inventory, const RunawayStrings &strings,
50 RunawayGameType game = kRunawayCabinDemo) :
51 _audio(audio), _inventory(inventory), _strings(strings), _game(game), _interrogation(mixer), _random("runawayShack"), _actor(),
52 _speech(audio, _random, game == kRunawayFullGame ? RunawaySpeech::kRecordedLipSync : RunawaySpeech::kTextLipSync),
53 _walkPath(Common::Point(623, 447)) {}
54 bool load(uint16 entryScene) override;
55 void start(uint32 now) override;
56 void resume() override;
57 void click(Common::Point mouse, RunawayVerb verb, byte item) override;
58 void update(uint32 now, int scrollDirection, bool inventoryOpen) override;
59 void draw() override;
60 void setCameraX(int x) override;
61 int cameraX() const override { return _cameraX; }
62 int roomWidth() const override { return kRoomWidth; }
63 Graphics::ManagedSurface &screen() override { return _screen; }
64 byte hotspotAt(Common::Point mouse) const override;
65 Common::U32String actionCaption(byte hotspot, RunawayVerb verb, byte item) const override;
66 const Common::U32String &committedCaption() const override { return _committedCaption; }
67 const Common::U32String &subtitle() const override { return _action == kPeekConversation ? _interrogation.subtitle() : _speech.subtitle(); }
68 bool busy() const override { return _action != kNone || _transition.scene; }
69 bool speaking() const override { return _action == kPeekConversation ? _interrogation.speaking() : _speechRow != 0; }
70 byte speechFrame() const override { return _speech.frame(_now); }
71 void skipSpeech() override;
72 bool playingVideo() const override { return _action == kIntroVideo || _action == kCleanWindowVideo; }
73 bool inventoryPresentation() const override { return _action == kIntroInventory; }
74 void skipVideo() override;
75 void cancelWalk();
76 void sayInventory(const RunawayInventory::Reply &reply) override;
77 bool escaped() const override { return _escaped; }
78 bool canSave() const override { return !busy() && !speaking() && !_escaped && !_walkPath.active(); }
79 void captureState(RunawaySaveState &state) const override;
80 bool restoreState(const RunawaySaveState &state, uint32 now, bool entering = false) override;
81 void setOptions(bool antialias, bool fastScrolling) override { _antialias = antialias; _fastScrolling = fastScrolling; }
82
83private:
84 Common::U32String hotspotName(byte id) const override;
85 enum Action {
86 kNone, kIntroVideo, kIntro, kIntroLookAround, kIntroInventory,
87 kIntroListen, kIntroWalkToDoor, kIntroExamineDoor,
88 kOpenLid, kCloseLid, kUnplug,
89 kCleanWindowSpeech, kCleanWindowClimb, kCleanWindowVideo,
90 kWaitSpeech, kWalkingAction, kPickup, kShirt,
91 kMeltIce, kMeltWait, kInspectIce, kFinishMelting,
92 kTryMoveCooler, kMoveCooler, kRevealHatch, kFinishMoving, kHatchFound,
93 kDrainCooler, kFinishDraining, kPryHatch, kOpenHatch, kEscape,
94 kPeekDoor, kPeekConversation, kReturnFromPeek,
95 kHeatHelmet, kPrepareStirringHelmet, kStirHelmet, kEnterHatch
96 };
97 enum IceState { kFrozen, kMelted, kDrained };
98 enum HatchState { kHidden, kLocked, kUnlocked, kOpen };
99 bool loadRoomGraphics();
100 void walkTo(Common::Point target);
101 void arrive(bool faceHotspot = true);
102 void say(uint16 row);
103 void sayCue(uint16 cue, byte variation);
104 void pickUp(byte hotspot, byte item, uint patch);
105 void useItem(byte item, byte hotspot);
106 void examine(byte hotspot);
107 void collect(byte hotspot);
108 void waitForSpeech(uint16 cue, byte variation, Action next);
109 void walkForAction(Common::Point target, byte facing, Action next);
110 void setPosition(Common::Point position, byte facing);
111 void updateAction();
112 void showSpeechRow();
113 void stopSpeech();
114 void playWalkFootstep();
115 void startAction(Action action);
116 void finishAction();
117 bool loadPatch(uint chunk, Common::Array<byte> &patch);
118 void applyPatch(uint chunk);
119 void drawPatch(const Common::Array<byte> &patch);
120
121 int _cameraX = 111;
122 ChunkArchive _archive;
123 SceneTextStore _text;
124 Graphics::ManagedSurface _background, _screen;
125 Common::Array<byte> _mask, _maps, _unplugPatch, _openLidPatch, _closedLidPatch;
126 Common::Array<byte> _pickupPatches[5];
127 Common::Array<uint16> _voiceSamples, _cueEnds;
128 RunawayAudio &_audio;
129 RunawayInventory &_inventory;
130 const RunawayStrings &_strings;
131 const RunawayGameType _game;
132 RunawayInterrogation _interrogation;
133 Common::RandomSource _random;
134 bool _peeked = false;
135 bool _entering = false;
136 bool _antialias = true, _fastScrolling = true;
137 RunawayActor _actor;
138 RunawaySpeech _speech;
139 RunawayIdleHead _idleHead;
140 RunawayAnimation _intro, _lidActor, _lid, _unplug, _climb, _actionAnimation, _water, _hatch;
141 RunawayVideo _video;
142 Common::Point _position = Common::Point(623, 447);
143 RunawayWalkPath _walkPath;
144 byte _facing = 3, _pendingHotspot = 0;
145 byte _pendingItem = 0;
146 RunawayVerb _pendingVerb = kVerbWalk;
147 Action _action = kNone;
148 Action _afterSpeech = kNone, _afterWalk = kNone;
149 byte _actionFacing = 0, _pickupHotspot = 0;
150 bool _lidOpen = false, _unplugged = false;
151 bool _windowClean = false;
152 bool _coolerMoved = false, _coolerInspected = false, _escaped = false;
153 IceState _ice = kFrozen;
154 HatchState _hatchState = kHidden;
155 bool _pickedUp[20] = {};
156 bool _examined[20] = {};
157 bool _globalSpeech = false;
158 uint32 _now = 0, _lastUpdate = 0, _actionStarted = 0;
159 uint32 _walkElapsed = 0, _lastFootstep = 0;
160 uint _step = 0;
161 uint16 _speechRow = 0, _speechEnd = 0;
162 uint16 _speechSample = 0;
163 RunawayInventory::Reply _nextInventoryReply = RunawayInventory::Reply(0);
164 Common::U32String _committedCaption;
165};
166
167} // End of namespace Runaway
168} // End of namespace Hollywood
169
170#endif // HOLLYWOOD_RUNAWAY_SCENE5030_H
Definition: mixer.h:70
Definition: random.h:44
Definition: ustr.h:57
Definition: managed_surface.h:51
Definition: resource.h:59
Definition: scene5030.h:42
Definition: graphics.h:69
Definition: graphics.h:54
Definition: audio.h:29
Definition: animation.h:47
Definition: presentation.h:82
Definition: inventory.h:41
Definition: scene.h:41
Definition: speech.h:31
Definition: strings.h:37
Definition: video.h:35
Definition: navigation.h:45
Definition: scene_text_store.h:64
Definition: rect.h:144
Definition: inventory.h:44
Definition: saveload.h:32