ScummVM API documentation
myst3.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 MYST3_ENGINE_H
23#define MYST3_ENGINE_H
24
25#include "engines/engine.h"
26
27#include "common/array.h"
28#include "common/ptr.h"
29#include "common/system.h"
30#include "common/random.h"
31
32#include "engines/myst3/archive.h"
33
34namespace Graphics {
35struct Surface;
36class FrameLimiter;
37}
38
39namespace Common {
40struct Event;
41}
42
43namespace Myst3 {
44
45// Engine Debug Flags
46enum {
47 kDebugVariable = 1,
48 kDebugSaveLoad,
49 kDebugNode,
50 kDebugScript,
51};
52
53enum TransitionType {
54 kTransitionFade = 1,
55 kTransitionNone,
56 kTransitionZip,
57 kTransitionLeftToRight,
58 kTransitionRightToLeft
59};
60
61class Archive;
62class Console;
63class Drawable;
64class GameState;
65class HotSpot;
66class Cursor;
67class Inventory;
68class Database;
69class Scene;
70class Script;
71class SpotItemFace;
72class SunSpot;
73class Renderer;
74class Menu;
75class Node;
76class Sound;
77class Ambient;
78class ScriptedMovie;
79class ShakeEffect;
80class RotationEffect;
81class Transition;
82struct NodeData;
83struct Myst3GameDescription;
84
85typedef Common::SharedPtr<NodeData> NodePtr;
86
87class Myst3Engine : public Engine {
88
89protected:
90 // Engine APIs
91 Common::Error run() override;
92 void syncSoundSettings() override;
93 void pauseEngineIntern(bool pause) override;
94
95public:
96 GameState *_state;
97 Scene *_scene;
98 Cursor *_cursor;
99 Inventory *_inventory;
100 Renderer *_gfx;
101 Menu *_menu;
102 Database *_db;
103 Sound *_sound;
104 Ambient *_ambient;
105
107
108 // Used by the projectors on J'nanin, see puzzle #14
109 Graphics::Surface *_projectorBackground;
110
111 Myst3Engine(OSystem *syst, const Myst3GameDescription *version);
112 virtual ~Myst3Engine();
113
114 bool hasFeature(EngineFeature f) const override;
115 Common::Platform getPlatform() const;
116 Common::Language getGameLanguage() const;
117 uint32 getGameLocalizationType() const;
118 uint32 getGameLayoutType() const;
119 bool isTextLanguageEnglish() const;
120 bool isWideScreenModEnabled() const;
121
122 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
123 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
124 Common::Error loadGameState(int slot) override;
125 Common::Error loadGameState(Common::String fileName, TransitionType transition);
126 Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
127 Common::Error saveGameState(const Common::String &desc, const Graphics::Surface *thumbnail, bool isAutosave);
128
129 ResourceDescription getFileDescription(const Common::String &room, uint32 index, uint16 face,
130 Archive::ResourceType type);
131 ResourceDescriptionArray listFilesMatching(const Common::String &room, uint32 index, uint16 face,
132 Archive::ResourceType type);
133
134 Graphics::Surface *loadTexture(uint16 id);
135 static Graphics::Surface *decodeJpeg(const ResourceDescription *jpegDesc);
136
137 void goToNode(uint16 nodeID, TransitionType transition);
138 void loadNode(uint16 nodeID, uint32 roomID = 0, uint32 ageID = 0);
139 void unloadNode();
140 void loadNodeCubeFaces(uint16 nodeID);
141 void loadNodeFrame(uint16 nodeID);
142 void loadNodeMenu(uint16 nodeID);
143
144 void setupTransition();
145 void drawTransition(TransitionType transitionType);
146
147 void dragItem(uint16 statusVar, uint16 movie, uint16 frame, uint16 hoverFrame, uint16 itemVar);
148 void dragSymbol(uint16 var, uint16 id);
149 int16 openDialog(uint16 id);
150
151 void runNodeInitScripts();
152 void runNodeBackgroundScripts();
153 void runScriptsFromNode(uint16 nodeID, uint32 roomID = 0, uint32 ageID = 0);
154 void runBackgroundSoundScriptsFromNode(uint16 nodeID, uint32 roomID = 0, uint32 ageID = 0);
155 void runAmbientScripts(uint32 node);
156
157 void loadMovie(uint16 id, uint16 condition, bool resetCond, bool loop);
158 void playMovieGoToNode(uint16 movie, uint16 node);
159 void playMovieFullFrame(uint16 movie);
160 void playSimpleMovie(uint16 id, bool fullframe = false, bool refreshAmbientSounds = false);
161 void removeMovie(uint16 id);
162 void setMovieLooping(uint16 id, bool loop);
163
164 void addSpotItem(uint16 id, int16 condition, bool fade);
165 SpotItemFace *addMenuSpotItem(uint16 id, int16 condition, const Common::Rect &rect);
166 void loadNodeSubtitles(uint32 id);
167
168 void addSunSpot(uint16 pitch, uint16 heading, uint16 intensity,
169 uint16 color, uint16 var, bool varControlledIntensity, uint16 radius);
170 SunSpot computeSunspotsIntensity(float pitch, float heading);
171
172 void setMenuAction(uint16 action) { _menuAction = action; }
173
174 void animateDirectionChange(float pitch, float heading, uint16 scriptTicks);
175 void getMovieLookAt(uint16 id, bool start, float &pitch, float &heading);
176
177 void drawFrame(bool noSwap = false, bool pausePreloadedScriptMovies = false);
178
179 void processInput(bool interactive);
180 void processEventForKeyboardState(const Common::Event &event);
181 void processEventForGamepad(const Common::Event &event);
182 void updateInputState();
183
184 bool inputValidatePressed();
185 bool inputEscapePressed();
186 bool inputSpacePressed();
187 bool inputTilePressed();
188
189 void settingsInitDefaults();
190 void settingsLoadToVars();
191 void settingsApplyFromVars();
192
193private:
194 OSystem *_system;
195 const Myst3GameDescription *_gameDescription;
196
197 Node *_node;
198
199 Common::Array<Archive *> _archivesCommon;
200 Archive *_archiveNode;
201
202 Script *_scriptEngine;
203
205 Common::Array<SunSpot *> _sunspots;
206 Common::Array<Drawable *> _drawables;
207
208 uint16 _menuAction;
209
210 // Used by Amateria's magnetic rings
211 ShakeEffect *_shakeEffect;
212 // Used by Voltaic's spinning gears
213 RotationEffect *_rotationEffect;
214
215 Graphics::FrameLimiter *_frameLimiter;
216 Transition *_transition;
217
218 bool _inputSpacePressed;
219 bool _inputEnterPressed;
220 bool _inputEscapePressed;
221 bool _inputEscapePressedNotConsumed;
222 bool _inputTildePressed;
223
224 bool _interactive;
225
226 uint32 _backgroundSoundScriptLastRoomId;
227 uint32 _backgroundSoundScriptLastAgeId;
228
235 bool _inventoryManualHide;
236
237 HotSpot *getHoveredHotspot(NodePtr nodeData, uint16 var = 0);
238 void updateCursor();
239
240 bool checkDatafiles();
241
242 bool addArchive(const Common::String &file, bool mandatory);
243 void openArchives();
244 void closeArchives();
245
246 bool isInventoryVisible();
247
248 void interactWithHoveredElement();
249
250 friend class Console;
251};
252
253} // end of namespace Myst3
254
255#endif
Definition: array.h:52
Definition: error.h:81
Definition: random.h:44
Definition: ptr.h:159
Definition: str.h:59
Definition: ustr.h:57
Definition: engine.h:149
EngineFeature
Definition: engine.h:282
Definition: framelimiter.h:40
Definition: ambient.h:31
Definition: archive.h:37
Definition: console.h:36
Definition: cursor.h:35
Definition: database.h:162
Definition: state.h:48
Definition: hotspot.h:49
Definition: inventory.h:38
Definition: menu.h:52
Definition: myst3.h:87
void pauseEngineIntern(bool pause) override
Common::Error run() override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
Common::Error loadGameState(int slot) override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
bool hasFeature(EngineFeature f) const override
void syncSoundSettings() override
Definition: node.h:131
Definition: gfx.h:107
Definition: archive.h:105
Definition: effects.h:160
Definition: scene.h:34
Definition: script.h:35
Definition: effects.h:139
Definition: sound.h:106
Definition: node.h:64
Definition: node.h:120
Definition: transition.h:35
Definition: system.h:166
Language
Definition: language.h:45
Platform
Definition: platform.h:93
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: events.h:218
Definition: rect.h:536
Definition: atari-cursor.h:35
Definition: surface.h:67
Definition: detection.h:43
Definition: lobject.h:332