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

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


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

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

Modified Paths:
--------------
    scummvm/trunk/engines/touche/detection.cpp
    scummvm/trunk/engines/touche/menu.cpp
    scummvm/trunk/engines/touche/opcodes.cpp
    scummvm/trunk/engines/touche/saveload.cpp
    scummvm/trunk/engines/touche/touche.cpp
    scummvm/trunk/engines/touche/touche.h

Modified: scummvm/trunk/engines/touche/detection.cpp
===================================================================
--- scummvm/trunk/engines/touche/detection.cpp	2008-09-01 20:22:10 UTC (rev 34257)
+++ scummvm/trunk/engines/touche/detection.cpp	2008-09-01 20:22:29 UTC (rev 34258)
@@ -25,6 +25,7 @@
 
 #include "common/config-manager.h"
 #include "common/advancedDetector.h"
+#include "common/savefile.h"
 
 #include "base/plugins.h"
 
@@ -135,9 +136,19 @@
 		return "Touche: The Adventures of the 5th Musketeer (C) Clipper Software";
 	}
 
+	virtual bool hasFeature(MetaEngineFeature f) const;
 	virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
+	virtual SaveStateList listSaves(const char *target) const;
 };
 
+bool ToucheMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsRTL) ||
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 bool ToucheMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
 	const Common::ADGameDescription *gd = desc;
 	if (gd) {
@@ -146,6 +157,57 @@
 	return gd != 0;
 }
 
+SaveStateList ToucheMetaEngine::listSaves(const char *target) const {
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::StringList filenames;
+	char saveDesc[Touche::kGameStateDescriptionLen];
+	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 digit of the filename, since they correspond to the save slot
+		int slotNum = atoi(file->c_str() + file->size() - 1);
+	
+		if (slotNum >= 0 && slotNum <= 9) {
+			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+			if (in) {
+				in->readUint16LE();
+				in->readUint16LE();
+				in->read(saveDesc, Touche::kGameStateDescriptionLen);
+				saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file));
+				delete in;
+			}
+		}
+	}
+	
+	pattern += "?";
+
+	filenames = saveFileMan->listSavefiles(pattern.c_str());
+	sort(filenames.begin(), filenames.end());	// Sort (hopefully ensuring we are sorted numerically..)
+
+	for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+		// Obtain the last 2 digits of the filename, since they correspond to the save slot
+		int slotNum = atoi(file->c_str() + file->size() - 2);
+	
+		if (slotNum >= 10 && slotNum <= 99) {
+			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+			if (in) {
+				in->readUint16LE();
+				in->readUint16LE();
+				in->read(saveDesc, Touche::kGameStateDescriptionLen);
+				saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file));
+				delete in;
+			}
+		}
+	}
+
+	return saveList;
+}
+
 #if PLUGIN_ENABLED_DYNAMIC(TOUCHE)
 	REGISTER_PLUGIN_DYNAMIC(TOUCHE, PLUGIN_TYPE_ENGINE, ToucheMetaEngine);
 #else

Modified: scummvm/trunk/engines/touche/menu.cpp
===================================================================
--- scummvm/trunk/engines/touche/menu.cpp	2008-09-01 20:22:10 UTC (rev 34257)
+++ scummvm/trunk/engines/touche/menu.cpp	2008-09-01 20:22:29 UTC (rev 34258)
@@ -297,7 +297,7 @@
 		menuData->quit = true;
 		break;
 	case kActionQuitGame:
-		_flagsTable[611] = 1;
+		quitGame();
 		menuData->quit = true;
 		break;
 	case kActionTextOnly:
@@ -395,10 +395,10 @@
 			while (_eventMan->pollEvent(event)) {
 				const Button *button = 0;
 				switch (event.type) {
+				case Common::EVENT_RTL:
 				case Common::EVENT_QUIT:
 					menuData.quit = true;
 					menuData.exit = true;
-					_flagsTable[611] = 1;
 					break;
 				case Common::EVENT_LBUTTONDOWN:
 					button = menuData.findButtonUnderCursor(event.mouse.x, event.mouse.y);
@@ -433,8 +433,9 @@
 			_system->delayMillis(10);
 		}
 		_fullRedrawCounter = 2;
-		if (!menuData.exit && _flagsTable[611] != 0) {
-			_flagsTable[611] = displayQuitDialog();
+		if (!menuData.exit && quit()) {
+			if (displayQuitDialog())
+				quitGame();
 		}
 	}
 }
