ScummVM API documentation
action_overlay.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_PLAYABLE_ACTION_OVERLAY_H
23#define HOLLYWOOD_MONSTERS_SCENES_PLAYABLE_ACTION_OVERLAY_H
24
25#include "common/types.h"
26
27#include "hollywood/monsters/scenes/animation_events.h"
28#include "hollywood/monsters/scenes/animation_layers.h"
29
30namespace Hollywood {
31
32// Playback bounds and interruption behavior for action overlays.
35 firstFrame(0),
36 endFrame(0),
37 allowSkip(true),
38 waitAfterFinalFrame(true) {
39 }
40
41 uint firstFrame;
42 uint endFrame;
43 bool allowSkip;
44 bool waitAfterFinalFrame;
45};
46
63struct ActionOverlaySpec : AnimationEventSpec<ActionOverlaySpec> {
64 ActionOverlaySpec(uint newChunkIndex, uint newDescriptorCount, uint32 newFrameMillis) :
65 chunkIndex(newChunkIndex),
66 descriptorCount(newDescriptorCount),
67 frameMap(nullptr),
68 frameMapSize(0),
69 frameMillis(newFrameMillis),
70 heldFrame(-1),
71 bookendLastFrame(false),
72 appendFirstFrame(false),
73 reversePlayback(false),
74 hasDrawStratum(false),
75 drawStratum(kSceneAnimationInFrontOfActors),
76 restoreBackgroundBeforeDraw(false),
77 options() {
78 }
79
80 ActionOverlaySpec(uint newChunkIndex, uint newDescriptorCount,
81 const byte *newFrameMap, uint newFrameMapSize, uint32 newFrameMillis) :
82 chunkIndex(newChunkIndex),
83 descriptorCount(newDescriptorCount),
84 frameMap(newFrameMap),
85 frameMapSize(newFrameMapSize),
86 frameMillis(newFrameMillis),
87 heldFrame(-1),
88 bookendLastFrame(false),
89 appendFirstFrame(false),
90 reversePlayback(false),
91 hasDrawStratum(false),
92 drawStratum(kSceneAnimationInFrontOfActors),
93 restoreBackgroundBeforeDraw(false),
94 options() {
95 }
96
97 ActionOverlaySpec &holdFirstFrame() {
98 return holdFrame(0);
99 }
100
101 ActionOverlaySpec &holdFrame(int frame) {
102 const uint frameCount = frameMap != nullptr ? frameMapSize : descriptorCount;
103 heldFrame = frame >= 0 && (uint)frame < frameCount ? frame : -1;
104 bookendLastFrame = false;
105 appendFirstFrame = false;
106 return *this;
107 }
108
109 ActionOverlaySpec &bookendWithLastFrame() {
110 heldFrame = -1;
111 bookendLastFrame = true;
112 appendFirstFrame = false;
113 return *this;
114 }
115
116 ActionOverlaySpec &returnToFirstFrame() {
117 heldFrame = -1;
118 bookendLastFrame = false;
119 appendFirstFrame = true;
120 return *this;
121 }
122
123 ActionOverlaySpec &reverse() {
124 reversePlayback = true;
125 return *this;
126 }
127
128 ActionOverlaySpec &drawAt(SceneAnimationStratum stratum) {
129 hasDrawStratum = true;
130 drawStratum = stratum;
131 return *this;
132 }
133
134 ActionOverlaySpec &restoreBaseBackground() {
135 restoreBackgroundBeforeDraw = true;
136 return *this;
137 }
138
139 ActionOverlaySpec &noFinalFrameDelay() {
140 options.waitAfterFinalFrame = false;
141 return *this;
142 }
143
144 ActionOverlaySpec &unskippable() {
145 options.allowSkip = false;
146 return *this;
147 }
148
149 ActionOverlaySpec &startAt(uint firstFrame) {
150 options.firstFrame = firstFrame;
151 return *this;
152 }
153
154 ActionOverlaySpec &endAt(uint endFrame) {
155 options.endFrame = endFrame;
156 return *this;
157 }
158
159 ActionOverlaySpec &frameRange(uint firstFrame, uint endFrame) {
160 options.firstFrame = firstFrame;
161 options.endFrame = endFrame;
162 return *this;
163 }
164
165 uint playbackFrameCount() const {
166 const uint frameCount = frameMap != nullptr ? frameMapSize : descriptorCount;
167 if (frameCount == 0)
168 return 0;
169 return frameCount + (heldFrame >= 0 || bookendLastFrame || appendFirstFrame ? 1 : 0);
170 }
171
172 uint targetFrame(uint playbackFrame) const {
173 const uint frameCount = frameMap != nullptr ? frameMapSize : descriptorCount;
174 if (frameCount == 0)
175 return 0;
176 if (bookendLastFrame) {
177 if (playbackFrame == 0 || (reversePlayback && playbackFrame == frameCount))
178 return frameCount - 1;
179 return reversePlayback ? frameCount - playbackFrame - 1 : playbackFrame - 1;
180 }
181 if (appendFirstFrame && playbackFrame == frameCount)
182 return 0;
183 uint frame = heldFrame < 0 || playbackFrame <= (uint)heldFrame ?
184 playbackFrame : playbackFrame - 1;
185 if (!reversePlayback)
186 return frame;
187 return frameCount - 1 - frame;
188 }
189
190 uint chunkIndex;
191 uint descriptorCount;
192 const byte *frameMap;
193 uint frameMapSize;
194 uint32 frameMillis;
195 int heldFrame;
196 bool bookendLastFrame;
197 bool appendFirstFrame;
198 bool reversePlayback;
199 bool hasDrawStratum;
200 SceneAnimationStratum drawStratum;
201 bool restoreBackgroundBeforeDraw;
202 ActionOverlayOptions options;
203};
204
205} // End of namespace Hollywood
206
207#endif
Definition: animation_events.h:140
Definition: action_overlay.h:33
Definition: action_overlay.h:63