[Scummvm-cvs-logs] SF.net SVN: scummvm:[33909] scummvm/branches/gsoc2008-rtl

cpage88 at users.sourceforge.net cpage88 at users.sourceforge.net
Fri Aug 15 20:15:15 CEST 2008


Revision: 33909
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33909&view=rev
Author:   cpage88
Date:     2008-08-15 18:15:14 +0000 (Fri, 15 Aug 2008)

Log Message:
-----------
Defined some MetaEngineFeatures for the engines, the launcher uses these features to allow/disallow loading and deleting saves

Modified Paths:
--------------
    scummvm/branches/gsoc2008-rtl/engines/agi/detection.cpp
    scummvm/branches/gsoc2008-rtl/engines/cine/detection.cpp
    scummvm/branches/gsoc2008-rtl/engines/kyra/detection.cpp
    scummvm/branches/gsoc2008-rtl/engines/lure/detection.cpp
    scummvm/branches/gsoc2008-rtl/engines/metaengine.h
    scummvm/branches/gsoc2008-rtl/engines/parallaction/detection.cpp
    scummvm/branches/gsoc2008-rtl/engines/queen/queen.cpp
    scummvm/branches/gsoc2008-rtl/engines/saga/detection.cpp
    scummvm/branches/gsoc2008-rtl/engines/scumm/detection.cpp
    scummvm/branches/gsoc2008-rtl/engines/sky/sky.cpp
    scummvm/branches/gsoc2008-rtl/engines/sword1/sword1.cpp
    scummvm/branches/gsoc2008-rtl/engines/sword2/sword2.cpp
    scummvm/branches/gsoc2008-rtl/engines/touche/detection.cpp
    scummvm/branches/gsoc2008-rtl/gui/launcher.cpp

Modified: scummvm/branches/gsoc2008-rtl/engines/agi/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/agi/detection.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/agi/detection.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -2122,11 +2122,21 @@
 		return "Sierra AGI Engine (C) Sierra On-Line 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;
+	
 	const Common::ADGameDescription *fallbackDetect(const FSList *fslist) const;
 };
 
+bool AgiMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
+
 bool AgiMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
 	const Agi::AGIGameDescription *gd = (const Agi::AGIGameDescription *)desc;
 	bool res = true;

Modified: scummvm/branches/gsoc2008-rtl/engines/cine/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/cine/detection.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/cine/detection.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -533,9 +533,16 @@
 	}
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
+	virtual bool hasFeature(MetaEngineFeature f) const;
 	virtual SaveStateList listSaves(const char *target) const;
 };
 
+bool CineMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad);
+}
+
 bool CineMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
 	const Cine::CINEGameDescription *gd = (const Cine::CINEGameDescription *)desc;
 	if (gd) {

Modified: scummvm/branches/gsoc2008-rtl/engines/kyra/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/kyra/detection.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/kyra/detection.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -931,11 +931,18 @@
 		return "The Legend of Kyrandia (C) Westwood Studios";
 	}
 
-	bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
-
-	SaveStateList listSaves(const char *target) const;
+	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 KyraMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 bool KyraMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
 	const KYRAGameDescription *gd = (const KYRAGameDescription *)desc;
 	bool res = true;

Modified: scummvm/branches/gsoc2008-rtl/engines/lure/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/lure/detection.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/lure/detection.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -185,10 +185,18 @@
 		return "Lure of the Temptress (C) Revolution";
 	}
 
+	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 LureMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 bool LureMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
 	const Lure::LureGameDescription *gd = (const Lure::LureGameDescription *)desc;
 	if (gd) {

Modified: scummvm/branches/gsoc2008-rtl/engines/metaengine.h
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/metaengine.h	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/metaengine.h	2008-08-15 18:15:14 UTC (rev 33909)
@@ -126,7 +126,7 @@
 	/**
 	 * Determine whether the engine supports the specified feature
 	 */	
-	virtual bool hasFeature(MetaEngineFeature f) { return false; };
+	virtual bool hasFeature(MetaEngineFeature f) const { return false; };
 
 	//@}
 };

Modified: scummvm/branches/gsoc2008-rtl/engines/parallaction/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/parallaction/detection.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/parallaction/detection.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -243,10 +243,18 @@
 		return "Nippon Safes Inc. (C) Dynabyte";
 	}
 
