summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorfires.gc <fires.gc@gmail.com>2008-09-16 12:09:35 +0000
committerfires.gc <fires.gc@gmail.com>2008-09-16 12:09:35 +0000
commitff863e0cec9bcf65deda1f0ce66946d0d0664f8f (patch)
tree3a51174b1c9d90610ef977f0dd324d8d575a6b06 /Source
parent2ab92c9222825dc185e00227596b18da827c746b (diff)
added gui support for compressed ISOs...
compression doesn't work and will be fixed (hopefully :D) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@537 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DiscIO/Src/Blob.cpp10
-rw-r--r--Source/Core/DiscIO/Src/Blob.h2
-rw-r--r--Source/Core/DolphinWX/Src/GameListCtrl.cpp83
-rw-r--r--Source/Core/DolphinWX/Src/GameListCtrl.h3
-rw-r--r--Source/Core/DolphinWX/Src/Globals.h1
-rw-r--r--Source/Core/DolphinWX/Src/ISOFile.cpp5
-rw-r--r--Source/Core/DolphinWX/Src/ISOFile.h4
7 files changed, 103 insertions, 5 deletions
diff --git a/Source/Core/DiscIO/Src/Blob.cpp b/Source/Core/DiscIO/Src/Blob.cpp
index ef198f43d6..35b53e54fd 100644
--- a/Source/Core/DiscIO/Src/Blob.cpp
+++ b/Source/Core/DiscIO/Src/Blob.cpp
@@ -278,7 +278,7 @@ class CompressedBlobReader
offset &= ~(1ULL << 63);
}
- u8* source = mapped_file->Lock(offset, comp_block_size);
+ u8* source = mapped_file->Lock(offset, comp_block_size + 64*1024);
u8* dest = cache[0];
if (uncompressed)
@@ -421,10 +421,14 @@ bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type, i
for (u32 i = 0; i < header.num_blocks; i++)
{
- if (i % (header.num_blocks / 100) == 0)
+ if (i % (header.num_blocks / 1000) == 0)
{
u64 inpos = ftell(inf);
- int ratio = (int)(100 * position / inpos);
+ int ratio = 0;
+ 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);
callback(temp, (float)i / (float)header.num_blocks, arg);
diff --git a/Source/Core/DiscIO/Src/Blob.h b/Source/Core/DiscIO/Src/Blob.h
index 5c2ae04259..d8de08d30a 100644
--- a/Source/Core/DiscIO/Src/Blob.h
+++ b/Source/Core/DiscIO/Src/Blob.h
@@ -42,7 +42,7 @@ class IBlobReader
private:
- IBlobReader(const IBlobReader& other) {}
+ IBlobReader(const IBlobReader& /*other*/) {}
};
diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp
index 7bee16cf40..8b5d4959e4 100644
--- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp
+++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp
@@ -26,6 +26,7 @@
#include "BootManager.h"
#include "Config.h"
#include "GameListCtrl.h"
+#include "Blob.h"
#if USE_XPM_BITMAPS
#include "../resources/Flag_Europe.xpm"
@@ -45,6 +46,7 @@ EVT_LIST_COL_END_DRAG(LIST_CTRL, CGameListCtrl::OnColEndDrag)
EVT_MENU(IDM_EDITPATCHFILE, CGameListCtrl::OnEditPatchFile)
EVT_MENU(IDM_OPENCONTAININGFOLDER, CGameListCtrl::OnOpenContainingFolder)
EVT_MENU(IDM_SETDEFAULTGCM, CGameListCtrl::OnSetDefaultGCM)
+EVT_MENU(IDM_COMPRESSGCM, CGameListCtrl::OnCompressGCM)
END_EVENT_TABLE()
CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
@@ -344,6 +346,14 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
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_SETDEFAULTGCM, wxString::FromAscii("Set as &default ISO"));
+
+ /* F|RES: compression doesn't work and will be rewritten ... if it is done reactivated this code the gui is ready :D
+ 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);
}
}
@@ -391,6 +401,79 @@ void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
SConfig::GetInstance().SaveSettings();
}
+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)) {
+ const CISOFile *iso = GetSelectedISO();
+ if (!iso)
+ return;
+
+ wxString path;
+
+ if (iso->IsCompressed())
+ {
+ path = wxFileSelector(
+ _T("Select the file to save"),
+ wxEmptyString, wxEmptyString, wxEmptyString,
+ wxString::Format
+ (
+ _T("All GC/Wii ISO files (gcz)|*.gcz|All files (%s)|%s"),
+ wxFileSelectorDefaultWildcardStr,
+ wxFileSelectorDefaultWildcardStr
+ ),
+ wxFD_SAVE,
+ this);
+
+ if (!path)
+ {
+ return;
+ }
+ }
+ else
+ {
+ path = wxFileSelector(
+ _T("Select the file to save"),
+ wxEmptyString, wxEmptyString, wxEmptyString,
+ wxString::Format
+ (
+ _T("All compressed GC/Wii ISO files (gcz)|*.gcz|All files (%s)|%s"),
+ wxFileSelectorDefaultWildcardStr,
+ wxFileSelectorDefaultWildcardStr
+ ),
+ wxFD_SAVE,
+ this);
+
+ if (!path)
+ {
+ return;
+ }
+ }
+
+ wxProgressDialog dialog(_T("Scanning for ISOs"),
+ _T("Scanning..."),
+ 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
+ );
+
+ dialog.CenterOnParent();
+ dialog.SetSize(wxSize(280, 180));
+
+ if (iso->IsCompressed())
+ DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(), path.c_str(), &CompressCB, &dialog);
+ else
+ DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), path.c_str(), 0, 16384, &CompressCB, &dialog);
+}
+
void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
{
const CISOFile *iso = GetSelectedISO();
diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.h b/Source/Core/DolphinWX/Src/GameListCtrl.h
index c6ab5853d7..6c6ae894e0 100644
--- a/Source/Core/DolphinWX/Src/GameListCtrl.h
+++ b/Source/Core/DolphinWX/Src/GameListCtrl.h
@@ -69,10 +69,13 @@ class CGameListCtrl : public wxListCtrl
void OnEditPatchFile(wxCommandEvent& event);
void OnOpenContainingFolder(wxCommandEvent& event);
void OnSetDefaultGCM(wxCommandEvent& event);
+ void OnCompressGCM(wxCommandEvent& event);
virtual bool MSWDrawSubItem(wxPaintDC& rPaintDC, int item, int subitem);
void AutomaticColumnWidth();
+
+ static void CompressCB(const char* text, float percent, void* arg);
};
diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h
index fe3cf02569..3f8aff4e54 100644
--- a/Source/Core/DolphinWX/Src/Globals.h
+++ b/Source/Core/DolphinWX/Src/Globals.h
@@ -50,6 +50,7 @@ enum
IDM_EDITPATCHFILE,
IDM_OPENCONTAININGFOLDER,
IDM_SETDEFAULTGCM,
+ IDM_COMPRESSGCM,
IDM_PLUGIN_OPTIONS,
IDM_CONFIG_GFX_PLUGIN,
IDM_CONFIG_DSP_PLUGIN,
diff --git a/Source/Core/DolphinWX/Src/ISOFile.cpp b/Source/Core/DolphinWX/Src/ISOFile.cpp
index 1040067404..6d89020923 100644
--- a/Source/Core/DolphinWX/Src/ISOFile.cpp
+++ b/Source/Core/DolphinWX/Src/ISOFile.cpp
@@ -25,6 +25,7 @@
#include "Filesystem.h"
#include "BannerLoader.h"
#include "FileSearch.h"
+#include "Blob.h"
#define DVD_BANNER_WIDTH 96
#define DVD_BANNER_HEIGHT 32
@@ -34,7 +35,8 @@ static u32 g_ImageTemp[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT];
CISOFile::CISOFile(const std::string& _rFileName)
: m_FileName(_rFileName),
m_FileSize(0),
- m_Valid(false)
+ m_Valid(false),
+ m_BlobCompressed(false)
{
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(_rFileName);
@@ -45,6 +47,7 @@ CISOFile::CISOFile(const std::string& _rFileName)
m_FileSize = pVolume->GetSize();
m_Name = pVolume->GetName();
m_UniqueID = pVolume->GetUniqueID();
+ m_BlobCompressed = DiscIO::IsCompressedBlob(_rFileName.c_str());
// check if we can get some infos from the banner file too
DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(*pVolume);
diff --git a/Source/Core/DolphinWX/Src/ISOFile.h b/Source/Core/DolphinWX/Src/ISOFile.h
index 44d430e2fe..66b5306c32 100644
--- a/Source/Core/DolphinWX/Src/ISOFile.h
+++ b/Source/Core/DolphinWX/Src/ISOFile.h
@@ -41,6 +41,8 @@ class CISOFile
DiscIO::IVolume::ECountry GetCountry() const {return(m_Country);}
+ bool IsCompressed() const {return(m_BlobCompressed); }
+
u64 GetFileSize() const {return(m_FileSize);}
const wxImage& GetImage() const {return(m_Image);}
@@ -65,6 +67,8 @@ class CISOFile
wxImage m_Image;
bool m_Valid;
+
+ bool m_BlobCompressed;
};