bool CMemcardManager::ReloadMemcard(const char *fileName, int card) { if (memoryCard[card]) delete memoryCard[card]; // TODO: add error checking and animate icons memoryCard[card] = new GCMemcard(fileName); if (memoryCard[card]->fail) return false; int j; wxString wxTitle, wxComment, wxBlock, wxFirstBlock, wxLabel, tString; m_MemcardList[card]->Hide(); m_MemcardList[card]->ClearAll(); m_MemcardList[card]->InsertColumn(COLUMN_BANNER, _("Banner")); m_MemcardList[card]->InsertColumn(COLUMN_TITLE, _("Title")); m_MemcardList[card]->InsertColumn(COLUMN_COMMENT, _("Comment")); m_MemcardList[card]->InsertColumn(COLUMN_ICON, _("Icon")); m_MemcardList[card]->InsertColumn(COLUMN_BLOCKS, _("Blocks")); m_MemcardList[card]->InsertColumn(COLUMN_FIRSTBLOCK, _("First Block")); wxImageList *list = m_MemcardList[card]->GetImageList(wxIMAGE_LIST_SMALL); list->RemoveAll(); int nFiles = memoryCard[card]->GetNumFiles(); int *images = new int[nFiles*2]; for (int i = 0;i < nFiles;i++) { static u32 pxdata[96*32]; static u8 animDelay[8]; static u32 animData[32*32*8]; int numFrames = memoryCard[card]->ReadAnimRGBA8(i,animData,animDelay); if (!memoryCard[card]->ReadBannerRGBA8(i,pxdata)) { memset(pxdata,0,96*32*4); if (numFrames>0) // Just use the first one { u32 *icdata = animData; for (int y=0;y<32;y++) { for (int x=0;x<32;x++) { pxdata[y*96+x+32] = icdata[y*32+x];// | 0xFF000000 } } } } wxBitmap map = wxBitmapFromMemoryRGBA((u8*)pxdata,96,32); images[i*2] = list->Add(map); if (numFrames>0) { memset(pxdata,0,96*32*4); int frames=3; if (numFrames<frames) frames=numFrames; for (int f=0;f<frames;f++) { for (int y=0;y<32;y++) { for (int x=0;x<32;x++) { pxdata[y*96 + x + 32*f] = animData[f*32*32 + y*32 + x]; } } } wxBitmap icon = wxBitmapFromMemoryRGBA((u8*)pxdata,96,32); images[i*2+1] = list->Add(icon); } } int pagesMax = (mcmSettings.usePages) ? (page[card] + 1) * itemsPerPage : 128; for (j = page[card] * itemsPerPage; (j < nFiles) && (j < pagesMax); j++) { char title[DENTRY_STRLEN]; char comment[DENTRY_STRLEN]; u16 blocks; u16 firstblock; int index = m_MemcardList[card]->InsertItem(j, wxEmptyString); m_MemcardList[card]->SetItem(index, COLUMN_BANNER, wxEmptyString); if (!memoryCard[card]->DEntry_Comment1(j, title)) title[0]=0; if (!memoryCard[card]->DEntry_Comment2(j, comment)) comment[0]=0; bool ascii = memoryCard[card]->IsAsciiEncoding(); #ifdef _WIN32 wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)); #else wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP)); #endif wxTitle = wxString(title, ascii ? *wxConvCurrent : SJISConv); wxComment = wxString(comment, ascii ? *wxConvCurrent : SJISConv); m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxTitle); m_MemcardList[card]->SetItem(index, COLUMN_COMMENT, wxComment); blocks = memoryCard[card]->DEntry_BlockCount(j); if (blocks == 0xFFFF) blocks = 0; wxBlock.Printf(wxT("%10d"), blocks); m_MemcardList[card]->SetItem(index,COLUMN_BLOCKS, wxBlock); firstblock = memoryCard[card]->DEntry_FirstBlock(j); if (firstblock == 0xFFFF) firstblock = 3; // to make firstblock -1 wxFirstBlock.Printf(wxT("%15d"), firstblock-4); m_MemcardList[card]->SetItem(index,COLUMN_FIRSTBLOCK, wxFirstBlock); m_MemcardList[card]->SetItem(index, COLUMN_ICON, wxEmptyString); if (images[j] >= 0) { m_MemcardList[card]->SetItemImage(index, images[j*2]); m_MemcardList[card]->SetItemColumnImage(index, COLUMN_ICON, images[j*2+1]); } } if (mcmSettings.usePages) { if (nFiles <= itemsPerPage) { m_PrevPage[card]->Disable(); m_MemcardList[card]->prevPage = false; } if (j == nFiles) { m_NextPage[card]->Disable(); m_MemcardList[card]->nextPage = false; } else { m_NextPage[card]->Enable(); m_MemcardList[card]->nextPage = true; } } delete[] images; // Automatic column width and then show the list for (int i = COLUMN_BANNER; i <= COLUMN_FIRSTBLOCK; i++) { if (mcmSettings.column[i]) m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE); else m_MemcardList[card]->SetColumnWidth(i, 0); } m_MemcardList[card]->Show(); wxLabel.Printf(_("%u Free Blocks; %u Free Dir Entries"), memoryCard[card]->GetFreeBlocks(), DIRLEN - nFiles); t_Status[card]->SetLabel(wxLabel); return true; }
void CGameListCtrl::InsertItemInReportView(long _Index) { // When using wxListCtrl, there is no hope of per-column text colors. // But for reference, here are the old colors that were used: (BGR) // title: 0xFF0000 // company: 0x007030 int ImageIndex = -1; #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 GameListItem& rISOFile = *m_ISOFiles[_Index]; m_gamePath.append(rISOFile.GetFileName() + '\n'); // Insert a first row with nothing in it, that will be used as the Index long ItemIndex = InsertItem(_Index, wxEmptyString); // Insert the platform's image in the first (visible) column SetItemColumnImage(_Index, COLUMN_PLATFORM, m_PlatformImageIndex[rISOFile.GetPlatform()]); if (rISOFile.GetImage().IsOk()) ImageIndex = m_imageListSmall->Add(rISOFile.GetImage()); // Set the game's banner in the second column SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex); std::wstring wstring_name; const std::wstring& wstring_description = rISOFile.GetDescription(); std::string company; wxString name; wxString description; // 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(); int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage; switch (rISOFile.GetCountry()) { 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())); description = wxString(company.size() ? company.c_str() : rISOFile.GetDescription(0).c_str(), SJISConv); } break; case DiscIO::IVolume::COUNTRY_USA: 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')); description = wxString(company.size() ? company.c_str() : rISOFile.GetDescription(SelectedLanguage).c_str(), WindowsCP1252); } break; } if (wstring_name.length()) name = wstring_name.c_str(); if (wstring_description.length()) description = wstring_description.c_str(); SetItem(_Index, COLUMN_TITLE, name, -1); SetItem(_Index, COLUMN_NOTES, description, -1); // Emulation state SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[rISOFile.GetEmuState()]); // Country SetItemColumnImage(_Index, COLUMN_COUNTRY, m_FlagImageIndex[rISOFile.GetCountry()]); // File size SetItem(_Index, COLUMN_SIZE, NiceSizeFormat(rISOFile.GetFileSize()), -1); // Background color SetBackgroundColor(); // Item data SetItemData(_Index, ItemIndex); }