From 2c6f851bbaea134d850636eed35535334f5a305a Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Sun, 1 Aug 2010 04:09:59 +0000 Subject: [PATCH] Clean up and fix some issues with the dialogs for compression and decompression of iso and gcm images. Also added a confirmation to overwrite existing files. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6024 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DiscIO/Src/CompressedBlob.cpp | 2 +- Source/Core/DolphinWX/Src/Frame.cpp | 10 +- Source/Core/DolphinWX/Src/FrameAui.cpp | 90 ++++++++-------- Source/Core/DolphinWX/Src/FrameTools.cpp | 24 ++--- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 118 +++++++++++++-------- 5 files changed, 134 insertions(+), 110 deletions(-) diff --git a/Source/Core/DiscIO/Src/CompressedBlob.cpp b/Source/Core/DiscIO/Src/CompressedBlob.cpp index 9523115bd7..e822d45e6c 100644 --- a/Source/Core/DiscIO/Src/CompressedBlob.cpp +++ b/Source/Core/DiscIO/Src/CompressedBlob.cpp @@ -227,7 +227,7 @@ bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type, if (inpos != 0) ratio = (int)(100 * position / inpos); char temp[512]; - sprintf(temp, "%i of %i blocks. compression ratio %i%%", i, header.num_blocks, ratio); + sprintf(temp, "%i of %i blocks. Compression ratio %i%%", i, header.num_blocks, ratio); callback(temp, (float)i / (float)header.num_blocks, arg); } diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index c26cbee1d9..a3443aebe7 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -432,9 +432,9 @@ CFrame::CFrame(wxFrame* parent, else { if (SConfig::GetInstance().m_InterfaceLogWindow) - ToggleLogWindow(true); + ToggleLogWindow(true); if (SConfig::GetInstance().m_InterfaceConsole) - ToggleConsole(true); + ToggleConsole(true); } // Show window @@ -450,7 +450,7 @@ CFrame::CFrame(wxFrame* parent, #if defined(HAVE_XRANDR) && HAVE_XRANDR m_XRRConfig = new X11Utils::XRRConfiguration(X11Utils::XDisplayFromHandle(GetHandle()), - X11Utils::XWindowFromHandle(GetHandle())); + X11Utils::XWindowFromHandle(GetHandle())); #endif // ------------------------- @@ -666,8 +666,8 @@ bool CFrame::RendererHasFocus() return false; // Why these different cases? if (m_RenderParent == wxWindow::FindFocus() || - m_RenderParent == wxWindow::FindFocus()->GetParent() || - m_RenderParent->GetParent() == wxWindow::FindFocus()->GetParent()) + m_RenderParent == wxWindow::FindFocus()->GetParent() || + m_RenderParent->GetParent() == wxWindow::FindFocus()->GetParent()) return true; #endif return false; diff --git a/Source/Core/DolphinWX/Src/FrameAui.cpp b/Source/Core/DolphinWX/Src/FrameAui.cpp index 16dc073946..0a8a4069e6 100644 --- a/Source/Core/DolphinWX/Src/FrameAui.cpp +++ b/Source/Core/DolphinWX/Src/FrameAui.cpp @@ -145,8 +145,8 @@ void CFrame::ToggleConsole(bool bShow) ConsoleParent->Enable(); DoAddPage(ConsoleParent, - g_pCodeWindow ? g_pCodeWindow->iNbAffiliation[1] : 0, - g_pCodeWindow ? bFloatWindow[1] : false); + g_pCodeWindow ? g_pCodeWindow->iNbAffiliation[1] : 0, + g_pCodeWindow ? bFloatWindow[1] : false); } else // Hide { @@ -246,9 +246,9 @@ void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event) wxAuiNotebook* Ctrl = (wxAuiNotebook*)event.GetEventObject(); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOGWINDOW) - ToggleLogWindow(false); + ToggleLogWindow(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_CONSOLEWINDOW) - ToggleConsole(false); + ToggleConsole(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_REGISTERWINDOW) g_pCodeWindow->ToggleRegisterWindow(false); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_BREAKPOINTWINDOW) @@ -308,7 +308,7 @@ void CFrame::DoFloatNotebookPage(wxWindowID Id) nb->RemovePage(nb->GetPageIndex(Win)); // Create the parent frame and reparent the window CreateParentFrame(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW, - Win->GetName(), Win); + Win->GetName(), Win); if (nb->GetPageCount() == 0) AddRemoveBlankPage(); } @@ -335,7 +335,7 @@ void CFrame::OnTab(wxAuiNotebookEvent& event) wxMenu* MenuPopup = new wxMenu; wxMenuItem* Item = new wxMenuItem(MenuPopup, wxID_ANY, - wxT("Select floating windows")); + wxT("Select floating windows")); MenuPopup->Append(Item); Item->Enable(false); MenuPopup->Append(new wxMenuItem(MenuPopup)); @@ -345,7 +345,7 @@ void CFrame::OnTab(wxAuiNotebookEvent& event) if (Win && Win->IsEnabled()) { Item = new wxMenuItem(MenuPopup, i + IDM_FLOAT_LOGWINDOW - IDM_LOGWINDOW, - Win->GetName(), wxT(""), wxITEM_CHECK); + Win->GetName(), wxT(""), wxITEM_CHECK); MenuPopup->Append(Item); Item->Check(!!FindWindowById(i + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW)); } @@ -402,7 +402,7 @@ void CFrame::DoRemovePage(wxWindow *Win, bool bHide) if (!Win) return; wxWindow *Parent = FindWindowById(Win->GetId() + - IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW); + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW); if (Parent) { @@ -446,7 +446,7 @@ void CFrame::DoAddPage(wxWindow *Win, int i, bool Float) GetNotebookFromId(i)->AddPage(Win, Win->GetName(), true); else CreateParentFrame(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW, - Win->GetName(), Win); + Win->GetName(), Win); } // Toolbar @@ -464,15 +464,15 @@ void CFrame::OnDropDownSettingsToolbar(wxAuiToolBarEvent& event) wxMenu* menuPopup = new wxMenu; wxMenuItem* Item = new wxMenuItem(menuPopup, IDM_PERSPECTIVES_ADD_PANE, - wxT("Add new pane")); + wxT("Add new pane")); menuPopup->Append(Item); menuPopup->Append(new wxMenuItem(menuPopup)); Item = new wxMenuItem(menuPopup, IDM_TAB_SPLIT, wxT("Tab split"), - wxT(""), wxITEM_CHECK); + wxT(""), wxITEM_CHECK); menuPopup->Append(Item); Item->Check(m_bTabSplit); Item = new wxMenuItem(menuPopup, IDM_NO_DOCKING, wxT("No docking"), - wxT(""), wxITEM_CHECK); + wxT(""), wxITEM_CHECK); menuPopup->Append(Item); Item->Check(m_bNoDocking); @@ -500,7 +500,7 @@ void CFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& event) // create the popup menu wxMenu* menuPopup = new wxMenu; wxMenuItem* Item = new wxMenuItem(menuPopup, IDM_ADD_PERSPECTIVE, - wxT("Create new perspective")); + wxT("Create new perspective")); menuPopup->Append(Item); if (Perspectives.size() > 0) @@ -509,8 +509,8 @@ void CFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& event) for (u32 i = 0; i < Perspectives.size(); i++) { wxMenuItem* mItem = new wxMenuItem(menuPopup, IDM_PERSPECTIVES_0 + i, - wxString::FromAscii(Perspectives[i].Name.c_str()), - wxT(""), wxITEM_CHECK); + wxString::FromAscii(Perspectives[i].Name.c_str()), + wxT(""), wxITEM_CHECK); menuPopup->Append(mItem); if (i == ActivePerspective) mItem->Check(true); } @@ -564,10 +564,10 @@ void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event) case IDM_ADD_PERSPECTIVE: { wxTextEntryDialog dlg(this, - wxT("Enter a name for the new perspective:"), - wxT("Create new perspective")); + wxT("Enter a name for the new perspective:"), + wxT("Create new perspective")); wxString DefaultValue = wxString::Format(wxT("Perspective %d"), - Perspectives.size() + 1); + Perspectives.size() + 1); dlg.SetValue(DefaultValue); bool DlgOk = false; int Return = 0; while (!DlgOk) @@ -578,7 +578,7 @@ void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event) else if (dlg.GetValue().Find(wxT(",")) != -1) { wxMessageBox(wxT("The name can not contain the character ','"), - wxT("Notice"), wxOK, this); + wxT("Notice"), wxOK, this); wxString Str = dlg.GetValue(); Str.Replace(wxT(","), wxT(""), true); dlg.SetValue(Str); @@ -586,7 +586,7 @@ void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event) else if (dlg.GetValue().IsSameAs(wxT(""))) { wxMessageBox(wxT("The name can not be empty"), - wxT("Notice"), wxOK, this); + wxT("Notice"), wxOK, this); dlg.SetValue(DefaultValue); } else @@ -697,7 +697,7 @@ void CFrame::ResizeConsole() if (!Win) return; const int wxBorder = 2, Border = 4, - MenuBar = 30, ScrollBar = 19; + MenuBar = 30, ScrollBar = 19; // Get the client size int X = Win->GetSize().GetX(); @@ -705,14 +705,14 @@ void CFrame::ResizeConsole() int InternalWidth = X - wxBorder*2 - ScrollBar; int InternalHeight = Y - wxBorder*2; int WindowWidth = InternalWidth + Border*2 + - /*max out the width in the word wrap mode*/ 100; + /*max out the width in the word wrap mode*/ 100; int WindowHeight = InternalHeight + MenuBar; // Resize buffer ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); Console->PixelSpace(0,0, InternalWidth, InternalHeight, false); // Move the window to hide the border MoveWindow(GetConsoleWindow(), -Border-wxBorder, -MenuBar-wxBorder, - WindowWidth + 100, WindowHeight, true); + WindowWidth + 100, WindowHeight, true); #endif } @@ -734,16 +734,16 @@ void CFrame::SetPaneSize() { if (!m_Mgr->GetAllPanes()[i].IsOk()) return; if (Perspectives[ActivePerspective].Width.size() <= j || - Perspectives[ActivePerspective].Height.size() <= j) - continue; + Perspectives[ActivePerspective].Height.size() <= j) + continue; u32 W = Perspectives[ActivePerspective].Width[j], - H = Perspectives[ActivePerspective].Height[j]; + H = Perspectives[ActivePerspective].Height[j]; // Check limits W = Limit(W, 5, 95); - H = Limit(H, 5, 95); + H = Limit(H, 5, 95); // Convert percentages to pixel lengths W = (W * iClientX) / 100; - H = (H * iClientY) / 100; + H = (H * iClientY) / 100; m_Mgr->GetAllPanes()[i].BestSize(W,H).MinSize(W,H); j++; @@ -826,7 +826,7 @@ void CFrame::LoadIniPerspectives() _Section = StringFromFormat("P - %s", Tmp.Name.c_str()); ini.Get(_Section.c_str(), "Perspective", &_Perspective, - "layout2|" + "layout2|" "name=Pane 0;caption=Pane 0;state=768;dir=5;prop=100000;|" "name=Pane 1;caption=Pane 1;state=31458108;dir=4;prop=100000;|" "dock_size(5,0,0)=22|dock_size(4,0,0)=333|"); @@ -868,7 +868,7 @@ void CFrame::UpdateCurrentPerspective() // Save width and height as a percentage of the client width and height current->Width.push_back( (m_Mgr->GetAllPanes()[i].window->GetClientSize().GetX() * 100) / - iClientX); + iClientX); current->Height.push_back( (m_Mgr->GetAllPanes()[i].window->GetClientSize().GetY() * 100) / iClientY); @@ -913,7 +913,7 @@ void CFrame::SaveIniPerspectives() } // Remove the ending "," SWidth = SWidth.substr(0, SWidth.length()-1); - SHeight = SHeight.substr(0, SHeight.length()-1); + SHeight = SHeight.substr(0, SHeight.length()-1); ini.Set(_Section.c_str(), "Width", SWidth.c_str()); ini.Set(_Section.c_str(), "Height", SHeight.c_str()); @@ -945,7 +945,7 @@ wxWindow * CFrame::GetNotebookPageFromId(wxWindowID Id) for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) - continue; + continue; wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; for(u32 j = 0; j < NB->GetPageCount(); j++) { @@ -956,10 +956,10 @@ wxWindow * CFrame::GetNotebookPageFromId(wxWindowID Id) } wxFrame * CFrame::CreateParentFrame(wxWindowID Id, const wxString& Title, - wxWindow * Child) + wxWindow * Child) { wxFrame * Frame = new wxFrame(this, Id, Title, - wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE); + wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE); Child->Reparent(Frame); @@ -989,10 +989,10 @@ wxFrame * CFrame::CreateParentFrame(wxWindowID Id, const wxString& Title, wxAuiNotebook* CFrame::CreateEmptyNotebook() { const long NOTEBOOK_STYLE = wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | - wxAUI_NB_TAB_EXTERNAL_MOVE | wxAUI_NB_SCROLL_BUTTONS | - wxAUI_NB_WINDOWLIST_BUTTON | wxNO_BORDER; + wxAUI_NB_TAB_EXTERNAL_MOVE | wxAUI_NB_SCROLL_BUTTONS | + wxAUI_NB_WINDOWLIST_BUTTON | wxNO_BORDER; wxAuiNotebook* NB = new wxAuiNotebook(this, wxID_ANY, - wxDefaultPosition, wxDefaultSize, NOTEBOOK_STYLE); + wxDefaultPosition, wxDefaultSize, NOTEBOOK_STYLE); return NB; } @@ -1001,15 +1001,15 @@ void CFrame::AddRemoveBlankPage() for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) - continue; + continue; wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; for(u32 j = 0; j < NB->GetPageCount(); j++) { if (NB->GetPageText(j).IsSameAs(wxT("<>")) && NB->GetPageCount() > 1) - NB->DeletePage(j); + NB->DeletePage(j); } if (NB->GetPageCount() == 0) - NB->AddPage(new wxPanel(this, wxID_ANY), wxT("<>"), true); + NB->AddPage(new wxPanel(this, wxID_ANY), wxT("<>"), true); } } @@ -1018,12 +1018,12 @@ int CFrame::GetNotebookAffiliation(wxWindowID Id) for (u32 i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) - continue; + continue; wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; for(u32 k = 0; k < NB->GetPageCount(); k++) { if (NB->GetPage(k)->GetId() == Id) - return j; + return j; } j++; } @@ -1050,7 +1050,7 @@ int CFrame::GetNotebookCount() for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) - Ret++; + Ret++; } return Ret; } @@ -1060,9 +1060,9 @@ wxAuiNotebook * CFrame::GetNotebookFromId(u32 NBId) for (u32 i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) - continue; + continue; if (j == NBId) - return (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; + return (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; j++; } return NULL; diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 9c53dd72d5..4091dd3b31 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -316,7 +316,7 @@ wxString CFrame::GetMenuLabel(int Id) case HK_WIIMOTE3_CONNECT: case HK_WIIMOTE4_CONNECT: Label = wxString::Format(_T("Connect Wiimote %i\t"), - Id - HK_WIIMOTE1_CONNECT + 1); + Id - HK_WIIMOTE1_CONNECT + 1); break; } @@ -361,7 +361,7 @@ void CFrame::PopulateToolbar(wxAuiToolBar* ToolBar) void CFrame::PopulateToolbarAui(wxAuiToolBar* ToolBar) { int w = m_Bitmaps[Toolbar_FileOpen].GetWidth(), - h = m_Bitmaps[Toolbar_FileOpen].GetHeight(); + h = m_Bitmaps[Toolbar_FileOpen].GetHeight(); ToolBar->SetToolBitmapSize(wxSize(w, h)); ToolBar->AddTool(IDM_SAVE_PERSPECTIVE, wxT("Save"), g_pCodeWindow->m_Bitmaps[Toolbar_GotoPC], wxT("Save current perspective")); @@ -719,7 +719,7 @@ void CFrame::OnRenderParentResize(wxSizeEvent& event) m_RenderParent->GetSize(&width, &height); m_RenderParent->GetPosition(&x, &y); X11Utils::SendClientEvent(X11Utils::XDisplayFromHandle(GetHandle()), - "RESIZE", x, y, width, height); + "RESIZE", x, y, width, height); #endif m_LogWindow->Refresh(); m_LogWindow->Update(); @@ -736,7 +736,7 @@ void CFrame::ToggleDisplayMode (bool bFullscreen) memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); dmScreenSettings.dmSize = sizeof(dmScreenSettings); sscanf(SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution.c_str(), - "%dx%d", &dmScreenSettings.dmPelsWidth, &dmScreenSettings.dmPelsHeight); + "%dx%d", &dmScreenSettings.dmPelsWidth, &dmScreenSettings.dmPelsHeight); dmScreenSettings.dmBitsPerPel = 32; dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; @@ -1450,20 +1450,20 @@ void CFrame::DoToggleToolbar(bool _show) { m_Mgr->GetPane(wxT("TBMain")).Show(); if (g_pCodeWindow) - { - m_Mgr->GetPane(wxT("TBDebug")).Show(); - m_Mgr->GetPane(wxT("TBAui")).Show(); - } + { + m_Mgr->GetPane(wxT("TBDebug")).Show(); + m_Mgr->GetPane(wxT("TBAui")).Show(); + } m_Mgr->Update(); } else { m_Mgr->GetPane(wxT("TBMain")).Hide(); if (g_pCodeWindow) - { - m_Mgr->GetPane(wxT("TBDebug")).Hide(); - m_Mgr->GetPane(wxT("TBAui")).Hide(); - } + { + m_Mgr->GetPane(wxT("TBDebug")).Hide(); + m_Mgr->GetPane(wxT("TBAui")).Hide(); + } m_Mgr->Update(); } } diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index d7d995d17f..f80e076fb6 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -1200,19 +1200,19 @@ void CGameListCtrl::CompressSelection(bool _compress) wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small ); - progressDialog.SetSize(wxSize(600, 180)); + progressDialog.SetSize(wxSize(340, 180)); progressDialog.CenterOnParent(); m_currentItem = 0; m_numberItem = GetSelectedItemCount(); - for (u32 i=0; iIsCompressed() && _compress) { - std::string FileName; - SplitPath(iso->GetFileName(), NULL, &FileName, NULL); + std::string FileName, FileExt; + SplitPath(iso->GetFileName(), NULL, &FileName, &FileExt); m_currentFilename = FileName; FileName.append(".gcz"); @@ -1221,6 +1221,14 @@ void CGameListCtrl::CompressSelection(bool _compress) (const char *)browseDialog.GetPath().mb_str(wxConvUTF8), FileName); + if (wxFileExists(wxString::FromAscii(OutputFileName.c_str())) && + wxMessageBox( + _("The file ") + wxString::FromAscii(OutputFileName.c_str()) + + _(" already exists.\nDo you wish to replace it?"), + _("Confirm File Overwrite"), + wxYES_NO) == wxNO) + continue; + DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), OutputFileName.c_str(), (iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0, @@ -1228,8 +1236,8 @@ void CGameListCtrl::CompressSelection(bool _compress) } else if (iso->IsCompressed() && !_compress) { - std::string FileName; - SplitPath(iso->GetFileName(), NULL, &FileName, NULL); + std::string FileName, FileExt; + SplitPath(iso->GetFileName(), NULL, &FileName, &FileExt); m_currentFilename = FileName; if (iso->GetPlatform() == GameListItem::WII_DISC) FileName.append(".iso"); @@ -1241,6 +1249,14 @@ void CGameListCtrl::CompressSelection(bool _compress) (const char *)browseDialog.GetPath().mb_str(wxConvUTF8), FileName); + if (wxFileExists(wxString::FromAscii(OutputFileName.c_str())) && + wxMessageBox( + _("The file ") + wxString::FromAscii(OutputFileName.c_str()) + + _(" already exists.\nDo you wish to replace it?"), + _("Confirm File Overwrite"), + wxYES_NO) == wxNO) + continue; + DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(), OutputFileName.c_str(), &MultiCompressCB, &progressDialog); } @@ -1261,52 +1277,60 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) if (!iso) return; - wxString path, Ext; + wxString path; - std::string FileName; - SplitPath(iso->GetFileName(), NULL, &FileName, NULL); + std::string FileName, FilePath, FileExtension; + SplitPath(iso->GetFileName(), &FilePath, &FileName, &FileExtension); - if (iso->IsCompressed()) + do { - if (iso->GetPlatform() == GameListItem::WII_DISC) - Ext = wxT("*.iso"); + if (iso->IsCompressed()) + { + wxString Ext; + if (iso->GetPlatform() == GameListItem::WII_DISC) + Ext = wxT("*.iso"); + else + Ext = wxT("*.gcm"); + + path = wxFileSelector( + _T("Save decompressed GCM/ISO"), + wxString(FilePath.c_str(), *wxConvCurrent), + wxString(FileName.c_str(), *wxConvCurrent) + Ext.After('*'), + wxEmptyString, + wxString::Format + ( + _T("All GC/Wii ISO files (%s)|%s|All files (%s)|%s"), + (wxChar *)Ext.After('.').wchar_str(), + (wxChar *)Ext.wchar_str(), + wxFileSelectorDefaultWildcardStr, + wxFileSelectorDefaultWildcardStr + ), + wxFD_SAVE, + this); + } else - Ext = wxT("*.gcm"); - - path = wxFileSelector( - _T("Save decompressed ISO"), - wxEmptyString, wxString(FileName.c_str(), *wxConvCurrent), wxEmptyString, - wxString::Format - ( - _T("All GC/Wii ISO files (%s)|%s|All files (%s)|%s"), - (char *)Ext.After('.').char_str(wxConvUTF8), - (char *)Ext.char_str(wxConvUTF8), - wxFileSelectorDefaultWildcardStr, - wxFileSelectorDefaultWildcardStr - ), - wxFD_SAVE, - this); - + { + path = wxFileSelector( + _T("Save compressed GCM/ISO"), + wxString(FilePath.c_str(), *wxConvCurrent), + wxString(FileName.c_str(), *wxConvCurrent) + _T(".gcz"), + wxEmptyString, + wxString::Format + ( + _T("All compressed GC/Wii ISO files (gcz)|*.gcz|All files (%s)|%s"), + wxFileSelectorDefaultWildcardStr, + wxFileSelectorDefaultWildcardStr + ), + wxFD_SAVE, + this); + } if (!path) return; - } - else - { - path = wxFileSelector( - _T("Save compressed ISO"), - wxEmptyString, wxString(FileName.c_str(), *wxConvCurrent), wxEmptyString, - wxString::Format - ( - _T("All compressed GC/Wii ISO files (gcz)|*.gcz|All files (%s)|%s"), - wxFileSelectorDefaultWildcardStr, - wxFileSelectorDefaultWildcardStr - ), - wxFD_SAVE, - this); - - if (!path) - return; - } + } while (wxFileExists(path) && + wxMessageBox( + _("The file ") + path + _(" already exists.\nDo you wish to replace it?"), + _("Confirm File Overwrite"), + wxYES_NO) == wxNO); wxProgressDialog dialog(iso->IsCompressed() ? _T("Decompressing ISO") : _T("Compressing ISO"), @@ -1320,7 +1344,7 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small ); - dialog.SetSize(wxSize(280, 180)); + dialog.SetSize(wxSize(340, 180)); dialog.CenterOnParent(); if (iso->IsCompressed())