ScummVM
engine.h
Go to the documentation of this file.
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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ENGINES_ENGINE_H
24 #define ENGINES_ENGINE_H
25 
26 #include "common/scummsys.h"
27 #include "common/str.h"
28 #include "common/language.h"
29 #include "common/platform.h"
30 #include "common/queue.h"
31 #include "common/singleton.h"
32 
33 class OSystem;
34 
35 namespace Audio {
36 class Mixer;
37 }
38 namespace Common {
39 class Error;
40 class EventManager;
41 class SaveFileManager;
42 class TimerManager;
43 class FSNode;
44 }
45 namespace GUI {
46 class Debugger;
47 class Dialog;
48 }
49 
53 void GUIErrorMessage(const Common::String &msg);
54 void GUIErrorMessageFormat(const char *fmt, ...) GCC_PRINTF(1, 2);
55 
56 
57 class Engine {
58 public:
61 
62 protected:
66 
68  virtual int runDialog(GUI::Dialog &dialog);
69 
70  const Common::String _targetName; // target name for saves
71 
72 private:
80 
85 
91 
98 
99 public:
100 
101 
113 
120 
128 
136 
142  kSupportsJoystick
143 
144  };
145 
146 
147 
153 
154  Engine(OSystem *syst);
155  virtual ~Engine();
156 
165  virtual void initializePath(const Common::FSNode &gamePath);
166 
171  virtual Common::Error run() = 0;
172 
176  virtual void errorString(const char *buf_input, char *buf_output, int buf_output_size);
177 
182  virtual GUI::Debugger *getDebugger() { return 0; }
183 
187  virtual bool hasFeature(EngineFeature f) const { return false; }
188 
189 // virtual EnginePlugin *getMetaEnginePlugin() const;
190 
206  virtual void syncSoundSettings();
207 
208  /*
209  * Initialize any engine-specific keymaps.
210  */
211  virtual void initKeymap() {}
212 
213  /*
214  * Cleanup any engine-specific keymaps.
215  */
216  virtual void deinitKeymap();
217 
221  virtual void flipMute();
222 
228  virtual Common::Error loadGameState(int slot);
229 
237  void setGameToLoadSlot(int slot);
238 
242  virtual bool canLoadGameStateCurrently();
243 
250  virtual Common::Error saveGameState(int slot, const Common::String &desc);
251 
255  virtual bool canSaveGameStateCurrently();
256 
257 protected:
258 
263  virtual void pauseEngineIntern(bool pause);
264 
266 
267 
268 public:
269 
274  static void quitGame();
275 
280  static bool shouldQuit();
281 
293  void pauseEngine(bool pause);
294 
298  bool isPaused() const { return _pauseLevel != 0; }
299 
303  void openMainMenuDialog();
304 
310  static bool warnUserAboutUnsupportedGame();
311 
317  uint32 getTotalPlayTime() const;
318 
328  void setTotalPlayTime(uint32 time = 0);
329 
330  inline Common::TimerManager *getTimerManager() { return _timer; }
331  inline Common::EventManager *getEventManager() { return _eventMan; }
332  inline Common::SaveFileManager *getSaveFileManager() { return _saveFileMan; }
333 
334 public:
335 
337  void checkCD();
338 
339 protected:
340 
344  bool shouldPerformAutoSave(int lastSaveTime);
345 
346 };
347 
348 // Chained games
349 
355 class ChainedGamesManager : public Common::Singleton<ChainedGamesManager> {
356 private:
357  struct Game {
359  int slot;
360  };
361 
363 
364 public:
366  void clear();
367  void push(const Common::String target, const int slot = -1);
368  bool pop(Common::String &target, int &slot);
369 };
370 
372 #define ChainedGamesMan ChainedGamesManager::instance()
373 
374 // FIXME: HACK for MidiEmu & error()
375 extern Engine *g_engine;
376 
377 #endif
Loading savestates during runtime is supported, that is, this engine implements loadGameState() and c...
Definition: engine.h:127
void run()
Definition: main.cpp:1377
signed int int32
Definition: cdtypes.h:29
Simple string class for ScummVM.
Definition: str.h:49
void GUIErrorMessage(const Common::String &msg)
Initializes graphics and shows error message.
Definition: engine.cpp:390
unsigned int uint32
Definition: cdtypes.h:26
Internal interface to the QuickTime audio decoder.
&#39;Return to launcher&#39; feature is supported, i.e., EVENT_RTL is handled either directly, or indirectly (that is, the engine calls and honors the result of the Engine::shouldQuit() method appropriately).
Definition: engine.h:119
The main audio mixer handles mixing of an arbitrary number of audio streams (in the form of AudioStre...
Definition: mixer.h:53
Singleton class which manages chained games.
Definition: engine.h:355
Variable size Queue class, implemented using our List class.
Definition: queue.h:35
static const BdfFontData desc
EngineFeature
A feature in this context means an ability of the engine which can be either available or not...
Definition: engine.h:107
Common::SaveFileManager * getSaveFileManager()
Definition: engine.h:332
Audio::Mixer * _mixer
Definition: engine.h:60
Common::TimerManager * _timer
Definition: engine.h:63
#define f(col, lum)
Definition: engine.h:57
bool isPaused() const
Return whether the engine is currently paused or not.
Definition: engine.h:298
#define GCC_PRINTF(x, y)
Definition: scummsys.h:344
bool checkCD()
Definition: cdaudio.cpp:519
Common::Queue< Game > _chainedGames
Definition: engine.h:362
Enables the subtitle speed and toggle items in the Options section of the global main menu...
Definition: engine.h:112
Generic template base class for implementing the singleton design pattern.
Definition: singleton.h:34
uint32 _pauseStartTime
The time when the pause was started.
Definition: engine.h:84
virtual void initKeymap()
Definition: engine.h:211
OSystem * _system
Definition: engine.h:59
Common::SaveFileManager * _saveFileMan
Definition: engine.h:65
Common::TimerManager * getTimerManager()
Definition: engine.h:330
Engine * g_engine
Definition: engine.cpp:73
void clear()
Definition: main.cpp:255
The EventManager provides user input events to the client code.
Definition: events.h:435
int pause(lua_State *L)
virtual GUI::Debugger * getDebugger()
Return the engine&#39;s debugger instance, if any.
Definition: engine.h:182
virtual bool hasFeature(EngineFeature f) const
Determine whether the engine supports the specified feature.
Definition: engine.h:187
EXT_C time_t time(time_t *dummy)
An Error instance pairs an error code with string description providing more details about the error...
Definition: error.h:77
const Common::String _targetName
Definition: engine.h:70
Aptr pop()
Definition: stack.cpp:45
Interface for ScummVM backends.
Definition: system.h:113
Common::EventManager * getEventManager()
Definition: engine.h:331
void GUIErrorMessageFormat(const char *fmt,...) GCC_PRINTF(1
Common::EventManager * _eventMan
Definition: engine.h:64
int _saveSlotToLoad
Save slot selected via global main menu.
Definition: engine.h:97
Loading savestates during runtime is supported, that is, this engine implements saveGameState() and c...
Definition: engine.h:135
FSNode, short for "File System Node", provides an abstraction for file paths, allowing for portable f...
Definition: fs.h:58
char fmt[4]
Definition: cdaudio.cpp:55
The SaveFileManager is serving as a factory for InSaveFile and OutSaveFile objects.
Definition: savefile.h:82
void push(Aptr i)
Definition: stack.cpp:39
int32 _engineStartTime
The time when the engine was started.
Definition: engine.h:90
GUI::Dialog * _mainMenuDialog
Definition: engine.h:67
Internal interfaces to the ADPCM decoders.
Definition: systemps2.h:44
static int dialog(lua_State *L)
Definition: lua-script.cpp:929
void quitGame(CONTEXT)
Definition: exe.cpp:201
Common::String target
Definition: engine.h:358
int _pauseLevel
The pause level, 0 means &#39;running&#39;, a positive value indicates how often the engine has been paused (...
Definition: engine.h:79