22#ifndef HOLLYWOOD_RUNAWAY_SCENE_H
23#define HOLLYWOOD_RUNAWAY_SCENE_H
25#include "hollywood/hotspots.h"
26#include "hollywood/resource.h"
27#include "hollywood/runaway/animation.h"
28#include "hollywood/runaway/audio.h"
29#include "hollywood/runaway/graphics.h"
30#include "hollywood/runaway/inventory.h"
31#include "hollywood/runaway/navigation.h"
32#include "hollywood/runaway/presentation.h"
33#include "hollywood/runaway/saveload.h"
34#include "hollywood/runaway/scene_data.h"
35#include "hollywood/runaway/sequence.h"
36#include "hollywood/runaway/speech.h"
37#include "hollywood/scene_text_store.h"
50 virtual bool load(uint16 entryScene) = 0;
51 virtual void start(uint32 now) = 0;
52 virtual void resume() = 0;
53 const Transition &transition()
const {
return _transition; }
54 virtual void click(
Common::Point mouse, RunawayVerb verb,
byte item) = 0;
55 virtual void update(uint32 now,
int scrollDirection,
bool inventoryOpen) = 0;
56 virtual void draw() = 0;
57 virtual void setCameraX(
int x) = 0;
58 virtual int cameraX()
const {
return 0; }
59 virtual int roomWidth()
const = 0;
62 virtual bool hasVerbControls()
const {
return true; }
64 virtual byte actionCursor(
byte hotspot)
const {
return 0; }
65 virtual bool preferLook(
byte hotspot)
const {
return false; }
66 virtual Common::U32String actionCaption(
byte hotspot, RunawayVerb verb,
byte item)
const = 0;
69 virtual bool busy()
const = 0;
70 virtual bool speaking()
const = 0;
71 virtual byte speechFrame()
const {
return 0; }
72 virtual void skipSpeech() = 0;
74 virtual void chooseDialogue(uint choice) {}
75 virtual bool playingVideo()
const {
return false; }
76 virtual bool inventoryPresentation()
const {
return false; }
77 virtual void skipVideo() {}
78 virtual void sayInventory(
const RunawayInventory::Reply &reply) = 0;
79 virtual bool escaped()
const {
return false; }
80 virtual bool canSave()
const {
return false; }
81 virtual void captureState(RunawaySaveState &state)
const {}
83 virtual bool restoreState(
const RunawaySaveState &state, uint32 now,
bool entering =
false) {
return false; }
84 virtual void setOptions(
bool antialias,
bool fastScrolling) = 0;
88 void skipPresentation(uint32 now)
override final { skipVideo(); }
89 void skipPresentationSpeech(uint32 now)
override final { skipSpeech(); }
92 uint16 _entryScene = 0;
93 Transition _transition;
103 bool load(uint16 entryScene)
override;
104 void start(uint32 now)
override;
105 void resume()
override;
106 void click(
Common::Point mouse, RunawayVerb verb,
byte item)
override;
107 void update(uint32 now,
int scrollDirection,
bool inventoryOpen)
override;
108 void draw()
override;
109 void setCameraX(
int x)
override;
110 int cameraX()
const override {
return _camera.
x; }
111 int roomWidth()
const override {
return _background.
w; }
114 byte actionCursor(
byte id)
const override;
115 bool preferLook(
byte id)
const override;
116 Common::U32String actionCaption(
byte hotspot, RunawayVerb verb,
byte item)
const override;
119 bool busy()
const override {
return _sequence.active() || _pendingHotspot != 0 || _transition.scene || _hospitalExit.scene || _arrivalFacing != 0xff || _roomAction || _conversation || speaking(); }
120 bool speaking()
const override {
return _sequence.active() ? !_sequence.subtitle().empty() : !_speech.subtitle().empty(); }
121 byte speechFrame()
const override {
return _sequence.active() ? _sequence.speechFrame() : _speech.frame(_now); }
122 bool playingVideo()
const override {
return _sequence.active(); }
123 void skipVideo()
override { _sequence.skip(); }
124 bool escaped()
const override {
return _chapterComplete; }
125 void skipSpeech()
override;
128 void chooseDialogue(uint choice)
override;
130 bool canSave()
const override {
return !busy() && !_walkPath.active() && _desert.guard != 1; }
132 bool restoreState(
const RunawaySaveState &state, uint32 now,
bool entering =
false)
override;
133 void setOptions(
bool antialias,
bool fastScrolling)
override { _antialias = antialias; _fastScrolling = fastScrolling; }
136 enum ObjectState { kUnexamined, kIdentified, kTaken };
137 enum ActionResult { kUnhandled, kHandled, kBackgroundChanged };
139 constexpr AnimationFootstep(
byte frameNumber, int16 position,
byte loudness = 255) :
140 frame(frameNumber), x(position), volume(loudness) {}
146 virtual bool loadCustomResources() {
return true; }
147 virtual bool loadBackground();
148 virtual bool applyCustomBackgroundPatches() {
return true; }
149 virtual void applyCustomHotspotState() {}
150 virtual void prepareCustomGameplayLoop() {}
151 virtual void runCustomEntrySequence() {}
152 virtual void advanceCustomGameplayLoop(uint32 delta) {}
155 virtual ActionResult dispatchCustomSceneAction(uint16 action) {
return kUnhandled; }
156 virtual byte defaultItemAction(
byte item,
byte hotspot)
const {
return 1; }
158 virtual bool handleCustomDialogueReply() {
return false; }
159 virtual void handleCustomDialogueChoice(
byte effect) {}
160 virtual void runCustomDialogueIntro() {}
161 virtual void finishCustomConversation() {}
162 virtual void resumeAmbientAudio(
bool entering);
163 virtual void stopAmbientSpeech() {}
164 virtual void runExitSideEffectsAfterLoop() {}
165 virtual void updateActor(uint elapsed,
int scrollDirection,
bool inventoryOpen);
167 virtual int sceneViewportYOffset()
const;
169 virtual uint sceneResourceNumber()
const {
return (_room % 1000) / 10; }
170 virtual uint sceneTextNumber()
const {
return finaleChapter() ? (_room - 2000) / 10 : _room / 10; }
171 virtual bool loadWalkMap();
172 virtual bool usesAlternateActor()
const {
return true; }
173 virtual byte initialActorFacing()
const {
return 3; }
174 virtual void setupActorDepth(RunawayActor::RenderParams ¶ms)
const {}
176 virtual bool shouldDrawActor()
const {
return true; }
177 virtual bool roomAnimationInForeground()
const {
return false; }
178 virtual bool shouldUpdateActor()
const {
return true; }
179 virtual bool shouldPlayGameplayClickPath()
const {
return true; }
180 virtual int8 customizeSceneActionApproach(
byte id,
bool use,
byte item, int8 approach)
const {
return approach; }
182 virtual bool adjustCustomWalkTargetToFloorMask(
Common::Point &target)
const {
return false; }
184 virtual bool updateCustomSequence() {
return false; }
185 virtual void finishCustomAnimation(uint16 action) {}
186 virtual void handleAnimationFrameHook() {}
187 virtual void finishCustomFilm() {}
188 virtual uint16 dialoguePlayerCue()
const {
return 80; }
189 virtual uint16 dialogueResponseCue()
const {
return 90; }
190 virtual uint16 dialogueCue(
byte choice,
bool response)
const {
return response ? dialogueResponseCue() : dialoguePlayerCue(); }
192 bool enterRoom(uint16 room,
Common::Point position,
byte facing);
193 bool loadForeground(uint layer, uint chunk,
bool pixels =
false);
197 bool rebuildBackground();
198 bool applyPatch(uint chunk);
200 void walkTo(
Common::Point target,
byte facing = 0xff,
bool scripted =
false,
bool reserved =
false);
202 void execute(uint16 action);
203 void executeItemAction(uint16 action);
204 void useItem(
byte item,
byte hotspot);
205 void say(uint16 cue,
byte variation = 0,
bool global =
false,
byte speaker = 0);
209 void beginRoomAnimation(uint16 action, uint chunk, uint frames,
const byte *order =
nullptr, uint count = 0,
bool hideActor =
true, uint frameDuration = 80);
210 void beginActorAnimation(uint16 action, uint bank, uint frames, uint count = 0, uint frameDuration = 60);
211 void beginAnimation(uint16 action, uint frames,
const byte *order, uint count,
bool hideActor, uint frameDuration);
212 void beginRoomAnimationRange(uint16 action, uint chunk, uint frames, uint first, uint last,
bool hideActor =
true, uint frameDuration = 80);
213 void holdRoomAnimation(uint16 action, uint chunk, uint frames, uint frame,
bool hideActor =
true);
214 void loopRoomAnimationDuringSpeech(uint16 action, uint chunk, uint frames, uint first, uint last,
bool hideActor =
true);
215 void setRoomAnimationOverlay(uint chunk, uint frames,
const byte *order, uint count);
216 bool drawingRoomAnimation()
const {
return !_actionUsesActor && _roomAction && !_actionFrames.
empty() && (_actionHoldSpeech || !speaking()) && !_walkPath.active(); }
217 void updateRoomAnimation();
218 void playAnimationFootsteps(uint frame,
byte surface,
const AnimationFootstep *steps, uint count);
219 virtual float actorHeight()
const {
return 455; }
220 virtual float actorWalkSpeed()
const {
return 0.18f * actorHeight() / 455; }
221 virtual const RunawayHotspot *hotspot(
byte id)
const;
223 virtual const char *actionCaptionVariant(
byte id,
bool look,
byte item)
const {
return nullptr; }
224 virtual bool isValidHotspot(
byte id)
const {
return hotspot(
id) !=
nullptr; }
226 virtual byte customizeSceneActionFacing(
byte id,
byte facing)
const {
return facing; }
227 virtual Common::Point sceneActionLookPosition(
byte id)
const {
return hotspot(
id)->lookPosition; }
229 byte walkZone()
const {
return _originalMaps[_mask[_position.
y * _background.
w + _position.
x]]; }
231 bool hospitalChapter()
const {
return _game == kRunawayFullGame && _room / 1000 == 2; }
232 void resumeHospital();
233 void updateHospital(uint elapsed);
234 void updateHospitalAudio();
235 bool sayHospitalInventory(
const RunawayInventory::Reply &reply);
236 void leaveHospitalRoom(uint16 scene,
Common::Point position,
byte facing);
238 bool museumChapter()
const {
return _game == kRunawayFullGame && _room / 1000 == 4; }
241 void updateMuseum(uint elapsed);
242 bool sayMuseumInventory(
const RunawayInventory::Reply &reply);
243 void deferMuseumAction(uint16 action);
244 void refreshMuseum();
245 void leaveMuseumRoom(uint16 scene,
Common::Point position,
byte facing = 3,
bool door =
false);
246 enum MuseumFilm { kArrivalFilm, kCliveFilm, kDrillingFilm, kLaserFilm, kRubyFilm,
247 kMobstersFilm, kPhoneFilm, kScannerFilm, kBetrayalFilm, kMuseumExitFilm };
248 void startMuseumFilm(MuseumFilm film);
249 void startConversation(
byte character);
250 void updateConversation();
251 void buildDialogueChoices();
252 void finishConversation();
253 byte speaker()
const {
return speaking() && _lineIndex < _lines.size() ? _lines[_lineIndex].speaker : 0; }
255 bool desertChapter()
const {
return _game == kRunawayFullGame && _room / 1000 == 5; }
258 void updateDesert(uint elapsed);
259 void visitDesertRoom(
byte index,
byte lines);
260 void leaveDesertRoom(uint16 scene);
261 void deferDesertAction(uint16 action);
263 bool townChapter()
const {
return _game == kRunawayFullGame && _room / 1000 == 6; }
265 bool sayTownInventory(
const RunawayInventory::Reply &reply);
266 void leaveTownRoom(uint16 scene);
267 void deferTownAction(uint16 action);
270 bool hopiChapter()
const {
return _game == kRunawayFullGame && _room / 1000 == 7; }
271 bool sayHopiInventory(
const RunawayInventory::Reply &reply);
272 bool finaleChapter()
const {
return _game == kRunawayFullGame && _room / 1000 == 8; }
273 bool sayFinaleInventory(
const RunawayInventory::Reply &reply);
274 void resumeFinaleOutdoorAudio(
bool entering, uint16 windCue,
byte windVolume);
275 void updateFinaleOutdoorAudio(
byte wildlifeVolume = 0);
276 void resumeFinaleJailAudio(
bool entering);
277 void updateFinaleJailAudio();
278 void updateOutdoorMusic(
byte cueCount = 3);
279 void updateGameplay(uint32 delta);
281 void deferAction(uint16 action);
282 void leaveRoom(uint16 scene);
284 RunawayAudio &_audio;
285 RunawaySequence _sequence;
286 bool _inventorySequence =
false;
287 RunawayInventory &_inventory;
288 const RunawayStrings &_strings;
289 const RunawayGameType _game;
291 RunawaySpeech _speech;
292 RunawayIdleHead _idleHead;
293 ChunkArchive _archive;
294 SceneTextStore _text;
296 RunawayAnimation _actionAnimation, _secondaryAnimation;
301 RunawayWalkPath _walkPath;
313 uint16 _room = 0, _pendingAction = 0;
314 byte _facing = 3, _pendingHotspot = 0, _pendingItem = 0;
315 byte _arrivalFacing = 0xff;
316 uint32 _now = 0, _lastUpdate = 0, _walkElapsed = 0;
317 bool _upperFloor =
true, _antialias =
true, _fastScrolling =
true;
318 bool _inventoryOpen =
false;
319 ObjectState _books = kUnexamined, _recorder = kUnexamined;
320 bool _moneyIdentified =
false, _safeOpen =
false;
321 bool _varnishTaken =
false, _talcTaken =
false, _coffeeTaken =
false;
323 uint32 _lastFootstep = 0;
330 MuseumFilm _museumFilm = kArrivalFilm;
334 byte enabled, node, transition, player, response, disable, selectable;
339 byte _conversation = 0, _dialogueDepth = 0, _dialogueNode = 0, _dialogueIntro = 0;
340 bool _dialogueEnding =
false;
341 uint16 _afterConversation = 0;
343 uint32 _nextMusic = 0;
344 uint32 _finaleAmbientTick = 0;
345 byte _finaleLastAmbient = 0;
346 bool _entering =
false;
347 uint16 _roomAction = 0;
348 bool _actionHidesActor =
true;
349 bool _actionUsesActor =
false;
350 bool _actionHoldSpeech =
false;
351 bool _actionLoopSpeech =
false;
352 byte _actionStage = 0;
353 uint _actionStep = 0;
354 uint _actionFrameDuration = 80;
355 uint32 _actionStarted = 0;
356 Transition _hospitalExit;
357 bool _chapterComplete =
false;
bool empty() const
Definition: array.h:352
Definition: managed_surface.h:51
int16 & w
Definition: managed_surface.h:134
Definition: hotspots.h:36
Definition: inventory.h:41
Definition: presentation.h:42
Definition: scene_text_store.h:64
Definition: inventory.h:44
Definition: scene_data.h:78
Definition: saveload.h:62
Definition: saveload.h:143
Definition: saveload.h:129
Definition: saveload.h:33
Definition: saveload.h:40
Definition: saveload.h:88
Definition: saveload.h:32