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 
34 namespace Graphics {
35 struct Surface;
36 class FrameLimiter;
37 }
38 
39 namespace Common {
40 struct Event;
41 }
42 
43 namespace Myst3 {
44 
45 // Engine Debug Flags
46 enum {
47  kDebugVariable = (1 << 0),
48  kDebugSaveLoad = (1 << 1),
49  kDebugNode = (1 << 2),
50  kDebugScript = (1 << 3)
51 };
52 
53 enum TransitionType {
54  kTransitionFade = 1,
55  kTransitionNone,
56  kTransitionZip,
57  kTransitionLeftToRight,
58  kTransitionRightToLeft
59 };
60 
61 class Archive;
62 class Console;
63 class Drawable;
64 class GameState;
65 class HotSpot;
66 class Cursor;
67 class Inventory;
68 class Database;
69 class Scene;
70 class Script;
71 class SpotItemFace;
72 class SunSpot;
73 class Renderer;
74 class Menu;
75 class Node;
76 class Sound;
77 class Ambient;
78 class ScriptedMovie;
79 class ShakeEffect;
80 class RotationEffect;
81 class Transition;
82 struct NodeData;
83 struct Myst3GameDescription;
84 
85 typedef Common::SharedPtr<NodeData> NodePtr;
86 
87 class Myst3Engine : public Engine {
88 
89 protected:
90  // Engine APIs
91  Common::Error run() override;
92  void syncSoundSettings() override;
93  void pauseEngineIntern(bool pause) override;
94 
95 public:
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 
106  Common::RandomSource *_rnd;
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);
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 
193 private:
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: node.h:120
Definition: framelimiter.h:37
Definition: str.h:59
Definition: surface.h:67
Definition: archive.h:37
EngineFeature
Definition: engine.h:253
Definition: error.h:84
Definition: ambient.h:31
Definition: array.h:52
Definition: effects.h:160
Definition: ambient.h:27
Definition: random.h:44
Definition: scene.h:34
Definition: effects.h:139
Definition: state.h:48
Definition: rect.h:144
Definition: hotspot.h:49
Definition: node.h:64
Definition: gfx.h:107
Definition: transition.h:35
Definition: node.h:131
Definition: ustr.h:57
Definition: atari-cursor.h:38
Definition: console.h:36
Definition: sound.h:106
Definition: events.h:199
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: script.h:35
Definition: menu.h:52
Definition: cursor.h:35
Definition: database.h:162
Definition: system.h:161
Definition: ptr.h:159
Definition: inventory.h:38
Definition: lobject.h:332
Definition: myst3.h:87
Definition: engine.h:144
Platform
Definition: platform.h:46
Definition: archive.h:105
Definition: detection.h:43
Language
Definition: language.h:45