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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Sep 1 22:21:53 CEST 2008


Revision: 34256
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34256&view=rev
Author:   fingolfin
Date:     2008-09-01 20:21:53 +0000 (Mon, 01 Sep 2008)

Log Message:
-----------
Merging more of the GSoC 2008 RTL branch: SWORD2

Modified Paths:
--------------
    scummvm/trunk/engines/sword2/animation.cpp
    scummvm/trunk/engines/sword2/controls.cpp
    scummvm/trunk/engines/sword2/function.cpp
    scummvm/trunk/engines/sword2/palette.cpp
    scummvm/trunk/engines/sword2/resman.cpp
    scummvm/trunk/engines/sword2/screen.cpp
    scummvm/trunk/engines/sword2/sword2.cpp
    scummvm/trunk/engines/sword2/sword2.h

Modified: scummvm/trunk/engines/sword2/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword2/animation.cpp	2008-09-01 20:21:30 UTC (rev 34255)
+++ scummvm/trunk/engines/sword2/animation.cpp	2008-09-01 20:21:53 UTC (rev 34256)
@@ -357,8 +357,8 @@
 		case Common::EVENT_SCREEN_CHANGED:
 			handleScreenChanged();
 			break;
+		case Common::EVENT_RTL:
 		case Common::EVENT_QUIT:
-			_vm->closeGame();
 			terminate = true;
 			break;
 		case Common::EVENT_KEYDOWN:
@@ -379,7 +379,7 @@
 	bool startNextText = false;
 
 	// This happens if the user quits during the "eye" cutscene.
-	if (_vm->_quit)
+	if (_vm->quit())
 		return;
 
 	_numSpeechLines = numLines;

Modified: scummvm/trunk/engines/sword2/controls.cpp
===================================================================
--- scummvm/trunk/engines/sword2/controls.cpp	2008-09-01 20:21:30 UTC (rev 34255)
+++ scummvm/trunk/engines/sword2/controls.cpp	2008-09-01 20:21:53 UTC (rev 34256)
@@ -396,7 +396,7 @@
 
 		_vm->_system->delayMillis(20);
 
-		if (_vm->_quit)
+		if (_vm->quit())
 			setResult(0);
 	}
 
@@ -842,7 +842,7 @@
 		if (startDialog.runModal())
 			return 1;
 
-		if (_vm->_quit)
+		if (_vm->quit())
 			return 0;
 
 		RestoreDialog restoreDialog(_vm);
@@ -850,7 +850,7 @@
 		if (restoreDialog.runModal())
 			return 0;
 
-		if (_vm->_quit)
+		if (_vm->quit())
 			return 0;
 	}
 
@@ -882,7 +882,7 @@
 	int result = MiniDialog::runModal();
 
 	if (result)
-		_vm->closeGame();
+		_vm->quitGame();
 
 	return result;
 }

Modified: scummvm/trunk/engines/sword2/function.cpp
===================================================================
--- scummvm/trunk/engines/sword2/function.cpp	2008-09-01 20:21:30 UTC (rev 34255)
+++ scummvm/trunk/engines/sword2/function.cpp	2008-09-01 20:21:53 UTC (rev 34256)
@@ -2388,7 +2388,7 @@
 	// params:	none
 
 	if (readVar(DEMO)) {
-		_vm->closeGame();
+		_vm->quitGame();
 		return IR_STOP;
 	}
 

