aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2008-10-02 17:48:01 +0000
committerMax Horn2008-10-02 17:48:01 +0000
commit3248906156d6fa2bb01c4bfa527aaba379456705 (patch)
tree0e6b02e3e7324eae9a71fbf02524cedf57c46f4e /engines
parentc77124ff50dee8864a94a31b4a0f2a588daed445 (diff)
downloadscummvm-rg350-3248906156d6fa2bb01c4bfa527aaba379456705.tar.gz
scummvm-rg350-3248906156d6fa2bb01c4bfa527aaba379456705.tar.bz2
scummvm-rg350-3248906156d6fa2bb01c4bfa527aaba379456705.zip
Engine class changed:
- Moved initCommonGFX() && GUIErrorMessage() out of class Engine - got rid of the _autosavePeriod member (this prevented users from changing the autosave period during runtime) - Got rid of an evil 'using GUI::Dialog' statement - Clarified some Doxygen comments svn-id: r34720
Diffstat (limited to 'engines')
-rw-r--r--engines/engine.cpp40
-rw-r--r--engines/engine.h55
-rw-r--r--engines/gob/video.cpp2
-rw-r--r--engines/kyra/resource.cpp2
-rw-r--r--engines/kyra/screen.cpp4
-rw-r--r--engines/kyra/staticres.cpp2
-rw-r--r--engines/lure/lure.cpp4
-rw-r--r--engines/parallaction/graphics.cpp4
-rw-r--r--engines/saga/gfx.cpp2
-rw-r--r--engines/sword2/resman.cpp16
10 files changed, 65 insertions, 66 deletions
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 4febccec05..57efad5c19 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -61,7 +61,6 @@ Engine::Engine(OSystem *syst)
_mainMenuDialog(NULL) {
g_engine = this;
- _autosavePeriod = ConfMan.getInt("autosave_period");
// 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
@@ -81,7 +80,7 @@ Engine::~Engine() {
g_engine = NULL;
}
-void Engine::initCommonGFX(bool defaultTo1XScaler) {
+void initCommonGFX(bool defaultTo1XScaler) {
const Common::ConfigManager::Domain *transientDomain = ConfMan.getDomain(Common::ConfigManager::kTransientDomain);
const Common::ConfigManager::Domain *gameDomain = ConfMan.getActiveDomain();
@@ -101,11 +100,11 @@ void Engine::initCommonGFX(bool defaultTo1XScaler) {
// FIXME: As a hack, we use "1x" here. Would be nicer to use
// getDefaultGraphicsMode() instead, but right now, we do not specify
// whether that is a 1x scaler or not...
- _system->setGraphicsMode("1x");
+ g_system->setGraphicsMode("1x");
} else {
// Override global scaler with any game-specific define
if (ConfMan.hasKey("gfx_mode")) {
- _system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
+ g_system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
}
}
@@ -118,11 +117,22 @@ void Engine::initCommonGFX(bool defaultTo1XScaler) {
// (De)activate aspect-ratio correction as determined by the config settings
if (gameDomain && gameDomain->contains("aspect_ratio"))
- _system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
+ g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
// (De)activate fullscreen mode as determined by the config settings
if (gameDomain && gameDomain->contains("fullscreen"))
- _system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
+ g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
+}
+
+void GUIErrorMessage(const Common::String msg) {
+ g_system->setWindowCaption("Error");
+ g_system->beginGFXTransaction();
+ initCommonGFX(false);
+ g_system->initSize(320, 200);
+ g_system->endGFXTransaction();
+
+ GUI::MessageDialog dialog(msg);
+ dialog.runModal();
}
void Engine::checkCD() {
@@ -178,24 +188,14 @@ void Engine::checkCD() {
bool Engine::shouldPerformAutoSave(int lastSaveTime) {
const int diff = _system->getMillis() - lastSaveTime;
- return _autosavePeriod != 0 && diff > _autosavePeriod * 1000;
+ const int autosavePeriod = ConfMan.getInt("autosave_period");
+ return autosavePeriod != 0 && diff > autosavePeriod * 1000;
}
void Engine::errorString(const char *buf1, char *buf2) {
strcpy(buf2, buf1);
}
-void Engine::GUIErrorMessage(const Common::String msg) {
- _system->setWindowCaption("Error");
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(320, 200);
- _system->endGFXTransaction();
-
- GUI::MessageDialog dialog(msg);
- dialog.runModal();
-}
-
void Engine::pauseEngine(bool pause) {
assert((pause && _pauseLevel >= 0) || (!pause && _pauseLevel));
@@ -216,14 +216,14 @@ void Engine::pauseEngineIntern(bool pause) {
_mixer->pauseAll(pause);
}
-void Engine::mainMenuDialog() {
+void Engine::openMainMenuDialog() {
if (!_mainMenuDialog)
_mainMenuDialog = new MainMenuDialog(this);
runDialog(*_mainMenuDialog);
syncSoundSettings();
}
-int Engine::runDialog(Dialog &dialog) {
+int Engine::runDialog(GUI::Dialog &dialog) {
pauseEngine(true);
int result = dialog.runModal();
pauseEngine(false);
diff --git a/engines/engine.h b/engines/engine.h
index 1f7a3a54e7..dec85885d8 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -25,9 +25,9 @@
#ifndef ENGINES_ENGINE_H
#define ENGINES_ENGINE_H
+#include "common/scummsys.h"
#include "common/events.h"
#include "common/fs.h"
-#include "common/scummsys.h"
#include "common/str.h"
class OSystem;
@@ -45,7 +45,16 @@ namespace GUI {
class Dialog;
}
-using GUI::Dialog;
+/**
+ * Setup the backend's graphics mode.
+ */
+void initCommonGFX(bool defaultTo1XScaler);
+
+/**
+ * Initialized graphics and shows error message.
+ */
+void GUIErrorMessage(const Common::String msg);
+
class Engine {
public:
@@ -57,8 +66,8 @@ protected:
Common::EventManager *_eventMan;
Common::SaveFileManager *_saveFileMan;
- Dialog *_mainMenuDialog;
- virtual int runDialog(Dialog &dialog);
+ GUI::Dialog *_mainMenuDialog;
+ virtual int runDialog(GUI::Dialog &dialog);
const Common::String _targetName; // target name for saves
@@ -66,11 +75,6 @@ protected:
private:
/**
- * The autosave interval, given in second. Used by shouldPerformAutoSave.
- */
- int _autosavePeriod;
-
- /**
* 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
@@ -79,13 +83,13 @@ private:
int _pauseLevel;
public:
+
/** @name Overloadable methods
*
* All Engine subclasses should consider overloading some or all of the following methods.
*/
//@{
-
Engine(OSystem *syst);
virtual ~Engine();
@@ -114,7 +118,11 @@ public:
*/
virtual GUI::Debugger *getDebugger() { return 0; }
- /** Sync the engine's sound settings with the config manager
+ /**
+ * 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
*/
virtual void syncSoundSettings();
@@ -132,16 +140,17 @@ protected:
public:
/**
- * Quit the engine, sends a Quit event to the Event Manager
+ * Request the engine to quit. Sends a EVENT_QUIT event to the Event
+ * Manager.
*/
void quitGame();
/**
- * Return whether or not the ENGINE should quit
+ * Return whether the ENGINE should quit respectively should return to the
+ * launcher.
*/
bool shouldQuit() const { return (_eventMan->shouldQuit() || _eventMan->shouldRTL()); }
-
/**
* Pause or resume the engine. This should stop/resume any audio playback
* and other stuff. Called right before the system runs a global dialog
@@ -163,7 +172,7 @@ public:
/**
* Run the Global Main Menu Dialog
*/
- void mainMenuDialog();
+ void openMainMenuDialog();
/**
* Determine whether the engine supports the specified MetaEngine feature.
@@ -172,24 +181,16 @@ public:
public:
- /**
- * Setup the backend's graphics mode.
- * @todo Must be public because e.g. Saga's Gfx class wants to invoke it. Move it to a better place?
- */
- void initCommonGFX(bool defaultTo1XScaler);
-
/** On some systems, check if the game appears to be run from CD. */
void checkCD();
- /** Indicate whether an autosave should be performed. */
- bool shouldPerformAutoSave(int lastSaveTime);
+protected:
/**
- * Initialized graphics and shows error message.
- * @todo Move this to a better place (not just engines need to access it, so it neither
- * needs to nor should be contained in class Engine)
+ * Indicate whether an autosave should be performed.
*/
- void GUIErrorMessage(const Common::String msg);
+ bool shouldPerformAutoSave(int lastSaveTime);
+
};
extern Engine *g_engine;
diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp
index 453613d1ae..30994cf4a7 100644
--- a/engines/gob/video.cpp
+++ b/engines/gob/video.cpp
@@ -171,7 +171,7 @@ void Video::clearScreen() {
void Video::setSize(bool defaultTo1XScaler) {
_vm->_system->beginGFXTransaction();
_vm->_system->initSize(_vm->_width, _vm->_height);
- _vm->initCommonGFX(defaultTo1XScaler);
+ initCommonGFX(defaultTo1XScaler);
_vm->_system->endGFXTransaction();
}
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp
index 9a789a9eb1..798290b16c 100644
--- a/engines/kyra/resource.cpp
+++ b/engines/kyra/resource.cpp
@@ -64,7 +64,7 @@ bool Resource::reset() {
if (!loadPakFile(StaticResource::staticDataFilename()) || !StaticResource::checkKyraDat(this)) {
Common::String errorMessage = "You're missing the '" + StaticResource::staticDataFilename() + "' file or it got corrupted, (re)get it from the ScummVM website";
- _vm->GUIErrorMessage(errorMessage);
+ GUIErrorMessage(errorMessage);
error(errorMessage.c_str());
}
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index d7c603fe11..0b859f5032 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -192,7 +192,7 @@ void Screen::setResolution() {
_system->initSize(960, 400);
else
_system->initSize(640, 400);
- _vm->initCommonGFX(true);
+ initCommonGFX(true);
_system->endGFXTransaction();
} else {
_system->beginGFXTransaction();
@@ -200,7 +200,7 @@ void Screen::setResolution() {
_system->initSize(640, 200);
else
_system->initSize(320, 200);
- _vm->initCommonGFX(false);
+ initCommonGFX(false);
_system->endGFXTransaction();
}
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index bfffefb70a..ba8de9c57f 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -361,7 +361,7 @@ void StaticResource::deinit() {
void StaticResource::outputError(const Common::String &error) {
Common::String errorMessage = "Your '" + StaticResource::staticDataFilename() + "' file " + error + ", reget a correct version from the ScummVM website";
- _vm->GUIErrorMessage(errorMessage);
+ GUIErrorMessage(errorMessage);
::error(errorMessage.c_str());
}
diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp
index 23737e2f77..32eb0dbe21 100644
--- a/engines/lure/lure.cpp
+++ b/engines/lure/lure.cpp
@@ -23,8 +23,6 @@
*
*/
-
-
#include "common/config-manager.h"
#include "common/system.h"
#include "common/savefile.h"
@@ -251,7 +249,7 @@ void LureEngine::GUIError(const char *msg, ...) {
vsnprintf(buffer, STRINGBUFLEN, msg, va);
va_end(va);
- Engine::GUIErrorMessage(buffer);
+ GUIErrorMessage(buffer);
}
void LureEngine::syncSoundSettings() {
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 2bd3935f01..5526ecc64d 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -750,8 +750,8 @@ Gfx::Gfx(Parallaction* vm) :
_vm(vm), _disk(vm->_disk) {
_vm->_system->beginGFXTransaction();
- _vm->_system->initSize(_vm->_screenWidth, _vm->_screenHeight);
- _vm->initCommonGFX(_vm->getGameType() == GType_BRA);
+ _vm->_system->initSize(_vm->_screenWidth, _vm->_screenHeight);
+ initCommonGFX(_vm->getGameType() == GType_BRA);
_vm->_system->endGFXTransaction();
setPalette(_palette);
diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp
index 85416991db..2cc4e8c095 100644
--- a/engines/saga/gfx.cpp
+++ b/engines/saga/gfx.cpp
@@ -41,7 +41,7 @@ namespace Saga {
Gfx::Gfx(SagaEngine *vm, OSystem *system, int width, int height) : _vm(vm), _system(system) {
_system->beginGFXTransaction();
- _vm->initCommonGFX(width > 320);
+ initCommonGFX(width > 320);
_system->initSize(width, height);
_system->endGFXTransaction();
diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp
index 0add2478a3..a30c6301cc 100644
--- a/engines/sword2/resman.cpp
+++ b/engines/sword2/resman.cpp
@@ -106,7 +106,7 @@ bool ResourceManager::init() {
Common::File file;
if (!file.open("resource.inf")) {
- _vm->GUIErrorMessage("Broken Sword 2: Cannot open resource.inf");
+ GUIErrorMessage("Broken Sword 2: Cannot open resource.inf");
return false;
}
@@ -117,7 +117,7 @@ bool ResourceManager::init() {
_resFiles[_totalClusters].numEntries = -1;
_resFiles[_totalClusters].entryTab = NULL;
if (++_totalClusters >= MAX_res_files) {
- _vm->GUIErrorMessage("Broken Sword 2: Too many entries in resource.inf");
+ GUIErrorMessage("Broken Sword 2: Too many entries in resource.inf");
return false;
}
}
@@ -126,7 +126,7 @@ bool ResourceManager::init() {
// Now load in the binary id to res conversion table
if (!file.open("resource.tab")) {
- _vm->GUIErrorMessage("Broken Sword 2: Cannot open resource.tab");
+ GUIErrorMessage("Broken Sword 2: Cannot open resource.tab");
return false;
}
@@ -143,14 +143,14 @@ bool ResourceManager::init() {
if (file.ioFailed()) {
file.close();
- _vm->GUIErrorMessage("Broken Sword 2: Cannot read resource.tab");
+ GUIErrorMessage("Broken Sword 2: Cannot read resource.tab");
return false;
}
file.close();
if (!file.open("cd.inf")) {
- _vm->GUIErrorMessage("Broken Sword 2: Cannot open cd.inf");
+ GUIErrorMessage("Broken Sword 2: Cannot open cd.inf");
return false;
}
@@ -164,7 +164,7 @@ bool ResourceManager::init() {
if (file.ioFailed()) {
delete cdInf;
file.close();
- _vm->GUIErrorMessage("Broken Sword 2: Cannot read cd.inf");
+ GUIErrorMessage("Broken Sword 2: Cannot read cd.inf");
return false;
}
@@ -190,7 +190,7 @@ bool ResourceManager::init() {
// the resource manager will print a fatal error.
if (cdInf[i].cd == 0 && !Common::File::exists((char *)cdInf[i].clusterName)) {
- _vm->GUIErrorMessage("Broken Sword 2: Cannot find " + Common::String((char *)cdInf[i].clusterName));
+ GUIErrorMessage("Broken Sword 2: Cannot find " + Common::String((char *)cdInf[i].clusterName));
delete[] cdInf;
return false;
}
@@ -206,7 +206,7 @@ bool ResourceManager::init() {
if (j == _totalClusters) {
delete[] cdInf;
- _vm->GUIErrorMessage(Common::String(_resFiles[i].fileName) + " is not in cd.inf");
+ GUIErrorMessage(Common::String(_resFiles[i].fileName) + " is not in cd.inf");
return false;
}