[Scummvm-cvs-logs] SF.net SVN: scummvm: [21166] scummvm/trunk/base

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Mar 9 04:53:02 CET 2006


Revision: 21166
Author:   fingolfin
Date:     2006-03-09 04:52:10 -0800 (Thu, 09 Mar 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21166&view=rev

Log Message:
-----------
Added new method DetectedGame::updateDesc, to ease generation of uniform description strings

Modified Paths:
--------------
    scummvm/trunk/base/plugins.cpp
    scummvm/trunk/base/plugins.h
    scummvm/trunk/engines/scumm/plugin.cpp
Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp	2006-03-09 12:45:23 UTC (rev 21165)
+++ scummvm/trunk/base/plugins.cpp	2006-03-09 12:52:10 UTC (rev 21166)
@@ -71,6 +71,37 @@
 
 #pragma mark -
 
+
+void DetectedGame::updateDesc(const char *extra) {
+	// TODO: The format used here (LANG/PLATFORM/EXTRA) is not set in stone.
+	// We may want to change the order (PLATFORM/EXTRA/LANG, anybody?), or
+	// the seperator (instead of '/' use ', ' or ' ').
+	const bool hasCustomLanguage = (language != Common::UNK_LANG);
+	const bool hasCustomPlatform = (platform != Common::kPlatformUnknown);
+	const bool hasExtraDesc = (extra && extra[0]);
+
+	// Adapt the description string if custom platform/language is set.
+	if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
+		description += " (";
+		if (hasCustomLanguage)
+			description += Common::getLanguageDescription(language);
+		if (hasCustomPlatform) {
+			if (hasCustomLanguage)
+				description += "/";
+			description += Common::getPlatformDescription(platform);
+		}
+		if (hasExtraDesc) {
+			if (hasCustomPlatform || hasCustomLanguage)
+				description += "/";
+			description += extra;
+		}
+		description += ")";
+	}
+}
+
+
+#pragma mark -
+
 #ifndef DYNAMIC_MODULES
 class StaticPlugin : public Plugin {
 	PluginRegistrator *_plugin;

Modified: scummvm/trunk/base/plugins.h
===================================================================
--- scummvm/trunk/base/plugins.h	2006-03-09 12:45:23 UTC (rev 21165)
+++ scummvm/trunk/base/plugins.h	2006-03-09 12:52:10 UTC (rev 21166)
@@ -54,6 +54,11 @@
 	             Common::Language l = Common::UNK_LANG,
 	             Common::Platform p = Common::kPlatformUnknown)
 		: GameDescriptor(game.gameid, game.description), language(l), platform(p) {}
+	
+	/**
+	 * Update the description string by appending (LANG/PLATFORM/EXTRA) to it.
+	 */
+	void updateDesc(const char *extra = 0);
 };
 
 

Modified: scummvm/trunk/engines/scumm/plugin.cpp
===================================================================
--- scummvm/trunk/engines/scumm/plugin.cpp	2006-03-09 12:45:23 UTC (rev 21165)
+++ scummvm/trunk/engines/scumm/plugin.cpp	2006-03-09 12:52:10 UTC (rev 21166)
@@ -1150,12 +1150,8 @@
 								fileSet[file->path()] = false;
 							}
 							
-							// If known, add the platform to the description string
-							if (dg.platform != Common::kPlatformUnknown) {
-								dg.description += "(";
-								dg.description += Common::getPlatformDescription(dg.platform);
-								dg.description += ")";
-							}
+							dg.updateDesc();	// Append the platform, if set, to the description.
+
 							detectedGames.push_back(dg);
 							break;
 						}
@@ -1200,28 +1196,7 @@
 					dg.platform = Common::kPlatformMacintosh;
 				else
 					dg.platform = elem->platform;
-
-				const bool hasCustomLanguage = (dg.language != Common::UNK_LANG);
-				const bool hasCustomPlatform = (dg.platform != Common::kPlatformUnknown);
-				const bool hasExtraDesc = (elem->extra && elem->extra[0]);
-
-				// Adapt the description string if custom platform/language is set.
-				if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
-					dg.description += " (";
-					if (hasCustomLanguage)
-						dg.description += Common::getLanguageDescription(dg.language);
-					if (hasCustomPlatform) {
-						if (hasCustomLanguage)
-							dg.description += "/";
-						dg.description += Common::getPlatformDescription(dg.platform);
-					}
-					if (hasExtraDesc) {
-						if (hasCustomPlatform || hasCustomLanguage)
-							dg.description += "/";
-						dg.description += elem->extra;
-					}
-					dg.description += ")";
-				}
+				dg.updateDesc(elem->extra);	// Append extra information to the description.
 				
 				// Insert the 'enhanced' game data into the candidate list
 				detectedGames.push_back(dg);


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