added support for multi selection to compress/decompress multiple files at once (btw: it sux that we have to kick the garbage with another tool:))
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@759 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
d162fa6ade
commit
8997f9cb3e
|
@ -154,7 +154,7 @@ CFrame::CFrame(wxFrame* parent,
|
|||
|
||||
m_GameListCtrl = new CGameListCtrl(m_Panel, LIST_CTRL,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL);
|
||||
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT);
|
||||
|
||||
wxBoxSizer* sizerPanel = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizerPanel->Add(m_GameListCtrl, 2, wxEXPAND | wxALL);
|
||||
|
|
|
@ -37,8 +37,12 @@
|
|||
#include "../resources/Flag_USA.xpm"
|
||||
#endif // USE_XPM_BITMAPS
|
||||
|
||||
static int currentColumn = 0;
|
||||
size_t CGameListCtrl::m_currentItem = 0;
|
||||
size_t CGameListCtrl::m_numberItem = 0;
|
||||
std::string CGameListCtrl::m_currentFilename;
|
||||
|
||||
|
||||
static int currentColumn = 0;
|
||||
bool operator < (const GameListItem &one, const GameListItem &other)
|
||||
{
|
||||
switch(currentColumn)
|
||||
|
@ -66,6 +70,8 @@ EVT_MENU(IDM_OPENCONTAININGFOLDER, CGameListCtrl::OnOpenContainingFolder)
|
|||
EVT_MENU(IDM_SETDEFAULTGCM, CGameListCtrl::OnSetDefaultGCM)
|
||||
EVT_MENU(IDM_FILESYSTEMVIEWER, CGameListCtrl::OnFilesystemViewer)
|
||||
EVT_MENU(IDM_COMPRESSGCM, CGameListCtrl::OnCompressGCM)
|
||||
EVT_MENU(IDM_MULTICOMPRESSGCM, CGameListCtrl::OnMultiCompressGCM)
|
||||
EVT_MENU(IDM_MULTIDECOMPRESSGCM, CGameListCtrl::OnMultiDecompressGCM)
|
||||
EVT_MENU(IDM_DELETEGCM, CGameListCtrl::OnDeleteGCM)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
@ -388,7 +394,6 @@ void CGameListCtrl::ScanForISOs()
|
|||
_T("Scanning..."),
|
||||
rFilenames.size(), // range
|
||||
this, // parent
|
||||
wxPD_CAN_ABORT |
|
||||
wxPD_APP_MODAL |
|
||||
// wxPD_AUTO_HIDE | -- try this as well
|
||||
wxPD_ELAPSED_TIME |
|
||||
|
@ -511,10 +516,18 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
|
|||
// Focus the clicked item.
|
||||
int flags;
|
||||
long item = HitTest(event.GetPosition(), flags);
|
||||
if (item != wxNOT_FOUND) {
|
||||
SetItemState(item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
|
||||
wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
||||
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)
|
||||
{
|
||||
|
@ -539,6 +552,14 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
|
|||
PopupMenu(&popupMenu);
|
||||
}
|
||||
}
|
||||
else if (GetSelectedItemCount() > 1)
|
||||
{
|
||||
wxMenu popupMenu;
|
||||
popupMenu.Append(IDM_MULTICOMPRESSGCM, wxString::FromAscii("Compress selected ISOs..."));
|
||||
popupMenu.Append(IDM_MULTIDECOMPRESSGCM, wxString::FromAscii("Decompress selected ISOs..."));
|
||||
PopupMenu(&popupMenu);
|
||||
}
|
||||
}
|
||||
|
||||
void CGameListCtrl::OnActivated(wxListEvent& event)
|
||||
{
|
||||
|
@ -566,7 +587,8 @@ const GameListItem * CGameListCtrl::GetSelectedISO() const
|
|||
return &m_ISOFiles[GetItemData(item)];
|
||||
}
|
||||
|
||||
void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) {
|
||||
void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
|
@ -575,7 +597,8 @@ void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) {
|
|||
File::Explore(path.c_str());
|
||||
}
|
||||
|
||||
void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||
void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
|
@ -583,7 +606,8 @@ void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
|
|||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||
void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
|
@ -594,7 +618,8 @@ void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event)) {
|
|||
Update();
|
||||
}
|
||||
|
||||
void CGameListCtrl::OnFilesystemViewer(wxCommandEvent& WXUNUSED (event)) {
|
||||
void CGameListCtrl::OnFilesystemViewer(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
|
@ -602,13 +627,95 @@ void CGameListCtrl::OnFilesystemViewer(wxCommandEvent& WXUNUSED (event)) {
|
|||
FSViewer.ShowModal();
|
||||
}
|
||||
|
||||
void CGameListCtrl::MultiCompressCB(const char* text, float percent, void* arg)
|
||||
{
|
||||
wxString textString(wxString::Format("%s (%i/%i) - %s", m_currentFilename.c_str(), m_currentItem+1, m_numberItem, text));
|
||||
|
||||
percent = (((float)m_currentItem) + percent) / (float)m_numberItem;
|
||||
wxProgressDialog* pDialog = (wxProgressDialog*)arg;
|
||||
pDialog->Update((int)(percent*1000), textString);
|
||||
}
|
||||
|
||||
void CGameListCtrl::OnMultiCompressGCM(wxCommandEvent& /*event*/)
|
||||
{
|
||||
CompressSelection(true);
|
||||
}
|
||||
|
||||
void CGameListCtrl::OnMultiDecompressGCM(wxCommandEvent& /*event*/)
|
||||
{
|
||||
CompressSelection(false);
|
||||
}
|
||||
|
||||
void CGameListCtrl::CompressSelection(bool _compress)
|
||||
{
|
||||
wxString dirHome;
|
||||
wxGetHomeDir(&dirHome);
|
||||
|
||||
wxDirDialog browseDialog(this, _T("Browse for output directory"), dirHome, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
|
||||
if (browseDialog.ShowModal() != wxID_OK)
|
||||
return;
|
||||
|
||||
wxProgressDialog progressDialog(_compress ? _T("Compressing ISO") : _T("Decompressing ISO"),
|
||||
_T("Working..."),
|
||||
1000, // range
|
||||
this, // parent
|
||||
wxPD_APP_MODAL |
|
||||
// wxPD_AUTO_HIDE | -- try this as well
|
||||
wxPD_ELAPSED_TIME |
|
||||
wxPD_ESTIMATED_TIME |
|
||||
wxPD_REMAINING_TIME |
|
||||
wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
|
||||
);
|
||||
|
||||
progressDialog.SetSize(wxSize(600, 180));
|
||||
progressDialog.CenterOnParent();
|
||||
|
||||
m_currentItem = 0;
|
||||
m_numberItem = GetSelectedItemCount();
|
||||
for (size_t i=0; i<GetItemCount(); i++)
|
||||
{
|
||||
const GameListItem& rISOFile = m_ISOFiles[i];
|
||||
if (GetItemState(i, wxLIST_STATE_SELECTED) == wxLIST_STATE_SELECTED)
|
||||
{
|
||||
if (!rISOFile.IsCompressed() && _compress)
|
||||
{
|
||||
std::string FileName;
|
||||
SplitPath(rISOFile.GetFileName(), NULL, &FileName, NULL);
|
||||
m_currentFilename = FileName;
|
||||
FileName.append(".gcz");
|
||||
|
||||
std::string OutputFileName;
|
||||
BuildCompleteFilename(OutputFileName, browseDialog.GetPath().ToAscii(), FileName);
|
||||
|
||||
DiscIO::CompressFileToBlob(rISOFile.GetFileName().c_str(), OutputFileName.c_str(), 0, 16384, &MultiCompressCB, &progressDialog);
|
||||
}
|
||||
else if (rISOFile.IsCompressed() && !_compress)
|
||||
{
|
||||
std::string FileName;
|
||||
SplitPath(rISOFile.GetFileName(), NULL, &FileName, NULL);
|
||||
m_currentFilename = FileName;
|
||||
FileName.append(".gcm");
|
||||
|
||||
std::string OutputFileName;
|
||||
BuildCompleteFilename(OutputFileName, browseDialog.GetPath().ToAscii(), FileName);
|
||||
|
||||
DiscIO::DecompressBlobToFile(rISOFile.GetFileName().c_str(), OutputFileName.c_str(), &MultiCompressCB, &progressDialog);
|
||||
}
|
||||
m_currentItem++;
|
||||
}
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
void CGameListCtrl::CompressCB(const char* text, float percent, void* arg)
|
||||
{
|
||||
wxProgressDialog* pDialog = (wxProgressDialog*)arg;
|
||||
pDialog->Update((int)(percent*1000), wxString::FromAscii(text));
|
||||
}
|
||||
|
||||
void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||
void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
|
@ -669,8 +776,8 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) {
|
|||
wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
|
||||
);
|
||||
|
||||
dialog.CenterOnParent();
|
||||
dialog.SetSize(wxSize(280, 180));
|
||||
dialog.CenterOnParent();
|
||||
|
||||
if (iso->IsCompressed())
|
||||
DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(), path.char_str(), &CompressCB, &dialog);
|
||||
|
@ -685,9 +792,12 @@ void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
|
|||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
|
||||
std::string filename = "GameIni/" + iso->GetUniqueID() + ".ini";
|
||||
if (!File::Exists(filename.c_str())) {
|
||||
if (AskYesNo("%s.ini does not exist. Do you want to create it?", iso->GetUniqueID().c_str())) {
|
||||
if (!File::Exists(filename.c_str()))
|
||||
{
|
||||
if (AskYesNo("%s.ini does not exist. Do you want to create it?", iso->GetUniqueID().c_str()))
|
||||
{
|
||||
FILE *f = fopen(filename.c_str(), "w");
|
||||
fprintf(f, "# %s - %s\r\n\r\n", iso->GetUniqueID().c_str(), iso->GetName().c_str());
|
||||
fprintf(f, "[EmuState]\n#The Emulation State.\n");
|
||||
|
@ -695,7 +805,9 @@ void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
|
|||
fprintf(f, "[OnFrame]\r\n#Add memory patches here.\r\n\r\n");
|
||||
fprintf(f, "[ActionReplay]\r\n#Add decrypted action replay cheats here.\r\n");
|
||||
fclose(f);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -731,3 +843,13 @@ void CGameListCtrl::AutomaticColumnWidth()
|
|||
SetColumnWidth(COLUMN_NOTES, wxMax(0.5*resizable, 100));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CGameListCtrl::UnselectAll()
|
||||
{
|
||||
for (size_t i=0; i<GetItemCount(); i++)
|
||||
{
|
||||
SetItemState(i, 0, wxLIST_STATE_SELECTED);
|
||||
}
|
||||
|
||||
}
|
|
@ -76,13 +76,21 @@ private:
|
|||
void OnSetDefaultGCM(wxCommandEvent& event);
|
||||
void OnDeleteGCM(wxCommandEvent& event);
|
||||
void OnCompressGCM(wxCommandEvent& event);
|
||||
void OnMultiCompressGCM(wxCommandEvent& event);
|
||||
void OnMultiDecompressGCM(wxCommandEvent& event);
|
||||
void OnFilesystemViewer(wxCommandEvent& event);
|
||||
|
||||
virtual bool MSWDrawSubItem(wxPaintDC& rPaintDC, int item, int subitem);
|
||||
|
||||
void CompressSelection(bool _compress);
|
||||
void AutomaticColumnWidth();
|
||||
void UnselectAll();
|
||||
|
||||
static size_t m_currentItem;
|
||||
static std::string m_currentFilename;
|
||||
static size_t m_numberItem;
|
||||
static void CompressCB(const char* text, float percent, void* arg);
|
||||
static void MultiCompressCB(const char* text, float percent, void* arg);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ enum
|
|||
IDM_DELETEGCM,
|
||||
IDM_FILESYSTEMVIEWER,
|
||||
IDM_COMPRESSGCM,
|
||||
IDM_MULTICOMPRESSGCM,
|
||||
IDM_MULTIDECOMPRESSGCM,
|
||||
IDM_CONFIG_MAIN,
|
||||
IDM_CONFIG_GFX_PLUGIN,
|
||||
IDM_CONFIG_DSP_PLUGIN,
|
||||
|
|
Loading…
Reference in New Issue