@@ -556,6 +557,7 @@
 		Common::Event event;
 		while (_eventMan->pollEvent(event)) {
 			switch (event.type) {
+			case Common::EVENT_RTL:
 			case Common::EVENT_QUIT:
 				quitLoop = true;
 				ret = 1;

Modified: scummvm/trunk/engines/touche/opcodes.cpp
===================================================================
--- scummvm/trunk/engines/touche/opcodes.cpp	2008-09-01 20:22:10 UTC (rev 34257)
+++ scummvm/trunk/engines/touche/opcodes.cpp	2008-09-01 20:22:29 UTC (rev 34258)
@@ -408,6 +408,10 @@
 	case 104:
 		_currentKeyCharNum = val;
 		break;
+	case 611:
+		if (val != 0)
+			quitGame();
+		break;
 	case 612:
 		_flagsTable[613] = getRandomNumber(val);
 		break;

Modified: scummvm/trunk/engines/touche/saveload.cpp
===================================================================
--- scummvm/trunk/engines/touche/saveload.cpp	2008-09-01 20:22:10 UTC (rev 34257)
+++ scummvm/trunk/engines/touche/saveload.cpp	2008-09-01 20:22:29 UTC (rev 34258)
@@ -31,11 +31,6 @@
 
 namespace Touche {
 
-enum {
-	kCurrentGameStateVersion = 6,
-	kGameStateDescriptionLen = 32
-};
-
 static void saveOrLoad(Common::WriteStream &stream, uint16 &i) {
 	stream.writeUint16LE(i);
 }
@@ -292,7 +287,7 @@
 	if (stream->readUint32LE() != saveLoadEndMarker) {
 		warning("Corrupted gamestate data");
 		// if that ever happens, exit the game
-		_flagsTable[611] = 1;
+		quitGame();
 	}
 	_flagsTable[614] = roomOffsX;
 	_flagsTable[615] = roomOffsY;

Modified: scummvm/trunk/engines/touche/touche.cpp
===================================================================
--- scummvm/trunk/engines/touche/touche.cpp	2008-09-01 20:22:10 UTC (rev 34257)
+++ scummvm/trunk/engines/touche/touche.cpp	2008-09-01 20:22:29 UTC (rev 34258)
@@ -95,7 +95,7 @@
 
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
-	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxMixerVolume);
+	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
 	return 0;
 }
 
@@ -111,7 +111,7 @@
 
 	res_deallocateTables();
 	res_closeDataFile();
-	return 0;
+	return _eventMan->shouldRTL();
 }
 
 void ToucheEngine::restart() {
@@ -234,6 +234,13 @@
 	return _eventMan->getMousePos();
 }
 
