ScummVM API documentation
hotspots.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_GAMEPLAY_HOTSPOTS_H
23#define HOLLYWOOD_MONSTERS_GAMEPLAY_HOTSPOTS_H
24
25#include "common/array.h"
26#include "common/rect.h"
27#include "common/str.h"
28#include "common/types.h"
29
30#include "hollywood/monsters/scenes/scene_data.h"
31
32namespace Graphics {
33struct HotspotInfo;
34struct Surface;
35}
36
37namespace Hollywood {
38
39class HollywoodFont;
40struct HollywoodGameStrings;
41
42Common::String inventoryActionCaption(const HollywoodGameStrings &strings, byte stripIndex);
43
45 uint16 actionHandlerId;
46 uint16 movementMode;
47};
48
50 ScenePoint interactionPoint;
51 ScenePoint approachPoint;
52 byte facing;
53};
54
63public:
64 bool load(const Common::Array<byte> &paletteMapBlock, const Common::Array<byte> &metadata,
65 const Common::Array<byte> &stageSmallRows);
66
67 byte resolveItemAt(const Graphics::Surface &savedFramebuffer, uint16 cursorX, uint16 cursorY,
68 uint16 xOffset, uint16 yOffset) const;
69 void getHotspotPositions(Common::Array<Graphics::HotspotInfo> &hotspots,
70 const Graphics::Surface &savedFramebuffer, uint16 xOffset, uint16 yOffset) const;
71 byte defaultStripForItem(byte itemId) const;
72 bool hasVerbAction(byte itemId, byte stripIndex) const;
73 SceneVerbActionRecord verbActionRecord(byte itemId, byte stripIndex) const;
74 SceneVerbActionRecord relationActionRecord(byte inventoryItemId, byte sceneItemId, byte relationMode) const;
75 SceneActionTarget actionTarget(byte itemId) const;
76 void setItemDefaultStrip(byte itemId, byte stripIndex);
77 void setItemName(byte itemId, const Common::String &name);
78 void setItemNames(const Common::Array<byte> &stageSmallRows);
79 void setActionTarget(byte itemId, const ScenePoint &interactionPoint, const ScenePoint &approachPoint);
80 void setActionInteraction(byte itemId, const ScenePoint &interactionPoint, byte facing);
81 // Claims pixels even when the resource maps them to another item.
82 void addOverrideRectHotspot(byte itemId, const Common::Rect &bounds);
83 // Updates a moving hotspot; empty bounds remove it.
84 void setOverrideRectHotspot(byte itemId, const Common::Rect &bounds);
85 // Claims otherwise unassigned pixels without overriding resource hotspots.
86 void addFallbackRectHotspot(byte itemId, const Common::Rect &bounds);
87 void setVerbActionHandlerByGlobalRecordIndex(uint globalRecordIndex, uint16 actionHandlerId);
88 void setVerbMovementModeByGlobalRecordIndex(uint globalRecordIndex, uint16 movementMode);
89 void setRelationActionHandler(byte inventoryItemId, byte sceneItemId,
90 byte relationMode, uint16 actionHandlerId);
91 void setRelationMovementMode(byte inventoryItemId, byte sceneItemId, byte relationMode, uint16 movementMode);
92 Common::String itemName(byte itemId) const;
93
94private:
95 struct RectHotspot {
96 byte itemId;
97 Common::Rect bounds;
98 };
99
100 Common::Array<byte> _colorToItemMap;
101 Common::Array<RectHotspot> _overrideRectHotspots;
102 Common::Array<RectHotspot> _fallbackRectHotspots;
103 Common::Array<byte> _itemDefaultStrips;
104 Common::Array<Common::String> _itemNameOverrides;
106 Common::Array<byte> _stageSmallRows;
107 Common::Array<SceneVerbActionRecord> _verbActionRecords;
108 Common::Array<SceneVerbActionRecord> _relationMode1ActionRecords;
109 Common::Array<SceneVerbActionRecord> _relationMode2ActionRecords;
110};
111
119public:
121
122 void reset();
123 void setCurrentStrip(byte stripIndex);
124 void setRelationContext(byte relationMode, byte primaryInventoryItem, const Common::String &primaryItemName);
125 bool refreshNow(const SceneHotspotTable &hotspots, const Graphics::Surface &savedFramebuffer,
126 uint16 cursorX, uint16 cursorY, uint16 xOffset, uint16 yOffset);
127 bool advance(uint32 deltaMillis, const SceneHotspotTable &hotspots,
128 const Graphics::Surface &savedFramebuffer, uint16 cursorX, uint16 cursorY,
129 uint16 xOffset, uint16 yOffset);
130
131 void applyPalette(Common::Array<byte> &palette) const;
132 void draw(Graphics::Surface &surface, HollywoodFont &font) const;
133
134 byte currentStrip() const { return _currentStrip; }
135 byte requestedStrip() const { return _requestedStrip; }
136 byte resolvedItem() const { return _resolvedItem; }
137 const Common::String &text() const { return _captionText; }
138
139private:
140 struct Descriptor {
141 byte verbTextIndex;
142 byte itemId;
143 byte itemSourceKind;
144 byte relationTextIndex;
145 byte secondItemId;
146 byte secondItemSourceKind;
147 };
148
149 bool updateCaption(const SceneHotspotTable &hotspots, const Graphics::Surface &savedFramebuffer,
150 uint16 cursorX, uint16 cursorY, uint16 xOffset, uint16 yOffset, bool force);
151 bool descriptorChanged(const Descriptor &descriptor) const;
152 Common::String buildCaption(const SceneHotspotTable &hotspots, const Descriptor &descriptor) const;
153 Common::String actionCaption(byte stripIndex) const;
154
155 Descriptor _descriptor;
156 Descriptor _lastDescriptor;
157 Common::String _captionText;
158 uint32 _timer;
159 const HollywoodGameStrings &_strings;
160 byte _currentStrip;
161 byte _relationMode;
162 byte _primaryInventoryItem;
163 Common::String _primaryItemName;
164 byte _requestedStrip;
165 byte _resolvedItem;
166 bool _hasLastDescriptor;
167};
168
169} // End of namespace Hollywood
170
171#endif // HOLLYWOOD_MONSTERS_GAMEPLAY_HOTSPOTS_H
Definition: str.h:59
Definition: font.h:32
Definition: hotspots.h:62
Definition: hotspots.h:118
Definition: formatinfo.h:28
Definition: rect.h:536
Definition: surface.h:67
Definition: game_strings.h:40
Definition: hotspots.h:49
Definition: scene_data.h:29
Definition: hotspots.h:44