lamguage changes for rombrowser

This commit is contained in:
zilmar 2015-03-17 22:34:47 +11:00
parent 5491271c8a
commit 262c8ffe9d
1 changed files with 77 additions and 42 deletions

View File

@ -12,7 +12,8 @@ CRomBrowser::CRomBrowser (HWND & MainWindow, HWND & StatusWindow ) :
m_ShowingRomBrowser(false), m_ShowingRomBrowser(false),
m_AllowSelectionLastRom(true) m_AllowSelectionLastRom(true)
{ {
if (g_Settings) { if (g_Settings)
{
m_RomIniFile = new CIniFile(g_Settings->LoadString(SupportFile_RomDatabase).c_str()); m_RomIniFile = new CIniFile(g_Settings->LoadString(SupportFile_RomDatabase).c_str());
m_NotesIniFile = new CIniFile(g_Settings->LoadString(SupportFile_Notes).c_str()); m_NotesIniFile = new CIniFile(g_Settings->LoadString(SupportFile_Notes).c_str());
m_ExtIniFile = new CIniFile(g_Settings->LoadString(SupportFile_ExtInfo).c_str()); m_ExtIniFile = new CIniFile(g_Settings->LoadString(SupportFile_ExtInfo).c_str());
@ -28,7 +29,8 @@ CRomBrowser::CRomBrowser (HWND & MainWindow, HWND & StatusWindow ) :
m_FieldType.resize(m_Fields.size()); m_FieldType.resize(m_Fields.size());
} }
CRomBrowser::~CRomBrowser (void){ CRomBrowser::~CRomBrowser (void)
{
m_StopRefresh = true; m_StopRefresh = true;
WatchThreadStop(); WatchThreadStop();
DeallocateBrushs(); DeallocateBrushs();
@ -248,7 +250,8 @@ int CRomBrowser::CalcSortPosition (DWORD lParam)
} }
size_t index; size_t index;
for (index = 0; index < m_Fields.size(); index++) { for (index = 0; index < m_Fields.size(); index++)
{
if (_stricmp(m_Fields[index].Name(),SortFieldName.c_str()) == 0) { break; } if (_stricmp(m_Fields[index].Name(),SortFieldName.c_str()) == 0) { break; }
} }
if (index >= m_Fields.size()) { continue; } if (index >= m_Fields.size()) { continue; }
@ -276,7 +279,8 @@ int CRomBrowser::CalcSortPosition (DWORD lParam)
return End + 1; return End + 1;
} }
void CRomBrowser::AddRomToList (const char * RomLocation, const char * lpLastRom) { void CRomBrowser::AddRomToList (const char * RomLocation, const char * lpLastRom)
{
ROM_INFO RomInfo; ROM_INFO RomInfo;
memset(&RomInfo, 0, sizeof(ROM_INFO)); memset(&RomInfo, 0, sizeof(ROM_INFO));
@ -285,7 +289,8 @@ void CRomBrowser::AddRomToList (const char * RomLocation, const char * lpLastRom
AddRomInfoToList(RomInfo,lpLastRom); AddRomInfoToList(RomInfo,lpLastRom);
} }
void CRomBrowser::AddRomInfoToList (ROM_INFO &RomInfo , const char * lpLastRom) { void CRomBrowser::AddRomInfoToList (ROM_INFO &RomInfo , const char * lpLastRom)
{
int ListPos = m_RomInfo.size(); int ListPos = m_RomInfo.size();
m_RomInfo.push_back(RomInfo); m_RomInfo.push_back(RomInfo);
@ -298,7 +303,6 @@ void CRomBrowser::AddRomInfoToList (ROM_INFO &RomInfo , const char * lpLastRom)
int index = ListView_InsertItem((HWND)m_hRomList, &lvItem); int index = ListView_InsertItem((HWND)m_hRomList, &lvItem);
int iItem = ListView_GetNextItem((HWND)m_hRomList, -1, LVNI_SELECTED); int iItem = ListView_GetNextItem((HWND)m_hRomList, -1, LVNI_SELECTED);
//if (iItem == -1) { return; } //if (iItem == -1) { return; }
@ -314,23 +318,30 @@ void CRomBrowser::AddRomInfoToList (ROM_INFO &RomInfo , const char * lpLastRom)
} }
} }
void CRomBrowser::AllocateBrushs (void) { void CRomBrowser::AllocateBrushs (void)
for (size_t count = 0; count < m_RomInfo.size(); count++) { {
if (m_RomInfo[count].SelColor == -1) { for (size_t count = 0; count < m_RomInfo.size(); count++)
{
if (m_RomInfo[count].SelColor == -1)
{
m_RomInfo[count].SelColorBrush = (DWORD)((HBRUSH)(COLOR_HIGHLIGHT + 1)); m_RomInfo[count].SelColorBrush = (DWORD)((HBRUSH)(COLOR_HIGHLIGHT + 1));
} else { }
else
{
m_RomInfo[count].SelColorBrush = (DWORD)CreateSolidBrush(m_RomInfo[count].SelColor); m_RomInfo[count].SelColorBrush = (DWORD)CreateSolidBrush(m_RomInfo[count].SelColor);
} }
} }
} }
DWORD CRomBrowser::AsciiToHex (char * HexValue) { DWORD CRomBrowser::AsciiToHex (char * HexValue)
{
DWORD Count, Finish, Value = 0; DWORD Count, Finish, Value = 0;
Finish = strlen(HexValue); Finish = strlen(HexValue);
if (Finish > 8 ) { Finish = 8; } if (Finish > 8 ) { Finish = 8; }
for (Count = 0; Count < Finish; Count++){ for (Count = 0; Count < Finish; Count++)
{
Value = (Value << 4); Value = (Value << 4);
switch( HexValue[Count] ) { switch( HexValue[Count] ) {
case '0': break; case '0': break;
@ -392,9 +403,6 @@ void CRomBrowser::DeallocateBrushs (void)
void CRomBrowser::FillRomExtensionInfo(ROM_INFO * pRomInfo) void CRomBrowser::FillRomExtensionInfo(ROM_INFO * pRomInfo)
{ {
stdstr NoGoodName;
NoGoodName.FromUTF16(GS(RB_NOT_GOOD_FILE));
//Initialize the structure //Initialize the structure
pRomInfo->UserNotes[0] = 0; pRomInfo->UserNotes[0] = 0;
pRomInfo->Developer[0] = 0; pRomInfo->Developer[0] = 0;
@ -403,7 +411,7 @@ void CRomBrowser::FillRomExtensionInfo(ROM_INFO * pRomInfo)
pRomInfo->Players = 1; pRomInfo->Players = 1;
pRomInfo->CoreNotes[0] = 0; pRomInfo->CoreNotes[0] = 0;
pRomInfo->PluginNotes[0] = 0; pRomInfo->PluginNotes[0] = 0;
strcpy(pRomInfo->GoodName,NoGoodName.c_str()); strcpy(pRomInfo->GoodName,"#340#");
strcpy(pRomInfo->Status,"Unknown"); strcpy(pRomInfo->Status,"Unknown");
//Get File Identifier //Get File Identifier
@ -734,7 +742,8 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory,
WriteTrace(TraceDebug,__FUNCTION__ ": 14"); WriteTrace(TraceDebug,__FUNCTION__ ": 14");
memcpy(RomInfo.InternalName,(void *)(RomData + 0x20),20); memcpy(RomInfo.InternalName,(void *)(RomData + 0x20),20);
for( int count = 0 ; count < 20; count += 4 ) { for( int count = 0 ; count < 20; count += 4 )
{
RomInfo.InternalName[count] ^= RomInfo.InternalName[count+3]; RomInfo.InternalName[count] ^= RomInfo.InternalName[count+3];
RomInfo.InternalName[count + 3] ^= RomInfo.InternalName[count]; RomInfo.InternalName[count + 3] ^= RomInfo.InternalName[count];
RomInfo.InternalName[count] ^= RomInfo.InternalName[count+3]; RomInfo.InternalName[count] ^= RomInfo.InternalName[count+3];
@ -755,9 +764,12 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory,
WriteTrace(TraceDebug,__FUNCTION__ ": 16"); WriteTrace(TraceDebug,__FUNCTION__ ": 16");
FillRomExtensionInfo(&RomInfo); FillRomExtensionInfo(&RomInfo);
if (RomInfo.SelColor == -1) { if (RomInfo.SelColor == -1)
{
RomInfo.SelColorBrush = (DWORD)((HBRUSH)(COLOR_HIGHLIGHT + 1)); RomInfo.SelColorBrush = (DWORD)((HBRUSH)(COLOR_HIGHLIGHT + 1));
} else { }
else
{
RomInfo.SelColorBrush = (DWORD)CreateSolidBrush(RomInfo.SelColor); RomInfo.SelColorBrush = (DWORD)CreateSolidBrush(RomInfo.SelColor);
} }
WriteTrace(TraceDebug,__FUNCTION__ ": 17"); WriteTrace(TraceDebug,__FUNCTION__ ": 17");
@ -770,20 +782,21 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory,
} }
continue; continue;
} }
} while (SearchPath.FindNext()); } while (SearchPath.FindNext());
m_ZipIniFile->FlushChanges(); m_ZipIniFile->FlushChanges();
} }
int CRomBrowser::GetCicChipID (BYTE * RomData) { int CRomBrowser::GetCicChipID (BYTE * RomData)
{
__int64 CRC = 0; __int64 CRC = 0;
int count; int count;
for (count = 0x40; count < 0x1000; count += 4) { for (count = 0x40; count < 0x1000; count += 4)
{
CRC += *(DWORD *)(RomData+count); CRC += *(DWORD *)(RomData+count);
} }
switch (CRC) { switch (CRC)
{
case 0x000000D0027FDF31: return CIC_NUS_6101; case 0x000000D0027FDF31: return CIC_NUS_6101;
case 0x000000CFFB631223: return CIC_NUS_6101; case 0x000000CFFB631223: return CIC_NUS_6101;
case 0x000000D057C85244: return CIC_NUS_6102; case 0x000000D057C85244: return CIC_NUS_6102;
@ -795,7 +808,8 @@ int CRomBrowser::GetCicChipID (BYTE * RomData) {
} }
} }
void CRomBrowser::HighLightLastRom(void) { void CRomBrowser::HighLightLastRom(void)
{
if (!m_AllowSelectionLastRom) if (!m_AllowSelectionLastRom)
{ {
return; return;
@ -830,7 +844,8 @@ void CRomBrowser::HighLightLastRom(void) {
} }
//if the last rom then highlight the item //if the last rom then highlight the item
if (_stricmp(pRomInfo->szFullFileName,lpLastRom) == 0) { if (_stricmp(pRomInfo->szFullFileName,lpLastRom) == 0)
{
ListView_SetItemState((HWND)m_hRomList,index,LVIS_SELECTED | LVIS_FOCUSED,LVIS_SELECTED | LVIS_FOCUSED); ListView_SetItemState((HWND)m_hRomList,index,LVIS_SELECTED | LVIS_FOCUSED,LVIS_SELECTED | LVIS_FOCUSED);
ListView_EnsureVisible((HWND)m_hRomList,index,FALSE); ListView_EnsureVisible((HWND)m_hRomList,index,FALSE);
return; return;
@ -838,10 +853,12 @@ void CRomBrowser::HighLightLastRom(void) {
} }
} }
bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, int * RomSize, FILE_FORMAT & FileFormat) { bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, int * RomSize, FILE_FORMAT & FileFormat)
{
BYTE Test[4]; BYTE Test[4];
if (_strnicmp(&FileName[strlen(FileName)-4], ".ZIP",4) == 0 ){ if (_strnicmp(&FileName[strlen(FileName)-4], ".ZIP",4) == 0 )
{
int len, port = 0, FoundRom; int len, port = 0, FoundRom;
unz_file_info info; unz_file_info info;
char zname[132]; char zname[132];
@ -851,46 +868,55 @@ bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, i
port = unzGoToFirstFile(file); port = unzGoToFirstFile(file);
FoundRom = FALSE; FoundRom = FALSE;
while(port == UNZ_OK && FoundRom == FALSE) { while(port == UNZ_OK && FoundRom == FALSE)
{
unzGetCurrentFileInfo(file, &info, zname, 128, NULL,0, NULL,0); unzGetCurrentFileInfo(file, &info, zname, 128, NULL,0, NULL,0);
if (unzLocateFile(file, zname, 1) != UNZ_OK ) { if (unzLocateFile(file, zname, 1) != UNZ_OK )
{
unzClose(file); unzClose(file);
return true; return true;
} }
if( unzOpenCurrentFile(file) != UNZ_OK ) { if( unzOpenCurrentFile(file) != UNZ_OK )
{
unzClose(file); unzClose(file);
return true; return true;
} }
unzReadCurrentFile(file,Test,4); unzReadCurrentFile(file,Test,4);
if (CN64Rom::IsValidRomImage(Test)) { if (CN64Rom::IsValidRomImage(Test))
{
FoundRom = true; FoundRom = true;
//RomFileSize = info.uncompressed_size;
memcpy(Data,Test,4); memcpy(Data,Test,4);
len = unzReadCurrentFile(file,&Data[4],DataLen - 4) + 4; len = unzReadCurrentFile(file,&Data[4],DataLen - 4) + 4;
if ((int)DataLen != len) { if ((int)DataLen != len)
{
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
unzClose(file); unzClose(file);
return false; return false;
} }
*RomSize = info.uncompressed_size; *RomSize = info.uncompressed_size;
if(unzCloseCurrentFile(file) == UNZ_CRCERROR) { if(unzCloseCurrentFile(file) == UNZ_CRCERROR)
{
unzClose(file); unzClose(file);
return false; return false;
} }
unzClose(file); unzClose(file);
} }
if (FoundRom == false) { if (FoundRom == false)
{
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
port = unzGoToNextFile(file); port = unzGoToNextFile(file);
} }
} }
if (FoundRom == false) { if (FoundRom == false)
{
return false; return false;
} }
FileFormat = Format_Zip; FileFormat = Format_Zip;
} else { }
else
{
DWORD dwRead; DWORD dwRead;
HANDLE hFile; HANDLE hFile;
@ -917,9 +943,11 @@ void CRomBrowser::ByteSwapRomData (BYTE * Data, int DataLen)
{ {
int count; int count;
switch (*((DWORD *)&Data[0])) { switch (*((DWORD *)&Data[0]))
{
case 0x12408037: case 0x12408037:
for( count = 0 ; count < DataLen; count += 4 ) { for( count = 0 ; count < DataLen; count += 4 )
{
Data[count] ^= Data[count+2]; Data[count] ^= Data[count+2];
Data[count + 2] ^= Data[count]; Data[count + 2] ^= Data[count];
Data[count] ^= Data[count+2]; Data[count] ^= Data[count+2];
@ -929,7 +957,8 @@ void CRomBrowser::ByteSwapRomData (BYTE * Data, int DataLen)
} }
break; break;
case 0x40123780: case 0x40123780:
for( count = 0 ; count < DataLen; count += 4 ) { for( count = 0 ; count < DataLen; count += 4 )
{
Data[count] ^= Data[count+3]; Data[count] ^= Data[count+3];
Data[count + 3] ^= Data[count]; Data[count + 3] ^= Data[count];
Data[count] ^= Data[count+3]; Data[count] ^= Data[count+3];
@ -1209,7 +1238,13 @@ bool CRomBrowser::RomListDrawItem(int idCtrl, DWORD lParam)
ListView_GetItemText((HWND)m_hRomList,ditem->itemID, 0, String, sizeof(String)); ListView_GetItemText((HWND)m_hRomList,ditem->itemID, 0, String, sizeof(String));
memcpy(&rcDraw,&rcItem,sizeof(RECT)); memcpy(&rcDraw,&rcItem,sizeof(RECT));
rcDraw.right -= 3; rcDraw.right -= 3;
DrawText(ditem->hDC, String, strlen(String), &rcDraw, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER); std::wstring text = stdstr(String).ToUTF16();
if (wcscmp(L"#340#", text.c_str()) == 0)
{
text = GS(RB_NOT_GOOD_FILE);
}
DrawTextW(ditem->hDC, text.c_str(), text.length(), &rcDraw, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
memset(&lvc,0,sizeof(lvc)); memset(&lvc,0,sizeof(lvc));
lvc.mask = LVCF_FMT | LVCF_WIDTH; lvc.mask = LVCF_FMT | LVCF_WIDTH;