ScummVM API documentation
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 NANCY_ACTION_OVERLAY_H
23 #define NANCY_ACTION_OVERLAY_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 
27 namespace Nancy {
28 namespace Action {
29 
30 // Places a static image or a looping animation on top of the background
31 // Can move along with the scene's background frame, however:
32 // - in animation mode, the animation is the same for every background frame
33 // - in static mode, every background frame gets its own static image
34 // Also supports:
35 // - playing a sound;
36 // - playing backwards;
37 // - looping (non-looping animated overlays are very rare);
38 // - getting interrupted by an event flag;
39 // - changing the scene/setting flags when clicked/interrupted
40 // Originally introduced in nancy1, where it was split into two different types:
41 // PlayStaticBitmapAnimation and PlayIntStaticBitmapAnimation (the latter was interruptible)
42 // In nancy2, the two got merged inside the newly-renamed Overlay;
43 // that was also when static mode got introduced.
44 class Overlay : public RenderActionRecord {
45 public:
46  Overlay(bool interruptible) : RenderActionRecord(7), _isInterruptible(interruptible), _usesAutotext(false) {}
47  virtual ~Overlay() { _fullSurface.free(); }
48 
49  void init() override;
50  void handleInput(NancyInput &input) override;
51 
52  void readData(Common::SeekableReadStream &stream) override;
53  void execute() override;
54 
55  Common::Path _imageName;
56 
57  uint16 _transparency = kPlayOverlayPlain;
58  uint16 _hasSceneChange = kPlayOverlaySceneChange;
59  uint16 _enableHotspot = kPlayOverlayNoHotspot;
60  uint16 _overlayType = kPlayOverlayAnimated;
61  uint16 _playDirection = kPlayOverlayForward;
62  uint16 _loop = kPlayOverlayOnce;
63  uint16 _firstFrame = 0;
64  uint16 _loopFirstFrame = 0;
65  uint16 _loopLastFrame = 0;
66  uint32 _frameTime = 0;
67  FlagDescription _interruptCondition;
68  SceneChangeDescription _sceneChange;
69  MultiEventFlagDescription _flagsOnTrigger;
70 
72 
73  // Describes a single frame in this animation
75  // Describes how the animation will be displayed on a single
76  // frame of the viewport
77  Common::Array<FrameBlitDescription> _blitDescriptions;
78 
79  int16 _currentFrame = -1;
80  int16 _currentViewportFrame = -1;
81  uint32 _nextFrameTime = 0;
82  bool _isInterruptible;
83  bool _usesAutotext;
84 
85 protected:
86  bool canHaveHotspot() const override { return true; }
87  Common::String getRecordTypeName() const override;
88  bool isViewportRelative() const override { return true; }
89 
90  Graphics::ManagedSurface _fullSurface;
91 };
92 
93 // Short version of a static overlay; assumes scene background doesn't move
94 class OverlayStaticTerse : public Overlay {
95 public:
96  OverlayStaticTerse() : Overlay(true) {}
97  virtual ~OverlayStaticTerse() {}
98 
99  void readData(Common::SeekableReadStream &stream) override;
100 
101 protected:
102  Common::String getRecordTypeName() const override { return "OverlayStaticTerse"; }
103 };
104 
105 // Short version of an animated overlay; assumes scene background doesn't move
106 class OverlayAnimTerse : public Overlay {
107 public:
108  OverlayAnimTerse() : Overlay(true) {}
109  virtual ~OverlayAnimTerse() {}
110 
111  void readData(Common::SeekableReadStream &stream) override;
112 
113 protected:
114  Common::String getRecordTypeName() const override { return "OverlayAnimTerse"; }
115 };
116 
117 class TableIndexOverlay : public Overlay {
118 public:
119  TableIndexOverlay() : Overlay(true) {}
120  virtual ~TableIndexOverlay() {}
121 
122  void readData(Common::SeekableReadStream &stream) override;
123  void execute() override;
124 
125 protected:
126  Common::String getRecordTypeName() const override { return "TableIndexOverlay"; }
127 
128  uint16 _tableIndex = 0;
129  int16 _lastIndexVal = -1;
130 };
131 
132 } // End of namespace Action
133 } // End of namespace Nancy
134 
135 #endif // NANCY_ACTION_OVERLAY_H
Definition: managed_surface.h:51
Definition: commontypes.h:199
Definition: str.h:59
Definition: commontypes.h:151
Definition: path.h:52
Definition: stream.h:745
Definition: input.h:41
Definition: overlay.h:117
Definition: actionrecord.h:149
Definition: overlay.h:94
Definition: overlay.h:44
Definition: commontypes.h:254
Definition: commontypes.h:166
Definition: overlay.h:106
Definition: actionmanager.h:32