2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2002-08-14 10:18:03 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-08-14 10:18:03 +00:00
|
|
|
*
|
2006-02-11 09:53:21 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-08-14 10:18:03 +00:00
|
|
|
*/
|
|
|
|
|
2008-02-01 23:37:16 +00:00
|
|
|
#ifndef ENGINES_ENGINE_H
|
|
|
|
#define ENGINES_ENGINE_H
|
2006-04-15 21:20:16 +00:00
|
|
|
|
2008-10-02 17:48:01 +00:00
|
|
|
#include "common/scummsys.h"
|
2008-11-06 17:05:54 +00:00
|
|
|
#include "common/error.h"
|
2003-10-10 13:55:08 +00:00
|
|
|
#include "common/str.h"
|
2002-08-18 17:48:18 +00:00
|
|
|
|
2004-12-27 22:08:20 +00:00
|
|
|
class OSystem;
|
2008-08-16 02:53:16 +00:00
|
|
|
|
2005-05-10 23:48:48 +00:00
|
|
|
namespace Audio {
|
|
|
|
class Mixer;
|
|
|
|
}
|
2005-05-10 23:17:38 +00:00
|
|
|
namespace Common {
|
2007-04-01 17:36:13 +00:00
|
|
|
class EventManager;
|
2005-05-10 23:17:38 +00:00
|
|
|
class SaveFileManager;
|
2006-06-24 09:34:49 +00:00
|
|
|
class TimerManager;
|
2005-05-10 23:17:38 +00:00
|
|
|
}
|
2006-09-16 19:31:23 +00:00
|
|
|
namespace GUI {
|
|
|
|
class Debugger;
|
2008-06-24 21:15:30 +00:00
|
|
|
class Dialog;
|
2006-09-16 19:31:23 +00:00
|
|
|
}
|
2002-08-18 17:48:18 +00:00
|
|
|
|
2008-11-14 22:08:10 +00:00
|
|
|
/**
|
|
|
|
* Initializes graphics and shows error message.
|
2008-10-02 17:48:01 +00:00
|
|
|
*/
|
|
|
|
void GUIErrorMessage(const Common::String msg);
|
|
|
|
|
2008-06-24 21:15:30 +00:00
|
|
|
|
2002-08-14 10:18:03 +00:00
|
|
|
class Engine {
|
|
|
|
public:
|
|
|
|
OSystem *_system;
|
2005-05-10 23:48:48 +00:00
|
|
|
Audio::Mixer *_mixer;
|
2002-08-14 10:18:03 +00:00
|
|
|
|
2002-08-18 22:47:11 +00:00
|
|
|
protected:
|
2008-12-25 20:53:59 +00:00
|
|
|
Common::TimerManager *_timer;
|
2007-04-01 17:36:13 +00:00
|
|
|
Common::EventManager *_eventMan;
|
2006-10-21 12:03:43 +00:00
|
|
|
Common::SaveFileManager *_saveFileMan;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-10-02 17:48:01 +00:00
|
|
|
GUI::Dialog *_mainMenuDialog;
|
|
|
|
virtual int runDialog(GUI::Dialog &dialog);
|
2006-10-21 12:03:43 +00:00
|
|
|
|
2006-04-15 20:36:41 +00:00
|
|
|
const Common::String _targetName; // target name for saves
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2005-11-23 19:11:33 +00:00
|
|
|
private:
|
2007-06-30 22:22:25 +00:00
|
|
|
/**
|
|
|
|
* The pause level, 0 means 'running', a positive value indicates
|
|
|
|
* how often the engine has been paused (and hence how often it has
|
|
|
|
* to be un-paused before it resumes running). This makes it possible
|
|
|
|
* to nest code which pauses the engine.
|
|
|
|
*/
|
|
|
|
int _pauseLevel;
|
2005-11-23 19:11:33 +00:00
|
|
|
|
2002-08-18 22:47:11 +00:00
|
|
|
public:
|
2008-10-02 17:48:01 +00:00
|
|
|
|
2008-11-04 16:11:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A feature in this context means an ability of the engine which can be
|
|
|
|
* either available or not.
|
|
|
|
* @see Engine::hasFeature()
|
|
|
|
*/
|
|
|
|
enum EngineFeature {
|
2009-02-07 06:47:19 +00:00
|
|
|
/**
|
|
|
|
* Enables the subtitle speed and toggle items in the Options section
|
|
|
|
* of the global main menu.
|
|
|
|
*/
|
|
|
|
kSupportsSubtitleOptions,
|
|
|
|
|
2008-11-04 16:11:40 +00:00
|
|
|
/**
|
|
|
|
* 'Return to launcher' 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).
|
|
|
|
*/
|
|
|
|
kSupportsRTL,
|
2009-01-01 15:06:43 +00:00
|
|
|
|
|
|
|
/**
|
2008-11-04 16:11:40 +00:00
|
|
|
* Loading savestates during runtime is supported, that is, this engine
|
|
|
|
* implements loadGameState() and canLoadGameStateCurrently().
|
|
|
|
* If this feature is supported, then the corresponding MetaEngine *must*
|
|
|
|
* support the kSupportsListSaves feature.
|
|
|
|
*/
|
|
|
|
kSupportsLoadingDuringRuntime,
|
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
/**
|
2008-11-04 16:11:40 +00:00
|
|
|
* Loading savestates during runtime is supported, that is, this engine
|
|
|
|
* implements saveGameState() and canSaveGameStateCurrently().
|
|
|
|
* If this feature is supported, then the corresponding MetaEngine *must*
|
|
|
|
* support the kSupportsListSaves feature.
|
|
|
|
*/
|
|
|
|
kSupportsSavingDuringRuntime
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-09-30 12:27:38 +00:00
|
|
|
/** @name Overloadable methods
|
|
|
|
*
|
|
|
|
* All Engine subclasses should consider overloading some or all of the following methods.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
|
2003-11-10 01:04:12 +00:00
|
|
|
Engine(OSystem *syst);
|
2002-08-18 17:48:18 +00:00
|
|
|
virtual ~Engine();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-11-23 00:03:25 +00:00
|
|
|
/**
|
2009-03-01 04:30:55 +00:00
|
|
|
* Init the engine and start its main loop.
|
2008-11-06 17:05:54 +00:00
|
|
|
* @return returns kNoError on success, else an error code.
|
2004-11-23 00:03:25 +00:00
|
|
|
*/
|
2009-03-01 04:30:55 +00:00
|
|
|
virtual Common::Error run() = 0;
|
2003-03-06 16:27:06 +00:00
|
|
|
|
2008-09-30 12:27:38 +00:00
|
|
|
/**
|
|
|
|
* Prepare an error string, which is printed by the error() function.
|
|
|
|
*/
|
2008-11-15 03:16:41 +00:00
|
|
|
virtual void errorString(const char *buf_input, char *buf_output, int buf_output_size);
|
2004-11-24 00:14:21 +00:00
|
|
|
|
2007-06-30 18:22:21 +00:00
|
|
|
/**
|
|
|
|
* Return the engine's debugger instance, if any. Used by error() to
|
|
|
|
* invoke the debugger when a severe error is reported.
|
|
|
|
*/
|
|
|
|
virtual GUI::Debugger *getDebugger() { return 0; }
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-11-04 16:11:40 +00:00
|
|
|
/**
|
|
|
|
* Determine whether the engine supports the specified feature.
|
|
|
|
*/
|
|
|
|
virtual bool hasFeature(EngineFeature f) const { return false; }
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-11-04 16:11:40 +00:00
|
|
|
// virtual EnginePlugin *getMetaEnginePlugin() const;
|
|
|
|
|
2008-10-02 17:48:01 +00:00
|
|
|
/**
|
|
|
|
* Notify the engine that the sound settings in the config manager may have
|
|
|
|
* changed and that it hence should adjust any internal volume etc. values
|
|
|
|
* accordingly.
|
|
|
|
* @todo find a better name for this
|
2008-09-30 12:27:38 +00:00
|
|
|
*/
|
|
|
|
virtual void syncSoundSettings();
|
|
|
|
|
2009-06-06 17:36:06 +00:00
|
|
|
/**
|
|
|
|
* Flip mute all sound option.
|
|
|
|
*/
|
|
|
|
virtual void flipMute();
|
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
/**
|
2008-11-03 20:00:36 +00:00
|
|
|
* Load a game state.
|
2008-11-06 15:41:38 +00:00
|
|
|
* @param slot the slot from which a savestate should be loaded
|
2008-11-06 17:05:54 +00:00
|
|
|
* @return returns kNoError on success, else an error code.
|
2008-11-03 18:32:16 +00:00
|
|
|
*/
|
2008-11-06 17:05:54 +00:00
|
|
|
virtual Common::Error loadGameState(int slot);
|
2008-11-03 18:32:16 +00:00
|
|
|
|
|
|
|
/**
|
2008-11-03 20:00:36 +00:00
|
|
|
* Indicates whether a game state can be loaded.
|
2008-11-03 18:32:16 +00:00
|
|
|
*/
|
|
|
|
virtual bool canLoadGameStateCurrently();
|
|
|
|
|
|
|
|
/**
|
2008-11-03 20:00:36 +00:00
|
|
|
* Save a game state.
|
2008-11-06 15:41:38 +00:00
|
|
|
* @param slot the slot into which the savestate should be stored
|
|
|
|
* @param desc a description for the savestate, entered by the user
|
2008-11-06 17:05:54 +00:00
|
|
|
* @return returns kNoError on success, else an error code.
|
2008-11-03 18:32:16 +00:00
|
|
|
*/
|
2008-11-06 17:05:54 +00:00
|
|
|
virtual Common::Error saveGameState(int slot, const char *desc);
|
2008-11-03 18:32:16 +00:00
|
|
|
|
|
|
|
/**
|
2008-11-03 20:00:36 +00:00
|
|
|
* Indicates whether a game state can be saved.
|
2008-11-03 18:32:16 +00:00
|
|
|
*/
|
|
|
|
virtual bool canSaveGameStateCurrently();
|
|
|
|
|
2008-09-30 12:27:38 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Actual implementation of pauseEngine by subclasses. See there
|
|
|
|
* for details.
|
|
|
|
*/
|
|
|
|
virtual void pauseEngineIntern(bool pause);
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
2008-10-02 17:48:01 +00:00
|
|
|
* Request the engine to quit. Sends a EVENT_QUIT event to the Event
|
|
|
|
* Manager.
|
2008-09-30 12:27:38 +00:00
|
|
|
*/
|
2009-01-30 16:04:39 +00:00
|
|
|
static void quitGame();
|
2008-09-30 12:27:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-10-02 17:48:01 +00:00
|
|
|
* Return whether the ENGINE should quit respectively should return to the
|
|
|
|
* launcher.
|
2008-09-30 12:27:38 +00:00
|
|
|
*/
|
2009-01-30 16:04:39 +00:00
|
|
|
static bool shouldQuit();
|
2008-09-30 12:27:38 +00:00
|
|
|
|
2007-06-30 18:22:21 +00:00
|
|
|
/**
|
|
|
|
* Pause or resume the engine. This should stop/resume any audio playback
|
|
|
|
* and other stuff. Called right before the system runs a global dialog
|
|
|
|
* (like a global pause, main menu, options or 'confirm exit' dialog).
|
|
|
|
*
|
2007-06-30 22:22:25 +00:00
|
|
|
* This is a convenience tracker which automatically keeps track on how
|
|
|
|
* often the engine has been paused, ensuring that after pausing an engine
|
|
|
|
* e.g. twice, it has to be unpaused twice before actuallying resuming.
|
|
|
|
*
|
2007-06-30 18:22:21 +00:00
|
|
|
* @param pause true to pause the engine, false to resume it
|
|
|
|
*/
|
2007-06-30 22:22:25 +00:00
|
|
|
void pauseEngine(bool pause);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-06-30 22:22:25 +00:00
|
|
|
/**
|
|
|
|
* Return whether the engine is currently paused or not.
|
|
|
|
*/
|
|
|
|
bool isPaused() const { return _pauseLevel != 0; }
|
2007-06-30 18:22:21 +00:00
|
|
|
|
2008-07-08 05:21:05 +00:00
|
|
|
/**
|
2008-09-30 12:27:38 +00:00
|
|
|
* Run the Global Main Menu Dialog
|
2008-06-26 23:22:28 +00:00
|
|
|
*/
|
2008-10-02 17:48:01 +00:00
|
|
|
void openMainMenuDialog();
|
2008-06-24 21:15:30 +00:00
|
|
|
|
2008-12-25 20:53:59 +00:00
|
|
|
inline Common::TimerManager *getTimerManager() { return _timer; }
|
|
|
|
inline Common::EventManager *getEventManager() { return _eventMan; }
|
|
|
|
inline Common::SaveFileManager *getSaveFileManager() { return _saveFileMan; }
|
2008-12-25 20:40:00 +00:00
|
|
|
|
2007-06-30 18:22:21 +00:00
|
|
|
public:
|
|
|
|
|
2005-06-14 08:54:11 +00:00
|
|
|
/** On some systems, check if the game appears to be run from CD. */
|
|
|
|
void checkCD();
|
2005-11-23 19:11:33 +00:00
|
|
|
|
2008-10-02 17:48:01 +00:00
|
|
|
protected:
|
2006-04-26 00:59:13 +00:00
|
|
|
|
2007-06-30 22:22:25 +00:00
|
|
|
/**
|
2008-10-02 17:48:01 +00:00
|
|
|
* Indicate whether an autosave should be performed.
|
2007-06-30 22:22:25 +00:00
|
|
|
*/
|
2008-10-02 17:48:01 +00:00
|
|
|
bool shouldPerformAutoSave(int lastSaveTime);
|
|
|
|
|
2002-08-14 10:18:03 +00:00
|
|
|
};
|
|
|
|
|
2009-09-24 14:02:05 +00:00
|
|
|
// FIXME: HACK for MidiEmu & error()
|
2003-03-07 15:38:11 +00:00
|
|
|
extern Engine *g_engine;
|
|
|
|
|
2002-08-14 10:18:03 +00:00
|
|
|
#endif
|