[Scummvm-cvs-logs] SF.net SVN: scummvm:[34720] scummvm/trunk/engines

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Oct 2 19:48:01 CEST 2008


Revision: 34720
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34720&view=rev
Author:   fingolfin
Date:     2008-10-02 17:48:01 +0000 (Thu, 02 Oct 2008)

Log Message:
-----------
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

Modified Paths:
--------------
    scummvm/trunk/engines/engine.cpp
    scummvm/trunk/engines/engine.h
    scummvm/trunk/engines/gob/video.cpp
    scummvm/trunk/engines/kyra/resource.cpp
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/engines/kyra/staticres.cpp
    scummvm/trunk/engines/lure/lure.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/saga/gfx.cpp
    scummvm/trunk/engines/sword2/resman.cpp

Modified: scummvm/trunk/engines/engine.cpp
===================================================================
--- scummvm/trunk/engines/engine.cpp	2008-10-02 17:20:21 UTC (rev 34719)
+++ scummvm/trunk/engines/engine.cpp	2008-10-02 17:48:01 UTC (rev 34720)
@@ -61,7 +61,6 @@
 		_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 @@
 	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 @@
 		// 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,13 +117,24 @@
 
 	// (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() {
 #if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
 	// It is a known bug under Windows that games that play CD audio cause
@@ -178,24 +188,14 @@
 
 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 @@
 	_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);

Modified: scummvm/trunk/engines/engine.h
===================================================================
--- scummvm/trunk/engines/engine.h	2008-10-02 17:20:21 UTC (rev 34719)
+++ scummvm/trunk/engines/engine.h	2008-10-02 17:48:01 UTC (rev 34720)
@@ -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,8 +45,17 @@
 	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:
 	OSystem *_system;
@@ -57,8 +66,8 @@
 	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 @@
 
 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 @@
 	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 @@
 	 */
 	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 @@
 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 @@
 	/**
 	 * Run the Global Main Menu Dialog
 	 */
-	void mainMenuDialog();
+	void openMainMenuDialog();
 
 	/**
 	 * Determine whether the engine supports the specified MetaEngine feature.
@@ -172,24 +181,16 @@
 
 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;

Modified: scummvm/trunk/engines/gob/video.cpp
===================================================================
--- scummvm/trunk/engines/gob/video.cpp	2008-10-02 17:20:21 UTC (rev 34719)
+++ scummvm/trunk/engines/gob/video.cpp	2008-10-02 17:48:01 UTC (rev 34720)
@@ -171,7 +171,7 @@
 void Video::setSize(bool defaultTo1XScaler) {
 	_vm->_system->beginGFXTransaction();
 		_vm->_system->initSize(_vm->_width, _vm->_height);
-		_vm->initCommonGFX(defaultTo1XScaler);
+		initCommonGFX(defaultTo1XScaler);
 	_vm->_system->endGFXTransaction();
 }
 

Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp	2008-10-02 17:20:21 UTC (rev 34719)
+++ scummvm/trunk/engines/kyra/resource.cpp	2008-10-02 17:48:01 UTC (rev 34720)
@@ -64,7 +64,7 @@
 
 	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());
 	}
 

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2008-10-02 17:20:21 UTC (rev 34719)
+++ scummvm/trunk/engines/kyra/screen.cpp	2008-10-02 17:48:01 UTC (rev 34720)
@@ -192,7 +192,7 @@
 				_system->initSize(960, 400);
 			else
 				_system->initSize(640, 400);
-			_vm->initCommonGFX(true);
+			initCommonGFX(true);
 		_system->endGFXTransaction();
 	} else {
 		_system->beginGFXTransaction();
@@ -200,7 +200,7 @@
 				_system->initSize(640, 200);
 			else
 				_system->initSize(320, 200);
-			_vm->initCommonGFX(false);
+			initCommonGFX(false);
 		_system->endGFXTransaction();
 	}
 

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2008-10-02 17:20:21 UTC (rev 34719)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2008-10-02 17:48:01 UTC (rev 34720)
@@ -361,7 +361,7 @@
 
 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());
 }
 

Modified: scummvm/trunk/engines/lure/lure.cpp
===================================================================
--- scummvm/trunk/engines/lure/lure.cpp	2008-10-02 17:20:21 UTC (rev 34719)
+++ scummvm/trunk/engines/lure/lure.cpp	2008-10-02 17:48:01 UTC (rev 34720)
@@ -23,8 +23,6 @@
  *
  */
 
-
-
 #include "common/config-manager.h"
 #include "common/system.h"
 #include "common/savefile.h"
@@ -251,7 +249,7 @@
 	vsnprintf(buffer, STRINGBUFLEN, msg, va);
 	va_end(va);
 
-	Engine::GUIErrorMessage(buffer);
+	GUIErrorMessage(buffer);
 }
 
 void LureEngine::syncSoundSettings() {	

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-10-02 17:20:21 UTC (rev 34719)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-10-02 17:48:01 UTC (rev 34720)
@@ -750,8 +750,8 @@
 	_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);

Modified: scummvm/trunk/engines/saga/gfx.cpp
===================================================================
--- scummvm/trunk/engines/saga/gfx.cpp	2008-10-02 17:20:21 UTC (rev 34719)
+++ scummvm/trunk/engines/saga/gfx.cpp	2008-10-02 17:48:01 UTC (rev 34720)
@@ -41,7 +41,7 @@
 
 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();
 

Modified: scummvm/trunk/engines/sword2/resman.cpp
===================================================================
--- scummvm/trunk/engines/sword2/resman.cpp	2008-10-02 17:20:21 UTC (rev 34719)
+++ scummvm/trunk/engines/sword2/resman.cpp	2008-10-02 17:48:01 UTC (rev 34720)
@@ -106,7 +106,7 @@
 	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 @@
 		_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 @@
 
 	// 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 @@
 
 	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 @@
 		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 @@
 		// 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 @@
 
 		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;
 		}
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list