+	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 ParallactionMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 bool ParallactionMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
 	const Parallaction::PARALLACTIONGameDescription *gd = (const Parallaction::PARALLACTIONGameDescription *)desc;
 	bool res = true;

Modified: scummvm/branches/gsoc2008-rtl/engines/queen/queen.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/queen/queen.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/queen/queen.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -60,6 +60,7 @@
 	virtual const char *getName() const;
 	virtual const char *getCopyright() const;
 
+	virtual bool hasFeature(MetaEngineFeature f) const;
 	virtual GameList getSupportedGames() const;
 	virtual GameDescriptor findGame(const char *gameid) const;
 	virtual GameList detectGames(const FSList &fslist) const;
@@ -76,6 +77,13 @@
 	return "Flight of the Amazon Queen (C) John Passfield and Steve Stamatiadis";
 }
 
+bool QueenMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 GameList QueenMetaEngine::getSupportedGames() const {
 	GameList games;
 	games.push_back(queenGameDescriptor);

Modified: scummvm/branches/gsoc2008-rtl/engines/saga/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/saga/detection.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/saga/detection.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -147,10 +147,18 @@
 		return "Inherit the Earth (C) Wyrmkeep Entertainment";
 	}
 
+	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 SagaMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 bool SagaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
 	const Saga::SAGAGameDescription *gd = (const Saga::SAGAGameDescription *)desc;
 	if (gd) {

Modified: scummvm/branches/gsoc2008-rtl/engines/scumm/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/scumm/detection.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/scumm/detection.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -674,16 +674,23 @@
 	virtual const char *getName() const;
 	virtual const char *getCopyright() const;
 
+	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 bool hasFeature(MetaEngineFeature f);
-
+	
 	virtual PluginError createInstance(OSystem *syst, Engine **engine) const;
 
 	virtual SaveStateList listSaves(const char *target) const;
 };
 
+bool ScummMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 GameList ScummMetaEngine::getSupportedGames() const {
 	return GameList(gameDescriptions);
 }
@@ -692,13 +699,6 @@
 	return Common::AdvancedDetector::findGameID(gameid, gameDescriptions, obsoleteGameIDsTable);
 }
 
-bool ScummMetaEngine::hasFeature(MetaEngineFeature f) {
-	return
-		(f == kSupportsListSaves) ||
-		(f == kSupportsDirectLoad) ||
-		(f == kSupportsDeleteSave);
-}
-
 GameList ScummMetaEngine::detectGames(const FSList &fslist) const {
 	GameList detectedGames;
 	Common::List<DetectorResult> results;

Modified: scummvm/branches/gsoc2008-rtl/engines/sky/sky.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/sky/sky.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/sky/sky.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -110,9 +110,10 @@
 	virtual const char *getName() const;
 	virtual const char *getCopyright() const;
 
+	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 GameList detectGames(const FSList &fslist) const;	
 
 	virtual PluginError createInstance(OSystem *syst, Engine **engine) const;
 
@@ -127,6 +128,12 @@
 	return "Beneath a Steel Sky (C) Revolution";
 }
 
+bool SkyMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad);
+}
+
 GameList SkyMetaEngine::getSupportedGames() const {
 	GameList games;
 	games.push_back(skySetting);

Modified: scummvm/branches/gsoc2008-rtl/engines/sword1/sword1.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/sword1/sword1.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/sword1/sword1.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -95,6 +95,7 @@
 		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;
@@ -103,6 +104,12 @@
 	virtual PluginError createInstance(OSystem *syst, Engine **engine) const;
 };
 
+bool SwordMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad);
+}
+
 GameList SwordMetaEngine::getSupportedGames() const {
 	GameList games;
 	games.push_back(sword1FullSettings);

Modified: scummvm/branches/gsoc2008-rtl/engines/sword2/sword2.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/sword2/sword2.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/sword2/sword2.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -80,6 +80,7 @@
 		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;
@@ -88,6 +89,13 @@
 	virtual PluginError createInstance(OSystem *syst, Engine **engine) const;
 };
 
