mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 15:31:17 +01:00
UI: makes dolphin displays japanese region games' names and their descriptions.
only work on windows and asian language support installed. (without fonts and codepages, we can not display text, I'm sure). BTW, I only test on GC games, I've no Wii games now, and .\User\Cache directory must be cleared to work (delete all cached files) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1972 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
56ee6e5497
commit
8f4d58e082
@ -23,6 +23,11 @@
|
||||
#include "VolumeCreator.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
// HyperIris: dunno if this suitable, may be need move.
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
bool IBannerLoader::CopyToStringAndCheck(std::string& _rDestination, const char* _src)
|
||||
@ -89,6 +94,89 @@ 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, 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, 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;
|
||||
#ifdef WIN32
|
||||
if (_src)
|
||||
{
|
||||
u32 ansiNameSize = WideCharToMultiByte(CP_ACP, 0,
|
||||
(LPCWSTR)_src, wcslen((const wchar_t*)_src),
|
||||
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)_src, wcslen((const wchar_t*)_src),
|
||||
pAnsiStrBuffer, ansiNameSize, NULL, NULL))
|
||||
{
|
||||
_rDestination = pAnsiStrBuffer;
|
||||
returnCode = true;
|
||||
}
|
||||
delete pAnsiStrBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
// not implement other than windows
|
||||
_rDestination = _src;
|
||||
returnCode = true;
|
||||
#endif
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
|
||||
IBannerLoader* CreateBannerLoader(DiscIO::IFileSystem& _rFileSystem)
|
||||
{
|
||||
|
@ -38,16 +38,18 @@ class IBannerLoader
|
||||
|
||||
virtual bool GetBanner(u32* _pBannerImage) = 0;
|
||||
|
||||
virtual bool GetName(std::string& _rName, int language) = 0;
|
||||
virtual bool GetName(std::string& _rName, DiscIO::IVolume::ECountry language) = 0;
|
||||
|
||||
virtual bool GetCompany(std::string& _rCompany) = 0;
|
||||
|
||||
virtual bool GetDescription(std::string& _rDescription) = 0;
|
||||
virtual bool GetDescription(std::string& _rDescription, DiscIO::IVolume::ECountry language) = 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);
|
||||
};
|
||||
|
||||
IBannerLoader* CreateBannerLoader(DiscIO::IFileSystem& _rFileSystem);
|
||||
|
@ -47,16 +47,22 @@ CBannerLoaderGC::CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem)
|
||||
if (FileSize > 0)
|
||||
{
|
||||
m_pBannerFile = new u8[FileSize];
|
||||
_rFileSystem.ReadFile("opening.bnr", m_pBannerFile, FileSize);
|
||||
m_IsValid = true;
|
||||
if (m_pBannerFile)
|
||||
{
|
||||
_rFileSystem.ReadFile("opening.bnr", m_pBannerFile, FileSize);
|
||||
m_IsValid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CBannerLoaderGC::~CBannerLoaderGC()
|
||||
{
|
||||
delete [] m_pBannerFile;
|
||||
m_pBannerFile = NULL;
|
||||
if (m_pBannerFile)
|
||||
{
|
||||
delete [] m_pBannerFile;
|
||||
m_pBannerFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -83,23 +89,38 @@ CBannerLoaderGC::GetBanner(u32* _pBannerImage)
|
||||
|
||||
|
||||
bool
|
||||
CBannerLoaderGC::GetName(std::string& _rName, int language)
|
||||
CBannerLoaderGC::GetName(std::string& _rName, DiscIO::IVolume::ECountry language)
|
||||
{
|
||||
_rName = "invalid image";
|
||||
_rName = "no name";
|
||||
|
||||
bool returnCode = false;
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
|
||||
|
||||
if (!CopyToStringAndCheck(_rName, language != 0 ? pBanner->comment[0].shortTitle : pBanner->comment[0].longTitle))
|
||||
// find Banner type
|
||||
if (DiscIO::IVolume::COUNTRY_JAP == language)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
DVDBanner* pBanner = (DVDBanner*)m_pBannerFile;
|
||||
|
||||
return(true);
|
||||
// dunno, if dolphin using unicode, it will be better = =;
|
||||
if (CopySJISToString(_rName, pBanner->comment.shortTitle))
|
||||
{
|
||||
returnCode = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
|
||||
|
||||
if (CopyToStringAndCheck(_rName, pBanner->comment[0].shortTitle))//language != 0 ? pBanner->comment[0].shortTitle : pBanner->comment[0].longTitle))
|
||||
{
|
||||
returnCode = true;
|
||||
}
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
|
||||
@ -125,23 +146,38 @@ CBannerLoaderGC::GetCompany(std::string& _rCompany)
|
||||
|
||||
|
||||
bool
|
||||
CBannerLoaderGC::GetDescription(std::string& _rDescription)
|
||||
CBannerLoaderGC::GetDescription(std::string& _rDescription, DiscIO::IVolume::ECountry language)
|
||||
{
|
||||
_rDescription = "invalid images";
|
||||
_rDescription = "";
|
||||
|
||||
bool returnCode = false;
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
|
||||
|
||||
if (!CopyToStringAndCheck(_rDescription, pBanner->comment[0].comment))
|
||||
// find Banner type
|
||||
if (DiscIO::IVolume::COUNTRY_JAP == language)
|
||||
{
|
||||
_rDescription = "";
|
||||
}
|
||||
DVDBanner* pBanner = (DVDBanner*)m_pBannerFile;
|
||||
|
||||
return(true);
|
||||
// dunno, if dolphin using unicode, it will be better = =;
|
||||
if (CopySJISToString(_rDescription, pBanner->comment.comment))
|
||||
{
|
||||
returnCode = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
|
||||
|
||||
if (CopyToStringAndCheck(_rDescription, pBanner->comment[0].comment))
|
||||
{
|
||||
returnCode = true;
|
||||
}
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,11 +35,11 @@ class CBannerLoaderGC
|
||||
|
||||
virtual bool GetBanner(u32* _pBannerImage);
|
||||
|
||||
virtual bool GetName(std::string& _rName, int language);
|
||||
virtual bool GetName(std::string& _rName, DiscIO::IVolume::ECountry language);
|
||||
|
||||
virtual bool GetCompany(std::string& _rCompany);
|
||||
|
||||
virtual bool GetDescription(std::string& _rDescription);
|
||||
virtual bool GetDescription(std::string& _rDescription, DiscIO::IVolume::ECountry language);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -115,17 +115,27 @@ CBannerLoaderWii::StupidWideCharToString(u16* _pSrc, size_t _max)
|
||||
}
|
||||
|
||||
bool
|
||||
CBannerLoaderWii::GetName(std::string& _rName, int language)
|
||||
CBannerLoaderWii::GetName(std::string& _rName, DiscIO::IVolume::ECountry language)
|
||||
{
|
||||
if (IsValid())
|
||||
{
|
||||
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
|
||||
_rName = "no name";
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// find Banner type
|
||||
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
|
||||
if (DiscIO::IVolume::COUNTRY_JAP == language)
|
||||
{
|
||||
return CopyUnicodeToString(_rName, pBanner->m_Comment[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// very stupid
|
||||
_rName = StupidWideCharToString(pBanner->m_Comment[0], WII_BANNER_COMMENT_SIZE);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -139,12 +149,23 @@ CBannerLoaderWii::GetCompany(std::string& _rCompany)
|
||||
|
||||
|
||||
bool
|
||||
CBannerLoaderWii::GetDescription(std::string& _rDescription)
|
||||
CBannerLoaderWii::GetDescription(std::string& _rDescription, DiscIO::IVolume::ECountry language)
|
||||
{
|
||||
if (IsValid())
|
||||
{
|
||||
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
|
||||
_rDescription = "";
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// find Banner type
|
||||
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
|
||||
if (DiscIO::IVolume::COUNTRY_JAP == language)
|
||||
{
|
||||
return CopyUnicodeToString(_rDescription, pBanner->m_Comment[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// very stupid
|
||||
_rDescription = StupidWideCharToString(pBanner->m_Comment[1], WII_BANNER_COMMENT_SIZE);
|
||||
return true;
|
||||
|
@ -35,11 +35,11 @@ class CBannerLoaderWii
|
||||
|
||||
virtual bool GetBanner(u32* _pBannerImage);
|
||||
|
||||
virtual bool GetName(std::string& _rName, int language);
|
||||
virtual bool GetName(std::string& _rName, DiscIO::IVolume::ECountry language);
|
||||
|
||||
virtual bool GetCompany(std::string& _rCompany);
|
||||
|
||||
virtual bool GetDescription(std::string& _rDescription);
|
||||
virtual bool GetDescription(std::string& _rDescription, DiscIO::IVolume::ECountry language);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -77,9 +77,9 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
||||
{
|
||||
if (pBannerLoader->IsValid())
|
||||
{
|
||||
pBannerLoader->GetName(m_Name, 0); //m_Country == DiscIO::IVolume::COUNTRY_JAP ? 1 : 0);
|
||||
pBannerLoader->GetName(m_Name, m_Country); //m_Country == DiscIO::IVolume::COUNTRY_JAP ? 1 : 0);
|
||||
pBannerLoader->GetCompany(m_Company);
|
||||
pBannerLoader->GetDescription(m_Description);
|
||||
pBannerLoader->GetDescription(m_Description, m_Country);
|
||||
if (pBannerLoader->GetBanner(g_ImageTemp))
|
||||
{
|
||||
m_ImageSize = DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT * 3;
|
||||
|
Loading…
x
Reference in New Issue
Block a user