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

grim.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 COPYRIGHT
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 GRIM_ENGINE_H
00024 #define GRIM_ENGINE_H
00025 
00026 #include "engines/engine.h"
00027 
00028 #include "common/str-array.h"
00029 #include "common/hashmap.h"
00030 #include "common/events.h"
00031 
00032 #include "engines/advancedDetector.h"
00033 
00034 #include "engines/grim/textobject.h"
00035 #include "engines/grim/iris.h"
00036 
00037 namespace Grim {
00038 
00039 class Actor;
00040 class SaveGame;
00041 class Bitmap;
00042 class Font;
00043 class Color;
00044 class ObjectState;
00045 class Set;
00046 class TextObject;
00047 class PrimitiveObject;
00048 class LuaBase;
00049 class GfxBase;
00050 
00051 enum GrimGameType {
00052     GType_GRIM,
00053     GType_MONKEY4
00054 };
00055 
00056 struct GrimGameDescription;
00057 
00058 struct ControlDescriptor {
00059     const char *name;
00060     int key;
00061 };
00062 
00063 class GrimEngine : public Engine {
00064 
00065 protected:
00066     // Engine APIs
00067     virtual Common::Error run() override;
00068 
00069 public:
00070     enum EngineMode {
00071         PauseMode = 1,
00072         NormalMode = 2,
00073         SmushMode = 3,
00074         DrawMode = 4,
00075         OverworldMode = 5
00076     };
00077     enum SpeechMode {
00078         TextOnly = 1,
00079         VoiceOnly = 2,
00080         TextAndVoice = 3
00081     };
00082 
00083     GrimEngine(OSystem *syst, uint32 gameFlags, GrimGameType gameType, Common::Platform platform, Common::Language language);
00084     virtual ~GrimEngine();
00085 
00086     void clearPools();
00087 
00088     int getGameFlags() { return _gameFlags; }
00089     GrimGameType getGameType() { return _gameType; }
00090     Common::Language getGameLanguage() { return _gameLanguage; }
00091     Common::Platform getGamePlatform() { return _gamePlatform; }
00092     virtual const char *getUpdateFilename();
00093     bool canLoadGameStateCurrently() override { return true; }
00094     Common::Error loadGameState(int slot) override;
00095 
00096     void setMode(EngineMode mode);
00097     EngineMode getMode() { return _mode; }
00098     void setPreviousMode(EngineMode mode) { _previousMode = mode; }
00099     EngineMode getPreviousMode() { return _previousMode; }
00100     void setSpeechMode(SpeechMode mode) { _speechMode = mode; }
00101     SpeechMode getSpeechMode() { return _speechMode; }
00102     SaveGame *savedState() { return _savedState; }
00103 
00104     void handleDebugLoadResource();
00105     void luaUpdate();
00106     void updateDisplayScene();
00107     void doFlip();
00108     void setFlipEnable(bool state) { _flipEnable = state; }
00109     bool getFlipEnable() { return _flipEnable; }
00110     virtual void drawTextObjects();
00111     void playIrisAnimation(Iris::Direction dir, int x, int y, int time);
00112 
00113     void mainLoop();
00114     unsigned getFrameStart() const { return _frameStart; }
00115     unsigned getFrameTime() const { return _frameTime; }
00116 
00117     // perSecond should allow rates of zero, some actors will accelerate
00118     // up to their normal speed (such as the bone wagon) so handling
00119     // a walking rate of zero should happen in the default actor creation
00120     float getPerSecond(float rate) const;
00121 
00122     int getTextSpeed() { return _textSpeed; }
00123     void setTextSpeed(int speed);
00124 
00125     void enableControl(int num) { _controlsEnabled[num] = true; }
00126     void disableControl(int num) { _controlsEnabled[num] = false; }
00127     float getControlAxis(int num);
00128     bool getControlState(int num);
00129     void clearEventQueue();
00130 
00131     Set *findSet(const Common::String &name);
00132     void setSetLock(const char *name, bool lockStatus);
00133     Set *loadSet(const Common::String &name);
00134     void setSet(const char *name);
00135     void setSet(Set *scene);
00136     Set *getCurrSet() { return _currSet; }
00137     void makeCurrentSetup(int num);
00138 
00139     void flagRefreshShadowMask(bool flag) { _refreshShadowMask = flag; }
00140     bool getFlagRefreshShadowMask() { return _refreshShadowMask; }
00141 
00142     void setSelectedActor(Actor *a) { _selectedActor = a; }
00143     Actor *getSelectedActor() { return _selectedActor; }
00144 
00149     virtual void invalidateActiveActorsList();
00150     virtual void invalidateTextObjectsSortOrder() {};
00154     const Common::List<Actor *> &getActiveActors() const { return _activeActors; }
00155 
00159     void addTalkingActor(Actor *actor);
00160     inline const Common::List<Actor *> &getTalkingActors() const { return _talkingActors; }
00161     bool areActorsTalking() const;
00162     void immediatelyRemoveActor(Actor *actor);
00163 
00164     void drawMovieSubtitle();
00165     void setMovieSubtitle(TextObject *to);
00166     void setMovieSetup();
00167 
00168     void saveGame(const Common::String &file);
00169     void loadGame(const Common::String &file);
00170 
00171     void changeHardwareState();
00172 
00173     // Engine APIs
00174     bool hasFeature(EngineFeature f) const override;
00175 
00176     Common::StringArray _listFiles;
00177     Common::StringArray::const_iterator _listFilesIter;
00178 
00179     TextObjectDefaults _sayLineDefaults, _printLineDefaults, _blastTextDefaults;
00180 
00181     void debugLua(const Common::String &str);
00182 
00183     void setSideTextures(const Common::String &setup);
00184 
00185 protected:
00186     virtual void pauseEngineIntern(bool pause) override;
00187 
00188     void handleControls(Common::EventType type, const Common::KeyState &key);
00189     void handleChars(Common::EventType type, const Common::KeyState &key);
00190     void handleJoyAxis(byte axis, int16 position);
00191     void handleJoyButton(Common::EventType type, byte button);
00192     void handleExit();
00193     void handlePause();
00194     void handleUserPaint();
00195     void cameraChangeHandle(int prev, int next);
00196     void cameraPostChangeHandle(int num);
00197     void buildActiveActorsList();
00198     void savegameCallback();
00199     GfxBase *createRenderer(int screenW, int screenH, bool fullscreen);
00200     void playAspyrLogo();
00201     virtual LuaBase *createLua();
00202     virtual void updateNormalMode();
00203     virtual void updateDrawMode();
00204     virtual void drawNormalMode();
00205 
00206     void savegameSave();
00207     void saveGRIM();
00208 
00209     void savegameRestore();
00210     void restoreGRIM();
00211 
00212     virtual void storeSaveGameImage(SaveGame *savedState);
00213 
00214     bool _savegameLoadRequest;
00215     bool _savegameSaveRequest;
00216     Common::String _savegameFileName;
00217     SaveGame *_savedState;
00218 
00219     Set *_currSet;
00220     EngineMode _mode, _previousMode;
00221     SpeechMode _speechMode;
00222     int _textSpeed;
00223     bool _flipEnable;
00224     char _fps[8];
00225     bool _doFlip;
00226     bool _refreshShadowMask;
00227     bool _shortFrame;
00228     bool _setupChanged;
00229     // This holds the name of the setup in which the movie must be drawed
00230     Common::String _movieSetup;
00231 
00232     unsigned _frameStart, _frameTime, _movieTime;
00233     int _prevSmushFrame;
00234     unsigned int _frameCounter;
00235     unsigned int _lastFrameTime;
00236     unsigned _speedLimitMs;
00237     bool _showFps;
00238     bool _softRenderer;
00239 
00240     bool *_controlsEnabled;
00241     bool *_controlsState;
00242     float *_joyAxisPosition;
00243 
00244     bool _changeHardwareState;
00245     bool _changeFullscreenState;
00246 
00247     Actor *_selectedActor;
00248     Iris *_iris;
00249     TextObject::Ptr _movieSubtitle;
00250 
00251     bool _buildActiveActorsList;
00252     Common::List<Actor *> _activeActors;
00253     Common::List<Actor *> _talkingActors;
00254 
00255     uint32 _gameFlags;
00256     GrimGameType _gameType;
00257     Common::Platform _gamePlatform;
00258     Common::Language _gameLanguage;
00259     uint32 _pauseStartTime;
00260 };
00261 
00262 extern GrimEngine *g_grim;
00263 
00264 extern int g_imuseState;
00265 
00266 // Fake KEYCODE_* values for joystick and mouse events
00267 
00268 enum {
00269     KEYCODE_JOY1_A = 512,
00270     KEYCODE_JOY1_B,
00271     KEYCODE_JOY1_X,
00272     KEYCODE_JOY1_Y,
00273     KEYCODE_JOY1_BACK,
00274     KEYCODE_JOY1_GUIDE,
00275     KEYCODE_JOY1_START,
00276     KEYCODE_JOY1_LEFTSTICK,
00277     KEYCODE_JOY1_RIGHTSTICK,
00278     KEYCODE_JOY1_L1,
00279     KEYCODE_JOY1_R1,
00280     KEYCODE_JOY1_HUP,
00281     KEYCODE_JOY1_HDOWN,
00282     KEYCODE_JOY1_HLEFT,
00283     KEYCODE_JOY1_HRIGHT,
00284     KEYCODE_JOY1_L2,
00285     KEYCODE_JOY1_R2,
00286     KEYCODE_JOY1_B14,
00287     KEYCODE_JOY1_B15,
00288     KEYCODE_JOY1_B16,
00289     KEYCODE_JOY1_B17,
00290     KEYCODE_JOY1_B18,
00291     KEYCODE_JOY1_B19,
00292     KEYCODE_JOY1_B20,
00293     KEYCODE_JOY2_A,
00294     KEYCODE_JOY2_B,
00295     KEYCODE_JOY2_X,
00296     KEYCODE_JOY2_Y,
00297     KEYCODE_JOY2_BACK,
00298     KEYCODE_JOY2_GUIDE,
00299     KEYCODE_JOY2_START,
00300     KEYCODE_JOY2_LEFTSTICK,
00301     KEYCODE_JOY2_RIGHTSTICK,
00302     KEYCODE_JOY2_L1,
00303     KEYCODE_JOY2_R1,
00304     KEYCODE_JOY2_HUP,
00305     KEYCODE_JOY2_HDOWN,
00306     KEYCODE_JOY2_HLEFT,
00307     KEYCODE_JOY2_HRIGHT,
00308     KEYCODE_JOY2_L2,
00309     KEYCODE_JOY2_R2,
00310     KEYCODE_MOUSE_B1,
00311     KEYCODE_MOUSE_B2,
00312     KEYCODE_MOUSE_B3,
00313     KEYCODE_MOUSE_B4,
00314     KEYCODE_AXIS_JOY1_X,
00315     KEYCODE_AXIS_JOY1_Y,
00316     KEYCODE_AXIS_JOY1_Z,
00317     KEYCODE_AXIS_JOY1_R,
00318     KEYCODE_AXIS_JOY1_U,
00319     KEYCODE_AXIS_JOY1_V,
00320     KEYCODE_AXIS_JOY2_X,
00321     KEYCODE_AXIS_JOY2_Y,
00322     KEYCODE_AXIS_JOY2_Z,
00323     KEYCODE_AXIS_JOY2_R,
00324     KEYCODE_AXIS_JOY2_U,
00325     KEYCODE_AXIS_JOY2_V,
00326     KEYCODE_AXIS_MOUSE_X,
00327     KEYCODE_AXIS_MOUSE_Y,
00328     KEYCODE_AXIS_MOUSE_Z,
00329     KEYCODE_EXTRA_LAST
00330 };
00331 
00332 #define NUM_JOY_AXES (KEYCODE_AXIS_JOY1_V - KEYCODE_AXIS_JOY1_X + 1)
00333 #define NUM_JOY_BUTTONS (KEYCODE_JOY1_R2 - KEYCODE_JOY1_A + 1)
00334 
00335 extern const ControlDescriptor controls[];
00336 
00337 } // end of namespace Grim
00338 
00339 #endif


Generated on Sat Aug 1 2020 05:01:15 for ResidualVM by doxygen 1.7.1
curved edge   curved edge