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

#include <engine.h>

Inheritance diagram for Engine:
Collaboration diagram for Engine:

List of all members.

Public Types

enum  EngineFeature {
  kSupportsSubtitleOptions, kSupportsReturnToLauncher, kSupportsLoadingDuringRuntime, kSupportsSavingDuringRuntime,
  kSupportsChangingOptionsDuringRuntime, kSupportsArbitraryResolutions, kSupportsJoystick
}
 

A feature in this context means an ability of the engine which can be either available or not.

More...

Public Member Functions

PauseToken pauseEngine ()
 Pause the engine.
bool isPaused () const
 Return whether the engine is currently paused or not.
void openMainMenuDialog ()
 Run the Global Main Menu Dialog.
uint32 getTotalPlayTime () const
 Get the total play time.
void setTotalPlayTime (uint32 time=0)
 Set the game time counter to the specified time.
Common::TimerManagergetTimerManager ()
Common::EventManagergetEventManager ()
Common::SaveFileManagergetSaveFileManager ()
void checkCD ()
 On some systems, check if the game appears to be run from CD.
void handleAutoSave ()
 Checks for whether it's time to do an autosave, and if so, does it.
void saveAutosaveIfEnabled ()
 Does an autosave immediately if autosaves are turned on.
virtual bool canSaveAutosaveCurrently ()
 Indicates whether an autosave can currently be saved.
virtual int getAutosaveSlot () const
 Returns the slot that should be used for autosaves.
bool shouldPerformAutoSave (int lastSaveTime)

Static Public Member Functions

static void quitGame ()
 Request the engine to quit.
static bool shouldQuit ()
 Return whether the ENGINE should quit respectively should return to the launcher.
static MetaEnginegetMetaEngine ()
static bool warnUserAboutUnsupportedGame ()
 Display a warning to the user that the game is not fully supported.

Public Attributes

OSystem_system
Audio::Mixer_mixer

Protected Member Functions

virtual int runDialog (GUI::Dialog &dialog)

Protected Attributes

Common::TimerManager_timer
Common::EventManager_eventMan
Common::SaveFileManager_saveFileMan
GUI::Dialog_mainMenuDialog
const Common::String _targetName

Private Member Functions

void resumeEngine ()
 Resume the engine.

Private Attributes

int _pauseLevel
 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).
uint32 _pauseStartTime
 The time when the pause was started.
int32 _engineStartTime
 The time when the engine was started.
const int _autosaveInterval
 Autosave interval.
int _lastAutosaveTime
 The last time an autosave was done.
int _saveSlotToLoad
 Save slot selected via global main menu.
GUI::Debugger_debugger
 Optional debugger for the engine.

Friends

class PauseToken

Overloadable methods

All Engine subclasses should consider overloading some or all of the following methods.



virtual void pauseEngineIntern (bool pause)
 Actual implementation of pauseEngine by subclasses.
 Engine (OSystem *syst)
virtual ~Engine ()
virtual void initializePath (const Common::FSNode &gamePath)
 Init SearchMan according to the game path.
virtual Common::Error run ()=0
 Init the engine and start its main loop.
virtual void errorString (const char *buf_input, char *buf_output, int buf_output_size)
 Prepare an error string, which is printed by the error() function.
virtual GUI::DebuggergetDebugger ()
 Return the engine's debugger instance, if any.
void setDebugger (GUI::Debugger *debugger)
 Sets the engine's debugger.
GUI::DebuggergetOrCreateDebugger ()
 Return the engine's debugger instance, or create one if none is present.
virtual bool hasFeature (EngineFeature f) const
 Determine whether the engine supports the specified feature.
virtual void syncSoundSettings ()
 Notify the engine that the sound settings in the config manager may have changed and that it hence should adjust any internal volume etc.
virtual void applyGameSettings ()
 Notify the engine that the settings editable from the game tab in the in-game options dialog may have changed and that they need to be applied if necessary.
virtual void flipMute ()
 Flip mute all sound option.
virtual Common::String getSaveStateName (int slot) const
 Generates the savegame filename.
virtual Common::Error loadGameState (int slot)
 Load a game state.
virtual Common::Error loadGameStream (Common::SeekableReadStream *stream)
 Load a game state.
void setGameToLoadSlot (int slot)
 Sets the game slot for a savegame to be loaded after global main menu execution.