Modified: scummvm/trunk/engines/sword2/palette.cpp
===================================================================
--- scummvm/trunk/engines/sword2/palette.cpp	2008-09-01 20:21:30 UTC (rev 34255)
+++ scummvm/trunk/engines/sword2/palette.cpp	2008-09-01 20:21:53 UTC (rev 34256)
@@ -212,7 +212,7 @@
 }
 
 void Screen::waitForFade() {
-	while (getFadeStatus() != RDFADE_NONE && getFadeStatus() != RDFADE_BLACK && !_vm->_quit) {
+	while (getFadeStatus() != RDFADE_NONE && getFadeStatus() != RDFADE_BLACK && !_vm->quit()) {
 		updateDisplay();
 		_vm->_system->delayMillis(20);
 	}

Modified: scummvm/trunk/engines/sword2/resman.cpp
===================================================================
--- scummvm/trunk/engines/sword2/resman.cpp	2008-09-01 20:21:30 UTC (rev 34255)
+++ scummvm/trunk/engines/sword2/resman.cpp	2008-09-01 20:21:53 UTC (rev 34256)
@@ -412,7 +412,7 @@
 		// quit while the game is asking for the user to insert a CD.
 		// But recovering from this situation gracefully is just too
 		// much trouble, so quit now.
-		if (_vm->_quit)
+		if (_vm->quit())
 			g_system->quit();
 
 		// If the file is supposed to be on hard disk, or we're

Modified: scummvm/trunk/engines/sword2/screen.cpp
===================================================================
--- scummvm/trunk/engines/sword2/screen.cpp	2008-09-01 20:21:30 UTC (rev 34255)
+++ scummvm/trunk/engines/sword2/screen.cpp	2008-09-01 20:21:53 UTC (rev 34256)
@@ -389,7 +389,7 @@
 		uint32 targetTime = _vm->getMillis() + (time * 1000);
 		_vm->sleepUntil(targetTime);
 	} else {
-		while (!_vm->_quit) {
+		while (!_vm->quit()) {
 			MouseEvent *me = _vm->mouseEvent();
 			if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN)))
 				break;
@@ -1035,7 +1035,7 @@
 
 	uint32 musicLength = MAX((int32)(1000 * (_vm->_sound->musicTimeRemaining() - 3)), 25 * (int32)scrollSteps);
 
-	while (scrollPos < scrollSteps && !_vm->_quit) {
+	while (scrollPos < scrollSteps && !_vm->quit()) {
 		clearScene();
 
 		for (i = startLine; i < lineCount; i++) {
@@ -1123,13 +1123,13 @@
 		// The music should either have stopped or be about to stop, so
 		// wait for it to really happen.
 
-		while (_vm->_sound->musicTimeRemaining() && !_vm->_quit) {
+		while (_vm->_sound->musicTimeRemaining() && !_vm->quit()) {
 			updateDisplay(false);
 			_vm->_system->delayMillis(100);
 		}
 	}
 
-	if (_vm->_quit)
+	if (_vm->quit())
 		return;
 
 	waitForFade();

Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp	2008-09-01 20:21:30 UTC (rev 34255)
+++ scummvm/trunk/engines/sword2/sword2.cpp	2008-09-01 20:21:53 UTC (rev 34256)
@@ -33,6 +33,7 @@
 #include "common/file.h"
 #include "common/fs.h"
 #include "common/events.h"
+#include "common/savefile.h"
 #include "common/system.h"
 
 #include "engines/metaengine.h"
@@ -79,13 +80,23 @@
 		return "Broken Sword Games (C) Revolution";
 	}
 
+	virtual bool hasFeature(MetaEngineFeature f) const;
 	virtual GameList getSupportedGames() const;
 	virtual GameDescriptor findGame(const char *gameid) const;
 	virtual GameList detectGames(const FSList &fslist) const;
+	virtual SaveStateList listSaves(const char *target) const;
 
 	virtual PluginError createInstance(OSystem *syst, Engine **engine) const;
 };
 
+bool Sword2MetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsRTL) ||
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 GameList Sword2MetaEngine::getSupportedGames() const {
 	const Sword2::GameSettings *g = Sword2::sword2_settings;
 	GameList games;
@@ -156,6 +167,35 @@
 	return detectedGames;
 }
 
+SaveStateList Sword2MetaEngine::listSaves(const char *target) const {
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::StringList filenames;
+	char saveDesc[SAVE_DESCRIPTION_LEN];
+	Common::String pattern = target;
+	pattern += ".???";
+
+	filenames = saveFileMan->listSavefiles(pattern.c_str());
+	sort(filenames.begin(), filenames.end());	// Sort (hopefully ensuring we are sorted numerically..)
+
+	SaveStateList saveList;
+	for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+		// Obtain the last 3 digits of the filename, since they correspond to the save slot
+		int slotNum = atoi(file->c_str() + file->size() - 3);
+		
+		if (slotNum >= 0 && slotNum <= 999) {
+			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+			if (in) {
+				in->readUint32LE();
+				in->read(saveDesc, SAVE_DESCRIPTION_LEN);
+				saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file));
+				delete in;
+			}
+		}
+	}
+
+	return saveList;
+}
+
 PluginError Sword2MetaEngine::createInstance(OSystem *syst, Engine **engine) const {
 	assert(syst);
 	assert(engine);
@@ -229,7 +269,6 @@
 	_gameCycle = 0;
 	_gameSpeed = 1;
 
-	_quit = false;
 	syst->getEventManager()->registerRandomSource(_rnd, "sword2");
 }
 
@@ -371,7 +410,7 @@
 		// player will kill the music for us. Otherwise, the restore
 		// will either have killed the music, or done a crossfade.
 
-		if (_quit)
+		if (quit())
 			return 0;
 
 		if (result)
@@ -443,7 +482,7 @@
 		// because we want the break to happen before updating the
 		// screen again.
 
-		if (_quit)
+		if (quit())
 			break;
 
 		// creates the debug text blocks
@@ -460,13 +499,9 @@
 #endif
 	}
 
-	return 0;
+	return _eventMan->shouldRTL();
 }
 
-void Sword2Engine::closeGame() {
-	_quit = true;
-}
-
 void Sword2Engine::restartGame() {
 	ScreenInfo *screenInfo = _screen->getScreenInfo();
 	uint32 temp_demo_flag;
@@ -610,9 +645,6 @@
 				_mouseEvent.buttons = RD_WHEELDOWN;
 			}
 			break;
-		case Common::EVENT_QUIT:
-			closeGame();
-			break;
 		default:
 			break;
 		}

Modified: scummvm/trunk/engines/sword2/sword2.h
===================================================================
--- scummvm/trunk/engines/sword2/sword2.h	2008-09-01 20:21:30 UTC (rev 34255)
+++ scummvm/trunk/engines/sword2/sword2.h	2008-09-01 20:21:53 UTC (rev 34256)
@@ -141,8 +141,6 @@
 	bool getSubtitles() { return _useSubtitles; }
 	void setSubtitles(bool b) { _useSubtitles = b; }
 
-	bool _quit;
-
 	uint32 _features;
 
 	MemoryManager *_memory;
@@ -210,7 +208,6 @@
 
 	void startGame();
 	void gameCycle();
-	void closeGame();
 	void restartGame();
 
 	void sleepUntil(uint32 time);


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