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

sev at users.sourceforge.net sev at users.sourceforge.net
Tue Jun 15 12:57:28 CEST 2010


Revision: 49786
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49786&view=rev
Author:   sev
Date:     2010-06-15 10:57:28 +0000 (Tue, 15 Jun 2010)

Log Message:
-----------
GUI: Implemented Languages as GUI options.

SCUMM and AdvancedDetector support this feature.

Modified Paths:
--------------
    scummvm/trunk/common/util.cpp
    scummvm/trunk/common/util.h
    scummvm/trunk/engines/advancedDetector.cpp
    scummvm/trunk/engines/game.cpp
    scummvm/trunk/engines/game.h
    scummvm/trunk/engines/scumm/detection.cpp
    scummvm/trunk/gui/PopUpWidget.h
    scummvm/trunk/gui/launcher.cpp
    scummvm/trunk/gui/options.cpp
    scummvm/trunk/gui/options.h

Modified: scummvm/trunk/common/util.cpp
===================================================================
--- scummvm/trunk/common/util.cpp	2010-06-15 10:56:46 UTC (rev 49785)
+++ scummvm/trunk/common/util.cpp	2010-06-15 10:57:28 UTC (rev 49786)
@@ -322,9 +322,26 @@
 	return false;
 }
 
+bool checkGameGUIOptionLanguage(Language lang, const String &str) {
+	if (!str.contains("lang_")) // If no languages are specified
+		return true;
+
+	if (str.contains(getGameGUIOptionsDescriptionLanguage(lang)))
+		return true;
+
+	return false;
+}
+
+const String getGameGUIOptionsDescriptionLanguage(Language lang) {
+	if (lang == UNK_LANG)
+		return "";
+
+	return String(String("lang_") + getLanguageDescription(lang));
+}
+
 uint32 parseGameGUIOptions(const String &str) {
 	uint32 res = 0;
-
+	
 	for (int i = 0; g_gameOptions[i].desc; i++)
 		if (str.contains(g_gameOptions[i].desc))
 			res |= g_gameOptions[i].option;
@@ -332,7 +349,7 @@
 	return res;
 }
 