virtual bool canLoadGameStateCurrently ()
 Indicates whether a game state can be loaded.
virtual Common::Error saveGameState (int slot, const Common::String &desc, bool isAutosave=false)
 Save a game state.
virtual Common::Error saveGameStream (Common::WriteStream *stream, bool isAutosave=false)
 Save a game state.
virtual bool canSaveGameStateCurrently ()
 Indicates whether a game state can be saved.
bool saveGameDialog ()
 Shows the ScummVM save dialog, allowing users to save their game.
bool loadGameDialog ()
 Shows the ScummVM Restore dialog, allowing users to load a game.

Detailed Description

Definition at line 98 of file engine.h.


Member Enumeration Documentation

A feature in this context means an ability of the engine which can be either available or not.

See also:
Engine::hasFeature()
Enumerator:
kSupportsSubtitleOptions 

Enables the subtitle speed and toggle items in the Options section of the global main menu.

kSupportsReturnToLauncher 

'Return to launcher' feature is supported, i.e., EVENT_RETURN_TO_LAUNCHER is handled either directly, or indirectly (that is, the engine calls and honors the result of the Engine::shouldQuit() method appropriately).

kSupportsLoadingDuringRuntime 

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.

kSupportsSavingDuringRuntime 

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.

kSupportsChangingOptionsDuringRuntime 

Changing the game settings during runtime is supported.

This enables showing the engine options tab in the config dialog accessed through the Global Main Menu.

kSupportsArbitraryResolutions 

Arbitrary resolutions are supported, that is, this engine allows the backend to override the resolution passed to OSystem::setupScreen.

The engine will need to read the actual resolution used by the backend using OSystem::getWidth and OSystem::getHeight.

kSupportsJoystick 

Engine must receive joystick events because the game uses them.

For engines which have not this feature, joystick events are converted to mouse events.

Definition at line 162 of file engine.h.


Constructor & Destructor Documentation

Engine::Engine ( OSystem syst  ) 

Definition at line 139 of file engine.cpp.

Engine::~Engine (  )  [virtual]

Definition at line 184 of file engine.cpp.


Member Function Documentation

virtual void Engine::applyGameSettings (  )  [inline, virtual]

Notify the engine that the settings editable from the game tab in the in-game options dialog may have changed and that they need to be applied if necessary.

Definition at line 294 of file engine.h.

bool Engine::canLoadGameStateCurrently (  )  [virtual]

Indicates whether a game state can be loaded.

Reimplemented in Grim::GrimEngine, Myst3::Myst3Engine, Stark::StarkEngine, and Wintermute::WintermuteEngine.

Definition at line 711 of file engine.cpp.

virtual bool Engine::canSaveAutosaveCurrently (  )  [inline, virtual]

Indicates whether an autosave can currently be saved.

Definition at line 472 of file engine.h.

bool Engine::canSaveGameStateCurrently (  )  [virtual]

Indicates whether a game state can be saved.

Reimplemented in Myst3::Myst3Engine, Stark::StarkEngine, and Wintermute::WintermuteEngine.

Definition at line 738 of file engine.cpp.

void Engine::checkCD (  ) 

On some systems, check if the game appears to be run from CD.

Definition at line 422 of file engine.cpp.

void Engine::errorString ( const char *  buf_input,
char *  buf_output,
int  buf_output_size 
) [virtual]

Prepare an error string, which is printed by the error() function.

Definition at line 529 of file engine.cpp.

void Engine::flipMute (  )  [virtual]

Flip mute all sound option.

Definition at line 671 of file engine.cpp.

virtual int Engine::getAutosaveSlot (  )  const [inline, virtual]

Returns the slot that should be used for autosaves.

Note:
This should match the meta engine getAutosaveSlot() method

Definition at line 480 of file engine.h.

virtual GUI::Debugger* Engine::getDebugger (  )  [inline, virtual]

Return the engine's debugger instance, if any.

Definition at line 250 of file engine.h.

Common::EventManager* Engine::getEventManager (  )  [inline]

Definition at line 451 of file engine.h.

MetaEngine & Engine::getMetaEngine (  )  [static]

Definition at line 832 of file engine.cpp.

GUI::Debugger * Engine::getOrCreateDebugger (  ) 

