ScummVM API documentation
presentation_scene.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_MONSTERS_SCENES_PRESENTATION_SCENE_H
23#define HOLLYWOOD_MONSTERS_SCENES_PRESENTATION_SCENE_H
24
25#include "common/array.h"
26
27#include "hollywood/monsters/graphics.h"
28#include "hollywood/monsters/scenes/animation_channels.h"
29#include "hollywood/monsters/scenes/animation_player.h"
30#include "hollywood/monsters/scenes/scene_resources.h"
31#include "hollywood/monsters/scenes/speech_overlay.h"
32
33namespace Hollywood {
34
35class HollywoodEngine;
36
37// Owns display, resources, timing, and skip plumbing shared by full-screen scenes.
39protected:
40 // Keeps fixed-duration cutscenes responsive while leaving frame updates to the scene.
41 // Each successful beginFrame() must be followed by finishFrame().
43 public:
44 enum DurationMode {
45 kUntilStopped
46 };
47
48 TimedPresentationLoop(PresentationScene &scene, uint32 durationMillis,
49 uint32 maximumSliceMillis = 10, bool allowSkip = true);
50 TimedPresentationLoop(PresentationScene &scene, DurationMode,
51 uint32 maximumSliceMillis = 10, bool allowSkip = true);
52
53 bool beginFrame();
54 uint32 finishFrame();
55
56 private:
57 PresentationScene &_scene;
58 uint32 _durationMillis;
59 uint32 _maximumSliceMillis;
60 uint32 _elapsedMillis;
61 uint32 _sliceMillis;
62 bool _allowSkip;
63 bool _durationLimited;
64 };
65
66 PresentationScene(HollywoodEngine *vm, const char *debugName,
67 uint32 sceneFramebufferSize = kSceneBufferByteCount,
68 uint32 savedFramebufferSize = kSceneBufferByteCount);
69 virtual ~PresentationScene() {}
70
71 virtual void stopAudio() {}
72 virtual void drawFrameOverlays();
73 virtual uint presentRowOffset() const;
74 virtual uint presentXOffset() const;
75 virtual int subtitleViewportYOffset() const;
76 bool animationPlaybackShouldStop() const override;
77 void presentAnimationFrame() override;
78 bool waitForAnimationFrame(uint32 millis, bool allowSkip) override;
79
80 bool showAnchoredSubtitle(const Common::String &text, byte colorIndex,
81 int centerX, int anchorBottomY,
82 SpeechOverlayWrapStyle wrapStyle = kSpeechOverlayAdaptiveWrap);
83 bool showAnchoredSubtitle(SpeechOverlay &overlay, const Common::String &text,
84 byte colorIndex, int centerX, int anchorBottomY,
85 SpeechOverlayWrapStyle wrapStyle = kSpeechOverlayAdaptiveWrap);
86 bool showPositionedSubtitle(const Common::String &text, byte colorIndex,
87 int centerX, int topY,
88 SpeechOverlayWrapStyle wrapStyle = kSpeechOverlayAdaptiveWrap);
89 bool showPositionedSubtitle(SpeechOverlay &overlay, const Common::String &text,
90 byte colorIndex, int centerX, int topY,
91 SpeechOverlayWrapStyle wrapStyle = kSpeechOverlayAdaptiveWrap);
92 void clearSubtitle();
93 void clearSubtitle(SpeechOverlay &overlay);
94 bool loadFixedChunk(uint index, Common::Array<byte> &destination, uint fixedSize);
95 bool loadFixedChunk(uint index, IndexedSurfaceBuffer &destination, uint fixedSize);
96 bool loadVariableChunk(uint index, Common::Array<byte> &destination);
97 bool loadChunkTo(uint index, Common::Array<byte> &destination,
98 uint32 destinationOffset);
99 bool loadArenaChunk(uint index);
100 bool loadArenaChunk(uint archiveIndex, uint localChunkIndex);
101 bool loadArenaChunkAlias(uint sourceIndex, uint aliasIndex, uint targetIndex);
102 void drawResourceSpriteLayer(const ResourceSpriteLayer &layer);
103 void drawLayerStack(SceneAnimationStratum stratum);
104
105 void presentFrame();
106 void presentFrame(uint rowOffset, uint xOffset);
107 virtual bool pollEvents(bool allowSkip = true);
108 bool delay(uint32 millis, bool allowSkip = true);
109 bool consumeStepAdvanceRequest();
110
111 bool revealSavedFramebufferWithCurtain(byte bandWidth = 0x14);
112 bool clearSceneFramebufferWithCurtain(byte bandWidth = 0x14);
113 void revealSavedFramebufferBand(uint sweepOffset, byte bandWidth, uint xOffset = 0);
114 void clearSceneFramebufferBand(uint sweepOffset, byte bandWidth);
115 void copySavedFramebufferRun(int y, int x, int width);
116 void clearSceneFramebufferRun(int y, int x, int width);
117
118 HollywoodEngine *_vm;
119 const char *_debugName;
120 SceneResources _resources;
121 SceneLayerStack _sceneLayers;
122 RealtimeAnimationTracks _realtimeAnimationTracks;
123 SceneAnimationPlayer _animationPlayer;
124 Common::Array<byte> _paletteCurrent;
125 IndexedSurfaceBuffer _sceneFramebuffer;
126 IndexedSurfaceBuffer _savedFramebuffer;
128 Palette6Bit _displayPalette;
129 SpeechOverlay _subtitle;
130 bool _skipRequested;
131 bool _stepAdvanceRequested;
132};
133
134} // End of namespace Hollywood
135
136#endif // HOLLYWOOD_MONSTERS_SCENES_PRESENTATION_SCENE_H
Definition: str.h:59
Definition: managed_surface.h:51
Definition: hollywood.h:47
Definition: presentation_scene.h:42
Definition: presentation_scene.h:38
Definition: animation_player.h:166