game name and description WIP: cache all 6 languages, so we don't need refresh cache after we changes language.

move some WIN32 code to CGameListCtrl.
nakee, please check linux build, sorry I've not enough time to setup a linux dev environment.
and, who can read German helps me to test game name and description display, thanks.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2090 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hyperiris
2009-02-03 15:03:34 +00:00
parent 4660943322
commit 9e3fed40f2
14 changed files with 244 additions and 154 deletions

View File

@ -94,55 +94,6 @@ bool IBannerLoader::CopyToStringAndCheck(std::string& _rDestination, const char*
return(bResult);
}
bool IBannerLoader::CopySJISToString( std::string& _rDestination, const char* _src )
{
bool returnCode = false;
#ifdef WIN32
// HyperIris: because dolphin using "Use Multi-Byte Character Set",
// we must convert the SJIS chars to unicode then to our windows local by hand
u32 unicodeNameSize = MultiByteToWideChar(932, MB_PRECOMPOSED,
_src, (int)strlen(_src), NULL, NULL);
if (unicodeNameSize > 0)
{
u16* pUnicodeStrBuffer = new u16[unicodeNameSize + 1];
if (pUnicodeStrBuffer)
{
memset(pUnicodeStrBuffer, 0, (unicodeNameSize + 1) * sizeof(u16));
if (MultiByteToWideChar(932, MB_PRECOMPOSED,
_src, (int)strlen(_src),
(LPWSTR)pUnicodeStrBuffer, unicodeNameSize))
{
u32 ansiNameSize = WideCharToMultiByte(CP_ACP, 0,
(LPCWSTR)pUnicodeStrBuffer, unicodeNameSize,
NULL, NULL, NULL, NULL);
if (ansiNameSize > 0)
{
char* pAnsiStrBuffer = new char[ansiNameSize + 1];
if (pAnsiStrBuffer)
{
memset(pAnsiStrBuffer, 0, (ansiNameSize + 1) * sizeof(char));
if (WideCharToMultiByte(CP_ACP, 0,
(LPCWSTR)pUnicodeStrBuffer, unicodeNameSize,
pAnsiStrBuffer, ansiNameSize, NULL, NULL))
{
_rDestination = pAnsiStrBuffer;
returnCode = true;
}
delete pAnsiStrBuffer;
}
}
}
delete pUnicodeStrBuffer;
}
}
#else
// not implement other than windows
_rDestination = _src;
returnCode = true;
#endif
return returnCode;
}
bool IBannerLoader::CopyUnicodeToString( std::string& _rDestination, const u16* _src )
{
bool returnCode = false;
@ -172,7 +123,7 @@ bool IBannerLoader::CopyUnicodeToString( std::string& _rDestination, const u16*
#else
// FIXME: Horribly broke on non win32
// _rDestination = _src;
returnCode = true;
returnCode = false;
#endif
return returnCode;
}

View File

@ -38,17 +38,17 @@ class IBannerLoader
virtual bool GetBanner(u32* _pBannerImage) = 0;
virtual bool GetName(std::string& _rName, DiscIO::IVolume::ECountry language) = 0;
virtual bool GetName(std::string* _rName) = 0;
virtual bool GetCompany(std::string& _rCompany) = 0;
virtual bool GetDescription(std::string& _rDescription, DiscIO::IVolume::ECountry language) = 0;
virtual bool GetDescription(std::string* _rDescription) = 0;
protected:
bool CopyToStringAndCheck(std::string& _rDestination, const char* _src);
bool CopySJISToString(std::string& _rDestination, const char* _src);
bool CopyUnicodeToString(std::string& _rDestination, const u16* _src);
};

View File