+bool Sword2MetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 GameList Sword2MetaEngine::getSupportedGames() const {
 	const Sword2::GameSettings *g = Sword2::sword2_settings;
 	GameList games;

Modified: scummvm/branches/gsoc2008-rtl/engines/touche/detection.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/touche/detection.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/engines/touche/detection.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -136,10 +136,18 @@
 		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 == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 bool ToucheMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
 	const Common::ADGameDescription *gd = desc;
 	if (gd) {

Modified: scummvm/branches/gsoc2008-rtl/gui/launcher.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/gui/launcher.cpp	2008-08-15 17:57:12 UTC (rev 33908)
+++ scummvm/branches/gsoc2008-rtl/gui/launcher.cpp	2008-08-15 18:15:14 UTC (rev 33909)
@@ -477,6 +477,7 @@
 	typedef Common::StringList StringList;
 protected:
 	bool			_delSave;
+	bool			_delSupport;
 	GUI::ListWidget		*_list;
 	GUI::ButtonWidget	*_chooseButton;
 	GUI::ButtonWidget	*_deleteButton;
@@ -493,7 +494,7 @@
 	virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
 	const String &getResultString() const;
 	void setList(const StringList& list);
-	int runModal();
+	int runModal(bool delSupport);
 
 	virtual void reflowLayout();
 
@@ -501,7 +502,7 @@
 };
 
 SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel)
-	: Dialog("scummsaveload"), _delSave(0), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0)  {
+	: Dialog("scummsaveload"), _delSave(0), _delSupport(0), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0)  {
 
 	_drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;
 
@@ -536,10 +537,11 @@
 	_list->setList(list);
 }
 
-int SaveLoadChooser::runModal() {
+int SaveLoadChooser::runModal(bool delSupport) {
 	if (_gfxWidget)
 		_gfxWidget->setGfx(0);
 	_delSave = false;
+	_delSupport = delSupport;
 	int ret = Dialog::runModal();
 	return ret;
 }
@@ -571,7 +573,8 @@
 		// list item is selected.
 		_chooseButton->setEnabled(selItem >= 0 && (!getResultString().empty()));
 		_chooseButton->draw();
-		_deleteButton->setEnabled(selItem >= 0 && (!getResultString().empty()));
+		// Delete will always be disabled if the engine doesn't support it.
+		_deleteButton->setEnabled(_delSupport && (selItem >= 0) && (!getResultString().empty()));
 		_deleteButton->draw();
 	} break;
 	case kDelCmd:
@@ -950,29 +953,37 @@
 
 	int idx;
 	if (plugin) {
-		do {
-			Common::StringList saveNames = generateSavegameList(item, plugin);
-			_loadDialog->setList(saveNames);
-			SaveStateList saveList = (*plugin)->listSaves(description.c_str());
-			idx = _loadDialog->runModal();
-			if (idx >= 0) {
-				// Delete the savegame
-				if (_loadDialog->delSave()) {
-					String filename = saveList[idx].filename();
-					printf("Deleting file: %s\n", filename.c_str());
-					//saveFileMan->removeSavefile(filename.c_str());
+		bool delSupport = (*plugin)->hasFeature(MetaEngine::kSupportsDeleteSave);
+
+		if ((*plugin)->hasFeature(MetaEngine::kSupportsListSaves)) {
+			do {
+				Common::StringList saveNames = generateSavegameList(item, plugin);
+				_loadDialog->setList(saveNames);
+				SaveStateList saveList = (*plugin)->listSaves(description.c_str());
+				idx = _loadDialog->runModal(delSupport);
+				if (idx >= 0) {
+					// Delete the savegame
+					if (_loadDialog->delSave()) {
+						String filename = saveList[idx].filename();
+						printf("Deleting file: %s\n", filename.c_str());
+						//saveFileMan->removeSavefile(filename.c_str());
+					}
+					// Load the savegame
+					else {
+						int slot = atoi(saveList[idx].save_slot().c_str());
+						printf("Loading slot: %d\n", slot);
+						ConfMan.setInt("save_slot", slot);
+						ConfMan.setActiveDomain(_domains[item]);
+						close();
+					}
 				}
-				// Load the savegame
-				else {
-					int slot = atoi(saveList[idx].save_slot().c_str());
-					printf("Loading slot: %d\n", slot);
-					ConfMan.setInt("save_slot", slot);
-					ConfMan.setActiveDomain(_domains[item]);
-					close();
-				}
 			}
+			while (_loadDialog->delSave());
+		} else {
+			MessageDialog dialog
+				("Sorry, this game does not yet support loading games from the launcher.", "OK");
+			dialog.runModal();
 		}
-		while (_loadDialog->delSave());
 	} else {
 		MessageDialog dialog("ScummVM could not find any engine capable of running the selected game!", "OK");
 		dialog.runModal();


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