147 lines
4.2 KiB
C++
147 lines
4.2 KiB
C++
|
/* Residual - Virtual machine to run LucasArts' 3D adventure games
|
||
|
*
|
||
|
* Residual is the legal property of its developers, whose names
|
||
|
* are too numerous to list here. Please refer to the AUTHORS
|
||
|
* file distributed with this source distribution.
|
||
|
*
|
||
|
* 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
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
*
|
||
|
* $URL$
|
||
|
* $Id$
|
||
|
*/
|
||
|
|
||
|
#if defined(WIN32)
|
||
|
#include <windows.h>
|
||
|
#include <direct.h>
|
||
|
// winnt.h defines ARRAYSIZE, but we want our own one...
|
||
|
#undef ARRAYSIZE
|
||
|
#endif
|
||
|
|
||
|
#include "engines/engine.h"
|
||
|
#include "common/config-manager.h"
|
||
|
#include "common/events.h"
|
||
|
#include "common/file.h"
|
||
|
#include "common/timer.h"
|
||
|
#include "common/savefile.h"
|
||
|
#include "common/system.h"
|
||
|
#include "mixer/mixer.h"
|
||
|
#include "engines/metaengine.h"
|
||
|
|
||
|
#ifdef _WIN32_WCE
|
||
|
extern bool isSmartphone(void);
|
||
|
#endif
|
||
|
|
||
|
Engine::Engine(OSystem *syst)
|
||
|
: _system(syst),
|
||
|
_mixer(_system->getMixer()),
|
||
|
_timer(_system->getTimerManager()),
|
||
|
_eventMan(_system->getEventManager()),
|
||
|
_saveFileMan(_system->getSavefileManager()),
|
||
|
_targetName(ConfMan.getActiveDomainName()),
|
||
|
_gameDataDir(ConfMan.get("path")),
|
||
|
_pauseLevel(0) {
|
||
|
|
||
|
// FIXME: Get rid of the following again. It is only here temporarily.
|
||
|
// We really should never run with a non-working Mixer, so ought to handle
|
||
|
// this at a much earlier stage. If we *really* want to support systems
|
||
|
// without a working mixer, then we need more work. E.g. we could modify the
|
||
|
// Mixer to immediately drop any streams passed to it. This way, at least
|
||
|
// we don't crash because heaps of (sound) memory get allocated but never
|
||
|
// freed. Of course, there still would be problems with many games...
|
||
|
if (!_mixer->isReady())
|
||
|
warning("Sound initialization failed. This may cause severe problems in some games.");
|
||
|
}
|
||
|
|
||
|
Engine::~Engine() {
|
||
|
_mixer->stopAll();
|
||
|
}
|
||
|
|
||
|
bool Engine::shouldPerformAutoSave(int lastSaveTime) {
|
||
|
const int diff = _system->getMillis() - lastSaveTime;
|
||
|
const int autosavePeriod = ConfMan.getInt("autosave_period");
|
||
|
return autosavePeriod != 0 && diff > autosavePeriod * 1000;
|
||
|
}
|
||
|
|
||
|
void Engine::pauseEngine(bool pause) {
|
||
|
assert((pause && _pauseLevel >= 0) || (!pause && _pauseLevel));
|
||
|
|
||
|
if (pause)
|
||
|
_pauseLevel++;
|
||
|
else
|
||
|
_pauseLevel--;
|
||
|
|
||
|
if (_pauseLevel == 1) {
|
||
|
pauseEngineIntern(true);
|
||
|
} else if (_pauseLevel == 0) {
|
||
|
pauseEngineIntern(false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Engine::pauseEngineIntern(bool pause) {
|
||
|
// By default, just (un)pause all digital sounds
|
||
|
_mixer->pauseAll(pause);
|
||
|
}
|
||
|
|
||
|
void Engine::syncSoundSettings() {
|
||
|
|
||
|
// Sync the engine with the config manager
|
||
|
int soundVolumeMusic = ConfMan.getInt("music_volume");
|
||
|
int soundVolumeSFX = ConfMan.getInt("sfx_volume");
|
||
|
int soundVolumeSpeech = ConfMan.getInt("speech_volume");
|
||
|
|
||
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
|
||
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolumeSFX);
|
||
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech);
|
||
|
}
|
||
|
|
||
|
Common::Error Engine::loadGameState(int slot) {
|
||
|
// Do nothing by default
|
||
|
return Common::kNoError;
|
||
|
}
|
||
|
|
||
|
bool Engine::canLoadGameStateCurrently() {
|
||
|
// Do not allow loading by default
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
Common::Error Engine::saveGameState(int slot, const char *desc) {
|
||
|
// Do nothing by default
|
||
|
return Common::kNoError;
|
||
|
}
|
||
|
|
||
|
bool Engine::canSaveGameStateCurrently() {
|
||
|
// Do not allow saving by default
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
void Engine::quitGame() {
|
||
|
Common::Event event;
|
||
|
|
||
|
event.type = Common::EVENT_QUIT;
|
||
|
g_system->getEventManager()->pushEvent(event);
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
EnginePlugin *Engine::getMetaEnginePlugin() const {
|
||
|
|
||
|
const EnginePlugin *plugin = 0;
|
||
|
Common::String gameid = ConfMan.get("gameid");
|
||
|
gameid.toLowercase();
|
||
|
EngineMan.findGame(gameid, &plugin);
|
||
|
return plugin;
|
||
|
}
|
||
|
|
||
|
*/
|