@ -92,9 +92,12 @@ CBannerLoaderGC::GetBanner(u32* _pBannerImage)
bool
CBannerLoaderGC::GetName(std::string& _rName, DiscIO::IVolume::ECountry language)
CBannerLoaderGC::GetName(std::string _rName[])
{
_rName = "no name";
for (int i = 0; i < 6; i++)
{
_rName[i] = "no name";
}
bool returnCode = false;
@ -109,21 +112,10 @@ CBannerLoaderGC::GetName(std::string& _rName, DiscIO::IVolume::ECountry language
case CBannerLoaderGC::BANNER_BNR1:
{
DVDBanner* pBanner = (DVDBanner*)m_pBannerFile;
if (DiscIO::IVolume::COUNTRY_JAP == language)
{
// dunno, if dolphin using unicode, it will be better = =;
if (CopySJISToString(_rName, pBanner->comment.shortTitle))
{
returnCode = true;
}
}
else
{
if (CopyToStringAndCheck(_rName, pBanner->comment.shortTitle))//language != 0 ? pBanner->comment[0].shortTitle : pBanner->comment[0].longTitle))
{
returnCode = true;
}
}
char tempBuffer[33] = {0};
memcpy(tempBuffer, pBanner->comment.shortTitle, 32);
_rName[0] = tempBuffer;
returnCode = true;
}
break;
case CBannerLoaderGC::BANNER_BNR2:
@ -131,10 +123,15 @@ CBannerLoaderGC::GetName(std::string& _rName, DiscIO::IVolume::ECountry language
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
u32 languageID = SConfig::GetInstance().m_InterfaceLanguage;
if (CopyToStringAndCheck(_rName, pBanner->comment[languageID].shortTitle))//language != 0 ? pBanner->comment[0].shortTitle : pBanner->comment[0].longTitle))
for (int i = 0; i < 6; i++)
{
returnCode = true;
char tempBuffer[33] = {0};
memcpy(tempBuffer, pBanner->comment[i].shortTitle, 32);
_rName[i] = tempBuffer;
}
returnCode = true;
}
break;
}
@ -165,9 +162,12 @@ CBannerLoaderGC::GetCompany(std::string& _rCompany)
bool
CBannerLoaderGC::GetDescription(std::string& _rDescription, DiscIO::IVolume::ECountry language)
CBannerLoaderGC::GetDescription(std::string* _rDescription)
{
_rDescription = "";
for (int i = 0; i< 6; i++)
{
_rDescription[i] = "";
}
bool returnCode = false;
@ -182,32 +182,23 @@ CBannerLoaderGC::GetDescription(std::string& _rDescription, DiscIO::IVolume::ECo
case CBannerLoaderGC::BANNER_BNR1:
{
DVDBanner* pBanner = (DVDBanner*)m_pBannerFile;
if (DiscIO::IVolume::COUNTRY_JAP == language)
{
// dunno, if dolphin using unicode, it will be better = =;
if (CopySJISToString(_rDescription, pBanner->comment.comment))
{
returnCode = true;
}
}
else
{
if (CopyToStringAndCheck(_rDescription, pBanner->comment.comment))//language != 0 ? pBanner->comment[0].shortTitle : pBanner->comment[0].longTitle))
{
returnCode = true;
}
}
char tempBuffer[129] = {0};
memcpy(tempBuffer, pBanner->comment.comment, 128);
_rDescription[0] = tempBuffer;
returnCode = true;
}
break;
case CBannerLoaderGC::BANNER_BNR2:
{
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
u32 languageID = SConfig::GetInstance().m_InterfaceLanguage;
if (CopyToStringAndCheck(_rDescription, pBanner->comment[languageID].comment))//language != 0 ? pBanner->comment[0].shortTitle : pBanner->comment[0].longTitle))
for (int i = 0; i< 6; i++)
{
returnCode = true;
char tempBuffer[129] = {0};
memcpy(tempBuffer, pBanner->comment[i].comment, 128);
_rDescription[i] = tempBuffer;
}
returnCode = true;
}
break;
}

View File

@ -35,11 +35,11 @@ class CBannerLoaderGC
virtual bool GetBanner(u32* _pBannerImage);
virtual bool GetName(std::string& _rName, DiscIO::IVolume::ECountry language);
virtual bool GetName(std::string* _rName);
virtual bool GetCompany(std::string& _rCompany);
virtual bool GetDescription(std::string& _rDescription, DiscIO::IVolume::ECountry language);
virtual bool GetDescription(std::string* _rDescription);
private:

View File

@ -115,9 +115,12 @@ CBannerLoaderWii::StupidWideCharToString(u16* _pSrc, size_t _max)
}
bool
CBannerLoaderWii::GetName(std::string& _rName, DiscIO::IVolume::ECountry language)
CBannerLoaderWii::GetName(std::string* _rName)
{
_rName = "no name";
for (int i = 0; i < 6; i++)
{
_rName[i] = "no name";
}
if (!IsValid())
{
@ -126,19 +129,17 @@ CBannerLoaderWii::GetName(std::string& _rName, DiscIO::IVolume::ECountry languag
// find Banner type
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
#ifdef _WIN32
if (DiscIO::IVolume::COUNTRY_JAP == language)
std::string name;
if (CopyUnicodeToString(name, pBanner->m_Comment[0]))
{
return CopyUnicodeToString(_rName, pBanner->m_Comment[0]);
}
else
#endif
{
// very stupid
_rName = StupidWideCharToString(pBanner->m_Comment[0], WII_BANNER_COMMENT_SIZE);
for (int i = 0; i < 6; i++)
{
_rName[i] = name;
}
return true;
}
return true;
return false;
}
@ -151,9 +152,12 @@ CBannerLoaderWii::GetCompany(std::string& _rCompany)
bool
CBannerLoaderWii::GetDescription(std::string& _rDescription, DiscIO::IVolume::ECountry language)
CBannerLoaderWii::GetDescription(std::string* _rDescription)
{
_rDescription = "";
for (int i = 0; i< 6; i++)
{
_rDescription[i] = "";
}
if (!IsValid())
{
@ -162,17 +166,16 @@ CBannerLoaderWii::GetDescription(std::string& _rDescription, DiscIO::IVolume::EC
// find Banner type
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
if (DiscIO::IVolume::COUNTRY_JAP == language)
std::string description;
if (CopyUnicodeToString(description, pBanner->m_Comment[1]))
{
return CopyUnicodeToString(_rDescription, pBanner->m_Comment[1]);
}
else
{
// very stupid
_rDescription = StupidWideCharToString(pBanner->m_Comment[1], WII_BANNER_COMMENT_SIZE);
for (int i = 0; i< 6; i++)
{
_rDescription[i] = description;
}
return true;
}
return false;
}

View File

@ -35,11 +35,11 @@ class CBannerLoaderWii
virtual bool GetBanner(u32* _pBannerImage);
virtual bool GetName(std::string& _rName, DiscIO::IVolume::ECountry language);
virtual bool GetName(std::string* _rName);
virtual bool GetCompany(std::string& _rCompany);
virtual bool GetDescription(std::string& _rDescription, DiscIO::IVolume::ECountry language);
virtual bool GetDescription(std::string* _rDescription);
private: