Reduce the use of string objects slightly. Add Delete ISO feature.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@610 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-09-22 19:48:12 +00:00
parent a0eb4ad055
commit 38f04809f1
14 changed files with 145 additions and 144 deletions

View File

@ -462,7 +462,7 @@ void CFrame::OnPluginGFX(wxCommandEvent& WXUNUSED (event))
{
CPluginManager::GetInstance().OpenConfig(
GetHandle(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str()
);
}
@ -471,7 +471,7 @@ void CFrame::OnPluginDSP(wxCommandEvent& WXUNUSED (event))
{
CPluginManager::GetInstance().OpenConfig(
GetHandle(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str()
);
}
@ -480,14 +480,14 @@ void CFrame::OnPluginPAD(wxCommandEvent& WXUNUSED (event))
{
CPluginManager::GetInstance().OpenConfig(
GetHandle(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin.c_str()
);
}
void CFrame::OnPluginWiiMote(wxCommandEvent& WXUNUSED (event))
{
CPluginManager::GetInstance().OpenConfig(
GetHandle(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin.c_str()
);
}

View File

@ -36,21 +36,19 @@
#include "../resources/Flag_USA.xpm"
#endif // USE_XPM_BITMAPS
/////////////////////////////////
int currentColumn ;
bool operator < (const CISOFile &one, const CISOFile &other)
{
switch(currentColumn)
{
case CGameListCtrl::COLUMN_TITLE: return strcasecmp(one.GetName().c_str(), other.GetName().c_str()) < 0;
case CGameListCtrl::COLUMN_COMPANY: return strcasecmp(one.GetCompany().c_str(), other.GetCompany().c_str()) < 0;
case CGameListCtrl::COLUMN_NOTES: return strcasecmp(one.GetDescription().c_str(), other.GetDescription().c_str()) < 0;
case CGameListCtrl::COLUMN_TITLE: return strcasecmp(one.GetName().c_str(), other.GetName().c_str()) < 0;
case CGameListCtrl::COLUMN_COMPANY: return strcasecmp(one.GetCompany().c_str(), other.GetCompany().c_str()) < 0;
case CGameListCtrl::COLUMN_NOTES: return strcasecmp(one.GetDescription().c_str(), other.GetDescription().c_str()) < 0;
case CGameListCtrl::COLUMN_COUNTRY: return (one.GetCountry() < other.GetCountry());
case CGameListCtrl::COLUMN_SIZE: return (one.GetFileSize() < other.GetFileSize());
case CGameListCtrl::COLUMN_SIZE: return (one.GetFileSize() < other.GetFileSize());
default: return strcasecmp(one.GetName().c_str(), other.GetName().c_str()) < 0;
}
}
/////////////////////////////////
BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl)
@ -66,6 +64,7 @@ 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_DELETEGCM, CGameListCtrl::OnDeleteGCM)
END_EVENT_TABLE()
CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
@ -465,16 +464,18 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
}
const CISOFile *selected_iso = GetSelectedISO();
if (selected_iso) {
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_SETDEFAULTGCM, wxString::FromAscii("Set as &default ISO"));
popupMenu.Append(IDM_FILESYSTEMVIEWER, wxString::FromAscii("Open in ISO viewer/dumper"));
popupMenu.Append(IDM_SETDEFAULTGCM, wxString::FromAscii("Set as &default ISO"));
popupMenu.AppendSeparator();
popupMenu.Append(IDM_DELETEGCM, wxString::FromAscii("&Delete ISO..."));
// F|RES: compression doesn't work and will be rewritten ... if it is fixed the gui is ready :D
if (selected_iso->IsCompressed())
popupMenu.Append(IDM_COMPRESSGCM, wxString::FromAscii("Decompress ISO... (UNTESTED)"));
else
@ -516,7 +517,7 @@ void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) {
return;
std::string path;
SplitPath(iso->GetFileName(), &path, 0, 0);
File::Explore(path);
File::Explore(path.c_str());
}
void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
@ -527,6 +528,16 @@ void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
SConfig::GetInstance().SaveSettings();
}
void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event)) {
const CISOFile *iso = GetSelectedISO();
if (!iso)
return;
if (wxMessageBox("Are you sure you want to delete this file?", wxMessageBoxCaptionStr, wxYES_NO) == wxYES)
{
File::Delete(iso->GetFileName().c_str());
}
}
void CGameListCtrl::OnFilesystemViewer(wxCommandEvent& WXUNUSED (event)) {
const CISOFile *iso = GetSelectedISO();
if (!iso)
@ -617,7 +628,7 @@ void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
if (!iso)
return;
std::string filename = "Patches/" + iso->GetUniqueID() + ".ini";
if (!File::Exists(filename)) {
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());
@ -628,7 +639,7 @@ void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
return;
}
}
File::Launch(filename);
File::Launch(filename.c_str());
}
void CGameListCtrl::OnSelected(wxListEvent& WXUNUSED (event))

