[Scummvm-cvs-logs] SF.net SVN: scummvm:[45504] scummvm/trunk/engines/sci/engine

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu Oct 29 19:07:39 CET 2009


Revision: 45504
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45504&view=rev
Author:   thebluegr
Date:     2009-10-29 18:07:39 +0000 (Thu, 29 Oct 2009)

Log Message:
-----------
- Implemented savegame deletion for SQ4 floppy
- Added a more proper way to disable the "Change Directory" button, by checking its name, rather than the string it contains

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kfile.cpp
    scummvm/trunk/engines/sci/engine/kgraphics.cpp

Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp	2009-10-29 16:27:23 UTC (rev 45503)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp	2009-10-29 18:07:39 UTC (rev 45504)
@@ -800,11 +800,31 @@
 	}
 	case K_FILEIO_UNLINK : {
 		Common::String name = s->_segMan->getString(argv[1]);
+		Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
+		// SQ4 floppy prepends /\ to the filenames
+		if (name.hasPrefix("/\\")) {
+			name.deleteChar(0);
+			name.deleteChar(0);
+		}
+
+		// Special case for SQ4 floppy: This game has hardcoded names for all of its
+		// savegames, and they are all named "sq4sg.xxx", where xxx is the slot. We just
+		// take the slot number here, and delete the appropriate save game
+		if (name.hasPrefix("sq4sg.")) {
+			// Special handling for SQ4... get the slot number and construct the save game name
+			int slotNum = atoi(name.c_str() + name.size() - 3);
+			Common::Array<SavegameDesc> saves;
+			listSavegames(saves);
+			int savedir_nr = saves[slotNum].id;
+			name = ((Sci::SciEngine*)g_engine)->getSavegameName(savedir_nr);
+			saveFileMan->removeSavefile(name);
+		} else {
+			const Common::String wrappedName = ((Sci::SciEngine*)g_engine)->wrapFilename(name);
+			saveFileMan->removeSavefile(wrappedName);
+		}
+
 		debug(3, "K_FILEIO_UNLINK(%s)", name.c_str());
 
-		Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
-		const Common::String wrappedName = ((Sci::SciEngine*)g_engine)->wrapFilename(name);
-		saveFileMan->removeSavefile(wrappedName);
 		// TODO/FIXME: Should we return something (like, a bool indicating
 		// whether deleting the save succeeded or failed)?
 		break;

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-29 16:27:23 UTC (rev 45503)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-29 18:07:39 UTC (rev 45504)
@@ -621,44 +621,14 @@
 	return s->r_acc;
 }
 
-static void disableCertainButtons(EngineState *s, Common::String gameName, reg_t obj) {
-	reg_t text_pos = GET_SEL32(s->_segMan, obj, text);
-	Common::String text;
-	if (!text_pos.isNull())
-		text = s->_segMan->getString(text_pos);
-	Common::String englishText = s->getLanguageString(text.c_str(), K_LANG_ENGLISH);
-	englishText.trim();
-	int type = GET_SEL32V(s->_segMan, obj, type);
-	int state = GET_SEL32V(s->_segMan, obj, state);
+static void disableCertainButtons(SegManager *segMan, reg_t obj) {
+	Common::String objName = segMan->getObjectName(obj);
 
-	/*
-	 * WORKAROUND: The function is a "prevent the user from doing something
-	 * nasty" type of thing, and goes back to the ugly way in which savegame
-	 * deletion is implemented in SCI (and even worse in SQ4/Floppy, for
-	 * which the workaround is intended). The result is basically that you
-	 * can't implement savegame deletion for SQ4/Floppy unless you duplicate
-	 * the exact naming scheme of savefiles (i.e. savefiles must be named
-	 * SQ4SG.<number>) and the exact file format of the savegame index
-	 * (SQ4SG.DIR). From the earlier discussions on file I/O handling -
-	 * before as well as after the merge - I gather that this is not an
-	 * option.
-	 *
-	 * SQ4/Floppy is special, being the first game to implement savegame
-	 * deletion at all. For later games, we manage to implement deletion by
-	 * using gross hacks in kDeviceInfo() (essentially repurposing a few
-	 * subfunctions). I decided at the time that SQ4/Floppy was not worth the
-	 * effort (see above), and to simply disable the delete functionality for
-	 * that game - bringing the save/load dialog on a par with SCI0.
-	 */
-	if (type == SCI_CONTROLS_TYPE_BUTTON && (gameName == "sq4") &&
-			getSciVersion() < SCI_VERSION_1_1 && englishText == "Delete") {
-		PUT_SEL32V(s->_segMan, obj, state, (state | kControlStateDisabled) & ~kControlStateEnabled);
-	}
-
 	// Disable the "Change Directory" button, as we don't allow the game engine to
 	// change the directory where saved games are placed
-	if (type == SCI_CONTROLS_TYPE_BUTTON && englishText == "Change\r\nDirectory") {
-		PUT_SEL32V(s->_segMan, obj, state, (state | kControlStateDisabled) & ~kControlStateEnabled);
+	if (objName == "changeDirI") {
+		int state = GET_SEL32V(segMan, obj, state);
+		PUT_SEL32V(segMan, obj, state, (state | kControlStateDisabled) & ~kControlStateEnabled);
 	}
 }
 
@@ -783,7 +753,7 @@
 reg_t kDrawControl(EngineState *s, int argc, reg_t *argv) {
 	reg_t controlObject = argv[0];
 
-	disableCertainButtons(s, s->_gameName, controlObject);
+	disableCertainButtons(s->_segMan, controlObject);
 	_k_GenericDrawControl(s, controlObject, false);
 	return NULL_REG;
 }


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