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

engine.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM 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 ENGINES_ENGINE_H
00024 #define ENGINES_ENGINE_H
00025 
00026 #include "common/scummsys.h"
00027 #include "common/str.h"
00028 #include "common/language.h"
00029 #include "common/platform.h"
00030 #include "common/queue.h"
00031 #include "common/singleton.h"
00032 
00033 class OSystem;
00034 
00035 namespace Audio {
00036 class Mixer;
00037 }
00038 namespace Common {
00039 class Error;
00040 class EventManager;
00041 class SaveFileManager;
00042 class TimerManager;
00043 class FSNode;
00044 }
00045 namespace GUI {
00046 class Debugger;
00047 class Dialog;
00048 }
00049 
00053 void GUIErrorMessage(const Common::String &msg);
00054 void GUIErrorMessageFormat(const char *fmt, ...) GCC_PRINTF(1, 2);
00055 
00056 
00057 class Engine {
00058 public:
00059     OSystem *_system;
00060     Audio::Mixer *_mixer;
00061 
00062 protected:
00063     Common::TimerManager *_timer;
00064     Common::EventManager *_eventMan;
00065     Common::SaveFileManager *_saveFileMan;
00066 
00067     GUI::Dialog *_mainMenuDialog;
00068     virtual int runDialog(GUI::Dialog &dialog);
00069 
00070     const Common::String _targetName; // target name for saves
00071 
00072 private:
00079     int _pauseLevel;
00080 
00084     uint32 _pauseStartTime;
00085 
00090     int32 _engineStartTime;
00091 
00097     int _saveSlotToLoad;
00098 
00099 public:
00100 
00101 
00107     enum EngineFeature {
00112         kSupportsSubtitleOptions,
00113 
00119         kSupportsRTL,
00120 
00127         kSupportsLoadingDuringRuntime,
00128 
00135         kSupportsSavingDuringRuntime,
00136 
00143         kSupportsArbitraryResolutions, // ResidualVM specific
00144 
00150         kSupportsJoystick // ResidualVM specific
00151     };
00152 
00153 
00154 
00160 
00161     Engine(OSystem *syst);
00162     virtual ~Engine();
00163 
00172     virtual void initializePath(const Common::FSNode &gamePath);
00173 
00178     virtual Common::Error run() = 0;
00179 
00183     virtual void errorString(const char *buf_input, char *buf_output, int buf_output_size);
00184 
00189     virtual GUI::Debugger *getDebugger() { return 0; }
00190 
00194     virtual bool hasFeature(EngineFeature f) const { return false; }
00195 
00196 //  virtual EnginePlugin *getMetaEnginePlugin() const;
00197 
00213     virtual void syncSoundSettings();
00214 
00215     /*
00216      * Initialize any engine-specific keymaps.
00217      */
00218     virtual void initKeymap() {}
00219 
00220     /*
00221      * Cleanup any engine-specific keymaps.
00222      */
00223     virtual void deinitKeymap();
00224 
00228     virtual void flipMute();
00229 
00235     virtual Common::Error loadGameState(int slot);
00236 
00244     void setGameToLoadSlot(int slot);
00245 
00249     virtual bool canLoadGameStateCurrently();
00250 
00257     virtual Common::Error saveGameState(int slot, const Common::String &desc);
00258 
00262     virtual bool canSaveGameStateCurrently();
00263 
00264 protected:
00265 
00270     virtual void pauseEngineIntern(bool pause);
00271 
00273 
00274 
00275 public:
00276 
00281     static void quitGame();
00282 
00287     static bool shouldQuit();
00288 
00300     void pauseEngine(bool pause);
00301 
00305     bool isPaused() const { return _pauseLevel != 0; }
00306 
00310     void openMainMenuDialog();
00311 
00317     static bool warnUserAboutUnsupportedGame();
00318 
00324     uint32 getTotalPlayTime() const;
00325 
00335     void setTotalPlayTime(uint32 time = 0);
00336 
00337     inline Common::TimerManager *getTimerManager() { return _timer; }
00338     inline Common::EventManager *getEventManager() { return _eventMan; }
00339     inline Common::SaveFileManager *getSaveFileManager() { return _saveFileMan; }
00340 
00341 public:
00342 
00344     void checkCD();
00345 
00346 protected:
00347 
00351     bool shouldPerformAutoSave(int lastSaveTime);
00352 
00353 };
00354 
00355 // Chained games
00356 
00362 class ChainedGamesManager : public Common::Singleton<ChainedGamesManager> {
00363 private:
00364     struct Game {
00365         Common::String target;
00366         int slot;
00367     };
00368 
00369     Common::Queue<Game> _chainedGames;
00370 
00371 public:
00372     ChainedGamesManager();
00373     void clear();
00374     void push(const Common::String target, const int slot = -1);
00375     bool pop(Common::String &target, int &slot);
00376 };
00377 
00379 #define ChainedGamesMan ChainedGamesManager::instance()
00380 
00381 // FIXME: HACK for MidiEmu & error()
00382 extern Engine *g_engine;
00383 
00384 #endif


Generated on Sat Dec 7 2019 05:00:30 for ResidualVM by doxygen 1.7.1
curved edge   curved edge