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


Generated on Sat Dec 14 2019 05:00:37 for ResidualVM by doxygen 1.7.1
curved edge   curved edge