Return the engine's debugger instance, or create one if none is present.

Used by error() to invoke the debugger when a severe error is reported.

Definition at line 816 of file engine.cpp.

Common::SaveFileManager* Engine::getSaveFileManager (  )  [inline]

Definition at line 452 of file engine.h.

virtual Common::String Engine::getSaveStateName ( int  slot  )  const [inline, virtual]

Generates the savegame filename.

Definition at line 304 of file engine.h.

Common::TimerManager* Engine::getTimerManager (  )  [inline]

Definition at line 450 of file engine.h.

uint32 Engine::getTotalPlayTime (  )  const

Get the total play time.

Returns:
How long the player has been playing in ms.

Definition at line 612 of file engine.cpp.

void Engine::handleAutoSave (  ) 

Checks for whether it's time to do an autosave, and if so, does it.

Definition at line 491 of file engine.cpp.

virtual bool Engine::hasFeature ( EngineFeature  f  )  const [inline, virtual]

Determine whether the engine supports the specified feature.

Reimplemented in Grim::GrimEngine, Myst3::Myst3Engine, Stark::StarkEngine, and Wintermute::WintermuteEngine.

Definition at line 270 of file engine.h.

void Engine::initializePath ( const Common::FSNode gamePath  )  [virtual]

Init SearchMan according to the game path.

By default it adds the directory in non-flat mode with a depth of 4 as priority 0 to SearchMan.

Parameters:
gamePath The base directory of the game data.

Definition at line 196 of file engine.cpp.

bool Engine::isPaused (  )  const [inline]

Return whether the engine is currently paused or not.

Definition at line 418 of file engine.h.

bool Engine::loadGameDialog (  ) 

Shows the ScummVM Restore dialog, allowing users to load a game.

Definition at line 743 of file engine.cpp.

Common::Error Engine::loadGameState ( int  slot  )  [virtual]

Load a game state.

Parameters:
slot the slot from which a savestate should be loaded
Returns:
returns kNoError on success, else an error code.

Reimplemented in Grim::GrimEngine, Myst3::Myst3Engine, Stark::StarkEngine, and Wintermute::WintermuteEngine.

Definition at line 686 of file engine.cpp.

Common::Error Engine::loadGameStream ( Common::SeekableReadStream stream  )  [virtual]

Load a game state.

Parameters:
stream the stream to load the savestate from
Returns:
returns kNoError on success, else an error code.

Definition at line 706 of file engine.cpp.

void Engine::openMainMenuDialog (  ) 

Run the Global Main Menu Dialog.

Definition at line 563 of file engine.cpp.

PauseToken Engine::pauseEngine (  ) 

Pause the engine.

This should stop 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).

Returns a PauseToken. Multiple pause tokens may exist. The engine will be resumed when all associated pause tokens reach the end of their lives.

Definition at line 533 of file engine.cpp.

void Engine::pauseEngineIntern ( bool  pause  )  [protected, virtual]

Actual implementation of pauseEngine by subclasses.

See there for details.

Reimplemented in Grim::GrimEngine, Myst3::Myst3Engine, and Stark::StarkEngine.

Definition at line 558 of file engine.cpp.

void Engine::quitGame (  )  [static]

Request the engine to quit.

Sends a EVENT_QUIT event to the Event Manager.

Definition at line 804 of file engine.cpp.

void Engine::resumeEngine (  )  [private]

Resume the engine.

This should resume any audio playback and other stuff.

Only PauseToken is allowed to call this member function. Use the PauseToken that you got from pauseEngine to resume the engine.

Definition at line 546 of file engine.cpp.

virtual Common::Error Engine::run (  )  [pure virtual]

Init the engine and start its main loop.

Returns:
returns kNoError on success, else an error code.

Implemented in Grim::GrimEngine, Myst3::Myst3Engine, Stark::StarkEngine, and Wintermute::WintermuteEngine.

int Engine::runDialog ( GUI::Dialog dialog  )  [protected, virtual]

Definition at line 630 of file engine.cpp.

void Engine::saveAutosaveIfEnabled (  ) 

Does an autosave immediately if autosaves are turned on.

Definition at line 500 of file engine.cpp.

bool Engine::saveGameDialog (  ) 

Shows the ScummVM save dialog, allowing users to save their game.