View File

@ -74,6 +74,7 @@ class CGameListCtrl : public wxListCtrl
void OnEditPatchFile(wxCommandEvent& event);
void OnOpenContainingFolder(wxCommandEvent& event);
void OnSetDefaultGCM(wxCommandEvent& event);
void OnDeleteGCM(wxCommandEvent& event);
void OnCompressGCM(wxCommandEvent& event);
void OnFilesystemViewer(wxCommandEvent& event);

View File

@ -49,6 +49,7 @@ enum
IDM_EDITPATCHFILE,
IDM_OPENCONTAININGFOLDER,
IDM_SETDEFAULTGCM,
IDM_DELETEGCM,
IDM_FILESYSTEMVIEWER,
IDM_COMPRESSGCM,
IDM_PLUGIN_OPTIONS,

View File

@ -19,6 +19,7 @@
#include <vector>
#include "Globals.h"
#include "FileUtil.h"
#include "ISOFile.h"
#include "VolumeCreator.h"
@ -44,7 +45,8 @@ CISOFile::CISOFile(const std::string& _rFileName)
{
m_Name = _rFileName;
m_Country = pVolume->GetCountry();
m_FileSize = pVolume->GetSize();
m_FileSize = File::GetSize(_rFileName.c_str());
m_VolumeSize = pVolume->GetSize();
m_Name = pVolume->GetName();
m_UniqueID = pVolume->GetUniqueID();
m_BlobCompressed = DiscIO::IsCompressedBlob(_rFileName.c_str());

View File

@ -22,48 +22,39 @@
class CISOFile
{
public:
public:
CISOFile(const std::string& _rFileName);
~CISOFile();
CISOFile(const std::string& _rFileName);
~CISOFile();
bool IsValid() const {return m_Valid;}
const std::string& GetFileName() const {return m_FileName;}
const std::string& GetName() const {return m_Name;}
const std::string& GetCompany() const {return m_Company;}
const std::string& GetDescription() const {return m_Description;}
const std::string& GetUniqueID() const {return m_UniqueID;}
DiscIO::IVolume::ECountry GetCountry() const {return m_Country;}
bool IsCompressed() const {return m_BlobCompressed;}
u64 GetFileSize() const {return m_FileSize;}
u64 GetVolumeSize() const {return m_VolumeSize;}
const wxImage& GetImage() const {return m_Image;}
bool IsValid() const {return(m_Valid);}
private:
std::string m_FileName;
std::string m_Name;
std::string m_Company;
std::string m_Description;
std::string m_UniqueID;
const std::string& GetFileName() const {return(m_FileName);}
u64 m_FileSize;
u64 m_VolumeSize;
const std::string& GetName() const {return(m_Name);}
DiscIO::IVolume::ECountry m_Country;
const std::string& GetCompany() const {return(m_Company);}
wxImage m_Image;
const std::string& GetDescription() const {return(m_Description);}
bool m_Valid;
const std::string& GetUniqueID() const {return(m_UniqueID);}
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);}
private:
std::string m_FileName;
std::string m_Name;
std::string m_Company;
std::string m_Description;
std::string m_UniqueID;
u64 m_FileSize;
DiscIO::IVolume::ECountry m_Country;
wxImage m_Image;
bool m_Valid;
bool m_BlobCompressed;
bool m_BlobCompressed;
};

View File