-String getGameGUIOptionsDescription(uint32 options) {
+const String getGameGUIOptionsDescription(uint32 options) {
 	String res = "";
 
 	for (int i = 0; g_gameOptions[i].desc; i++)

Modified: scummvm/trunk/common/util.h
===================================================================
--- scummvm/trunk/common/util.h	2010-06-15 10:56:46 UTC (rev 49785)
+++ scummvm/trunk/common/util.h	2010-06-15 10:57:28 UTC (rev 49786)
@@ -228,8 +228,10 @@
 };
 
 bool checkGameGUIOption(GameGUIOption option, const String &str);
+bool checkGameGUIOptionLanguage(Language lang, const String &str);
 uint32 parseGameGUIOptions(const String &str);
-String getGameGUIOptionsDescription(uint32 options);
+const String getGameGUIOptionsDescription(uint32 options);
+const String getGameGUIOptionsDescriptionLanguage(Language lang);
 
 /**
  * Updates the GUI options of the current config manager

Modified: scummvm/trunk/engines/advancedDetector.cpp
===================================================================
--- scummvm/trunk/engines/advancedDetector.cpp	2010-06-15 10:56:46 UTC (rev 49785)
+++ scummvm/trunk/engines/advancedDetector.cpp	2010-06-15 10:57:28 UTC (rev 49786)
@@ -208,6 +208,7 @@
 		desc["extra"] = realDesc->extra;
 
 	desc.setGUIOptions(realDesc->guioptions | params.guioptions);
+	desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(realDesc->language));
 }
 
 GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {

Modified: scummvm/trunk/engines/game.cpp
===================================================================
--- scummvm/trunk/engines/game.cpp	2010-06-15 10:56:46 UTC (rev 49785)
+++ scummvm/trunk/engines/game.cpp	2010-06-15 10:57:28 UTC (rev 49786)
@@ -73,6 +73,10 @@
 		erase("guioptions");
 }
 
+void GameDescriptor::appendGUIOptions(const Common::String &str) {
+	setVal("guioptions", getVal("guioptions", "") + " " + str);
+}
+
 void GameDescriptor::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

Modified: scummvm/trunk/engines/game.h
===================================================================
--- scummvm/trunk/engines/game.h	2010-06-15 10:56:46 UTC (rev 49785)
+++ scummvm/trunk/engines/game.h	2010-06-15 10:57:28 UTC (rev 49786)
@@ -83,6 +83,7 @@
 	void updateDesc(const char *extra = 0);
 
 	void setGUIOptions(uint32 options);
+	void appendGUIOptions(const Common::String &str);
 
 	Common::String &gameid() { return getVal("gameid"); }
 	Common::String &description() { return getVal("description"); }

Modified: scummvm/trunk/engines/scumm/detection.cpp
===================================================================
--- scummvm/trunk/engines/scumm/detection.cpp	2010-06-15 10:56:46 UTC (rev 49785)
+++ scummvm/trunk/engines/scumm/detection.cpp	2010-06-15 10:57:28 UTC (rev 49786)
@@ -884,6 +884,7 @@
 		}
 
 		dg.setGUIOptions(x->game.guioptions | MidiDriver::midiDriverFlags2GUIO(x->game.midi));
+		dg.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(x->language));
 
 		detectedGames.push_back(dg);
 	}

Modified: scummvm/trunk/gui/PopUpWidget.h
===================================================================
--- scummvm/trunk/gui/PopUpWidget.h	2010-06-15 10:56:46 UTC (rev 49785)
+++ scummvm/trunk/gui/PopUpWidget.h	2010-06-15 10:57:28 UTC (rev 49786)
@@ -66,6 +66,7 @@
 
 	void appendEntry(const String &entry, uint32 tag = (uint32)-1);
 	void clearEntries();
+	int numEntries() { return _entries.size(); }
 
 	/** Select the entry at the given index. */
 	void setSelected(int item);

Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp	2010-06-15 10:56:46 UTC (rev 49785)
+++ scummvm/trunk/gui/launcher.cpp	2010-06-15 10:57:28 UTC (rev 49786)
@@ -180,11 +180,12 @@
 	// Language popup
 	_langPopUpDesc = new StaticTextWidget(tab, "GameOptions_Game.LangPopupDesc", _("Language:"), _("Language of the game. This will not turn your Spanish game version into English"));
 	_langPopUp = new PopUpWidget(tab, "GameOptions_Game.LangPopup", _("Language of the game. This will not turn your Spanish game version into English"));
-	_langPopUp->appendEntry(_("<default>"));
-	_langPopUp->appendEntry("");
+	_langPopUp->appendEntry(_("<default>"), 0);
+	_langPopUp->appendEntry("", 0);
 	const Common::LanguageDescription *l = Common::g_languages;
 	for (; l->code; ++l) {
-		_langPopUp->appendEntry(l->description, l->id);
+		if (checkGameGUIOptionLanguage(l->id, _guioptionsString))
+			_langPopUp->appendEntry(l->description, l->id);
 	}
 
 	// Platform popup
@@ -311,19 +312,18 @@
 
 	// TODO: game path
 
-	const Common::LanguageDescription *l = Common::g_languages;
 	const Common::Language lang = Common::parseLanguage(ConfMan.get("language", _domain));
 
-	sel = 0;
 	if (ConfMan.hasKey("language", _domain)) {
-		for (i = 0; l->code; ++l, ++i) {
-			if (lang == l->id)
-				sel = i + 2;
-		}
+		_langPopUp->setSelectedTag(lang);
 	}
-	_langPopUp->setSelected(sel);
 
+	if (_langPopUp->numEntries() <= 3) { // If only one language is avaliable
+		_langPopUpDesc->setEnabled(false);
+		_langPopUp->setEnabled(false);
+	}
 
+
 	const Common::PlatformDescription *p = Common::g_platforms;
 	const Common::Platform platform = Common::parsePlatform(ConfMan.get("platform", _domain));
 	sel = 0;

Modified: scummvm/trunk/gui/options.cpp
===================================================================
--- scummvm/trunk/gui/options.cpp	2010-06-15 10:56:46 UTC (rev 49785)
+++ scummvm/trunk/gui/options.cpp	2010-06-15 10:57:28 UTC (rev 49786)
@@ -126,8 +126,10 @@
 
 	// Retrieve game GUI options
 	_guioptions = 0;
-	if (ConfMan.hasKey("guioptions", _domain))
-		_guioptions = parseGameGUIOptions(ConfMan.get("guioptions", _domain));
+	if (ConfMan.hasKey("guioptions", _domain)) {
+		_guioptionsString = ConfMan.get("guioptions", _domain);
+		_guioptions = parseGameGUIOptions(_guioptionsString);
+	}
 }
 
 void OptionsDialog::open() {
@@ -138,8 +140,10 @@
 
 	// Retrieve game GUI options
 	_guioptions = 0;
-	if (ConfMan.hasKey("guioptions", _domain))
-		_guioptions = parseGameGUIOptions(ConfMan.get("guioptions", _domain));
+	if (ConfMan.hasKey("guioptions", _domain)) {
+		_guioptionsString = ConfMan.get("guioptions", _domain);
+		_guioptions = parseGameGUIOptions(_guioptionsString);
+	}
 
 	// Graphic options
 	if (_fullscreenCheckbox) {

Modified: scummvm/trunk/gui/options.h
===================================================================
--- scummvm/trunk/gui/options.h	2010-06-15 10:56:46 UTC (rev 49785)
+++ scummvm/trunk/gui/options.h	2010-06-15 10:57:28 UTC (rev 49786)
@@ -156,6 +156,7 @@
 	// Game GUI options
 	//
 	uint32 _guioptions;
+	Common::String _guioptionsString;
 };
 
 


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