Definition at line 772 of file engine.cpp.

Common::Error Engine::saveGameState ( int  slot,
const Common::String desc,
bool  isAutosave = false 
) [virtual]

Save a game state.

Parameters:
slot the slot into which the savestate should be stored
desc a description for the savestate, entered by the user
isAutosave Expected to be true if an autosave is being created
Returns:
returns kNoError on success, else an error code.

Reimplemented in Myst3::Myst3Engine, Stark::StarkEngine, and Wintermute::WintermuteEngine.

Definition at line 716 of file engine.cpp.

Common::Error Engine::saveGameStream ( Common::WriteStream stream,
bool  isAutosave = false 
) [virtual]

Save a game state.

Parameters:
stream The write stream to save the savegame data to
isAutosave Expected to be true if an autosave is being created
Returns:
returns kNoError on success, else an error code.

Definition at line 733 of file engine.cpp.

void Engine::setDebugger ( GUI::Debugger debugger  )  [inline]

Sets the engine's debugger.

Once set, the Engine class is responsible for managing the debugger, and freeing it on exit

Definition at line 256 of file engine.h.

void Engine::setGameToLoadSlot ( int  slot  ) 

Sets the game slot for a savegame to be loaded after global main menu execution.

This is to avoid loading a savegame from inside the menu loop which causes bugs like #2822778.

Parameters:
slot the slot from which a savestate should be loaded.

Definition at line 637 of file engine.cpp.

void Engine::setTotalPlayTime ( uint32  time = 0  ) 

Set the game time counter to the specified time.

This can be used to set the play time counter after loading a savegame for example. Another use case is in case the engine wants to exclude time from the counter the user spent in original engine dialogs.

Parameters:
time Play time to set up in ms.

Definition at line 619 of file engine.cpp.

bool Engine::shouldPerformAutoSave ( int  lastSaveTime  )  [inline]

Definition at line 484 of file engine.h.

bool Engine::shouldQuit (  )  [static]

Return whether the ENGINE should quit respectively should return to the launcher.

Definition at line 811 of file engine.cpp.

void Engine::syncSoundSettings (  )  [virtual]

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. The default implementation sets the volume levels of all mixer sound types according to the config entries of the active domain. When overwriting, call the default implementation first, then adjust the volumes further (if required).

Note:
When setting volume levels, respect the "mute" config entry.
The volume for the plain sound type is reset to the maximum volume. If the engine can associate its own value for this type, it needs to overwrite this member and set it accordingly.
Todo:
find a better name for this

Reimplemented in Myst3::Myst3Engine.

Definition at line 641 of file engine.cpp.

bool Engine::warnUserAboutUnsupportedGame (  )  [static]

Display a warning to the user that the game is not fully supported.

Returns:
true if the user chose to start anyway, false otherwise

Definition at line 601 of file engine.cpp.


Friends And Related Function Documentation

friend class PauseToken [friend]

Definition at line 411 of file engine.h.


Member Data Documentation

const int Engine::_autosaveInterval [private]

Autosave interval.

Definition at line 136 of file engine.h.

Optional debugger for the engine.

Reimplemented in Wintermute::WintermuteEngine.

Definition at line 153 of file engine.h.

The time when the engine was started.

This value is used to calculate the current play time of the game running.

Definition at line 131 of file engine.h.

Definition at line 105 of file engine.h.

The last time an autosave was done.

Definition at line 141 of file engine.h.

Definition at line 108 of file engine.h.

Definition at line 101 of file engine.h.

int Engine::_pauseLevel [private]

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.

Definition at line 120 of file engine.h.

The time when the pause was started.

Reimplemented in Grim::GrimEngine.

Definition at line 125 of file engine.h.

Definition at line 106 of file engine.h.

int Engine::_saveSlotToLoad [private]

Save slot selected via global main menu.

This slot will be loaded after main menu execution (not from inside the menu loop, to avoid bugs like #2822778).

Definition at line 148 of file engine.h.

Reimplemented in Myst3::Myst3Engine.

Definition at line 100 of file engine.h.

Definition at line 111 of file engine.h.

Definition at line 104 of file engine.h.


The documentation for this class was generated from the following files:


Generated on Sat Jul 4 2020 05:02:57 for ResidualVM by doxygen 1.7.1
curved edge   curved edge