@ -35,8 +35,7 @@ CPluginManager::~CPluginManager()
{}
void
CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
void CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
{
m_PluginInfos.clear();
@ -91,7 +90,7 @@ CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
break;
}
CPluginInfo PluginInfo(orig_name);
CPluginInfo PluginInfo(orig_name.c_str());
if (PluginInfo.IsValid())
{
m_PluginInfos.push_back(PluginInfo);
@ -100,11 +99,9 @@ CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
}
}
void
CPluginManager::OpenAbout(void* _Parent, const std::string& _rFilename)
void CPluginManager::OpenAbout(void* _Parent, const char *_rFilename)
{
if (Common::CPlugin::Load(_rFilename.c_str()))
if (Common::CPlugin::Load(_rFilename))
{
Common::CPlugin::About((HWND)_Parent);
Common::CPlugin::Release();
@ -112,40 +109,34 @@ CPluginManager::OpenAbout(void* _Parent, const std::string& _rFilename)
}
void
CPluginManager::OpenConfig(void* _Parent, const std::string& _rFilename)
void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename)
{
if (Common::CPlugin::Load(_rFilename.c_str()))
if (Common::CPlugin::Load(_rFilename))
{
Common::CPlugin::Config((HWND)_Parent);
Common::CPlugin::Release();
}
}
CPluginInfo::CPluginInfo(const std::string& _rFileName)
CPluginInfo::CPluginInfo(const char *_rFileName)
: m_FileName(_rFileName)
, m_Valid(false)
{
if (Common::CPlugin::Load(_rFileName.c_str()))
if (Common::CPlugin::Load(_rFileName))
{
if (Common::CPlugin::GetInfo(m_PluginInfo))
{
m_Valid = true;
}
else
{
PanicAlert("Could not get info about plugin %s", _rFileName.c_str());
}
PanicAlert("Could not get info about plugin %s", _rFileName);
Common::CPlugin::Release();
}
else
{
if (!File::Exists(_rFileName)) {
PanicAlert("Could not load plugin %s - file does not exist", _rFileName.c_str());
PanicAlert("Could not load plugin %s - file does not exist", _rFileName);
} else {
PanicAlert("Failed to load plugin %s - unknown error.\n", _rFileName.c_str());
PanicAlert("Failed to load plugin %s - unknown error.\n", _rFileName);
}
}
}

View File

@ -22,58 +22,37 @@
class CPluginInfo
{
public:
public:
CPluginInfo(const char *_rFileName);
bool IsValid() const {return(m_Valid);}
const PLUGIN_INFO& GetPluginInfo() const {return(m_PluginInfo);}
const std::string& GetFileName() const {return(m_FileName);}
CPluginInfo(const std::string& _rFileName);
bool IsValid() const {return(m_Valid);}
const PLUGIN_INFO& GetPluginInfo() const {return(m_PluginInfo);}
const std::string& GetFileName() const {return(m_FileName);}
private:
PLUGIN_INFO m_PluginInfo;
std::string m_FileName;
bool m_Valid;
private:
PLUGIN_INFO m_PluginInfo;
std::string m_FileName;
bool m_Valid;
};
typedef std::vector<CPluginInfo>CPluginInfos;
class CPluginManager
{
public:
public:
static CPluginManager& GetInstance() {return(m_Instance);}
void ScanForPlugins(wxWindow* _wxWindow);
void OpenAbout(void* _Parent, const char *_rFilename);
void OpenConfig(void* _Parent, const char *_rFilename);
const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);}
static CPluginManager& GetInstance() {return(m_Instance);}
private:
static CPluginManager m_Instance;
bool m_Initialized;
CPluginInfos m_PluginInfos;
void ScanForPlugins(wxWindow* _wxWindow);
void OpenAbout(void* _Parent, const std::string& _rFilename);
void OpenConfig(void* _Parent, const std::string& _rFilename);
const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);}
private:
static CPluginManager m_Instance;
bool m_Initialized;
CPluginInfos m_PluginInfos;
CPluginManager();
~CPluginManager();
CPluginManager();
~CPluginManager();
};

View File

@ -252,9 +252,7 @@ void CPluginOptions::CallConfig(wxChoice* _pChoice)
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
if (pInfo != NULL)
{
CPluginManager::GetInstance().OpenConfig((HWND) this->GetHandle(), pInfo->GetFileName());
}
CPluginManager::GetInstance().OpenConfig((HWND) this->GetHandle(), pInfo->GetFileName().c_str());
}
}
@ -268,9 +266,7 @@ void CPluginOptions::CallAbout(wxChoice* _pChoice)
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
if (pInfo != NULL)
{
CPluginManager::GetInstance().OpenAbout((HWND) this->GetHandle(), pInfo->GetFileName());
}
CPluginManager::GetInstance().OpenAbout((HWND) this->GetHandle(), pInfo->GetFileName().c_str());
}
}
@ -305,4 +301,3 @@ bool CPluginOptions::GetFilename(wxChoice* _pChoice, std::string& _rFilename)
return(false);
}