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
This commit is contained in:
Glenn Rice 2010-08-01 04:09:59 +00:00
parent 949fec41ca
commit 2c6f851bba
5 changed files with 134 additions and 110 deletions

View File

@ -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);
}

View File

@ -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; i<m_numberItem; i++)
for (u32 i=0; i < m_numberItem; i++)
{
const GameListItem *iso = GetSelectedISO();
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;
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,40 +1277,44 @@ 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);
do
{
if (iso->IsCompressed())
{
wxString Ext;
if (iso->GetPlatform() == GameListItem::WII_DISC)
Ext = wxT("*.iso");
else
Ext = wxT("*.gcm");
path = wxFileSelector(
_T("Save decompressed ISO"),
wxEmptyString, wxString(FileName.c_str(), *wxConvCurrent), wxEmptyString,
_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"),
(char *)Ext.After('.').char_str(wxConvUTF8),
(char *)Ext.char_str(wxConvUTF8),
(wxChar *)Ext.After('.').wchar_str(),
(wxChar *)Ext.wchar_str(),
wxFileSelectorDefaultWildcardStr,
wxFileSelectorDefaultWildcardStr
),
wxFD_SAVE,
this);
if (!path)
return;
}
else
{
path = wxFileSelector(
_T("Save compressed ISO"),
wxEmptyString, wxString(FileName.c_str(), *wxConvCurrent), wxEmptyString,
_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"),
@ -1303,10 +1323,14 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
),
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())