ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

myst3.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef MYST3_ENGINE_H
00024 #define MYST3_ENGINE_H
00025 
00026 #include "engines/engine.h"
00027 
00028 #include "common/array.h"
00029 #include "common/ptr.h"
00030 #include "common/system.h"
00031 #include "common/random.h"
00032 
00033 #include "engines/myst3/directorysubentry.h"
00034 
00035 namespace Graphics {
00036 struct Surface;
00037 }
00038 
00039 namespace Common {
00040 struct Event;
00041 }
00042 
00043 namespace Myst3 {
00044 
00045 // Engine Debug Flags
00046 enum {
00047     kDebugVariable = (1 << 0),
00048     kDebugSaveLoad = (1 << 1),
00049     kDebugNode     = (1 << 2),
00050     kDebugScript   = (1 << 3)
00051 };
00052 
00053 enum TransitionType {
00054     kTransitionFade = 1,
00055     kTransitionNone,
00056     kTransitionZip,
00057     kTransitionLeftToRight,
00058     kTransitionRightToLeft
00059 };
00060 
00061 class Archive;
00062 class Console;
00063 class Drawable;
00064 class GameState;
00065 class HotSpot;
00066 class Cursor;
00067 class Inventory;
00068 class Database;
00069 class Scene;
00070 class Script;
00071 class SpotItemFace;
00072 class SunSpot;
00073 class Renderer;
00074 class Menu;
00075 class Node;
00076 class Sound;
00077 class Ambient;
00078 class ScriptedMovie;
00079 class ShakeEffect;
00080 class RotationEffect;
00081 class Transition;
00082 class FrameLimiter;
00083 struct NodeData;
00084 struct Myst3GameDescription;
00085 
00086 typedef Common::SharedPtr<NodeData> NodePtr;
00087 
00088 class Myst3Engine : public Engine {
00089 
00090 protected:
00091     // Engine APIs
00092     virtual Common::Error run() override;
00093     virtual void syncSoundSettings() override;
00094     virtual GUI::Debugger *getDebugger() override { return (GUI::Debugger *)_console; }
00095     virtual void pauseEngineIntern(bool pause) override;
00096 
00097 public:
00098     GameState *_state;
00099     Scene *_scene;
00100     Cursor *_cursor;
00101     Inventory *_inventory;
00102     Renderer *_gfx;
00103     Menu *_menu;
00104     Database *_db;
00105     Sound *_sound;
00106     Ambient *_ambient;
00107     
00108     Common::RandomSource *_rnd;
00109 
00110     // Used by the projectors on J'nanin, see puzzle #14
00111     Graphics::Surface *_projectorBackground;
00112 
00113     Myst3Engine(OSystem *syst, const Myst3GameDescription *version);
00114     virtual ~Myst3Engine();
00115 
00116     bool hasFeature(EngineFeature f) const override;
00117     Common::Platform getPlatform() const;
00118     Common::Language getGameLanguage() const;
00119     uint32 getGameLocalizationType() const;
00120     bool isTextLanguageEnglish() const;
00121     bool isWideScreenModEnabled() const;
00122 
00123     bool canSaveGameStateCurrently() override;
00124     bool canLoadGameStateCurrently() override;
00125     void tryAutoSaving();
00126     Common::Error loadGameState(int slot) override;
00127     Common::Error saveGameState(int slot, const Common::String &desc) override;
00128     Common::Error loadGameState(Common::String fileName, TransitionType transition);
00129 
00130     const DirectorySubEntry *getFileDescription(const Common::String &room, uint32 index, uint16 face,
00131                                                 DirectorySubEntry::ResourceType type);
00132     DirectorySubEntryList listFilesMatching(const Common::String &room, uint32 index, uint16 face,
00133                                             DirectorySubEntry::ResourceType type);
00134 
00135     Graphics::Surface *loadTexture(uint16 id);
00136     static Graphics::Surface *decodeJpeg(const DirectorySubEntry *jpegDesc);
00137 
00138     void goToNode(uint16 nodeID, TransitionType transition);
00139     void loadNode(uint16 nodeID, uint32 roomID = 0, uint32 ageID = 0);
00140     void unloadNode();
00141     void loadNodeCubeFaces(uint16 nodeID);
00142     void loadNodeFrame(uint16 nodeID);
00143     void loadNodeMenu(uint16 nodeID);
00144 
00145     void setupTransition();
00146     void drawTransition(TransitionType transitionType);
00147 
00148     void dragItem(uint16 statusVar, uint16 movie, uint16 frame, uint16 hoverFrame, uint16 itemVar);
00149     void dragSymbol(uint16 var, uint16 id);
00150     int16 openDialog(uint16 id);
00151 
00152     void runNodeInitScripts();
00153     void runNodeBackgroundScripts();
00154     void runScriptsFromNode(uint16 nodeID, uint32 roomID = 0, uint32 ageID = 0);
00155     void runBackgroundSoundScriptsFromNode(uint16 nodeID, uint32 roomID = 0, uint32 ageID = 0);
00156     void runAmbientScripts(uint32 node);
00157 
00158     void loadMovie(uint16 id, uint16 condition, bool resetCond, bool loop);
00159     void playMovieGoToNode(uint16 movie, uint16 node);
00160     void playMovieFullFrame(uint16 movie);
00161     void playSimpleMovie(uint16 id, bool fullframe = false, bool refreshAmbientSounds = false);
00162     void removeMovie(uint16 id);
00163     void setMovieLooping(uint16 id, bool loop);
00164 
00165     void addSpotItem(uint16 id, int16 condition, bool fade);
00166     SpotItemFace *addMenuSpotItem(uint16 id, int16 condition, const Common::Rect &rect);
00167     void loadNodeSubtitles(uint32 id);
00168 
00169     void addSunSpot(uint16 pitch, uint16 heading, uint16 intensity,
00170             uint16 color, uint16 var, bool varControlledIntensity, uint16 radius);
00171     SunSpot computeSunspotsIntensity(float pitch, float heading);
00172 
00173     void setMenuAction(uint16 action) { _menuAction = action; }
00174 
00175     void animateDirectionChange(float pitch, float heading, uint16 scriptTicks);
00176     void getMovieLookAt(uint16 id, bool start, float &pitch, float &heading);
00177 
00178     void drawFrame(bool noSwap = false);
00179 
00180     void processInput(bool interactive);
00181     void processEventForKeyboardState(const Common::Event &event);
00182     void processEventForGamepad(const Common::Event &event);
00183     void updateInputState();
00184 
00185     bool inputValidatePressed();
00186     bool inputEscapePressed();
00187     bool inputSpacePressed();
00188     bool inputTilePressed();
00189 
00190     void settingsInitDefaults();
00191     void settingsLoadToVars();
00192     void settingsApplyFromVars();
00193 
00194 private:
00195     OSystem *_system;
00196     Console *_console;
00197     const Myst3GameDescription *_gameDescription;
00198 
00199     Node *_node;
00200 
00201     Common::Array<Archive *> _archivesCommon;
00202     Archive *_archiveNode;
00203 
00204     Script *_scriptEngine;
00205 
00206     Common::Array<ScriptedMovie *> _movies;
00207     Common::Array<SunSpot *> _sunspots;
00208     Common::Array<Drawable *> _drawables;
00209 
00210     uint16 _menuAction;
00211 
00212     // Used by Amateria's magnetic rings
00213     ShakeEffect *_shakeEffect;
00214     // Used by Voltaic's spinning gears
00215     RotationEffect *_rotationEffect;
00216 
00217     FrameLimiter *_frameLimiter;
00218     Transition *_transition;
00219 
00220     bool _inputSpacePressed;
00221     bool _inputEnterPressed;
00222     bool _inputEscapePressed;
00223     bool _inputEscapePressedNotConsumed;
00224     bool _inputTildePressed;
00225 
00226     bool _interactive;
00227 
00228     uint32 _lastSaveTime;
00229 
00230     uint32 _backgroundSoundScriptLastRoomId;
00231     uint32 _backgroundSoundScriptLastAgeId;
00232 
00239     bool _inventoryManualHide;
00240 
00241     HotSpot *getHoveredHotspot(NodePtr nodeData, uint16 var = 0);
00242     void updateCursor();
00243 
00244     bool checkDatafiles();
00245 
00246     bool addArchive(const Common::String &file, bool mandatory);
00247     void openArchives();
00248     void closeArchives();
00249 
00250     bool isInventoryVisible();
00251 
00252     void interactWithHoveredElement();
00253 
00254     friend class Console;
00255 };
00256 
00257 } // end of namespace Myst3
00258 
00259 #endif


Generated on Sat Nov 9 2019 05:00:29 for ResidualVM by doxygen 1.7.1
curved edge   curved edge