From a73ad3554c8a33762d97dacd52bf38e888ab8d43 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sun, 18 Dec 2011 21:42:20 -0800 Subject: [PATCH 1/7] add the function to read all unicode gamenames from a wad file --- Source/Core/DiscIO/Src/Volume.h | 1 + Source/Core/DiscIO/Src/VolumeWad.cpp | 45 +++++++++++++++++++++++++++- Source/Core/DiscIO/Src/VolumeWad.h | 1 + 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Source/Core/DiscIO/Src/Volume.h b/Source/Core/DiscIO/Src/Volume.h index f1bb5d3773..ec20e47b6c 100644 --- a/Source/Core/DiscIO/Src/Volume.h +++ b/Source/Core/DiscIO/Src/Volume.h @@ -38,6 +38,7 @@ public: virtual std::string GetUniqueID() const = 0; virtual std::string GetMakerID() const = 0; virtual std::string GetName() const = 0; + virtual bool GetWName(std::vector& _rwNames) const {return false;}; virtual u32 GetFSTSize() const = 0; virtual std::string GetApploaderDate() const = 0; diff --git a/Source/Core/DiscIO/Src/VolumeWad.cpp b/Source/Core/DiscIO/Src/VolumeWad.cpp index 5fd81cca8b..0cdfc85925 100644 --- a/Source/Core/DiscIO/Src/VolumeWad.cpp +++ b/Source/Core/DiscIO/Src/VolumeWad.cpp @@ -107,6 +107,45 @@ bool CVolumeWAD::GetTitleID(u8* _pBuffer) const return true; } +bool CVolumeWAD::GetWName(std::vector& _rwNames) const +{ + u32 footer_size; + + if (!Read(0x1C, 4, (u8*)&footer_size)) + { + return false; + } + //Japanese, English, German, French, Spanish, Italian, Dutch, unknown, unknown, Korean + + // Offset to the english title + for (int i = 0; i < 10; i++) + { + u16 temp[42]; + std::wstring out_temp; + + if (!Read(0x9C + (i*84) + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1 + || !temp[0]) + { + _rwNames.push_back(L""); + continue; + } + for (int i = 0; i < 42; ++i) + { + u16 t = Common::swap16(temp[i]); + if (t == 0 && i > 0) + { + if (out_temp.at(out_temp.size()-1) != ' ') + out_temp.push_back(' '); + } + else + out_temp.push_back(t); + } + + _rwNames.push_back(out_temp); + } + return true; +} + std::string CVolumeWAD::GetName() const { u32 footer_size; @@ -114,9 +153,13 @@ std::string CVolumeWAD::GetName() const if (!Read(0x1C, 4, (u8*)&footer_size)) return ""; + + //Japanese, English, German, French, Spanish, Italian, Dutch, unknown, unknown, Korean + // Offset to the english title char temp[84]; - if (!Read(0xF1 + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1) + if (!Read(0xF1 + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1 || + !Common::swap16(temp[0])) return ""; // Remove the null bytes due to 16bit char length diff --git a/Source/Core/DiscIO/Src/VolumeWad.h b/Source/Core/DiscIO/Src/VolumeWad.h index 06bd772699..956844acd1 100644 --- a/Source/Core/DiscIO/Src/VolumeWad.h +++ b/Source/Core/DiscIO/Src/VolumeWad.h @@ -39,6 +39,7 @@ public: std::string GetUniqueID() const; std::string GetMakerID() const; std::string GetName() const; + bool GetWName(std::vector& _rwNames) const; u32 GetFSTSize() const { return 0; } std::string GetApploaderDate() const { return "0"; } ECountry GetCountry() const; From 7f4efa094ee23b05bb349a333ef55ae0d5276a6c Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sun, 18 Dec 2011 21:56:13 -0800 Subject: [PATCH 2/7] add the function to read the game name and description from the banner as unicode --- Source/Core/DiscIO/Src/BannerLoader.h | 3 +- Source/Core/DiscIO/Src/BannerLoaderWii.cpp | 38 ++++++++++++++++++++++ Source/Core/DiscIO/Src/BannerLoaderWii.h | 3 ++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Source/Core/DiscIO/Src/BannerLoader.h b/Source/Core/DiscIO/Src/BannerLoader.h index 02d60858e4..1fe48dd364 100644 --- a/Source/Core/DiscIO/Src/BannerLoader.h +++ b/Source/Core/DiscIO/Src/BannerLoader.h @@ -39,10 +39,11 @@ class IBannerLoader virtual bool GetBanner(u32* _pBannerImage) = 0; virtual bool GetName(std::string* _rName) = 0; - + virtual bool GetName(std::vector& _rNames) {return false;}; virtual bool GetCompany(std::string& _rCompany) = 0; virtual bool GetDescription(std::string* _rDescription) = 0; + virtual bool GetDescription(std::wstring& _rDescription) {return false;}; protected: diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp index 9c02ef8d08..88a660c739 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp +++ b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp @@ -164,6 +164,26 @@ bool CBannerLoaderWii::GetName(std::string* _rName) return false; } +bool CBannerLoaderWii::GetName(std::vector& _rNames) +{ + if (IsValid()) + { + // find Banner type + SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile; + + std::wstring temp; + for (int i = 0; i < WII_BANNER_COMMENT_SIZE; ++i) + { + temp.push_back(Common::swap16(pBanner->m_Comment[0][i])); + } + temp.push_back('\0'); + _rNames.push_back(temp); + return true; + } + + return false; +} + bool CBannerLoaderWii::GetCompany(std::string& _rCompany) { _rCompany = "N/A"; @@ -190,6 +210,24 @@ bool CBannerLoaderWii::GetDescription(std::string* _rDescription) return false; } +bool CBannerLoaderWii::GetDescription(std::wstring& _rDescription) +{ + if (IsValid()) + { + // find Banner type + SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile; + + std::wstring description; + for (int i = 0; i < WII_BANNER_COMMENT_SIZE; ++i) + description.push_back(Common::swap16(pBanner->m_Comment[1][i])); + + description.push_back('\0'); + _rDescription = description; + return true; + } + return false; +} + void CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height) { for (int y = 0; y < height; y += 4) diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.h b/Source/Core/DiscIO/Src/BannerLoaderWii.h index fb28f5a2e0..bfc87dc19e 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderWii.h +++ b/Source/Core/DiscIO/Src/BannerLoaderWii.h @@ -37,10 +37,13 @@ class CBannerLoaderWii virtual bool GetName(std::string* _rName); + bool GetName(std::vector& _rNames); + virtual bool GetCompany(std::string& _rCompany); virtual bool GetDescription(std::string* _rDescription); + bool GetDescription(std::wstring& _rDescription); private: From de4e3e7462c86c2eac4383d80dd917a81a9a6cfa Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sun, 18 Dec 2011 22:01:46 -0800 Subject: [PATCH 3/7] add wstring name(s)/description to the cachefile, use when available in gamelist and properties window --- Source/Core/Common/Src/ChunkFile.h | 16 ++- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 95 ++++++++-------- Source/Core/DolphinWX/Src/ISOFile.cpp | 100 +++++++++++++++-- Source/Core/DolphinWX/Src/ISOFile.h | 4 + Source/Core/DolphinWX/Src/ISOProperties.cpp | 116 ++++++++++++-------- 5 files changed, 226 insertions(+), 105 deletions(-) diff --git a/Source/Core/Common/Src/ChunkFile.h b/Source/Core/Common/Src/ChunkFile.h index b0662d2517..4ed781dcbd 100644 --- a/Source/Core/Common/Src/ChunkFile.h +++ b/Source/Core/Common/Src/ChunkFile.h @@ -154,7 +154,21 @@ public: } (*ptr) += stringLen; } - + + void Do(std::wstring &x) + { + int stringLen = sizeof(wchar_t)*((int)x.length() + 1); + Do(stringLen); + + switch (mode) { + case MODE_READ: x = (wchar_t*)*ptr; break; + case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; + case MODE_MEASURE: break; + case MODE_VERIFY: _dbg_assert_msg_(COMMON, x == (wchar_t*)*ptr, "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n", x.c_str(), (wchar_t*)*ptr, ptr); break; + } + (*ptr) += stringLen; + } + template void DoArray(T *x, int count) { DoVoid((void *)x, sizeof(T) * count); diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 05f8c8365a..22fdd89a8d 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -465,61 +465,62 @@ void CGameListCtrl::InsertItemInReportView(long _Index) // Set the game's banner in the second column SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex); + + std::wstring wname; + const std::wstring& wdescription = rISOFile.GetDescription(); + std::string company; - if (rISOFile.GetPlatform() != GameListItem::WII_WAD) + // We show the company string on Gamecube only + // On Wii we show the description instead as the company string is empty + if (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC) + company = rISOFile.GetCompany().c_str(); + + switch (rISOFile.GetCountry()) { - std::string company; - - // We show the company string on Gamecube only - // On Wii we show the description instead as the company string is empty - if (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC) - company = rISOFile.GetCompany().c_str(); - - switch (rISOFile.GetCountry()) + case DiscIO::IVolume::COUNTRY_TAIWAN: + case DiscIO::IVolume::COUNTRY_JAPAN: { - case DiscIO::IVolume::COUNTRY_TAIWAN: - case DiscIO::IVolume::COUNTRY_JAPAN: - { - wxString name = wxString(rISOFile.GetName(0).c_str(), SJISConv); - m_gameList.append(StringFromFormat("%s (J)\n", (const char *)name.c_str())); - SetItem(_Index, COLUMN_TITLE, name, -1); - SetItem(_Index, COLUMN_NOTES, wxString(company.size() ? - company.c_str() : rISOFile.GetDescription(0).c_str(), - SJISConv), -1); - } - break; - case DiscIO::IVolume::COUNTRY_USA: - m_gameList.append(StringFromFormat("%s (U)\n", rISOFile.GetName(0).c_str())); - SetItem(_Index, COLUMN_TITLE, - wxString::From8BitData(rISOFile.GetName(0).c_str()), -1); - SetItem(_Index, COLUMN_NOTES, - wxString::From8BitData(company.size() ? - company.c_str() : rISOFile.GetDescription(0).c_str()), -1); - break; - default: - m_gameList.append(StringFromFormat("%s (E)\n", - rISOFile.GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str())); - SetItem(_Index, COLUMN_TITLE, - wxString::From8BitData( - rISOFile.GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str()), - -1); - SetItem(_Index, COLUMN_NOTES, - wxString::From8BitData(company.size() ? - company.c_str() : - rISOFile.GetDescription(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str()), - -1); - break; + rISOFile.GetName(wname, -1); + wxString name = wxString(rISOFile.GetName(0).c_str(), SJISConv); + m_gameList.append(StringFromFormat("%s (J)\n", (const char *)name.c_str())); + SetItem(_Index, COLUMN_TITLE, name, -1); + SetItem(_Index, COLUMN_NOTES, wxString(company.size() ? + company.c_str() : rISOFile.GetDescription(0).c_str(), + SJISConv), -1); } - } - else // It's a Wad file - { - m_gameList.append(StringFromFormat("%s (WAD)\n", rISOFile.GetName(0).c_str())); + break; + case DiscIO::IVolume::COUNTRY_USA: + rISOFile.GetName(wname); SetItem(_Index, COLUMN_TITLE, - wxString(rISOFile.GetName(0).c_str(), SJISConv), -1); + wxString::From8BitData(rISOFile.GetName(0).c_str()), -1); + m_gameList.append(StringFromFormat("%s (U)\n", rISOFile.GetName(0).c_str())); SetItem(_Index, COLUMN_NOTES, - wxString(rISOFile.GetDescription(0).c_str(), SJISConv), -1); + wxString::From8BitData(company.size() ? + company.c_str() : rISOFile.GetDescription(0).c_str()), -1); + break; + default: + rISOFile.GetName(wname, SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage); + + SetItem(_Index, COLUMN_TITLE, + wxString::From8BitData( + rISOFile.GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str()), + -1); + m_gameList.append(StringFromFormat("%s (E)\n", + rISOFile.GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str())); + SetItem(_Index, COLUMN_NOTES, + wxString::From8BitData(company.size() ? + company.c_str() : + rISOFile.GetDescription(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str()), + -1); + break; } + if (wname.length()) + SetItem(_Index, COLUMN_TITLE, wname, -1); + if (wdescription.length()) + SetItem(_Index, COLUMN_NOTES, wdescription, -1); + + #ifndef _WIN32 // Emulation state SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[rISOFile.GetEmuState()]); diff --git a/Source/Core/DolphinWX/Src/ISOFile.cpp b/Source/Core/DolphinWX/Src/ISOFile.cpp index 8505203322..d2fb1098ee 100644 --- a/Source/Core/DolphinWX/Src/ISOFile.cpp +++ b/Source/Core/DolphinWX/Src/ISOFile.cpp @@ -36,7 +36,7 @@ #include "ChunkFile.h" #include "../resources/no_banner.cpp" -#define CACHE_REVISION 0x10B +#define CACHE_REVISION 0x10C #define DVD_BANNER_WIDTH 96 #define DVD_BANNER_HEIGHT 32 @@ -63,18 +63,26 @@ GameListItem::GameListItem(const std::string& _rFileName) if (!DiscIO::IsVolumeWadFile(pVolume)) m_Platform = DiscIO::IsVolumeWiiDisc(pVolume) ? WII_DISC : GAMECUBE_DISC; else + { m_Platform = WII_WAD; + pVolume->GetWName(m_wNames); + } m_Company = "N/A"; + + + m_Name[0] = pVolume->GetName(); + + if(m_Name[0] == "") // Couldn't find the name in the WAD... + { + std::string FileName; + SplitPath(m_FileName, NULL, &FileName, NULL); + m_Name[0] = FileName; // Then just display the filename... Better than something like "No Name" + } + for (int i = 0; i < 6; i++) { - m_Name[i] = pVolume->GetName(); - if(m_Name[i] == "") // Couldn't find the name in the WAD... - { - std::string FileName; - SplitPath(_rFileName, NULL, &FileName, NULL); - m_Name[i] = FileName; // Then just display the filename... Better than something like "No Name" - } + m_Name[i] = m_Name[0]; m_Description[i] = "No Description"; } m_Country = pVolume->GetCountry(); @@ -95,9 +103,13 @@ GameListItem::GameListItem(const std::string& _rFileName) { if (pBannerLoader->IsValid()) { - pBannerLoader->GetName(m_Name); //m_Country == DiscIO::IVolume::COUNTRY_JAP ? 1 : 0); + m_wNames.clear(); + if (!pBannerLoader->GetName(m_wNames)) + pBannerLoader->GetName(m_Name); pBannerLoader->GetCompany(m_Company); - pBannerLoader->GetDescription(m_Description); + if (!pBannerLoader->GetDescription(m_wDescription)) + pBannerLoader->GetDescription(m_Description); + if (pBannerLoader->GetBanner(g_ImageTemp)) { // resize vector to image size @@ -116,6 +128,25 @@ GameListItem::GameListItem(const std::string& _rFileName) delete pFileSystem; } + std::vector::iterator i, end = m_wNames.end(); + std::wstring wFileName; + for (i = m_wNames.begin(); i != end; ++i) + { + if (*i == L"") + { + if (!wFileName.length()) + { + std::string FileName; + SplitPath(m_FileName, NULL, &FileName, NULL); + int length = FileName.length(); + wFileName.reserve(length+1); + for (int i = 0; i < length; ++i) + wFileName.push_back(FileName[i]); + wFileName.push_back(0); + } + *i = wFileName; + } + } delete pVolume; @@ -172,9 +203,31 @@ void GameListItem::DoState(PointerWrap &p) { p.Do(m_Name[0]); p.Do(m_Name[1]); p.Do(m_Name[2]); p.Do(m_Name[3]); p.Do(m_Name[4]); p.Do(m_Name[5]); + + int wNamesSize = m_wNames.size(); + p.Do(wNamesSize); + + if (p.mode == p.MODE_READ) + { + for (int i = 0; i < wNamesSize; ++i) + { + std::wstring temp; + p.Do(temp); + m_wNames.push_back(temp); + } + } + else + { + for (int i = 0; i < wNamesSize; ++i) + { + p.Do(m_wNames[i]); + } + } + p.Do(m_Company); p.Do(m_Description[0]); p.Do(m_Description[1]); p.Do(m_Description[2]); p.Do(m_Description[3]); p.Do(m_Description[4]); p.Do(m_Description[5]); + p.Do(m_wDescription); p.Do(m_UniqueID); p.Do(m_FileSize); p.Do(m_VolumeSize); @@ -211,6 +264,11 @@ const std::string& GameListItem::GetDescription(int index) const return m_Description[0]; } +const std::wstring& GameListItem::GetDescription() const +{ + return m_wDescription; +} + const std::string& GameListItem::GetName(int index) const { if ((index >=0) && (index < 6)) @@ -220,6 +278,28 @@ const std::string& GameListItem::GetName(int index) const return m_Name[0]; } +bool GameListItem::GetName(std::wstring& wName, int index) const +{ + // This function will only succeed for wii discs with banners or WADs + // utilize the same array as for gc discs (-1= Japanese, 0 = English etc + index++; + if ((index >=0) && (index < 10)) + { + if (m_wNames.size() > index) + { + wName = m_wNames[index]; + return true; + } + } + if (m_wNames.size() > 0) + { + wName = m_wNames[0]; + return true; + } + return false; + +} + const std::string GameListItem::GetWiiFSPath() const { DiscIO::IVolume *Iso = DiscIO::CreateVolumeFromFilename(m_FileName); diff --git a/Source/Core/DolphinWX/Src/ISOFile.h b/Source/Core/DolphinWX/Src/ISOFile.h index 35cec18772..fe7d3d6c6c 100644 --- a/Source/Core/DolphinWX/Src/ISOFile.h +++ b/Source/Core/DolphinWX/Src/ISOFile.h @@ -35,8 +35,10 @@ public: bool IsValid() const {return m_Valid;} const std::string& GetFileName() const {return m_FileName;} const std::string& GetName(int index) const; + bool GetName(std::wstring& wName, int index=0) const; const std::string& GetCompany() const {return m_Company;} const std::string& GetDescription(int index) const; + const std::wstring& GetDescription() const; const std::string& GetUniqueID() const {return m_UniqueID;} const std::string GetWiiFSPath() const; DiscIO::IVolume::ECountry GetCountry() const {return m_Country;} @@ -63,8 +65,10 @@ public: private: std::string m_FileName; std::string m_Name[6]; + std::vector m_wNames; std::string m_Company; std::string m_Description[6]; + std::wstring m_wDescription; std::string m_UniqueID; std::string m_issues; diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp index 731cfac932..71771e48a7 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.cpp +++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp @@ -154,7 +154,15 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW } // Disk header and apploader - m_Name->SetValue(wxString(OpenISO->GetName().c_str(), wxConvUTF8)); + + std::wstring wname; + wxString name; + if (OpenGameListItem->GetName(wname)) + name = wname; + else + name = wxString(OpenISO->GetName().c_str(), wxConvUTF8); + m_Name->SetValue(name); + m_GameID->SetValue(wxString(OpenISO->GetUniqueID().c_str(), wxConvUTF8)); switch (OpenISO->GetCountry()) { @@ -1253,53 +1261,67 @@ void CISOProperties::OnChangeBannerLang(wxCommandEvent& event) void CISOProperties::ChangeBannerDetails(int lang) { - if (OpenGameListItem->GetCountry() == DiscIO::IVolume::COUNTRY_JAPAN - || OpenGameListItem->GetCountry() == DiscIO::IVolume::COUNTRY_TAIWAN - || OpenGameListItem->GetPlatform() == GameListItem::WII_WAD) - { + std::wstring wname; + wxString shortName, + comment, + maker; + #ifdef _WIN32 - wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent); - static bool validCP932 = ::IsValidCodePage(932) != 0; - if (validCP932) - { - SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)); - } - else - { - WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932"); - } -#else - wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP)); -#endif - - wxString name = wxString(OpenGameListItem->GetName(0).c_str(), SJISConv); - - // Updates the informations shown in the window - m_ShortName->SetValue(name); - m_Comment->SetValue(wxString(OpenGameListItem->GetDescription(0).c_str(), SJISConv)); - m_Maker->SetValue(wxString(OpenGameListItem->GetCompany().c_str(), SJISConv));//dev too - - std::string filename, extension; - SplitPath(OpenGameListItem->GetFileName(), 0, &filename, &extension); - - // Also sets the window's title - SetTitle(wxString::Format(wxT("%s%s"), - wxString(StringFromFormat("%s%s: %s - ", filename.c_str(), extension.c_str(), OpenGameListItem->GetUniqueID().c_str()).c_str(), *wxConvCurrent).c_str(), - name.c_str())); - } - else // Do the same for PAL/US Games (assuming ISO 8859-1) + wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent); + static bool validCP932 = ::IsValidCodePage(932) != 0; + if (validCP932) { - wxString name = wxString::From8BitData(OpenGameListItem->GetName(lang).c_str()); - - m_ShortName->SetValue(name); - m_Comment->SetValue(wxString::From8BitData(OpenGameListItem->GetDescription(lang).c_str())); - m_Maker->SetValue(wxString::From8BitData(OpenGameListItem->GetCompany().c_str()));//dev too - - std::string filename, extension; - SplitPath(OpenGameListItem->GetFileName(), 0, &filename, &extension); - - SetTitle(wxString::Format(wxT("%s%s"), - wxString::From8BitData(StringFromFormat("%s%s: %s - ", filename.c_str(), extension.c_str(), OpenGameListItem->GetUniqueID().c_str()).c_str()).c_str(), - name.c_str())); + SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)); } + else + { + WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932"); + } +#else + wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP)); +#endif + switch (OpenGameListItem->GetCountry()) + { + case DiscIO::IVolume::COUNTRY_TAIWAN: + case DiscIO::IVolume::COUNTRY_JAPAN: + + if (OpenGameListItem->GetName(wname, -1)) + shortName = wname; + else + shortName = wxString(OpenGameListItem->GetName(0).c_str(), SJISConv); + + if ((comment = OpenGameListItem->GetDescription()).size() == 0) + comment = wxString(OpenGameListItem->GetDescription(0).c_str(), SJISConv); + maker = wxString(OpenGameListItem->GetCompany().c_str(), SJISConv); + break; + case DiscIO::IVolume::COUNTRY_USA: + if (OpenGameListItem->GetName(wname)) + shortName = wname; + else + shortName = wxString::From8BitData(OpenGameListItem->GetName(0).c_str()); + if ((comment = OpenGameListItem->GetDescription()).size() == 0) + comment = wxString(OpenGameListItem->GetDescription(0).c_str(), SJISConv); + maker = wxString::From8BitData(OpenGameListItem->GetCompany().c_str()); + break; + default: + if (OpenGameListItem->GetName(wname, lang)) + shortName = wname; + else + shortName = wxString::From8BitData(OpenGameListItem->GetName(lang).c_str()); + if ((comment = OpenGameListItem->GetDescription()).size() == 0) + comment = wxString(OpenGameListItem->GetDescription(lang).c_str(), SJISConv); + maker = wxString::From8BitData(OpenGameListItem->GetCompany().c_str()); + break; + + break; + } + // Updates the informations shown in the window + m_ShortName->SetValue(shortName); + m_Comment->SetValue(comment); + m_Maker->SetValue(maker);//dev too + + std::string filename, extension; + SplitPath(OpenGameListItem->GetFileName(), 0, &filename, &extension); + // Also sets the window's title + SetTitle(wxString(StringFromFormat("%s%s: %s - ", filename.c_str(), extension.c_str(), OpenGameListItem->GetUniqueID().c_str()).c_str(), *wxConvCurrent)+shortName); } From 9ddb67d4a96a53698a71a7f3c8936c2437dd81de Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Tue, 20 Dec 2011 01:35:12 -0800 Subject: [PATCH 4/7] fix shift-jis conversion on linux, and check for the codepage on windows in the memorycard manager like everywhere else --- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 4 +++- Source/Core/DolphinWX/Src/ISOProperties.cpp | 6 ++++-- Source/Core/DolphinWX/Src/LogWindow.cpp | 7 ++++--- Source/Core/DolphinWX/Src/MemcardManager.cpp | 16 ++++++++++++++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 22fdd89a8d..53485199e3 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -446,7 +446,9 @@ void CGameListCtrl::InsertItemInReportView(long _Index) WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932"); } #else - wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP)); + // on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) + // it returns CP-932, in order to use iconv we need to use CP932 + wxCSConv SJISConv(L"CP932"); #endif GameListItem& rISOFile = *m_ISOFiles[_Index]; diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp index 71771e48a7..40c78bba4e 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.cpp +++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp @@ -1278,8 +1278,10 @@ void CISOProperties::ChangeBannerDetails(int lang) WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932"); } #else - wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP)); -#endif + // on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) + // it returns CP-932, in order to use iconv we need to use CP932 + wxCSConv SJISConv(L"CP932"); +#endif switch (OpenGameListItem->GetCountry()) { case DiscIO::IVolume::COUNTRY_TAIWAN: diff --git a/Source/Core/DolphinWX/Src/LogWindow.cpp b/Source/Core/DolphinWX/Src/LogWindow.cpp index 94b542eb2f..3942988efe 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.cpp +++ b/Source/Core/DolphinWX/Src/LogWindow.cpp @@ -41,7 +41,7 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos, , x(0), y(0), winpos(0) , Parent(parent) , m_LogAccess(true) , m_Log(NULL), m_cmdline(NULL), m_FontChoice(NULL) - , m_SJISConv(wxT("")) + , m_SJISConv(*(wxCSConv*)wxConvCurrent) { #ifdef _WIN32 static bool validCP932 = ::IsValidCodePage(932) != 0; @@ -52,10 +52,11 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos, else { WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932"); - m_SJISConv = *(wxCSConv*)wxConvCurrent; } #else - m_SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP)); + // on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) + // it returns CP-932, in order to use iconv we need to use CP932 + m_SJISConv = wxCSConv(L"CP932"); #endif m_LogManager = LogManager::GetInstance(); diff --git a/Source/Core/DolphinWX/Src/MemcardManager.cpp b/Source/Core/DolphinWX/Src/MemcardManager.cpp index 7eb0243e2c..68ae0f9ff2 100644 --- a/Source/Core/DolphinWX/Src/MemcardManager.cpp +++ b/Source/Core/DolphinWX/Src/MemcardManager.cpp @@ -701,10 +701,22 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card) if (!memoryCard[card]->DEntry_Comment2(j, comment)) comment[0]=0; bool ascii = memoryCard[card]->IsAsciiEncoding(); + #ifdef _WIN32 - wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)); + wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent); + static bool validCP932 = ::IsValidCodePage(932) != 0; + if (validCP932) + { + SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)); + } + else + { + WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932"); + } #else - wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP)); + // on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) + // it returns CP-932, in order to use iconv we need to use CP932 + wxCSConv SJISConv(L"CP932"); #endif wxTitle = wxString(title, ascii ? *wxConvCurrent : SJISConv); wxComment = wxString(comment, ascii ? *wxConvCurrent : SJISConv); From e4c4602d9e2004c22cee9d72c2607c688d6d817b Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Tue, 20 Dec 2011 02:10:40 -0800 Subject: [PATCH 5/7] use windows-1252 for gamename/description, fixes copyright/tm symbol in the gamelist & isoproperties --- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 15 ++++++++------- Source/Core/DolphinWX/Src/ISOProperties.cpp | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 53485199e3..35b664a22d 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -434,6 +434,7 @@ void CGameListCtrl::InsertItemInReportView(long _Index) // company: 0x007030 int ImageIndex = -1; + wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252)); #ifdef _WIN32 wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent); static bool validCP932 = ::IsValidCodePage(932) != 0; @@ -494,25 +495,25 @@ void CGameListCtrl::InsertItemInReportView(long _Index) case DiscIO::IVolume::COUNTRY_USA: rISOFile.GetName(wname); SetItem(_Index, COLUMN_TITLE, - wxString::From8BitData(rISOFile.GetName(0).c_str()), -1); + wxString(rISOFile.GetName(0).c_str(), WindowsCP1252), -1); m_gameList.append(StringFromFormat("%s (U)\n", rISOFile.GetName(0).c_str())); SetItem(_Index, COLUMN_NOTES, - wxString::From8BitData(company.size() ? - company.c_str() : rISOFile.GetDescription(0).c_str()), -1); + wxString(company.size() ? + company.c_str() : rISOFile.GetDescription(0).c_str(), WindowsCP1252), -1); break; default: rISOFile.GetName(wname, SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage); SetItem(_Index, COLUMN_TITLE, - wxString::From8BitData( - rISOFile.GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str()), + wxString( + rISOFile.GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str(), WindowsCP1252), -1); m_gameList.append(StringFromFormat("%s (E)\n", rISOFile.GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str())); SetItem(_Index, COLUMN_NOTES, - wxString::From8BitData(company.size() ? + wxString(company.size() ? company.c_str() : - rISOFile.GetDescription(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str()), + rISOFile.GetDescription(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str(), WindowsCP1252), -1); break; } diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp index 40c78bba4e..51bbdcda30 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.cpp +++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp @@ -1265,7 +1265,8 @@ void CISOProperties::ChangeBannerDetails(int lang) wxString shortName, comment, maker; - + + wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252)); #ifdef _WIN32 wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent); static bool validCP932 = ::IsValidCodePage(932) != 0; @@ -1300,19 +1301,19 @@ void CISOProperties::ChangeBannerDetails(int lang) if (OpenGameListItem->GetName(wname)) shortName = wname; else - shortName = wxString::From8BitData(OpenGameListItem->GetName(0).c_str()); + shortName = wxString(OpenGameListItem->GetName(0).c_str(), WindowsCP1252); if ((comment = OpenGameListItem->GetDescription()).size() == 0) - comment = wxString(OpenGameListItem->GetDescription(0).c_str(), SJISConv); - maker = wxString::From8BitData(OpenGameListItem->GetCompany().c_str()); + comment = wxString(OpenGameListItem->GetDescription(0).c_str(), WindowsCP1252); + maker = wxString(OpenGameListItem->GetCompany().c_str(), WindowsCP1252); break; default: if (OpenGameListItem->GetName(wname, lang)) shortName = wname; else - shortName = wxString::From8BitData(OpenGameListItem->GetName(lang).c_str()); + shortName = wxString(OpenGameListItem->GetName(lang).c_str(), WindowsCP1252); if ((comment = OpenGameListItem->GetDescription()).size() == 0) - comment = wxString(OpenGameListItem->GetDescription(lang).c_str(), SJISConv); - maker = wxString::From8BitData(OpenGameListItem->GetCompany().c_str()); + comment = wxString(OpenGameListItem->GetDescription(lang).c_str(), WindowsCP1252); + maker = wxString(OpenGameListItem->GetCompany().c_str(), WindowsCP1252); break; break; From 8f6c25a5aa27f0c8df1d12a79f3082eae7c6c092 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Tue, 20 Dec 2011 02:19:46 -0800 Subject: [PATCH 6/7] cleanup: merge handling of ntsc/pal games in gamelist/isoproperties --- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 27 +++++++++------------ Source/Core/DolphinWX/Src/ISOProperties.cpp | 15 +++--------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 35b664a22d..eb510fd37e 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -434,7 +434,6 @@ void CGameListCtrl::InsertItemInReportView(long _Index) // company: 0x007030 int ImageIndex = -1; - wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252)); #ifdef _WIN32 wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent); static bool validCP932 = ::IsValidCodePage(932) != 0; @@ -477,7 +476,7 @@ void CGameListCtrl::InsertItemInReportView(long _Index) // On Wii we show the description instead as the company string is empty if (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC) company = rISOFile.GetCompany().c_str(); - + int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage; switch (rISOFile.GetCountry()) { case DiscIO::IVolume::COUNTRY_TAIWAN: @@ -493,28 +492,24 @@ void CGameListCtrl::InsertItemInReportView(long _Index) } break; case DiscIO::IVolume::COUNTRY_USA: - rISOFile.GetName(wname); - SetItem(_Index, COLUMN_TITLE, - wxString(rISOFile.GetName(0).c_str(), WindowsCP1252), -1); - m_gameList.append(StringFromFormat("%s (U)\n", rISOFile.GetName(0).c_str())); - SetItem(_Index, COLUMN_NOTES, - wxString(company.size() ? - company.c_str() : rISOFile.GetDescription(0).c_str(), WindowsCP1252), -1); - break; - default: - rISOFile.GetName(wname, SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage); + SelectedLanguage = 0; + default: + { + wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252)); + rISOFile.GetName(wname, SelectedLanguage); SetItem(_Index, COLUMN_TITLE, wxString( - rISOFile.GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str(), WindowsCP1252), + rISOFile.GetName(SelectedLanguage).c_str(), WindowsCP1252), -1); - m_gameList.append(StringFromFormat("%s (E)\n", - rISOFile.GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str())); + m_gameList.append(StringFromFormat("%s (%c)\n", + rISOFile.GetName(SelectedLanguage).c_str(), (rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA)?'U':'E')); SetItem(_Index, COLUMN_NOTES, wxString(company.size() ? company.c_str() : - rISOFile.GetDescription(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage).c_str(), WindowsCP1252), + rISOFile.GetDescription(SelectedLanguage).c_str(), WindowsCP1252), -1); + } break; } diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp index 51bbdcda30..85b95f3cb4 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.cpp +++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp @@ -1266,7 +1266,6 @@ void CISOProperties::ChangeBannerDetails(int lang) comment, maker; - wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252)); #ifdef _WIN32 wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent); static bool validCP932 = ::IsValidCodePage(932) != 0; @@ -1298,15 +1297,10 @@ void CISOProperties::ChangeBannerDetails(int lang) maker = wxString(OpenGameListItem->GetCompany().c_str(), SJISConv); break; case DiscIO::IVolume::COUNTRY_USA: - if (OpenGameListItem->GetName(wname)) - shortName = wname; - else - shortName = wxString(OpenGameListItem->GetName(0).c_str(), WindowsCP1252); - if ((comment = OpenGameListItem->GetDescription()).size() == 0) - comment = wxString(OpenGameListItem->GetDescription(0).c_str(), WindowsCP1252); - maker = wxString(OpenGameListItem->GetCompany().c_str(), WindowsCP1252); - break; + lang = 0; default: + { + wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252)); if (OpenGameListItem->GetName(wname, lang)) shortName = wname; else @@ -1314,8 +1308,7 @@ void CISOProperties::ChangeBannerDetails(int lang) if ((comment = OpenGameListItem->GetDescription()).size() == 0) comment = wxString(OpenGameListItem->GetDescription(lang).c_str(), WindowsCP1252); maker = wxString(OpenGameListItem->GetCompany().c_str(), WindowsCP1252); - break; - + } break; } // Updates the informations shown in the window From 825e2ea4df8315e488f1a94311e4ecf50b846329 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Thu, 22 Dec 2011 14:28:12 -0800 Subject: [PATCH 7/7] fix an ascii/wxstring in gamelistctrl, replace fromascii("") with wxemptystring, don't push_back 0 at the end of wstrings --- Source/Core/DiscIO/Src/BannerLoaderWii.cpp | 4 +--- Source/Core/DolphinWX/Src/Debugger/DSPRegisterView.cpp | 4 ++-- Source/Core/DolphinWX/Src/Debugger/RegisterView.cpp | 6 +++--- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp index 88a660c739..ab66a346d4 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp +++ b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp @@ -176,7 +176,6 @@ bool CBannerLoaderWii::GetName(std::vector& _rNames) { temp.push_back(Common::swap16(pBanner->m_Comment[0][i])); } - temp.push_back('\0'); _rNames.push_back(temp); return true; } @@ -220,8 +219,7 @@ bool CBannerLoaderWii::GetDescription(std::wstring& _rDescription) std::wstring description; for (int i = 0; i < WII_BANNER_COMMENT_SIZE; ++i) description.push_back(Common::swap16(pBanner->m_Comment[1][i])); - - description.push_back('\0'); + _rDescription = description; return true; } diff --git a/Source/Core/DolphinWX/Src/Debugger/DSPRegisterView.cpp b/Source/Core/DolphinWX/Src/Debugger/DSPRegisterView.cpp index 863d09436c..ca275ba66a 100644 --- a/Source/Core/DolphinWX/Src/Debugger/DSPRegisterView.cpp +++ b/Source/Core/DolphinWX/Src/Debugger/DSPRegisterView.cpp @@ -27,10 +27,10 @@ wxString CDSPRegTable::GetValue(int row, int col) { case 0: return wxString::FromAscii(pdregname(row)); case 1: return wxString::Format(wxT("0x%04x"), DSPCore_ReadRegister(row)); - default: return wxString::FromAscii(""); + default: return wxEmptyString; } } - return wxString::FromAscii(""); + return wxEmptyString; } void CDSPRegTable::SetValue(int, int, const wxString &) diff --git a/Source/Core/DolphinWX/Src/Debugger/RegisterView.cpp b/Source/Core/DolphinWX/Src/Debugger/RegisterView.cpp index ecd706cf9a..c4a30fd522 100644 --- a/Source/Core/DolphinWX/Src/Debugger/RegisterView.cpp +++ b/Source/Core/DolphinWX/Src/Debugger/RegisterView.cpp @@ -56,18 +56,18 @@ wxString CRegTable::GetValue(int row, int col) case 2: return wxString::FromAscii(GetFPRName(row)); case 3: return wxString::Format(wxT("%016llx"), riPS0(row)); case 4: return wxString::Format(wxT("%016llx"), riPS1(row)); - default: return wxString::FromAscii(""); + default: return wxEmptyString; } } else { if (row - 32 < NUM_SPECIALS) { switch (col) { case 0: return wxString::FromAscii(special_reg_names[row - 32]); case 1: return wxString::Format(wxT("%08x"), GetSpecialRegValue(row - 32)); - default: return wxString::FromAscii(""); + default: return wxEmptyString; } } } - return wxString::FromAscii(""); + return wxEmptyString; } static void SetSpecialRegValue(int reg, u32 value) { diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index eb510fd37e..9dbbf656e9 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -1179,7 +1179,7 @@ void CGameListCtrl::CompressSelection(bool _compress) if (wxFileExists(wxString::FromAscii(OutputFileName.c_str())) && wxMessageBox( wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"), - OutputFileName.c_str()), + wxString(OutputFileName.c_str(), *wxConvCurrent).c_str()), _("Confirm File Overwrite"), wxYES_NO) == wxNO) continue; @@ -1207,7 +1207,7 @@ void CGameListCtrl::CompressSelection(bool _compress) if (wxFileExists(wxString::FromAscii(OutputFileName.c_str())) && wxMessageBox( wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"), - OutputFileName.c_str()), + wxString(OutputFileName.c_str(), *wxConvCurrent).c_str()), _("Confirm File Overwrite"), wxYES_NO) == wxNO) continue;