[Scummvm-cvs-logs] SF.net SVN: scummvm:[54697] scummvm/trunk/backends/platform/wii

jvprat at users.sourceforge.net jvprat at users.sourceforge.net
Wed Dec 1 13:23:38 CET 2010


Revision: 54697
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54697&view=rev
Author:   jvprat
Date:     2010-12-01 12:23:37 +0000 (Wed, 01 Dec 2010)

Log Message:
-----------
WII: Add system language auto-detection.

Modified Paths:
--------------
    scummvm/trunk/backends/platform/wii/osystem.cpp
    scummvm/trunk/backends/platform/wii/osystem.h

Modified: scummvm/trunk/backends/platform/wii/osystem.cpp
===================================================================
--- scummvm/trunk/backends/platform/wii/osystem.cpp	2010-12-01 11:29:26 UTC (rev 54696)
+++ scummvm/trunk/backends/platform/wii/osystem.cpp	2010-12-01 12:23:37 UTC (rev 54697)
@@ -21,6 +21,7 @@
 
 #include <unistd.h>
 
+#include <ogc/conf.h>
 #include <ogc/mutex.h>
 #include <ogc/lwp_watchdog.h>
 
@@ -218,21 +219,21 @@
 }
 
 void OSystem_Wii::lockMutex(MutexRef mutex) {
-	s32 res = LWP_MutexLock(*(mutex_t *) mutex);
+	s32 res = LWP_MutexLock(*(mutex_t *)mutex);
 
 	if (res)
 		printf("ERROR locking mutex %p (%d)\n", mutex, res);
 }
 
 void OSystem_Wii::unlockMutex(MutexRef mutex) {
-	s32 res = LWP_MutexUnlock(*(mutex_t *) mutex);
+	s32 res = LWP_MutexUnlock(*(mutex_t *)mutex);
 
 	if (res)
 		printf("ERROR unlocking mutex %p (%d)\n", mutex, res);
 }
 
 void OSystem_Wii::deleteMutex(MutexRef mutex) {
-	s32 res = LWP_MutexDestroy(*(mutex_t *) mutex);
+	s32 res = LWP_MutexDestroy(*(mutex_t *)mutex);
 
 	if (res)
 		printf("ERROR destroying mutex %p (%d)\n", mutex, res);
@@ -290,3 +291,77 @@
 	_padAcceleration = 9 - ConfMan.getInt("wii_pad_acceleration");
 }
 
+#ifndef GAMECUBE
+Common::String OSystem_Wii::getSystemLanguage() const {
+	const char *wiiCountries[] = {
+		"JP", // CONF_AREA_JPN Japan
+		"US", // CONF_AREA_USA United States of America
+		"",   // CONF_AREA_EUR Europe?
+		"AU", // CONF_AREA_AUS Australia, Commonwealth of
+		"BR", // CONF_AREA_BRA Brazil, Federative Republic of
+		"TW", // CONF_AREA_TWN Taiwan, Province of China
+		"",   // CONF_AREA_ROC Republic of China (Taiwan)
+		"KR", // CONF_AREA_KOR Korea, Republic of
+		"HK", // CONF_AREA_HKG Hong Kong, Special Administrative Region of China
+		"",   // CONF_AREA_ASI Asia?
+		"",   // CONF_AREA_LTN Lithuania?
+		"",   // CONF_AREA_SAF South-Africa?
+		"CN"  // CONF_AREA_CHN China, People's Republic of
+	};
+
+	// Start by detecting the country, since we can deduce some languages not
+	// supported on the Wii from it.
+	Common::String country;
+	// TODO: Can we get more fine-grained country setting?
+	int32 areaID = CONF_GetArea();
+	if ((areaID >= CONF_AREA_JPN) && (areaID <= CONF_AREA_CHN) {
+		// It's a known area.
+		if (areaID == CONF_AREA_BRA) {
+			// Portuguese isn't available on the Wii, but we know it's the
+			// official language in Brazil, so we handle it separately.
+			return "pt_BR";
+		} else {
+			// Let's use our manual area to country mapping.
+			country = wiiCountries[areaID];
+		}
+	} else {
+		// This will only happen when new areas are added to the API.
+		warning("WII: Unknown system area: %d", areaID);
+	}
+
+
+	const char *wiiLanguages[] = {
+		"ja",      // CONF_LANG_JAPANESE     Japanese
+		"en",      // CONF_LANG_ENGLISH      English
+		"de",      // CONF_LANG_GERMAN       German
+		"fr",      // CONF_LANG_FRENCH       French
+		"es",      // CONF_LANG_SPANISH      Spanish
+		"it",      // CONF_LANG_ITALIAN      Italian
+		"nl",      // CONF_LANG_DUTCH        Dutch
+		"zh-Hans", // CONF_LANG_SIMP_CHINESE Simplified Chinese
+		"zh-Hant", // CONF_LANG_TRAD_CHINESE Traditional Chinese
+		"ko"       // CONF_LANG_KOREAN       Korean
+	};
+
+	// Now let's read the system language.
+	Common::String lang;
+	int32 langID = CONF_GetLanguage();
+	if ((langID >= CONF_LANG_JAPANESE) && (langID <= CONF_LANG_KOREAN)) {
+		// It's a known language, let's use our manual language mapping.
+		lang = wiiLanguages[langID];
+
+		if (country.empty()) {
+			// We don't know how to improve the detection,
+			// let's return the language alone.
+			return lang;
+		} else {
+			// Return the complete language_country string.
+			return lang + "_" + country;
+		}
+	} else {
+		// This will only happen when new languages are added to the API.
+		warning("WII: Unknown system language: %d", langID);
+		return "";
+	}
+}
+#endif // !GAMECUBE

Modified: scummvm/trunk/backends/platform/wii/osystem.h
===================================================================
--- scummvm/trunk/backends/platform/wii/osystem.h	2010-12-01 11:29:26 UTC (rev 54696)
+++ scummvm/trunk/backends/platform/wii/osystem.h	2010-12-01 12:23:37 UTC (rev 54697)
@@ -213,7 +213,10 @@
 	virtual Common::TimerManager *getTimerManager();
 	virtual FilesystemFactory *getFilesystemFactory();
 	virtual void getTimeAndDate(TimeDate &t) const;
+
+#ifndef GAMECUBE
+	virtual Common::String getSystemLanguage() const;
+#endif // GAMECUBE
 };
 
 #endif
-


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