summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorfires.gc <fires.gc@gmail.com>2008-10-03 21:48:18 +0000
committerfires.gc <fires.gc@gmail.com>2008-10-03 21:48:18 +0000
commit8997f9cb3e2eaa86e731d1897ce7d669437a2115 (patch)
tree50b308d5ba98a3acadc6a4042d4ea148a2a72e15 /Source/Core
parentd162fa6ade19f7fe6f86cbaee781e7167b8a73ec (diff)
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
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinWX/Src/Frame.cpp2
-rw-r--r--Source/Core/DolphinWX/Src/GameListCtrl.cpp190
-rw-r--r--Source/Core/DolphinWX/Src/GameListCtrl.h8
-rw-r--r--Source/Core/DolphinWX/Src/Globals.h2
4 files changed, 167 insertions, 35 deletions
diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp
index 6d43afd6e0..d2683ad189 100644
--- a/Source/Core/DolphinWX/Src/Frame.cpp
+++ b/Source/Core/DolphinWX/Src/Frame.cpp
@@ -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);
diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp
index f20ab2f34d..1ce34be67b 100644
--- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp
+++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp
@@ -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,31 +516,47 @@ 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);
}
- const GameListItem *selected_iso = GetSelectedISO();
- if (selected_iso)
+
+ if (GetSelectedItemCount() == 1)
{
- std::string unique_id = selected_iso->GetUniqueID();
- wxMenu popupMenu;
- std::string menu_text = StringFromFormat("Edit &patch file: %s.ini", unique_id.c_str());
- popupMenu.Append(IDM_EDITPATCHFILE, wxString::FromAscii(menu_text.c_str())); //Pretty much everything in wxwidgets is a wxString, try to convert to those first!
- popupMenu.Append(IDM_OPENCONTAININGFOLDER, wxString::FromAscii("Open &containing folder"));
- popupMenu.Append(IDM_FILESYSTEMVIEWER, wxString::FromAscii("Open in ISO viewer/dumper"));
- popupMenu.AppendCheckItem(IDM_SETDEFAULTGCM, wxString::FromAscii("Set as &default ISO"));
- if(selected_iso->GetFileName() == SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM)
- popupMenu.FindItemByPosition(3)->Check();
-
- popupMenu.AppendSeparator();
- popupMenu.Append(IDM_DELETEGCM, wxString::FromAscii("&Delete ISO..."));
-
- if (selected_iso->IsCompressed())
- popupMenu.Append(IDM_COMPRESSGCM, wxString::FromAscii("Decompress ISO... (UNTESTED)"));
- else
- popupMenu.Append(IDM_COMPRESSGCM, wxString::FromAscii("Compress ISO... (UNTESTED)"));
+ const GameListItem *selected_iso = GetSelectedISO();
+ if (selected_iso)
+ {
+ std::string unique_id = selected_iso->GetUniqueID();
+ wxMenu popupMenu;
+ std::string menu_text = StringFromFormat("Edit &patch file: %s.ini", unique_id.c_str());
+ popupMenu.Append(IDM_EDITPATCHFILE, wxString::FromAscii(menu_text.c_str())); //Pretty much everything in wxwidgets is a wxString, try to convert to those first!
+ popupMenu.Append(IDM_OPENCONTAININGFOLDER, wxString::FromAscii("Open &containing folder"));
+ popupMenu.Append(IDM_FILESYSTEMVIEWER, wxString::FromAscii("Open in ISO viewer/dumper"));
+ popupMenu.AppendCheckItem(IDM_SETDEFAULTGCM, wxString::FromAscii("Set as &default ISO"));
+ if(selected_iso->GetFileName() == SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM)
+ popupMenu.FindItemByPosition(3)->Check();
+
+ popupMenu.AppendSeparator();
+ popupMenu.Append(IDM_DELETEGCM, wxString::FromAscii("&Delete ISO..."));
+
+ if (selected_iso->IsCompressed())
+ popupMenu.Append(IDM_COMPRESSGCM, wxString::FromAscii("Decompress ISO... (UNTESTED)"));
+ else
+ popupMenu.Append(IDM_COMPRESSGCM, wxString::FromAscii("Compress ISO... (UNTESTED)"));
+ 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);
}
}
@@ -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;
@@ -668,9 +775,9 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) {
wxPD_REMAINING_TIME |
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);
+ }
+
+} \ No newline at end of file
diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.h b/Source/Core/DolphinWX/Src/GameListCtrl.h
index 2b579625b3..eec8fe933a 100644
--- a/Source/Core/DolphinWX/Src/GameListCtrl.h
+++ b/Source/Core/DolphinWX/Src/GameListCtrl.h
@@ -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);
};
diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h
index 26666a00c2..883d6f96b3 100644
--- a/Source/Core/DolphinWX/Src/Globals.h
+++ b/Source/Core/DolphinWX/Src/Globals.h
@@ -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,