ScummVM API documentation
game_loop.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_GAME_LOOP_H
23#define HOLLYWOOD_MONSTERS_GAMEPLAY_GAME_LOOP_H
24
25#include "common/array.h"
26#include "common/keyboard.h"
27#include "common/path.h"
28#include "common/str.h"
29#include "common/types.h"
30
31#include "hollywood/monsters/gameplay/hotspots.h"
32
33namespace Graphics {
34struct Surface;
35}
36
37namespace Hollywood {
38
39class HollywoodEngine;
40enum InventoryMediaId : int;
41
42extern const uint16 kGameplayVerbPanelStripXOffsets[9];
43
45 uint16 cursorX;
46 uint16 cursorY;
47 uint16 sceneX;
48 uint16 sceneY;
49 byte currentStrip;
50 byte requestedStrip;
51 byte resolvedItem;
52 byte inventoryOwner;
53 uint16 inventoryActionHandlerId;
54 byte relationMode;
55 byte primaryInventoryItem;
56 bool relationModeActive;
57 bool inventoryItemSelected;
58};
59
62
63 bool visible() const { return verbPanelVisible || inventoryPanelVisible; }
64
65 bool verbPanelVisible;
66 bool inventoryPanelVisible;
67 byte currentStrip;
68 byte requestedStrip;
69 byte resolvedItem;
70 Common::String itemName;
71 Common::String captionText;
72};
73
83public:
84 virtual ~GameplayLoopDelegate();
85
86 virtual const SceneHotspotTable &hotspots() const = 0;
87 virtual const Graphics::Surface &savedFramebuffer() const = 0;
88 virtual uint16 viewportXOffset() const = 0;
89 virtual uint16 viewportYOffset() const;
90
91 virtual void prepareGameplayLoop();
92 virtual void advanceGameplayLoop(uint32 deltaMillis) = 0;
93 virtual void drawGameplayFrame() = 0;
94 virtual void presentGameplayFrame(const SceneHoverCaption &hoverCaption, const GameplayPanelState &panelState) = 0;
95 virtual void invalidatePresentationPalette();
96 virtual void prepareOptionsMenuPalette(Common::Array<byte> &palette) const;
97 virtual Common::Path optionsMenuSoundBank0ArchiveName() const;
98 virtual bool optionsMenuSpeechPreviewSampleId(uint16 &sampleId) const;
99 virtual void suspendAudioForOptionsMenu();
100 virtual void refreshTranslatedText();
101 virtual bool shouldExitGameplayLoop() const;
102 virtual bool isInventoryPanelAvailable() const;
103 virtual Common::String inventoryItemName(byte owner, byte itemId) const;
104 virtual void beginSharedInventorySpeechLine(uint16 rowIndex, byte frameIndex);
105 virtual byte randomSharedInventorySpeechFrame(byte maxFrameIndex);
106 virtual void playSharedInventorySound(byte sampleId);
107 virtual void showTravelScreenViewer();
108 // Returns false only when the requested media cannot be loaded.
109 virtual bool showInventoryMedia(InventoryMediaId mediaId);
110 virtual bool playSueTapeRecording();
111 virtual void handleLeftClick(const GameplayLoopCursorState &state);
112 virtual void handleInventoryItemClick(const GameplayLoopCursorState &state);
113 virtual void handleRightClick(const GameplayLoopCursorState &state);
114};
115
124public:
126
127 bool run();
128 void setCurrentStrip(byte stripIndex);
129
130 byte currentStrip() const { return _currentStrip; }
131 const SceneHoverCaption &hoverCaption() const { return _hoverCaption; }
132
133private:
134 bool pollEvents();
135 void handleKeyDown(const Common::KeyState &keyState);
136 void handleKeyUp(const Common::KeyState &keyState);
137 void handleLeftClick();
138 void handleRightClick();
139 void enterKeyboardStripMode();
140 void leaveKeyboardStripMode();
141 void selectPreviousKeyboardStrip();
142 void selectNextKeyboardStrip();
143 void selectNextStrip();
144 void openVerbPanel();
145 void closeVerbPanel();
146 void openInventoryPanel();
147 void closeInventoryPanel();
148 void openOptionsMenu();
149 void updatePanelHover(uint32 deltaMillis);
150 void updatePanelFromMousePosition();
151 void selectPanelStrip(byte stripIndex);
152 byte panelStripAt(uint16 cursorX, uint16 cursorY) const;
153 byte inventoryPanelStripAt(uint16 cursorX, uint16 cursorY) const;
154 uint inventoryPanelSlotAtPosition(uint16 cursorX, uint16 cursorY) const;
155 byte inventoryItemAtPanelPosition(uint16 cursorX, uint16 cursorY) const;
156 byte currentInventoryOwner() const;
157 uint16 fixedInventoryActionHandler(byte owner, byte itemId, byte stripIndex) const;
158 uint16 dialogueInventoryRelationHandler(byte primaryItemId, byte secondaryItemId, byte relationMode) const;
159 bool scrollInventoryPanelPreviousPage();
160 bool scrollInventoryPanelNextPage();
161 bool isInventoryPanelOptionsButton(uint16 cursorX, uint16 cursorY) const;
162 bool isInventoryPanelPreviousPageArrow(uint16 cursorX, uint16 cursorY) const;
163 bool isInventoryPanelNextPageArrow(uint16 cursorX, uint16 cursorY) const;
164 void updatePanelCaption();
165 void updateInventoryPanelCaption();
166 void syncPanelState();
167 GameplayLoopCursorState makeCursorState() const;
168 GameplayLoopCursorState makeInventoryItemState(byte owner, byte itemId, uint16 actionHandlerId) const;
169 void clearButtonLatches();
170 void syncHoverCaptionRelationContext();
171 void refreshHoverCaption();
172
173 HollywoodEngine *_vm;
174 GameplayLoopDelegate *_delegate;
175 SceneHoverCaption _hoverCaption;
176 byte _currentStrip;
177 bool _leftButtonDown;
178 bool _rightButtonDown;
179 bool _keyboardStripMode;
180 bool _restoreDefaultStripOnInventoryClose;
181 byte _relationMode;
182 byte _primaryInventoryItem;
183 GameplayPanelState _panelState;
184 uint32 _panelHoverTimer;
185};
186
187} // End of namespace Hollywood
188
189#endif // HOLLYWOOD_MONSTERS_GAMEPLAY_GAME_LOOP_H
Definition: path.h:52
Definition: str.h:59
Definition: game_loop.h:82
Definition: game_loop.h:123
Definition: hollywood.h:47
Definition: hotspots.h:62
Definition: hotspots.h:118
Definition: formatinfo.h:28
Definition: keyboard.h:294
Definition: surface.h:67
Definition: game_loop.h:44
Definition: game_loop.h:60