// Save this file as the default file void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& event) { const GameListItem *iso = GetSelectedISO(); if (!iso) return; if (event.IsChecked()) { // Write the new default value and save it the ini file SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM = iso->GetFileName(); SConfig::GetInstance().SaveSettings(); } else { // Otherwise blank the value and save it SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM = ""; SConfig::GetInstance().SaveSettings(); } }
void CGameListCtrl::OnRightClick(wxMouseEvent& event) { // Focus the clicked item. int flags; long item = HitTest(event.GetPosition(), flags); if (item != wxNOT_FOUND) { if (GetItemState(item, wxLIST_STATE_SELECTED) != wxLIST_STATE_SELECTED) { UnselectAll(); SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); } SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); } if (GetSelectedItemCount() == 1) { const GameListItem *selected_iso = GetSelectedISO(); if (selected_iso) { wxMenu* popupMenu = new wxMenu; popupMenu->Append(IDM_PROPERTIES, _("&Properties")); popupMenu->Append(IDM_GAMEWIKI, _("&Wiki")); popupMenu->AppendSeparator(); if (selected_iso->GetPlatform() != GameListItem::GAMECUBE_DISC) { popupMenu->Append(IDM_OPENSAVEFOLDER, _("Open Wii &save folder")); popupMenu->Append(IDM_EXPORTSAVE, _("Export Wii save (Experimental)")); } popupMenu->Append(IDM_OPENCONTAININGFOLDER, _("Open &containing folder")); popupMenu->AppendCheckItem(IDM_SETDEFAULTGCM, _("Set as &default ISO")); // First we have to decide a starting value when we append it if(selected_iso->GetFileName() == SConfig::GetInstance(). m_LocalCoreStartupParameter.m_strDefaultGCM) popupMenu->FindItem(IDM_SETDEFAULTGCM)->Check(); popupMenu->AppendSeparator(); popupMenu->Append(IDM_DELETEGCM, _("&Delete ISO...")); if (selected_iso->GetPlatform() != GameListItem::WII_WAD) { if (selected_iso->IsCompressed()) popupMenu->Append(IDM_COMPRESSGCM, _("Decompress ISO...")); else if (selected_iso->GetFileName().substr(selected_iso->GetFileName().find_last_of(".")) != ".ciso" && selected_iso->GetFileName().substr(selected_iso->GetFileName().find_last_of(".")) != ".wbfs") popupMenu->Append(IDM_COMPRESSGCM, _("Compress ISO...")); } else popupMenu->Append(IDM_LIST_INSTALLWAD, _("Install to Wii Menu")); PopupMenu(popupMenu); } } else if (GetSelectedItemCount() > 1) { wxMenu* popupMenu = new wxMenu; popupMenu->Append(IDM_DELETEGCM, _("&Delete selected ISOs...")); popupMenu->AppendSeparator(); popupMenu->Append(IDM_MULTICOMPRESSGCM, _("Compress selected ISOs...")); popupMenu->Append(IDM_MULTIDECOMPRESSGCM, _("Decompress selected ISOs...")); PopupMenu(popupMenu); } }
void CGameListCtrl::Update() { int scrollPos = wxWindow::GetScrollPos(wxVERTICAL); // Don't let the user refresh it while a game is running if (Core::GetState() != Core::CORE_UNINITIALIZED) return; if (m_imageListSmall) { delete m_imageListSmall; m_imageListSmall = NULL; } // NetPlay : Set/Reset the GameList string m_gameList.clear(); m_gamePath.clear(); Hide(); ScanForISOs(); ClearAll(); if (m_ISOFiles.size() != 0) { // Don't load bitmaps unless there are games to list InitBitmaps(); // add columns InsertColumn(COLUMN_DUMMY,_T("")); InsertColumn(COLUMN_PLATFORM, _T("")); InsertColumn(COLUMN_BANNER, _("Banner")); InsertColumn(COLUMN_TITLE, _("Title")); // Instead of showing the notes + the company, which is unknown with // wii titles We show in the same column : company for GC games and // description for wii/wad games InsertColumn(COLUMN_NOTES, _("Notes")); InsertColumn(COLUMN_COUNTRY, _T("")); InsertColumn(COLUMN_SIZE, _("Size")); InsertColumn(COLUMN_EMULATION_STATE, _("State")); #ifdef __WXMSW__ const int platform_padding = 0; #else const int platform_padding = 8; #endif // set initial sizes for columns SetColumnWidth(COLUMN_DUMMY,0); SetColumnWidth(COLUMN_PLATFORM, 35 + platform_padding); SetColumnWidth(COLUMN_BANNER, 96 + platform_padding); SetColumnWidth(COLUMN_TITLE, 200 + platform_padding); SetColumnWidth(COLUMN_NOTES, 200 + platform_padding); SetColumnWidth(COLUMN_COUNTRY, 32 + platform_padding); SetColumnWidth(COLUMN_EMULATION_STATE, 50 + platform_padding); // add all items for (int i = 0; i < (int)m_ISOFiles.size(); i++) { InsertItemInReportView(i); if (m_ISOFiles[i]->IsCompressed()) SetItemTextColour(i, wxColour(0xFF0000)); } // Sort items by Title if (!sorted) last_column = 0; sorted = false; wxListEvent event; event.m_col = SConfig::GetInstance().m_ListSort2; OnColumnClick(event); event.m_col = SConfig::GetInstance().m_ListSort; OnColumnClick(event); sorted = true; SetColumnWidth(COLUMN_SIZE, wxLIST_AUTOSIZE); } else { wxString errorString; // We just check for one hide setting to be enabled, as we may only // have GC games for example, and hide them, so we should show the // second message instead if ((SConfig::GetInstance().m_ListGC && SConfig::GetInstance().m_ListWii && SConfig::GetInstance().m_ListWad) && (SConfig::GetInstance().m_ListJap && SConfig::GetInstance().m_ListUsa && SConfig::GetInstance().m_ListPal)) { errorString = _("Dolphin could not find any GC/Wii ISOs. Doubleclick here to browse for files..."); } else { errorString = _("Dolphin is currently set to hide all games. Doubleclick here to show all games..."); } InsertColumn(0, _("No ISOs or WADS found")); long index = InsertItem(0, errorString); SetItemFont(index, *wxITALIC_FONT); SetColumnWidth(0, wxLIST_AUTOSIZE); } if (GetSelectedISO() == NULL) main_frame->UpdateGUI(); Show(); AutomaticColumnWidth(); ScrollLines(scrollPos); SetFocus(); }
void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) { const GameListItem *iso = GetSelectedISO(); if (!iso) return; wxString path; std::string FileName, FilePath, FileExtension; SplitPath(iso->GetFileName(), &FilePath, &FileName, &FileExtension); do { if (iso->IsCompressed()) { wxString FileType; if (iso->GetPlatform() == GameListItem::WII_DISC) FileType = _("All Wii ISO files (iso)") + wxString(wxT("|*.iso")); else FileType = _("All Gamecube GCM files (gcm)") + wxString(wxT("|*.gcm")); path = wxFileSelector( _("Save decompressed GCM/ISO"), wxString(FilePath.c_str(), *wxConvCurrent), wxString(FileName.c_str(), *wxConvCurrent) + FileType.After('*'), wxEmptyString, FileType + wxT("|") + wxGetTranslation(wxALL_FILES), wxFD_SAVE, this); } else { path = wxFileSelector( _("Save compressed GCM/ISO"), wxString(FilePath.c_str(), *wxConvCurrent), wxString(FileName.c_str(), *wxConvCurrent) + _T(".gcz"), wxEmptyString, _("All compressed GC/Wii ISO files (gcz)") + wxString::Format(wxT("|*.gcz|%s"), wxGetTranslation(wxALL_FILES)), wxFD_SAVE, this); } if (!path) return; } while (wxFileExists(path) && wxMessageBox( wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"), path.c_str()), _("Confirm File Overwrite"), wxYES_NO) == wxNO); bool all_good = false; { wxProgressDialog dialog( iso->IsCompressed() ? _("Decompressing ISO") : _("Compressing ISO"), _("Working..."), 1000, this, wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME | wxPD_SMOOTH ); if (iso->IsCompressed()) all_good = DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(), path.char_str(), &CompressCB, &dialog); else all_good = DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), path.char_str(), (iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0, 16384, &CompressCB, &dialog); } if (!all_good) wxMessageBox(_("Dolphin was unable to complete the requested action.")); Update(); }
void CGameListCtrl::CompressSelection(bool _compress) { wxString dirHome; wxGetHomeDir(&dirHome); wxDirDialog browseDialog(this, _("Browse for output directory"), dirHome, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST); if (browseDialog.ShowModal() != wxID_OK) return; bool all_good = true; { wxProgressDialog progressDialog( _compress ? _("Compressing ISO") : _("Decompressing ISO"), _("Working..."), 1000, this, wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME | wxPD_SMOOTH ); m_currentItem = 0; m_numberItem = GetSelectedItemCount(); for (u32 i=0; i < m_numberItem; i++) { const GameListItem *iso = GetSelectedISO(); if (!iso->IsCompressed() && _compress) { std::string FileName, FileExt; SplitPath(iso->GetFileName(), NULL, &FileName, &FileExt); m_currentFilename = FileName; FileName.append(".gcz"); std::string OutputFileName; BuildCompleteFilename(OutputFileName, (const char *)browseDialog.GetPath().mb_str(wxConvUTF8), FileName); if (wxFileExists(wxString::FromAscii(OutputFileName.c_str())) && wxMessageBox( wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"), wxString(OutputFileName.c_str(), *wxConvCurrent).c_str()), _("Confirm File Overwrite"), wxYES_NO) == wxNO) continue; all_good &= DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), OutputFileName.c_str(), (iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0, 16384, &MultiCompressCB, &progressDialog); } else if (iso->IsCompressed() && !_compress) { std::string FileName, FileExt; SplitPath(iso->GetFileName(), NULL, &FileName, &FileExt); m_currentFilename = FileName; if (iso->GetPlatform() == GameListItem::WII_DISC) FileName.append(".iso"); else FileName.append(".gcm"); std::string OutputFileName; BuildCompleteFilename(OutputFileName, (const char *)browseDialog.GetPath().mb_str(wxConvUTF8), FileName); if (wxFileExists(wxString::FromAscii(OutputFileName.c_str())) && wxMessageBox( wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"), wxString(OutputFileName.c_str(), *wxConvCurrent).c_str()), _("Confirm File Overwrite"), wxYES_NO) == wxNO) continue; all_good &= DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(), OutputFileName.c_str(), &MultiCompressCB, &progressDialog); } m_currentItem++; } } if (!all_good) wxMessageBox(_("Dolphin was unable to complete the requested action.")); Update(); }
void CGameListCtrl::OnRightClick(wxMouseEvent& event) { // Focus the clicked item. int flags; long item = HitTest(event.GetPosition(), flags); if (item != wxNOT_FOUND) { if (GetItemState(item, wxLIST_STATE_SELECTED) != wxLIST_STATE_SELECTED) { UnselectAll(); SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); } SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); } if (GetSelectedItemCount() == 1) { const GameListItem* selected_iso = GetSelectedISO(); if (selected_iso) { wxMenu popupMenu; DiscIO::IVolume::EPlatform platform = selected_iso->GetPlatform(); if (platform != DiscIO::IVolume::ELF_DOL) { popupMenu.Append(IDM_PROPERTIES, _("&Properties")); popupMenu.Append(IDM_GAME_WIKI, _("&Wiki")); popupMenu.AppendSeparator(); } if (platform == DiscIO::IVolume::WII_DISC || platform == DiscIO::IVolume::WII_WAD) { popupMenu.Append(IDM_OPEN_SAVE_FOLDER, _("Open Wii &save folder")); popupMenu.Append(IDM_EXPORT_SAVE, _("Export Wii save (Experimental)")); } popupMenu.Append(IDM_OPEN_CONTAINING_FOLDER, _("Open &containing folder")); if (platform != DiscIO::IVolume::ELF_DOL) popupMenu.AppendCheckItem(IDM_SET_DEFAULT_ISO, _("Set as &default ISO")); // First we have to decide a starting value when we append it if (platform == SConfig::GetInstance().m_strDefaultISO) popupMenu.FindItem(IDM_SET_DEFAULT_ISO)->Check(); popupMenu.AppendSeparator(); popupMenu.Append(IDM_DELETE_ISO, _("&Delete File...")); if (platform == DiscIO::IVolume::GAMECUBE_DISC || platform == DiscIO::IVolume::WII_DISC) { if (selected_iso->GetBlobType() == DiscIO::BlobType::GCZ) popupMenu.Append(IDM_COMPRESS_ISO, _("Decompress ISO...")); else if (selected_iso->GetBlobType() == DiscIO::BlobType::PLAIN) popupMenu.Append(IDM_COMPRESS_ISO, _("Compress ISO...")); wxMenuItem* changeDiscItem = popupMenu.Append(IDM_LIST_CHANGE_DISC, _("Change &Disc")); changeDiscItem->Enable(Core::IsRunning()); } if (platform == DiscIO::IVolume::WII_WAD) popupMenu.Append(IDM_LIST_INSTALL_WAD, _("Install to Wii Menu")); PopupMenu(&popupMenu); } } else if (GetSelectedItemCount() > 1) { wxMenu popupMenu; popupMenu.Append(IDM_DELETE_ISO, _("&Delete selected ISOs...")); popupMenu.AppendSeparator(); popupMenu.Append(IDM_MULTI_COMPRESS_ISO, _("Compress selected ISOs...")); popupMenu.Append(IDM_MULTI_DECOMPRESS_ISO, _("Decompress selected ISOs...")); PopupMenu(&popupMenu); } }
void CGameListCtrl::Update() { int scrollPos = wxWindow::GetScrollPos(wxVERTICAL); // Don't let the user refresh it while a game is running if (Core::GetState() != Core::CORE_UNINITIALIZED) return; if (m_imageListSmall) { delete m_imageListSmall; m_imageListSmall = nullptr; } Hide(); ScanForISOs(); ClearAll(); if (m_ISOFiles.size() != 0) { // Don't load bitmaps unless there are games to list InitBitmaps(); // add columns InsertColumn(COLUMN_DUMMY, ""); InsertColumn(COLUMN_PLATFORM, ""); InsertColumn(COLUMN_BANNER, _("Banner")); InsertColumn(COLUMN_TITLE, _("Title")); InsertColumn(COLUMN_MAKER, _("Maker")); InsertColumn(COLUMN_FILENAME, _("File")); InsertColumn(COLUMN_ID, _("ID")); InsertColumn(COLUMN_COUNTRY, ""); InsertColumn(COLUMN_SIZE, _("Size")); InsertColumn(COLUMN_EMULATION_STATE, _("State")); #ifdef __WXMSW__ const int platform_padding = 0; #else const int platform_padding = 8; #endif const int platform_icon_padding = 1; // set initial sizes for columns SetColumnWidth(COLUMN_DUMMY, 0); SetColumnWidth(COLUMN_PLATFORM, SConfig::GetInstance().m_showSystemColumn ? 32 + platform_icon_padding + platform_padding : 0); SetColumnWidth(COLUMN_BANNER, SConfig::GetInstance().m_showBannerColumn ? 96 + platform_padding : 0); SetColumnWidth(COLUMN_TITLE, 175 + platform_padding); SetColumnWidth(COLUMN_MAKER, SConfig::GetInstance().m_showMakerColumn ? 150 + platform_padding : 0); SetColumnWidth(COLUMN_FILENAME, SConfig::GetInstance().m_showFileNameColumn ? 100 + platform_padding : 0); SetColumnWidth(COLUMN_ID, SConfig::GetInstance().m_showIDColumn ? 75 + platform_padding : 0); SetColumnWidth(COLUMN_COUNTRY, SConfig::GetInstance().m_showRegionColumn ? 32 + platform_padding : 0); SetColumnWidth(COLUMN_EMULATION_STATE, SConfig::GetInstance().m_showStateColumn ? 48 + platform_padding : 0); // add all items for (int i = 0; i < (int)m_ISOFiles.size(); i++) { InsertItemInReportView(i); if (SConfig::GetInstance().m_ColorCompressed && m_ISOFiles[i]->IsCompressed()) SetItemTextColour(i, wxColour(0xFF0000)); } // Sort items by Title if (!sorted) last_column = 0; sorted = false; wxListEvent event; event.m_col = SConfig::GetInstance().m_ListSort2; OnColumnClick(event); event.m_col = SConfig::GetInstance().m_ListSort; OnColumnClick(event); sorted = true; SetColumnWidth(COLUMN_SIZE, SConfig::GetInstance().m_showSizeColumn ? wxLIST_AUTOSIZE : 0); } else { wxString errorString; // We just check for one hide setting to be enabled, as we may only // have GC games for example, and hide them, so we should show the // first message instead if (IsHidingItems()) { errorString = _("Dolphin is currently set to hide all games. Double-click here to show all games..."); } else { errorString = _("Dolphin could not find any GameCube/Wii ISOs or WADs. Double-click here to set a games directory..."); } InsertColumn(0, ""); long index = InsertItem(0, errorString); SetItemFont(index, *wxITALIC_FONT); SetColumnWidth(0, wxLIST_AUTOSIZE); } if (GetSelectedISO() == nullptr) main_frame->UpdateGUI(); Show(); AutomaticColumnWidth(); ScrollLines(scrollPos); SetFocus(); }
void CGameListCtrl::OnCompressISO(wxCommandEvent& WXUNUSED (event)) { const GameListItem* iso = GetSelectedISO(); if (!iso) return; bool is_compressed = iso->GetBlobType() == DiscIO::BlobType::GCZ; wxString path; std::string FileName, FilePath, FileExtension; SplitPath(iso->GetFileName(), &FilePath, &FileName, &FileExtension); do { if (is_compressed) { wxString FileType; if (iso->GetPlatform() == DiscIO::IVolume::WII_DISC) FileType = _("All Wii ISO files (iso)") + "|*.iso"; else FileType = _("All GameCube GCM files (gcm)") + "|*.gcm"; path = wxFileSelector( _("Save decompressed GCM/ISO"), StrToWxStr(FilePath), StrToWxStr(FileName) + FileType.After('*'), wxEmptyString, FileType + "|" + wxGetTranslation(wxALL_FILES), wxFD_SAVE, this); } else { if (iso->GetPlatform() == DiscIO::IVolume::WII_DISC && !WiiCompressWarning()) return; path = wxFileSelector( _("Save compressed GCM/ISO"), StrToWxStr(FilePath), StrToWxStr(FileName) + ".gcz", wxEmptyString, _("All compressed GC/Wii ISO files (gcz)") + wxString::Format("|*.gcz|%s", wxGetTranslation(wxALL_FILES)), wxFD_SAVE, this); } if (!path) return; } while (wxFileExists(path) && wxMessageBox( wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"), path.c_str()), _("Confirm File Overwrite"), wxYES_NO) == wxNO); bool all_good = false; { wxProgressDialog dialog( is_compressed ? _("Decompressing ISO") : _("Compressing ISO"), _("Working..."), 1000, this, wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME | wxPD_SMOOTH ); if (is_compressed) all_good = DiscIO::DecompressBlobToFile(iso->GetFileName(), WxStrToStr(path), &CompressCB, &dialog); else all_good = DiscIO::CompressFileToBlob(iso->GetFileName(), WxStrToStr(path), (iso->GetPlatform() == DiscIO::IVolume::WII_DISC) ? 1 : 0, 16384, &CompressCB, &dialog); } if (!all_good) WxUtils::ShowErrorDialog(_("Dolphin was unable to complete the requested action.")); Update(); }