[Scummvm-cvs-logs] SF.net SVN: scummvm: [21915] scummvm/trunk/gui

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Apr 15 10:40:01 CEST 2006


Revision: 21915
Author:   fingolfin
Date:     2006-04-15 10:39:14 -0700 (Sat, 15 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21915&view=rev

Log Message:
-----------
Removed GameDetector::_gameid in favor of using a config manager entry

Modified Paths:
--------------
    scummvm/trunk/backends/symbian/src/SymbianActions.cpp
    scummvm/trunk/backends/symbian/src/SymbianOS.cpp
    scummvm/trunk/backends/wince/CEActionsPocket.cpp
    scummvm/trunk/backends/wince/CEActionsSmartphone.cpp
    scummvm/trunk/backends/wince/wince-sdl.cpp
    scummvm/trunk/base/gameDetector.cpp
    scummvm/trunk/base/gameDetector.h
    scummvm/trunk/base/main.cpp
    scummvm/trunk/engines/scumm/plugin.cpp
    scummvm/trunk/engines/simon/game.cpp
    scummvm/trunk/engines/sword1/sword1.cpp
    scummvm/trunk/engines/sword2/sword2.cpp
    scummvm/trunk/gui/Actions.cpp
    scummvm/trunk/gui/Actions.h
Modified: scummvm/trunk/backends/symbian/src/SymbianActions.cpp
===================================================================
--- scummvm/trunk/backends/symbian/src/SymbianActions.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/backends/symbian/src/SymbianActions.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -62,8 +62,8 @@
 #endif
 
 // creator function according to Factory Pattern
-void SymbianActions::init(const Common::String &gameid) {
-	_instance = new SymbianActions(gameid);
+void SymbianActions::init() {
+	_instance = new SymbianActions();
 }
 
 
@@ -83,8 +83,8 @@
 	return ACTION_VERSION;
 }
 
-SymbianActions::SymbianActions(const Common::String &gameid) :
-	Actions(gameid) {
+SymbianActions::SymbianActions()
+ : Actions() {
 	int i;
 
 	for (i = 0; i < ACTION_LAST; i++) {
@@ -121,17 +121,18 @@
 }
 
 void SymbianActions::initInstanceGame() {
-	bool is_simon = (strncmp(_gameid.c_str(), "simon", 5) == 0);
-	bool is_sky = (_gameid == "sky");
-	bool is_queen = (_gameid == "queen");
-	bool is_gob = (strncmp(_gameid.c_str(), "gob", 3) == 0);
-	bool is_ite = ((strncmp(_gameid.c_str(), "ite", 3) == 0) ||
-				  (strncmp(_gameid.c_str(), "ihnm", 4) == 0));
+	String gameid(ConfMan.get("gameid"));
+	bool is_simon = (strncmp(gameid.c_str(), "simon", 5) == 0);
+	bool is_sky = (gameid == "sky");
+	bool is_queen = (gameid == "queen");
+	bool is_gob = (strncmp(gameid.c_str(), "gob", 3) == 0);
+	bool is_ite = ((strncmp(gameid.c_str(), "ite", 3) == 0) ||
+				  (strncmp(gameid.c_str(), "ihnm", 4) == 0));
 	
 	Actions::initInstanceGame();
 
 	// See if a right click mapping could be needed
-	if (is_sky || _gameid == "samnmax" || is_gob)
+	if (is_sky || gameid == "samnmax" || is_gob)
 		_right_click_needed = true;
 
 	// Initialize keys for different actions

Modified: scummvm/trunk/backends/symbian/src/SymbianOS.cpp
===================================================================
--- scummvm/trunk/backends/symbian/src/SymbianOS.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/backends/symbian/src/SymbianOS.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -377,7 +377,7 @@
 }
 
 void OSystem_SDL_Symbian::check_mappings() {
-	if (!GUI::Actions::Instance()->_gameid.size() || GUI::Actions::Instance()->initialized())
+	if (ConfMan.get("gameid").empty() || GUI::Actions::Instance()->initialized())
 		return;
 
 	GUI::Actions::Instance()->initInstanceGame();

Modified: scummvm/trunk/backends/wince/CEActionsPocket.cpp
===================================================================
--- scummvm/trunk/backends/wince/CEActionsPocket.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/backends/wince/CEActionsPocket.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -98,21 +98,22 @@
 }
 
 void CEActionsPocket::initInstanceGame() {
-	bool is_simon = (strncmp(_gameid.c_str(), "simon", 5) == 0);
-	bool is_sword1 = (_gameid == "sword1");
-	bool is_sword2 = (strcmp(_gameid.c_str(), "sword2") == 0);
-	bool is_queen = (_gameid == "queen");
-	bool is_sky = (_gameid == "sky");
-	bool is_comi = (strncmp(_gameid.c_str(), "comi", 4) == 0);
-	bool is_gob = (strncmp(_gameid.c_str(), "gob", 3) == 0);
-	bool is_ite = ((strncmp(_gameid.c_str(), "ite", 3) == 0) ||
-				  (strncmp(_gameid.c_str(), "ihnm", 4) == 0));
+	String gameid(ConfMan.get("gameid"));
+	bool is_simon = (strncmp(gameid.c_str(), "simon", 5) == 0);
+	bool is_sword1 = (gameid == "sword1");
+	bool is_sword2 = (strcmp(gameid.c_str(), "sword2") == 0);
+	bool is_queen = (gameid == "queen");
+	bool is_sky = (gameid == "sky");
+	bool is_comi = (strncmp(gameid.c_str(), "comi", 4) == 0);
+	bool is_gob = (strncmp(gameid.c_str(), "gob", 3) == 0);
+	bool is_ite = ((strncmp(gameid.c_str(), "ite", 3) == 0) ||
+				  (strncmp(gameid.c_str(), "ihnm", 4) == 0));
 
 	GUI_Actions::initInstanceGame();
 
 	// See if a right click mapping could be needed
 	if (is_sword1 || is_sword2 || is_sky || is_queen || is_comi || is_gob ||
-		_gameid == "samnmax")
+		gameid == "samnmax")
 		_right_click_needed = true;
 
 	// See if a "hide toolbar" mapping could be needed

Modified: scummvm/trunk/backends/wince/CEActionsSmartphone.cpp
===================================================================
--- scummvm/trunk/backends/wince/CEActionsSmartphone.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/backends/wince/CEActionsSmartphone.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -60,8 +60,8 @@
 const int ACTIONS_SMARTPHONE_DEFAULT[] = { '4', '6', '8', '2', 0x11a, 0x11b, '0', VK_ESCAPE, '9', 0, VK_RETURN };
 #endif
 
-void CEActionsSmartphone::init(const Common::String &gameid) {
-	_instance = new CEActionsSmartphone(gameid);
+void CEActionsSmartphone::init() {
+	_instance = new CEActionsSmartphone();
 }
 
 
@@ -81,9 +81,8 @@
 	return SMARTPHONE_ACTION_VERSION;
 }
 
-CEActionsSmartphone::CEActionsSmartphone(const Common::String &gameid) :
-GUI::Actions(gameid)
-{
+CEActionsSmartphone::CEActionsSmartphone()
+: GUI::Actions() {
 	int i;
 
 	for (i=0; i<SMARTPHONE_ACTION_LAST; i++) {
@@ -112,17 +111,18 @@
 }
 
 void CEActionsSmartphone::initInstanceGame() {
-	bool is_simon = (strncmp(_gameid.c_str(), "simon", 5) == 0);
-	bool is_sky = (_gameid == "sky");
-	bool is_queen = (_gameid == "queen");
-	bool is_gob = (strncmp(_gameid.c_str(), "gob", 3) == 0);
-	bool is_ite = ((strncmp(_gameid.c_str(), "ite", 3) == 0) ||
-				  (strncmp(_gameid.c_str(), "ihnm", 4) == 0));
+	String gameid(ConfMan.get("gameid"));
+	bool is_simon = (strncmp(gameid.c_str(), "simon", 5) == 0);
+	bool is_sky = (gameid == "sky");
+	bool is_queen = (gameid == "queen");
+	bool is_gob = (strncmp(gameid.c_str(), "gob", 3) == 0);
+	bool is_ite = ((strncmp(gameid.c_str(), "ite", 3) == 0) ||
+				  (strncmp(gameid.c_str(), "ihnm", 4) == 0));
 
 	GUI_Actions::initInstanceGame();
 
 	// See if a right click mapping could be needed
-	if (is_sky || _gameid == "samnmax" || is_gob)
+	if (is_sky || gameid == "samnmax" || is_gob)
 		_right_click_needed = true;
 
 	// Initialize keys for different actions

Modified: scummvm/trunk/backends/wince/wince-sdl.cpp
===================================================================
--- scummvm/trunk/backends/wince/wince-sdl.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/backends/wince/wince-sdl.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -522,7 +522,7 @@
 
 void OSystem_WINCE3::get_sample_rate() {
 	// Force at least medium quality FM synthesis for FOTAQ
-	Common::String gameid(GUI::Actions::Instance()->_gameid);
+	Common::String gameid(ConfMan.get("gameid"));
 	if (gameid == "queen") {
 		if (!((ConfMan.hasKey("FM_high_quality") && ConfMan.getBool("FM_high_quality")) ||
 			(ConfMan.hasKey("FM_medium_quality") && ConfMan.getBool("FM_medium_quality")))) {
@@ -653,9 +653,9 @@
 void OSystem_WINCE3::check_mappings() {
 		CEActionsPocket *instance;
 
-		Common::String gameid(GUI::Actions::Instance()->_gameid);
+		Common::String gameid(ConfMan.get("gameid"));
 
-		if (!gameid.size() || GUI_Actions::Instance()->initialized())
+		if (gameid.empty() || GUI_Actions::Instance()->initialized())
 			return;
 
 		GUI_Actions::Instance()->initInstanceGame();
@@ -707,10 +707,10 @@
 }
 
 void OSystem_WINCE3::update_game_settings() {
-	Common::String gameid(GUI::Actions::Instance()->_gameid);
+	Common::String gameid(ConfMan.get("gameid"));
 
 	// Finish panel initialization
-	if (!_panelInitialized && gameid.size()) {
+	if (!_panelInitialized && !gameid.empty()) {
 		Panel *panel;
 		_panelInitialized = true;
 		// Add the main panel

Modified: scummvm/trunk/base/gameDetector.cpp
===================================================================
--- scummvm/trunk/base/gameDetector.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/base/gameDetector.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -261,7 +261,7 @@
 	PluginList::const_iterator iter = plugins.begin();
 	for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
 		result = (*iter)->findGame(gameName.c_str());
-		if (result.gameid.size() > 0) {
+		if (!result.gameid.empty()) {
 			if (plugin)
 				*plugin = *iter;
 			break;
@@ -581,14 +581,12 @@
 	_targetName = target;
 	ConfMan.setActiveDomain(target);
 
+	// Make sure the gameid is set in the config manager, and that it is lowercase.
+	String gameid(_targetName);
 	if (ConfMan.hasKey("gameid"))
-		_gameid = ConfMan.get("gameid");
-	else
-		_gameid = _targetName;
-	
-	// TODO: In the future, simply insert the gameid into the transient domain.
-	// That way, all code (including backends) can reliably access it.
-	//ConfMan.set("gameid", _gameid, Common::ConfigManager::kTransientDomain);
+		gameid = ConfMan.get("gameid");
+	gameid.toLowercase();
+	ConfMan.set("gameid", gameid);
 }
 
 const Plugin *GameDetector::detectMain() {
@@ -599,8 +597,8 @@
 		return 0;
 	}
 
-	printf("Looking for %s\n", _gameid.c_str());
-	GameDescriptor game = findGame(_gameid, &plugin);
+	printf("Looking for %s\n", ConfMan.get("gameid").c_str());
+	GameDescriptor game = findGame(ConfMan.get("gameid"), &plugin);
 
 	if (plugin == 0) {
 		printf("Failed game detection\n");

Modified: scummvm/trunk/base/gameDetector.h
===================================================================
--- scummvm/trunk/base/gameDetector.h	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/base/gameDetector.h	2006-04-15 17:39:14 UTC (rev 21915)
@@ -70,7 +70,6 @@
 	const Plugin *detectMain();
 
 	String _targetName;
-	String _gameid;
 
 public:
 	static GameDescriptor findGame(const String &gameName, const Plugin **plugin = NULL);

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/base/main.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -181,7 +181,7 @@
 	// Set the window caption to the game name
 	Common::String caption(ConfMan.get("description", detector._targetName));
 
-	Common::String desc = GameDetector::findGame(detector._gameid).description;
+	Common::String desc = GameDetector::findGame(ConfMan.get("gameid")).description;
 	if (caption.empty() && !desc.empty())
 		caption = desc;
 	if (caption.empty())
@@ -292,7 +292,7 @@
 
 #if defined(__SYMBIAN32__) || defined(_WIN32_WCE)
 	// init keymap support here: we wanna move this somewhere else?
-	GUI::Actions::init(detector._gameid);
+	GUI::Actions::init(ConfMan.get("gameid"));
 #endif
 
 #ifdef PALMOS_68K

Modified: scummvm/trunk/engines/scumm/plugin.cpp
===================================================================
--- scummvm/trunk/engines/scumm/plugin.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/engines/scumm/plugin.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -1620,15 +1620,15 @@
  */
 Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) {
 	Engine *engine;
+	const char *gameid = ConfMan.get("gameid").c_str();
 
 	// We start by checking whether the specified game ID is obsolete.
 	// If that is the case, we automatically upgrade the target to use
 	// the correct new game ID (and platform, if specified).
-	const ObsoleteGameID *o = obsoleteGameIDsTable;
-	while (o->from) {
-		if (!scumm_stricmp(detector->_gameid.c_str(), o->from)) {
+	for (const ObsoleteGameID *o = obsoleteGameIDsTable; o->from; ++o) {
+		if (!scumm_stricmp(gameid, o->from)) {
 			// Match found, perform upgrade
-			detector->_gameid = o->to;
+			gameid = o->to;
 			ConfMan.set("gameid", o->to);
 
 			if (o->platform != Common::kPlatformUnknown)
@@ -1638,14 +1638,13 @@
 			ConfMan.flushToDisk();
 			break;
 		}
-		o++;
 	}
 
 	// Lookup the game ID in our database. If this lookup fails, then
 	// the game ID is unknown, and we have to abort.
 	const GameSettings *g = gameVariantsTable;
 	while (g->gameid) {
-		if (!scumm_stricmp(detector->_gameid.c_str(), g->gameid))
+		if (!scumm_stricmp(gameid, g->gameid))
 			break;
 		g++;
 	}
@@ -1655,7 +1654,7 @@
 
 	// We now want to calculate the MD5 of the games detection file, so that we
 	// can store it in savegames etc..
-	const char *gameid = g->gameid;
+	gameid = g->gameid;
 	char detectName[256], tempName[256];
 	uint8 md5sum[16];
 	SubstResFileNames subst = { 0, 0, kGenAsIs };

Modified: scummvm/trunk/engines/simon/game.cpp
===================================================================
--- scummvm/trunk/engines/simon/game.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/engines/simon/game.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -113,11 +113,12 @@
 }
 
 Engine *Engine_SIMON_create(GameDetector *detector, OSystem *syst) {
-	const ObsoleteGameID *o = obsoleteGameIDsTable;
-	while (o->from) {
-		if (!scumm_stricmp(detector->_gameid.c_str(), o->from)) {
-			detector->_gameid = o->to;
+	const char *gameid = ConfMan.get("gameid").c_str();
 
+	for (const ObsoleteGameID *o = obsoleteGameIDsTable; o->from; ++o) {
+		if (!scumm_stricmp(gameid, o->from)) {
+			// Match found, perform upgrade
+			gameid = o->to;
 			ConfMan.set("gameid", o->to);
 
 			if (o->platform != Common::kPlatformUnknown)
@@ -127,7 +128,6 @@
 			ConfMan.flushToDisk();
 			break;
 		}
-		o++;
 	}
 
 	return new Simon::SimonEngine(syst);

Modified: scummvm/trunk/engines/sword1/sword1.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sword1.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/engines/sword1/sword1.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -134,7 +134,7 @@
 SwordEngine::SwordEngine(GameDetector *detector, OSystem *syst)
 	: Engine(syst) {
 
-	if (0 == scumm_stricmp(detector->_gameid.c_str(), "sword1demo"))
+	if (0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1demo"))
 		_features = GF_DEMO;
 	else
 		_features = 0;

Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/engines/sword2/sword2.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -129,7 +129,7 @@
 	Common::File::addDefaultDirectory(_gameDataPath + "sword2/");
 	Common::File::addDefaultDirectory(_gameDataPath + "video/");
 
-	if (0 == scumm_stricmp(detector->_gameid.c_str(), "sword2demo"))
+	if (0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2demo"))
 		_features = GF_DEMO;
 	else
 		_features = 0;

Modified: scummvm/trunk/gui/Actions.cpp
===================================================================
--- scummvm/trunk/gui/Actions.cpp	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/gui/Actions.cpp	2006-04-15 17:39:14 UTC (rev 21915)
@@ -39,8 +39,8 @@
 	return _instance;
 }
 
-Actions::Actions(const Common::String &gameid) :
-	_gameid(gameid), _mapping_active(false), _initialized(false)
+Actions::Actions() :
+	_mapping_active(false), _initialized(false)
 {
 }
 
@@ -49,15 +49,15 @@
 }
 
 // call the correct object creator function according to the Factory Pattern
-void Actions::init(const Common::String &gameid) {
+void Actions::init() {
 #ifdef _WIN32_WCE
 	// For WinCE: now use software + Factory pattern to create correct objects
 	if (!CEDevice::isSmartphone())
-		CEActionsPocket::init(gameid);
+		CEActionsPocket::init();
 	else
-		CEActionsSmartphone::init(gameid);
+		CEActionsSmartphone::init();
 #elif defined(__SYMBIAN32__)
-	SymbianActions::init(gameid);
+	SymbianActions::init();
 #endif
 }
 

Modified: scummvm/trunk/gui/Actions.h
===================================================================
--- scummvm/trunk/gui/Actions.h	2006-04-15 17:32:06 UTC (rev 21914)
+++ scummvm/trunk/gui/Actions.h	2006-04-15 17:39:14 UTC (rev 21915)
@@ -37,7 +37,7 @@
 
 public:
 	static Actions* Instance();
-	static void init(const Common::String &gameid);
+	static void init();
 	virtual void initInstanceMain(OSystem *mainSystem);
 	virtual void initInstanceGame();
 	bool initialized();
@@ -65,12 +65,8 @@
 
 	virtual ~Actions();
 
-public:
-	// Since _gameid is const it's safe to let the public read it.
-	const Common::String _gameid;
-
 protected:
-	Actions(const Common::String &gameid);
+	Actions();
 
 protected:
 	static Actions* _instance;


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