Eliminate the wstring game name.
Some cleanup throughout related code. (try to make logic in ISOFile understandable by a human) Encode strings in UTF-8 rather than somehow trying to determine the encoding in the GUI code. Non-windows OSes temporarily broken.
This commit is contained in:
parent
2b1af36900
commit
6c8adf6130
|
@ -395,17 +395,41 @@ std::string UTF16ToUTF8(const std::wstring& input)
|
|||
return output;
|
||||
}
|
||||
|
||||
std::wstring UTF8ToUTF16(const std::string& input)
|
||||
std::wstring CPToUTF16(u32 code_page, const std::string& input)
|
||||
{
|
||||
auto const size = MultiByteToWideChar(CP_UTF8, 0, input.data(), input.size(), nullptr, 0);
|
||||
auto const size = MultiByteToWideChar(code_page, 0, input.data(), input.size(), nullptr, 0);
|
||||
|
||||
std::wstring output;
|
||||
output.resize(size);
|
||||
|
||||
if (size != MultiByteToWideChar(CP_UTF8, 0, input.data(), input.size(), &output[0], output.size()))
|
||||
if (size != MultiByteToWideChar(code_page, 0, input.data(), input.size(), &output[0], output.size()))
|
||||
output.clear();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
std::wstring UTF8ToUTF16(const std::string& input)
|
||||
{
|
||||
return CPToUTF16(CP_UTF8, input);
|
||||
}
|
||||
|
||||
std::string SHIFTJISToUTF8(const std::string& input)
|
||||
{
|
||||
return UTF16ToUTF8(CPToUTF16(932, input));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
std::string UTF16ToUTF8(const std::wstring& input)
|
||||
{
|
||||
// TODO: implement
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string SHIFTJISToUTF8(const std::string& input)
|
||||
{
|
||||
// TODO: implement
|
||||
return std::string();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -97,9 +97,11 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
|
|||
std::string UriDecode(const std::string & sSrc);
|
||||
std::string UriEncode(const std::string & sSrc);
|
||||
|
||||
std::string SHIFTJISToUTF8(const std::string& str);
|
||||
std::string UTF16ToUTF8(const std::wstring& str);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
std::string UTF16ToUTF8(const std::wstring& str);
|
||||
std::wstring UTF8ToUTF16(const std::string& str);
|
||||
|
||||
#ifdef _UNICODE
|
||||
|
|
|
@ -24,58 +24,6 @@
|
|||
|
||||
namespace DiscIO
|
||||
{
|
||||
void IBannerLoader::CopyToStringAndCheck(std::string& _rDestination, const char* _src)
|
||||
{
|
||||
static bool bValidChars[256];
|
||||
static bool bInitialized = false;
|
||||
|
||||
if (!bInitialized)
|
||||
{
|
||||
for (int i = 0; i < 0x20; i++)
|
||||
{
|
||||
bValidChars[i] = false;
|
||||
}
|
||||
|
||||
// generate valid chars
|
||||
for (int i = 0x20; i < 256; i++)
|
||||
{
|
||||
bValidChars[i] = true;
|
||||
}
|
||||
|
||||
bValidChars[0x0a] = true;
|
||||
//bValidChars[0xa9] = true;
|
||||
//bValidChars[0xe9] = true;
|
||||
|
||||
bInitialized = true;
|
||||
}
|
||||
|
||||
char destBuffer[2048] = {0};
|
||||
char* dest = destBuffer;
|
||||
const char* src = _src;
|
||||
|
||||
// copy the string and check for "unknown" characters
|
||||
while (*src != 0x00)
|
||||
{
|
||||
u8 c = *src;
|
||||
|
||||
if (c == 0x0a){c = 0x20;}
|
||||
|
||||
if (bValidChars[c] == false)
|
||||
{
|
||||
src++;
|
||||
continue;
|
||||
}
|
||||
|
||||
*dest = c;
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
|
||||
// finalize the string
|
||||
*dest = 0x00;
|
||||
|
||||
_rDestination = destBuffer;
|
||||
}
|
||||
|
||||
IBannerLoader* CreateBannerLoader(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume *pVolume)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#ifndef _BANNER_LOADER_H_
|
||||
#define _BANNER_LOADER_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "Filesystem.h"
|
||||
|
||||
namespace DiscIO
|
||||
|
@ -38,15 +41,9 @@ class IBannerLoader
|
|||
|
||||
virtual bool GetBanner(u32* _pBannerImage) = 0;
|
||||
|
||||
virtual bool GetName(std::string* _rName) = 0;
|
||||
virtual bool GetName(std::vector<std::wstring>& _rNames) {return false;};
|
||||
virtual bool GetCompany(std::string& _rCompany) = 0;
|
||||
|
||||
virtual bool GetDescription(std::string* _rDescription) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
void CopyToStringAndCheck(std::string& _rDestination, const char* _src);
|
||||
virtual std::vector<std::string> GetNames() = 0;
|
||||
virtual std::string GetCompany() = 0;
|
||||
virtual std::vector<std::string> GetDescriptions() = 0;
|
||||
|
||||
private:
|
||||
u16 swap16(u16 data)
|
||||
|
|
|
@ -29,7 +29,7 @@ CBannerLoaderGC::CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem)
|
|||
{
|
||||
// load the opening.bnr
|
||||
size_t FileSize = (size_t) _rFileSystem.GetFileSize("opening.bnr");
|
||||
if (FileSize == sizeof(DVDBanner) || FileSize == sizeof(DVDBanner2))
|
||||
if (FileSize == BNR1_SIZE || FileSize == BNR2_SIZE)
|
||||
{
|
||||
m_pBannerFile = new u8[FileSize];
|
||||
if (m_pBannerFile)
|
||||
|
@ -62,7 +62,6 @@ bool CBannerLoaderGC::IsValid()
|
|||
return m_IsValid;
|
||||
}
|
||||
|
||||
|
||||
bool CBannerLoaderGC::GetBanner(u32* _pBannerImage)
|
||||
{
|
||||
if (!IsValid())
|
||||
|
@ -70,132 +69,111 @@ bool CBannerLoaderGC::GetBanner(u32* _pBannerImage)
|
|||
return false;
|
||||
}
|
||||
|
||||
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
|
||||
auto const pBanner = (DVDBanner*)m_pBannerFile;
|
||||
decode5A3image(_pBannerImage, pBanner->image, DVD_BANNER_WIDTH, DVD_BANNER_HEIGHT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CBannerLoaderGC::GetName(std::string _rName[])
|
||||
std::vector<std::string> CBannerLoaderGC::GetNames()
|
||||
{
|
||||
bool returnCode = false;
|
||||
std::vector<std::string> names;
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
return false;
|
||||
return names;
|
||||
}
|
||||
|
||||
u32 name_count = 0;
|
||||
|
||||
// find Banner type
|
||||
switch (m_BNRType)
|
||||
{
|
||||
case CBannerLoaderGC::BANNER_BNR1:
|
||||
{
|
||||
DVDBanner* pBanner = (DVDBanner*)m_pBannerFile;
|
||||
char tempBuffer[65] = {0};
|
||||
if (pBanner->comment.longTitle[0])
|
||||
{
|
||||
memcpy(tempBuffer, pBanner->comment.longTitle, 64);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(tempBuffer, pBanner->comment.shortTitle, 32);
|
||||
}
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
CopyToStringAndCheck(_rName[i], tempBuffer);
|
||||
}
|
||||
returnCode = true;
|
||||
}
|
||||
name_count = 1;
|
||||
break;
|
||||
|
||||
case CBannerLoaderGC::BANNER_BNR2:
|
||||
{
|
||||
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
char tempBuffer[65] = {0};
|
||||
if (pBanner->comment[i].longTitle[0])
|
||||
{
|
||||
memcpy(tempBuffer, pBanner->comment[i].longTitle, 64);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(tempBuffer, pBanner->comment[i].shortTitle, 32);
|
||||
}
|
||||
CopyToStringAndCheck(_rName[i], tempBuffer);
|
||||
}
|
||||
|
||||
returnCode = true;
|
||||
|
||||
}
|
||||
name_count = 6;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
auto const banner = reinterpret_cast<const DVDBanner*>(m_pBannerFile);
|
||||
|
||||
for (int i = 0; i != name_count; ++i)
|
||||
{
|
||||
auto& comment = banner->comment[i];
|
||||
|
||||
if (comment.longTitle[0])
|
||||
{
|
||||
auto& data = comment.longTitle;
|
||||
names.push_back(GetDecodedString(data));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& data = comment.shortTitle;
|
||||
names.push_back(GetDecodedString(data));
|
||||
}
|
||||
}
|
||||
|
||||
return returnCode;
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
bool CBannerLoaderGC::GetCompany(std::string& _rCompany)
|
||||
std::string CBannerLoaderGC::GetCompany()
|
||||
{
|
||||
_rCompany = "N/A";
|
||||
std::string company;
|
||||
|
||||
if (!IsValid())
|
||||
if (IsValid())
|
||||
{
|
||||
return(false);
|
||||
auto const pBanner = (DVDBanner*)m_pBannerFile;
|
||||
auto& data = pBanner->comment[0].shortMaker;
|
||||
company = GetDecodedString(data);
|
||||
}
|
||||
|
||||
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
|
||||
|
||||
CopyToStringAndCheck(_rCompany, pBanner->comment[0].shortMaker);
|
||||
|
||||
return true;
|
||||
return company;
|
||||
}
|
||||
|
||||
|
||||
bool CBannerLoaderGC::GetDescription(std::string* _rDescription)
|
||||
std::vector<std::string> CBannerLoaderGC::GetDescriptions()
|
||||
{
|
||||
bool returnCode = false;
|
||||
std::vector<std::string> descriptions;
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
return false;
|
||||
return descriptions;
|
||||
}
|
||||
|
||||
u32 desc_count = 0;
|
||||
|
||||
// find Banner type
|
||||
switch (m_BNRType)
|
||||
{
|
||||
case CBannerLoaderGC::BANNER_BNR1:
|
||||
{
|
||||
DVDBanner* pBanner = (DVDBanner*)m_pBannerFile;
|
||||
char tempBuffer[129] = {0};
|
||||
memcpy(tempBuffer, pBanner->comment.comment, 128);
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
CopyToStringAndCheck(_rDescription[i], tempBuffer);
|
||||
}
|
||||
returnCode = true;
|
||||
}
|
||||
desc_count = 1;
|
||||
break;
|
||||
case CBannerLoaderGC::BANNER_BNR2:
|
||||
{
|
||||
DVDBanner2* pBanner = (DVDBanner2*)m_pBannerFile;
|
||||
|
||||
for (int i = 0; i< 6; i++)
|
||||
{
|
||||
char tempBuffer[129] = {0};
|
||||
memcpy(tempBuffer, pBanner->comment[i].comment, 128);
|
||||
CopyToStringAndCheck(_rDescription[i], tempBuffer);
|
||||
}
|
||||
returnCode = true;
|
||||
}
|
||||
case CBannerLoaderGC::BANNER_BNR2:
|
||||
desc_count = 6;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return returnCode;
|
||||
|
||||
auto banner = reinterpret_cast<const DVDBanner*>(m_pBannerFile);
|
||||
|
||||
for (int i = 0; i != desc_count; ++i)
|
||||
{
|
||||
auto& data = banner->comment[i].comment;
|
||||
descriptions.push_back(GetDecodedString(data));
|
||||
}
|
||||
|
||||
return descriptions;
|
||||
}
|
||||
|
||||
|
||||
|
@ -223,13 +201,17 @@ CBannerLoaderGC::BANNER_TYPE CBannerLoaderGC::getBannerType()
|
|||
CBannerLoaderGC::BANNER_TYPE type = CBannerLoaderGC::BANNER_UNKNOWN;
|
||||
switch (bannerSignature)
|
||||
{
|
||||
// "BNR1"
|
||||
case 0x31524e42:
|
||||
type = CBannerLoaderGC::BANNER_BNR1;
|
||||
break;
|
||||
|
||||
// "BNR2"
|
||||
case 0x32524e42:
|
||||
type = CBannerLoaderGC::BANNER_BNR2;
|
||||
break;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -32,9 +32,10 @@ class CBannerLoaderGC
|
|||
virtual bool IsValid();
|
||||
|
||||
virtual bool GetBanner(u32* _pBannerImage);
|
||||
virtual bool GetName(std::string* _rName);
|
||||
virtual bool GetCompany(std::string& _rCompany);
|
||||
virtual bool GetDescription(std::string* _rDescription);
|
||||
|
||||
virtual std::vector<std::string> GetNames();
|
||||
virtual std::string GetCompany();
|
||||
virtual std::vector<std::string> GetDescriptions();
|
||||
|
||||
private:
|
||||
enum
|
||||
|
@ -60,24 +61,25 @@ class CBannerLoaderGC
|
|||
char comment[128]; // Game description shown in IPL game start screen in two lines.
|
||||
};
|
||||
|
||||
// "opening.bnr" file format for JP/US console
|
||||
struct DVDBanner
|
||||
{
|
||||
u32 id; // 'BNR1'
|
||||
u32 padding[7];
|
||||
u16 image[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT]; // RGB5A3 96x32 texture image
|
||||
DVDBannerComment comment;
|
||||
};
|
||||
|
||||
// "opening.bnr" file format for EU console
|
||||
struct DVDBanner2
|
||||
struct DVDBanner
|
||||
{
|
||||
u32 id; // 'BNR2'
|
||||
u32 padding[7];
|
||||
u16 image[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT]; // RGB5A3 96x32 texture image
|
||||
DVDBannerComment comment[6]; // Comments in six languages
|
||||
DVDBannerComment comment[6]; // Comments in six languages (only 1 for BNR1 type)
|
||||
};
|
||||
|
||||
static const u32 BNR1_SIZE = sizeof(DVDBanner) - sizeof(DVDBannerComment) * 5;
|
||||
static const u32 BNR2_SIZE = sizeof(DVDBanner);
|
||||
|
||||
template <u32 N>
|
||||
std::string GetDecodedString(const char (&data)[N])
|
||||
{
|
||||
// Can I always assume SHIFT-JIS?
|
||||
return SHIFTJISToUTF8(std::string(data, strnlen(data, sizeof(data))));
|
||||
}
|
||||
|
||||
u8* m_pBannerFile;
|
||||
bool m_IsValid;
|
||||
BANNER_TYPE m_BNRType;
|
||||
|
|
|
@ -196,28 +196,27 @@ bool CBannerLoaderWii::GetStringFromComments(const CommentIndex index, std::wstr
|
|||
return false;
|
||||
}
|
||||
|
||||
bool CBannerLoaderWii::GetName(std::string* _rName)
|
||||
std::vector<std::string> CBannerLoaderWii::GetNames()
|
||||
{
|
||||
return GetStringFromComments(NAME_IDX, *_rName);
|
||||
}
|
||||
std::vector<std::string> ret(1);
|
||||
|
||||
if (!GetStringFromComments(NAME_IDX, ret[0]))
|
||||
ret.clear();
|
||||
|
||||
bool CBannerLoaderWii::GetName(std::vector<std::wstring>& _rNames)
|
||||
{
|
||||
std::wstring temp;
|
||||
bool ret = GetStringFromComments(NAME_IDX, temp);
|
||||
_rNames.push_back(temp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CBannerLoaderWii::GetCompany(std::string& _rCompany)
|
||||
std::string CBannerLoaderWii::GetCompany()
|
||||
{
|
||||
_rCompany = "N/A";
|
||||
return true;
|
||||
return "";
|
||||
}
|
||||
|
||||
bool CBannerLoaderWii::GetDescription(std::string* _rDescription)
|
||||
std::vector<std::string> CBannerLoaderWii::GetDescriptions()
|
||||
{
|
||||
return GetStringFromComments(DESC_IDX, *_rDescription);
|
||||
std::vector<std::string> result(1);
|
||||
if (!GetStringFromComments(DESC_IDX, result[0]))
|
||||
result.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
void CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height)
|
||||
|
|
|
@ -35,13 +35,9 @@ class CBannerLoaderWii
|
|||
|
||||
virtual bool GetBanner(u32* _pBannerImage);
|
||||
|
||||
virtual bool GetName(std::string* _rName);
|
||||
|
||||
bool GetName(std::vector<std::wstring>& _rNames);
|
||||
|
||||
virtual bool GetCompany(std::string& _rCompany);
|
||||
|
||||
virtual bool GetDescription(std::string* _rDescription);
|
||||
virtual std::vector<std::string> GetNames();
|
||||
virtual std::string GetCompany();
|
||||
virtual std::vector<std::string> GetDescriptions();
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ public:
|
|||
virtual void GetTMD(u8*, u32 *_sz) const { *_sz=0; }
|
||||
virtual std::string GetUniqueID() const = 0;
|
||||
virtual std::string GetMakerID() const = 0;
|
||||
virtual std::string GetName() const = 0;
|
||||
virtual bool GetWName(std::vector<std::wstring>& _rwNames) const { return false; }
|
||||
virtual std::string GetName() const;
|
||||
virtual std::vector<std::string> GetNames() const = 0;
|
||||
virtual u32 GetFSTSize() const = 0;
|
||||
virtual std::string GetApploaderDate() const = 0;
|
||||
virtual bool SupportsIntegrityCheck() const { return false; }
|
||||
|
|
|
@ -111,5 +111,13 @@ u8 GetSysMenuRegion(u16 _TitleVersion)
|
|||
}
|
||||
}
|
||||
|
||||
};
|
||||
std::string IVolume::GetName() const
|
||||
{
|
||||
auto names = GetNames();
|
||||
if (names.empty())
|
||||
return "";
|
||||
else
|
||||
return names[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -207,11 +207,10 @@ std::string CVolumeDirectory::GetMakerID() const
|
|||
return "VOID";
|
||||
}
|
||||
|
||||
std::string CVolumeDirectory::GetName() const
|
||||
std::vector<std::string> CVolumeDirectory::GetNames() const
|
||||
{
|
||||
_dbg_assert_(DVDINTERFACE, m_diskHeader);
|
||||
std::string name = (char*)(m_diskHeader + 0x20);
|
||||
return name;
|
||||
return std::vector<std::string>(1, (char*)(m_diskHeader + 0x20));
|
||||
}
|
||||
|
||||
void CVolumeDirectory::SetName(std::string _Name)
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
std::string GetMakerID() const;
|
||||
|
||||
std::string GetName() const;
|
||||
std::vector<std::string> GetNames() const;
|
||||
void SetName(std::string);
|
||||
|
||||
u32 GetFSTSize() const;
|
||||
|
|
|
@ -91,16 +91,15 @@ std::string CVolumeGC::GetMakerID() const
|
|||
return makerID;
|
||||
}
|
||||
|
||||
std::string CVolumeGC::GetName() const
|
||||
std::vector<std::string> CVolumeGC::GetNames() const
|
||||
{
|
||||
if (m_pReader == NULL)
|
||||
return "";
|
||||
std::vector<std::string> names;
|
||||
|
||||
char name[128];
|
||||
if (!Read(0x20, 0x60, (u8*)&name))
|
||||
return "";
|
||||
char name[128] = {};
|
||||
if (m_pReader != NULL && Read(0x20, 0x60, (u8*)&name))
|
||||
names.push_back(name);
|
||||
|
||||
return name;
|
||||
return names;
|
||||
}
|
||||
|
||||
u32 CVolumeGC::GetFSTSize() const
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
bool RAWRead(u64 _Offset, u64 _Length, u8* _pBuffer) const;
|
||||
std::string GetUniqueID() const;
|
||||
std::string GetMakerID() const;
|
||||
std::string GetName() const;
|
||||
std::vector<std::string> GetNames() const;
|
||||
u32 GetFSTSize() const;
|
||||
std::string GetApploaderDate() const;
|
||||
ECountry GetCountry() const;
|
||||
|
|
|
@ -107,13 +107,15 @@ bool CVolumeWAD::GetTitleID(u8* _pBuffer) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CVolumeWAD::GetWName(std::vector<std::wstring>& _rwNames) const
|
||||
std::vector<std::string> CVolumeWAD::GetNames() const
|
||||
{
|
||||
u32 footer_size;
|
||||
std::vector<std::string> names;
|
||||
return names;
|
||||
|
||||
u32 footer_size;
|
||||
if (!Read(0x1C, 4, (u8*)&footer_size))
|
||||
{
|
||||
return false;
|
||||
return names;
|
||||
}
|
||||
//Japanese, English, German, French, Spanish, Italian, Dutch, unknown, unknown, Korean
|
||||
|
||||
|
@ -126,7 +128,7 @@ bool CVolumeWAD::GetWName(std::vector<std::wstring>& _rwNames) const
|
|||
if (!Read(0x9C + (i*84) + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1
|
||||
|| !temp[0])
|
||||
{
|
||||
_rwNames.push_back(L"");
|
||||
names.push_back("");
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < 42; ++j)
|
||||
|
@ -141,44 +143,10 @@ bool CVolumeWAD::GetWName(std::vector<std::wstring>& _rwNames) const
|
|||
out_temp.push_back(t);
|
||||
}
|
||||
|
||||
_rwNames.push_back(out_temp);
|
||||
names.push_back(UTF16ToUTF8(out_temp));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string CVolumeWAD::GetName() const
|
||||
{
|
||||
u32 footer_size;
|
||||
|
||||
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 ||
|
||||
!Common::swap16(temp[0]))
|
||||
return "";
|
||||
|
||||
// Remove the null bytes due to 16bit char length
|
||||
std::string out_temp;
|
||||
for (unsigned int i = 0; i < sizeof(temp); i+=2)
|
||||
{
|
||||
// Replace null chars with a single space per null section
|
||||
if (temp[i] == '\0' && i > 0)
|
||||
{
|
||||
if (out_temp.at(out_temp.size()-1) != ' ')
|
||||
out_temp.push_back(' ');
|
||||
}
|
||||
else
|
||||
out_temp.push_back(temp[i]);
|
||||
}
|
||||
// Make it a null terminated string
|
||||
out_temp.replace(out_temp.end()-1, out_temp.end(), 1, '\0');
|
||||
|
||||
return out_temp;
|
||||
return names;
|
||||
}
|
||||
|
||||
u64 CVolumeWAD::GetSize() const
|
||||
|
|
|
@ -38,8 +38,7 @@ public:
|
|||
bool GetTitleID(u8* _pBuffer) const;
|
||||
std::string GetUniqueID() const;
|
||||
std::string GetMakerID() const;
|
||||
std::string GetName() const;
|
||||
bool GetWName(std::vector<std::wstring>& _rwNames) const;
|
||||
std::vector<std::string> GetNames() const;
|
||||
u32 GetFSTSize() const { return 0; }
|
||||
std::string GetApploaderDate() const { return "0"; }
|
||||
ECountry GetCountry() const;
|
||||
|
|
|
@ -168,21 +168,17 @@ std::string CVolumeWiiCrypted::GetMakerID() const
|
|||
return makerID;
|
||||
}
|
||||
|
||||
std::string CVolumeWiiCrypted::GetName() const
|
||||
std::vector<std::string> CVolumeWiiCrypted::GetNames() const
|
||||
{
|
||||
if (m_pReader == NULL)
|
||||
std::vector<std::string> names;
|
||||
|
||||
char name[0xFF] = {};
|
||||
if (m_pReader != NULL && Read(0x20, 0x60, (u8*)&name))
|
||||
{
|
||||
return std::string();
|
||||
names.push_back(name);
|
||||
}
|
||||
|
||||
char name[0xFF];
|
||||
|
||||
if (!Read(0x20, 0x60, (u8*)&name))
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
return name;
|
||||
return names;
|
||||
}
|
||||
|
||||
u32 CVolumeWiiCrypted::GetFSTSize() const
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
void GetTMD(u8* _pBuffer, u32* _sz) const;
|
||||
std::string GetUniqueID() const;
|
||||
std::string GetMakerID() const;
|
||||
std::string GetName() const;
|
||||
std::vector<std::string> GetNames() const;
|
||||
u32 GetFSTSize() const;
|
||||
std::string GetApploaderDate() const;
|
||||
ECountry GetCountry() const;
|
||||
|
|
|
@ -454,10 +454,8 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
|||
|
||||
// Set the game's banner in the second column
|
||||
SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);
|
||||
|
||||
std::wstring wstring_name;
|
||||
|
||||
wxString name;
|
||||
std::string name;
|
||||
|
||||
int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
|
||||
switch (rISOFile.GetCountry())
|
||||
|
@ -465,9 +463,8 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
|||
case DiscIO::IVolume::COUNTRY_TAIWAN:
|
||||
case DiscIO::IVolume::COUNTRY_JAPAN:
|
||||
{
|
||||
rISOFile.GetName(wstring_name, -1);
|
||||
name = wxString(rISOFile.GetName(0).c_str(), SJISConv);
|
||||
m_gameList.append(StringFromFormat("%s (J)\n", (const char *)name.c_str()));
|
||||
name = rISOFile.GetName(-1);
|
||||
m_gameList.append(StringFromFormat("%s (J)\n", name.c_str()));
|
||||
}
|
||||
break;
|
||||
case DiscIO::IVolume::COUNTRY_USA:
|
||||
|
@ -475,22 +472,15 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
|||
SelectedLanguage = 0;
|
||||
default:
|
||||
{
|
||||
wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252));
|
||||
rISOFile.GetName(wstring_name, SelectedLanguage);
|
||||
|
||||
name = wxString(rISOFile.GetName(SelectedLanguage).c_str(), WindowsCP1252);
|
||||
m_gameList.append(StringFromFormat("%s (%c)\n",
|
||||
rISOFile.GetName(SelectedLanguage).c_str(),
|
||||
(rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA) ? 'U' : 'E'));
|
||||
name = rISOFile.GetName(SelectedLanguage);
|
||||
m_gameList.append(StringFromFormat("%s (%c)\n", name.c_str(),
|
||||
(rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA) ? 'U' : 'E'));
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (wstring_name.length())
|
||||
name = wstring_name.c_str();
|
||||
|
||||
SetItem(_Index, COLUMN_TITLE, name, -1);
|
||||
|
||||
SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1);
|
||||
|
||||
// We show the company string on Gamecube only
|
||||
// On Wii we show the description instead as the company string is empty
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "ChunkFile.h"
|
||||
#include "ConfigManager.h"
|
||||
|
||||
#define CACHE_REVISION 0x110
|
||||
#define CACHE_REVISION 0x112
|
||||
|
||||
#define DVD_BANNER_WIDTH 96
|
||||
#define DVD_BANNER_HEIGHT 32
|
||||
|
@ -66,26 +66,10 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
|||
else
|
||||
{
|
||||
m_Platform = WII_WAD;
|
||||
pVolume->GetWName(m_wNames);
|
||||
}
|
||||
|
||||
m_Company = "N/A";
|
||||
m_volume_names = pVolume->GetNames();
|
||||
|
||||
|
||||
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] = m_Name[0];
|
||||
m_Description[i] = "No Description";
|
||||
}
|
||||
m_Country = pVolume->GetCountry();
|
||||
m_FileSize = File::GetSize(_rFileName);
|
||||
m_VolumeSize = pVolume->GetSize();
|
||||
|
@ -105,11 +89,9 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
|||
{
|
||||
if (pBannerLoader->IsValid())
|
||||
{
|
||||
m_wNames.clear();
|
||||
pBannerLoader->GetName(m_wNames);
|
||||
pBannerLoader->GetName(m_Name);
|
||||
pBannerLoader->GetCompany(m_Company);
|
||||
pBannerLoader->GetDescription(m_Description);
|
||||
m_names = pBannerLoader->GetNames();
|
||||
m_company = pBannerLoader->GetCompany();
|
||||
m_descriptions = pBannerLoader->GetDescriptions();
|
||||
|
||||
if (pBannerLoader->GetBanner(g_ImageTemp))
|
||||
{
|
||||
|
@ -129,25 +111,6 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
|||
|
||||
delete pFileSystem;
|
||||
}
|
||||
std::vector<std::wstring>::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 j = 0; j < length; ++j)
|
||||
wFileName.push_back(FileName[j]);
|
||||
wFileName.push_back(0);
|
||||
}
|
||||
*i = wFileName;
|
||||
}
|
||||
}
|
||||
|
||||
delete pVolume;
|
||||
|
||||
|
@ -208,32 +171,10 @@ void GameListItem::SaveToCache()
|
|||
|
||||
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_volume_names);
|
||||
p.Do(m_company);
|
||||
p.Do(m_names);
|
||||
p.Do(m_descriptions);
|
||||
p.Do(m_UniqueID);
|
||||
p.Do(m_FileSize);
|
||||
p.Do(m_VolumeSize);
|
||||
|
@ -262,44 +203,51 @@ std::string GameListItem::CreateCacheFilename()
|
|||
return fullname;
|
||||
}
|
||||
|
||||
const std::string& GameListItem::GetDescription(int index) const
|
||||
std::string GameListItem::GetCompany() const
|
||||
{
|
||||
if ((index >=0) && (index < 6))
|
||||
{
|
||||
return m_Description[index];
|
||||
}
|
||||
return m_Description[0];
|
||||
if (m_company.empty())
|
||||
return "N/A";
|
||||
else
|
||||
return m_company;
|
||||
}
|
||||
|
||||
const std::string& GameListItem::GetName(int index) const
|
||||
// (-1 = Japanese, 0 = English, etc)
|
||||
std::string GameListItem::GetDescription(int _index) const
|
||||
{
|
||||
if ((index >=0) && (index < 6))
|
||||
{
|
||||
return m_Name[index];
|
||||
}
|
||||
return m_Name[0];
|
||||
const u32 index = _index + 1;
|
||||
|
||||
if (index < m_descriptions.size())
|
||||
return m_descriptions[index];
|
||||
|
||||
if (!m_descriptions.empty())
|
||||
return m_descriptions[0];
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
bool GameListItem::GetName(std::wstring& wName, int index) const
|
||||
// (-1 = Japanese, 0 = English, etc)
|
||||
std::string GameListItem::GetName(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() > (size_t)index)
|
||||
{
|
||||
wName = m_wNames[index];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (m_wNames.size() > 0)
|
||||
{
|
||||
wName = m_wNames[0];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
u32 const index = _index + 1;
|
||||
|
||||
// banner name
|
||||
if (index < m_names.size() && !m_names[index].empty())
|
||||
return m_names[index];
|
||||
|
||||
if (!m_names.empty() && !m_names[0].empty())
|
||||
return m_names[0];
|
||||
|
||||
// volume name
|
||||
if (index < m_volume_names.size() && !m_volume_names[index].empty())
|
||||
return m_volume_names[index];
|
||||
|
||||
if (!m_volume_names.empty() && !m_volume_names[0].empty())
|
||||
return m_volume_names[0];
|
||||
|
||||
// No usable name, return filename (better than nothing)
|
||||
std::string FileName;
|
||||
SplitPath(m_FileName, NULL, &FileName, NULL);
|
||||
return FileName;
|
||||
}
|
||||
|
||||
const std::string GameListItem::GetWiiFSPath() const
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#ifndef __ISOFILE_H_
|
||||
#define __ISOFILE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "Volume.h"
|
||||
#include "VolumeCreator.h"
|
||||
|
||||
|
@ -34,10 +37,9 @@ 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 = 0) const;
|
||||
std::string GetName(int index) const;
|
||||
std::string GetCompany() const;
|
||||
std::string GetDescription(int index = 0) const;
|
||||
const std::string& GetUniqueID() const {return m_UniqueID;}
|
||||
const std::string GetWiiFSPath() const;
|
||||
DiscIO::IVolume::ECountry GetCountry() const {return m_Country;}
|
||||
|
@ -64,10 +66,15 @@ public:
|
|||
|
||||
private:
|
||||
std::string m_FileName;
|
||||
std::string m_Name[6];
|
||||
std::vector<std::wstring> m_wNames;
|
||||
std::string m_Company;
|
||||
std::string m_Description[6];
|
||||
|
||||
// TODO: eliminate this and overwrite with names from banner when available?
|
||||
std::vector<std::string> m_volume_names;
|
||||
|
||||
// Stuff from banner
|
||||
std::string m_company;
|
||||
std::vector<std::string> m_names;
|
||||
std::vector<std::string> m_descriptions;
|
||||
|
||||
std::string m_UniqueID;
|
||||
|
||||
std::string m_issues;
|
||||
|
|
|
@ -158,15 +158,8 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
|
|||
|
||||
// Disk header and apploader
|
||||
|
||||
std::wstring wname;
|
||||
wxString name;
|
||||
if (OpenGameListItem->GetName(wname))
|
||||
name = wname.c_str();
|
||||
else
|
||||
name = wxString(OpenISO->GetName().c_str(), wxConvUTF8);
|
||||
m_Name->SetValue(name);
|
||||
|
||||
m_GameID->SetValue(wxString(OpenISO->GetUniqueID().c_str(), wxConvUTF8));
|
||||
m_Name->SetValue(StrToWxStr(OpenISO->GetName()));
|
||||
m_GameID->SetValue(StrToWxStr(OpenISO->GetUniqueID()));
|
||||
switch (OpenISO->GetCountry())
|
||||
{
|
||||
case DiscIO::IVolume::COUNTRY_EUROPE:
|
||||
|
@ -1308,54 +1301,29 @@ void CISOProperties::OnChangeBannerLang(wxCommandEvent& event)
|
|||
|
||||
void CISOProperties::ChangeBannerDetails(int lang)
|
||||
{
|
||||
std::wstring wname;
|
||||
std::string name;
|
||||
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
|
||||
// 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(wxT("CP932"));
|
||||
#endif
|
||||
switch (OpenGameListItem->GetCountry())
|
||||
{
|
||||
case DiscIO::IVolume::COUNTRY_TAIWAN:
|
||||
case DiscIO::IVolume::COUNTRY_JAPAN:
|
||||
|
||||
if (OpenGameListItem->GetName(wname, -1))
|
||||
shortName = wname.c_str();
|
||||
else
|
||||
shortName = wxString(OpenGameListItem->GetName(0).c_str(), SJISConv);
|
||||
|
||||
shortName = StrToWxStr(OpenGameListItem->GetName(-1));
|
||||
comment = StrToWxStr(OpenGameListItem->GetDescription());
|
||||
maker = wxString(OpenGameListItem->GetCompany().c_str(), SJISConv);
|
||||
break;
|
||||
case DiscIO::IVolume::COUNTRY_USA:
|
||||
// why?
|
||||
lang = 0;
|
||||
default:
|
||||
{
|
||||
wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252));
|
||||
if (OpenGameListItem->GetName(wname, lang))
|
||||
shortName = wname.c_str();
|
||||
else
|
||||
shortName = wxString(OpenGameListItem->GetName(lang).c_str(), WindowsCP1252);
|
||||
shortName = StrToWxStr(OpenGameListItem->GetName(lang));
|
||||
comment = StrToWxStr(OpenGameListItem->GetDescription(lang));
|
||||
maker = wxString(OpenGameListItem->GetCompany().c_str(), WindowsCP1252);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
maker = StrToWxStr(OpenGameListItem->GetCompany());
|
||||
|
||||
// Updates the informations shown in the window
|
||||
m_ShortName->SetValue(shortName);
|
||||
m_Comment->SetValue(comment);
|
||||
|
|
Loading…
Reference in New Issue