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  bool isTextLanguageEnglish() const;
119  bool isWideScreenModEnabled() const;
120 
121  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
122  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
123  Common::Error loadGameState(int slot) override;
124  Common::Error loadGameState(Common::String fileName, TransitionType transition);
125  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
126  Common::Error saveGameState(const Common::String &desc, const Graphics::Surface *thumbnail, bool isAutosave);
127 
128  ResourceDescription getFileDescription(const Common::String &room, uint32 index, uint16 face,
129  Archive::ResourceType type);
130  ResourceDescriptionArray listFilesMatching(const Common::String &room, uint32 index, uint16 face,
131  Archive::ResourceType type);
132 
133  Graphics::Surface *loadTexture(uint16 id);
134  static Graphics::Surface *decodeJpeg(const ResourceDescription *jpegDesc);
135 
136  void goToNode(uint16 nodeID, TransitionType transition);
137  void loadNode(uint16 nodeID, uint32 roomID = 0, uint32 ageID = 0);
138  void unloadNode();
139  void loadNodeCubeFaces(uint16 nodeID);
140  void loadNodeFrame(uint16 nodeID);
141  void loadNodeMenu(uint16 nodeID);
142 
143  void setupTransition();
144  void drawTransition(TransitionType transitionType);
145 
146  void dragItem(uint16 statusVar, uint16 movie, uint16 frame, uint16 hoverFrame, uint16 itemVar);
147  void dragSymbol(uint16 var, uint16 id);
148  int16 openDialog(uint16 id);
149 
150  void runNodeInitScripts();
151  void runNodeBackgroundScripts();
152  void runScriptsFromNode(uint16 nodeID, uint32 roomID = 0, uint32 ageID = 0);
153  void runBackgroundSoundScriptsFromNode(uint16 nodeID, uint32 roomID = 0, uint32 ageID = 0);
154  void runAmbientScripts(uint32 node);
155 
156  void loadMovie(uint16 id, uint16 condition, bool resetCond, bool loop);
157  void playMovieGoToNode(uint16 movie, uint16 node);
158  void playMovieFullFrame(uint16 movie);
159  void playSimpleMovie(uint16 id, bool fullframe = false, bool refreshAmbientSounds = false);
160  void removeMovie(uint16 id);
161  void setMovieLooping(uint16 id, bool loop);
162 
163  void addSpotItem(uint16 id, int16 condition, bool fade);
164  SpotItemFace *addMenuSpotItem(uint16 id, int16 condition, const Common::Rect &rect);
165  void loadNodeSubtitles(uint32 id);
166 
167  void addSunSpot(uint16 pitch, uint16 heading, uint16 intensity,
168  uint16 color, uint16 var, bool varControlledIntensity, uint16 radius);
169  SunSpot computeSunspotsIntensity(float pitch, float heading);
170 
171  void setMenuAction(uint16 action) { _menuAction = action; }
172 
173  void animateDirectionChange(float pitch, float heading, uint16 scriptTicks);
174  void getMovieLookAt(uint16 id, bool start, float &pitch, float &heading);
175 
176  void drawFrame(bool noSwap = false);
177 
178  void processInput(bool interactive);
179  void processEventForKeyboardState(const Common::Event &event);
180  void processEventForGamepad(const Common::Event &event);
181  void updateInputState();
182 
183  bool inputValidatePressed();
184  bool inputEscapePressed();
185  bool inputSpacePressed();
186  bool inputTilePressed();
187 
188  void settingsInitDefaults();
189  void settingsLoadToVars();
190  void settingsApplyFromVars();
191 
192 private:
193  OSystem *_system;
194  const Myst3GameDescription *_gameDescription;
195 
196  Node *_node;
197 
198  Common::Array<Archive *> _archivesCommon;
199  Archive *_archiveNode;
200 
201  Script *_scriptEngine;
202 
204  Common::Array<SunSpot *> _sunspots;
205  Common::Array<Drawable *> _drawables;
206 
207  uint16 _menuAction;
208 
209  // Used by Amateria's magnetic rings
210  ShakeEffect *_shakeEffect;
211  // Used by Voltaic's spinning gears
212  RotationEffect *_rotationEffect;
213 
214  Graphics::FrameLimiter *_frameLimiter;
215  Transition *_transition;
216 
217  bool _inputSpacePressed;
218  bool _inputEnterPressed;
219  bool _inputEscapePressed;
220  bool _inputEscapePressedNotConsumed;
221  bool _inputTildePressed;
222 
223  bool _interactive;
224 
225  uint32 _backgroundSoundScriptLastRoomId;
226  uint32 _backgroundSoundScriptLastAgeId;
227 
234  bool _inventoryManualHide;
235 
236  HotSpot *getHoveredHotspot(NodePtr nodeData, uint16 var = 0);
237  void updateCursor();
238 
239  bool checkDatafiles();
240 
241  bool addArchive(const Common::String &file, bool mandatory);
242  void openArchives();
243  void closeArchives();
244 
245  bool isInventoryVisible();
246 
247  void interactWithHoveredElement();
248 
249  friend class Console;
250 };
251 
252 } // end of namespace Myst3
253 
254 #endif
Definition: node.h:120
Definition: framelimiter.h:37
Definition: str.h:59
Definition: surface.h:66
Definition: archive.h:37
EngineFeature
Definition: engine.h:250
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: console.h:36
Definition: sound.h:106
Definition: events.h:198
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: cursor.h:27
Definition: script.h:35
Definition: menu.h:52
Definition: cursor.h:35
Definition: database.h:162
Definition: system.h:167
Definition: ptr.h:159
Definition: inventory.h:38
Definition: lobject.h:332
Definition: myst3.h:87
Definition: engine.h:143
Platform
Definition: platform.h:46
Definition: archive.h:105
Definition: detection.h:35
Language
Definition: language.h:45