diff options
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/launcher.cpp | 27 | ||||
| -rw-r--r-- | gui/massadd.cpp | 27 | ||||
| -rw-r--r-- | gui/massadd.h | 2 | 
3 files changed, 36 insertions, 20 deletions
| diff --git a/gui/launcher.cpp b/gui/launcher.cpp index f257c53e11..4edd3527f4 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -376,11 +376,20 @@ void LauncherDialog::addGame() {  	} while (looping);  } +namespace { + +static void addStringToConf(const Common::String &key, const Common::String &value, const Common::String &domain) { +	if (!value.empty()) +		ConfMan.set(key, value, domain); +} + +} // End of anonymous namespace +  Common::String addGameToConf(const GameDescriptor &result) {  	// The auto detector or the user made a choice.  	// Pick a domain name which does not yet exist (after all, we  	// are *adding* a game to the config, not replacing). -	Common::String domain = result.preferredtarget(); +	Common::String domain = result.preferredTarget;  	assert(!domain.empty());  	if (ConfMan.hasGameDomain(domain)) { @@ -396,11 +405,15 @@ Common::String addGameToConf(const GameDescriptor &result) {  	// Add the name domain  	ConfMan.addGameDomain(domain); -	// Copy all non-empty key/value pairs into the new domain -	for (GameDescriptor::const_iterator iter = result.begin(); iter != result.end(); ++iter) { -		if (!iter->_value.empty() && iter->_key != "preferredtarget") -			ConfMan.set(iter->_key, iter->_value, domain); -	} +	// Copy all non-empty relevant values into the new domain +	// FIXME: Factor out +	addStringToConf("gameid", result.gameId, domain); +	addStringToConf("description", result.description, domain); +	addStringToConf("language", Common::getLanguageCode(result.language), domain); +	addStringToConf("platform", Common::getPlatformCode(result.platform), domain); +	addStringToConf("path", result.path, domain); +	addStringToConf("extra", result.extra, domain); +	addStringToConf("guioptions", result.getGUIOptions(), domain);  	// TODO: Setting the description field here has the drawback  	// that the user does never notice when we upgrade our descriptions. @@ -601,7 +614,7 @@ bool LauncherDialog::doGameDetection(const Common::String &path) {  		// Display the candidates to the user and let her/him pick one  		StringArray list;  		for (idx = 0; idx < (int)candidates.size(); idx++) -			list.push_back(candidates[idx].matchedGame.description()); +			list.push_back(candidates[idx].matchedGame.description);  		ChooserDialog dialog(_("Pick the game:"));  		dialog.setList(list); diff --git a/gui/massadd.cpp b/gui/massadd.cpp index 2774d476db..7c54c503a3 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -121,13 +121,13 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir)  struct GameTargetLess {  	bool operator()(const GameDescriptor &x, const GameDescriptor &y) const { -		return x.preferredtarget().compareToIgnoreCase(y.preferredtarget()) < 0; +		return x.preferredTarget.compareToIgnoreCase(y.preferredTarget) < 0;  	}  };  struct GameDescLess {  	bool operator()(const GameDescriptor &x, const GameDescriptor &y) const { -		return x.description().compareToIgnoreCase(y.description()) < 0; +		return x.description.compareToIgnoreCase(y.description) < 0;  	}  }; @@ -143,13 +143,13 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data  	if (cmd == kOkCmd) {  		// Sort the detected games. This is not strictly necessary, but nice for  		// people who want to edit their config file by hand after a mass add. -		sort(_games.begin(), _games.end(), GameTargetLess()); +		Common::sort(_games.begin(), _games.end(), GameTargetLess());  		// Add all the detected games to the config  		for (GameList::iterator iter = _games.begin(); iter != _games.end(); ++iter) {  			debug(1, "  Added gameid '%s', desc '%s'\n", -				(*iter)["gameid"].c_str(), -				(*iter)["description"].c_str()); -			(*iter)["gameid"] = addGameToConf(*iter); +				iter->gameId.c_str(), +				iter->description.c_str()); +			iter->gameId = addGameToConf(*iter);  		}  		// Write everything to disk @@ -157,8 +157,8 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data  		// And scroll to first detected game  		if (!_games.empty()) { -			sort(_games.begin(), _games.end(), GameDescLess()); -			ConfMan.set("temp_selection", _games.front().gameid()); +			Common::sort(_games.begin(), _games.end(), GameDescLess()); +			ConfMan.set("temp_selection", _games.front().gameId);  		}  		close(); @@ -211,6 +211,9 @@ void MassAddDialog::handleTickle() {  			// Check for existing config entries for this path/gameid/lang/platform combination  			if (_pathToTargets.contains(path)) { +				const char *resultPlatformCode = Common::getPlatformCode(result.platform); +				const char *resultLanguageCode = Common::getLanguageCode(result.language); +  				bool duplicate = false;  				const StringArray &targets = _pathToTargets[path];  				for (StringArray::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) { @@ -218,9 +221,9 @@ void MassAddDialog::handleTickle() {  					Common::ConfigManager::Domain *dom = ConfMan.getDomain(*iter);  					assert(dom); -					if ((*dom)["gameid"] == result["gameid"] && -					    (*dom)["platform"] == result["platform"] && -					    (*dom)["language"] == result["language"]) { +					if ((*dom)["gameid"] == result.gameId && +					    (*dom)["platform"] == resultPlatformCode && +					    (*dom)["language"] == resultLanguageCode) {  						duplicate = true;  						break;  					} @@ -232,7 +235,7 @@ void MassAddDialog::handleTickle() {  			}  			_games.push_back(result); -			_list->append(result.description()); +			_list->append(result.description);  		} diff --git a/gui/massadd.h b/gui/massadd.h index 116a420d79..58071cda0a 100644 --- a/gui/massadd.h +++ b/gui/massadd.h @@ -44,7 +44,7 @@ public:  	Common::String getFirstAddedTarget() const {  		if (!_games.empty()) -			return _games.front().gameid(); +			return _games.front().gameId;  		return Common::String();  	} | 