+void ToucheEngine::syncSoundSettings() {
+	readConfigurationSettings();
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
+	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
+}
+	
 void ToucheEngine::mainLoop() {
 	restart();
 
@@ -245,10 +252,13 @@
 	_inp_rightMouseButtonPressed = false;
 
 	if (ConfMan.hasKey("save_slot")) {
-		loadGameState(ConfMan.getInt("save_slot"));
-		_newEpisodeNum = 0;
-		resetSortedKeyCharsTable();
-		showCursor(true);
+		int saveSlot = ConfMan.getInt("save_slot");
+		if (saveSlot >= 0 && saveSlot <= 99) {
+			loadGameState(saveSlot);
+			_newEpisodeNum = 0;
+			resetSortedKeyCharsTable();
+			showCursor(true);
+		}
 	} else {
 		_newEpisodeNum = ConfMan.getInt("boot_param");
 		if (_newEpisodeNum == 0) {
@@ -258,7 +268,7 @@
 	}
 
 	uint32 frameTimeStamp = _system->getMillis();
-	for (uint32 cycleCounter = 0; _flagsTable[611] == 0; ++cycleCounter) {
+	for (uint32 cycleCounter = 0; !quit(); ++cycleCounter) {
 		if ((cycleCounter % 3) == 0) {
 			runCycle();
 		}
@@ -287,9 +297,6 @@
 	Common::Event event;
 	while (_eventMan->pollEvent(event)) {
 		switch (event.type) {
-		case Common::EVENT_QUIT:
-			_flagsTable[611] = 1;
-			break;
 		case Common::EVENT_KEYDOWN:
 			if (!handleKeyEvents) {
 				break;
@@ -297,7 +304,8 @@
 			_flagsTable[600] = event.kbd.keycode;
 			if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
 				if (_displayQuitDialog) {
-					_flagsTable[611] = displayQuitDialog();
+					if (displayQuitDialog())
+						quitGame();
 				}
 			} else if (event.kbd.keycode == Common::KEYCODE_F5) {
 				if (_flagsTable[618] == 0 && !_hideInventoryTexts) {
@@ -1829,7 +1837,7 @@
 	_menuRedrawCounter = 2;
 	Common::Rect rect(0, y, kScreenWidth, y + h);
 	i = -1;
-	while (_inp_rightMouseButtonPressed && _flagsTable[611] == 0) {
+	while (_inp_rightMouseButtonPressed && !quit()) {
 		Common::Point mousePos = getMousePos();
 		if (rect.contains(mousePos)) {
 			int c = (mousePos.y - y) / kTextHeight;
@@ -2692,10 +2700,10 @@
 		const int md2 = _programWalkTable[num1].point2;
 		_programPointsTable[md2].order = 0;
 	}
-	bool quit = false;
+	bool quitLoop = false;
 	int order = 1;
-	while (!quit) {
-		quit = true;
+	while (!quitLoop) {
+		quitLoop = true;
 		for (uint i = 0; i < _programWalkTable.size(); ++i) {
 			const int md1 = _programWalkTable[i].point1;
 			const int md2 = _programWalkTable[i].point2;
@@ -2703,11 +2711,11 @@
 				assert((md2 & 0x4000) == 0);
 				if (_programPointsTable[md1].order == order - 1 && _programPointsTable[md2].order > order) {
 					_programPointsTable[md2].order = order;
-					quit = false;
+					quitLoop = false;
 				}
 				if (_programPointsTable[md2].order == order - 1 && _programPointsTable[md1].order > order) {
 					_programPointsTable[md1].order = order;
-					quit = false;
+					quitLoop = false;
 				}
 			}
 		}
@@ -2939,9 +2947,9 @@
 	resetPointsData(0);
 	if (pointsDataNum != -1) {
 		_programPointsTable[pointsDataNum].order = 1;
-		bool quit = false;
-		while (!quit) {
-			quit = true;
+		bool quitLoop = false;
+		while (!quitLoop) {
+			quitLoop = true;
 			for (uint i = 0; i < _programWalkTable.size(); ++i) {
 				int16 md1 = _programWalkTable[i].point1;
 				int16 md2 = _programWalkTable[i].point2;
@@ -2949,11 +2957,11 @@
 					assert((md2 & 0x4000) == 0);
 					if (_programPointsTable[md1].order != 0 && _programPointsTable[md2].order == 0) {
 						_programPointsTable[md2].order = 1;
-						quit = false;
+						quitLoop = false;
 					}
 					if (_programPointsTable[md2].order != 0 && _programPointsTable[md1].order == 0) {
 						_programPointsTable[md1].order = 1;
-						quit = false;
+						quitLoop = false;
 					}
 				}
 			}

Modified: scummvm/trunk/engines/touche/touche.h
===================================================================
--- scummvm/trunk/engines/touche/touche.h	2008-09-01 20:22:10 UTC (rev 34257)
+++ scummvm/trunk/engines/touche/touche.h	2008-09-01 20:22:29 UTC (rev 34258)
@@ -328,7 +328,9 @@
 	kCursorHeight = 42,
 	kTextHeight = 16,
 	kMaxProgramDataSize = 61440,
-	kMaxSaveStates = 100
+	kMaxSaveStates = 100,
+	kGameStateDescriptionLen = 32,	// Need these two values defined here
+	kCurrentGameStateVersion = 6	// for --list-saves support
 };
 
 enum StringType {
@@ -361,6 +363,7 @@
 
 	virtual int init();
 	virtual int go();
+	virtual void syncSoundSettings();
 
 protected:
 


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