constification, code style, changed vector<FileInfo*> to vector<FileInfo> for less allocs and more speed in debug mode
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@611 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
38f04809f1
commit
cca92d4e38
|
@ -135,20 +135,20 @@ bool AsciiToHex(const char* _szValue, u32& result)
|
|||
return (true);
|
||||
}
|
||||
|
||||
|
||||
bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args)
|
||||
{
|
||||
int writtenCount = vsnprintf(out, outsize, format, args);
|
||||
|
||||
if (writtenCount > 0)
|
||||
if (writtenCount > 0 && writtenCount < outsize)
|
||||
{
|
||||
out[writtenCount] = '\0';
|
||||
return(true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
out[outsize - 1] = '\0';
|
||||
return(false);
|
||||
PanicAlert("DANGER WILL ROBINSON! CharArrayFromFormatV overflowed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,6 +165,8 @@ void StringFromFormatV(std::string* out, const char* format, va_list args)
|
|||
delete [] buf;
|
||||
buf = new char[newSize + 1];
|
||||
writtenCount = vsnprintf(buf, newSize, format, args);
|
||||
if (writtenCount > (int)newSize)
|
||||
writtenCount = -1;
|
||||
// ARGH! vsnprintf does no longer return -1 on truncation in newer libc!
|
||||
// WORKAROUND! let's fake the old behaviour (even though it's less efficient).
|
||||
// TODO: figure out why the fix causes an invalid read in strlen called from vsnprintf :(
|
||||
|
|
|
@ -36,97 +36,69 @@ CFileSystemGCWii::CFileSystemGCWii(const IVolume *_rVolume)
|
|||
|
||||
CFileSystemGCWii::~CFileSystemGCWii()
|
||||
{
|
||||
while(m_FileInfoVector.size() > 0) {
|
||||
SFileInfo *sfi = m_FileInfoVector.back();
|
||||
m_FileInfoVector.pop_back();
|
||||
delete sfi;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CFileSystemGCWii::IsInitialized()
|
||||
bool CFileSystemGCWii::IsInitialized() const
|
||||
{
|
||||
return(m_Initialized);
|
||||
return m_Initialized;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
CFileSystemGCWii::GetFileSize(const char* _rFullPath)
|
||||
size_t CFileSystemGCWii::GetFileSize(const char* _rFullPath) const
|
||||
{
|
||||
if (!m_Initialized)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
if (pFileInfo != NULL)
|
||||
{
|
||||
return(pFileInfo->m_FileSize);
|
||||
}
|
||||
return pFileInfo->m_FileSize;
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
CFileSystemGCWii::GetFileName(u64 _Address)
|
||||
const char* CFileSystemGCWii::GetFileName(u64 _Address) const
|
||||
{
|
||||
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
||||
{
|
||||
if ((m_FileInfoVector[i]->m_Offset <= _Address) &&
|
||||
((m_FileInfoVector[i]->m_Offset + m_FileInfoVector[i]->m_FileSize) > _Address))
|
||||
if ((m_FileInfoVector[i].m_Offset <= _Address) &&
|
||||
((m_FileInfoVector[i].m_Offset + m_FileInfoVector[i].m_FileSize) > _Address))
|
||||
{
|
||||
return(m_FileInfoVector[i]->m_FullPath);
|
||||
return m_FileInfoVector[i].m_FullPath;
|
||||
}
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
CFileSystemGCWii::ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize)
|
||||
size_t CFileSystemGCWii::ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const
|
||||
{
|
||||
if (!m_Initialized)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
if (pFileInfo == NULL)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
if (pFileInfo->m_FileSize > _MaxBufferSize)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
m_rVolume->Read(pFileInfo->m_Offset, pFileInfo->m_FileSize, _pBuffer);
|
||||
return(pFileInfo->m_FileSize);
|
||||
return pFileInfo->m_FileSize;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFilename)
|
||||
bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFilename) const
|
||||
{
|
||||
size_t filesize = GetFileSize(_rFullPath);
|
||||
|
||||
if (filesize == 0)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
return false;
|
||||
|
||||
u8* buffer = new u8[filesize];
|
||||
|
||||
if (!ReadFile(_rFullPath, buffer, filesize))
|
||||
{
|
||||
delete[] buffer;
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
FILE* f = fopen(_rExportFilename, "wb");
|
||||
|
@ -136,62 +108,52 @@ CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFilenam
|
|||
fwrite(buffer, filesize, 1, f);
|
||||
fclose(f);
|
||||
delete[] buffer;
|
||||
return(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CFileSystemGCWii::ExportAllFiles(const char* _rFullPath)
|
||||
bool CFileSystemGCWii::ExportAllFiles(const char* _rFullPath) const
|
||||
{
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
u32
|
||||
CFileSystemGCWii::Read32(u64 _Offset) const
|
||||
u32 CFileSystemGCWii::Read32(u64 _Offset) const
|
||||
{
|
||||
u32 Temp = 0;
|
||||
m_rVolume->Read(_Offset, 4, (u8*)&Temp);
|
||||
return(Common::swap32(Temp));
|
||||
return Common::swap32(Temp);
|
||||
}
|
||||
|
||||
|
||||
void CFileSystemGCWii::GetStringFromOffset(u64 _Offset, char* Filename) const
|
||||
{
|
||||
m_rVolume->Read(_Offset, 255, (u8*)Filename);
|
||||
}
|
||||
|
||||
size_t CFileSystemGCWii::GetFileList(std::vector<SFileInfo *> &_rFilenames)
|
||||
size_t CFileSystemGCWii::GetFileList(std::vector<const SFileInfo *> &_rFilenames) const
|
||||
{
|
||||
if (_rFilenames.size())
|
||||
PanicAlert("GetFileList : input list has contents?");
|
||||
_rFilenames.clear();
|
||||
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
||||
{
|
||||
_rFilenames.push_back(new SFileInfo(*m_FileInfoVector[i]));
|
||||
}
|
||||
_rFilenames.push_back(&m_FileInfoVector[i]);
|
||||
return m_FileInfoVector.size();
|
||||
}
|
||||
|
||||
const SFileInfo*
|
||||
CFileSystemGCWii::FindFileInfo(const char* _rFullPath) const
|
||||
const SFileInfo* CFileSystemGCWii::FindFileInfo(const char* _rFullPath) const
|
||||
{
|
||||
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
||||
{
|
||||
if (!strcasecmp(m_FileInfoVector[i]->m_FullPath, _rFullPath))
|
||||
{
|
||||
return(m_FileInfoVector[i]);
|
||||
}
|
||||
if (!strcasecmp(m_FileInfoVector[i].m_FullPath, _rFullPath))
|
||||
return &m_FileInfoVector[i];
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CFileSystemGCWii::InitFileSystem()
|
||||
bool CFileSystemGCWii::InitFileSystem()
|
||||
{
|
||||
if (Read32(0x18) == 0x5D1C9EA3)
|
||||
{
|
||||
|
@ -203,7 +165,7 @@ CFileSystemGCWii::InitFileSystem()
|
|||
}
|
||||
else
|
||||
{
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the whole FST
|
||||
|
@ -225,11 +187,11 @@ CFileSystemGCWii::InitFileSystem()
|
|||
|
||||
for (u32 i = 0; i < Root.m_FileSize; i++)
|
||||
{
|
||||
SFileInfo *sfi = new SFileInfo();
|
||||
SFileInfo sfi;
|
||||
u64 Offset = FSTOffset + (i * 0xC);
|
||||
sfi->m_NameOffset = Read32(Offset + 0x0);
|
||||
sfi->m_Offset = (u64)Read32(Offset + 0x4) << m_OffsetShift;
|
||||
sfi->m_FileSize = Read32(Offset + 0x8);
|
||||
sfi.m_NameOffset = Read32(Offset + 0x0);
|
||||
sfi.m_Offset = (u64)Read32(Offset + 0x4) << m_OffsetShift;
|
||||
sfi.m_FileSize = Read32(Offset + 0x8);
|
||||
|
||||
m_FileInfoVector.push_back(sfi);
|
||||
|
||||
|
@ -239,24 +201,23 @@ CFileSystemGCWii::InitFileSystem()
|
|||
BuildFilenames(1, m_FileInfoVector.size(), NULL, NameTableOffset);
|
||||
}
|
||||
|
||||
return(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
//
|
||||
// Changed this stuff from C++ string to C strings for speed in debug mode. Doesn't matter in release, but
|
||||
// std::string is SLOW in debug mode.
|
||||
size_t
|
||||
CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset)
|
||||
size_t CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset)
|
||||
{
|
||||
size_t CurrentIndex = _FirstIndex;
|
||||
|
||||
while (CurrentIndex < _LastIndex)
|
||||
{
|
||||
SFileInfo *rFileInfo = m_FileInfoVector[CurrentIndex];
|
||||
SFileInfo *rFileInfo = &m_FileInfoVector[CurrentIndex];
|
||||
u64 uOffset = _NameTableOffset + (rFileInfo->m_NameOffset & 0xFFFFFF);
|
||||
char filename[512];
|
||||
memset(filename, 0, sizeof(filename));
|
||||
GetStringFromOffset(uOffset, filename);
|
||||
|
||||
// check next index
|
||||
|
@ -264,13 +225,9 @@ CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastInd
|
|||
{
|
||||
// this is a directory, build up the new szDirectory
|
||||
if (_szDirectory != NULL)
|
||||
{
|
||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s%s\\", _szDirectory, filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s\\", filename);
|
||||
}
|
||||
|
||||
CurrentIndex = BuildFilenames(CurrentIndex + 1, rFileInfo->m_FileSize, rFileInfo->m_FullPath, _NameTableOffset);
|
||||
}
|
||||
|
@ -278,19 +235,16 @@ CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastInd
|
|||
{
|
||||
// this is a filename
|
||||
if (_szDirectory != NULL)
|
||||
{
|
||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s%s", _szDirectory, filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s", filename);
|
||||
}
|
||||
|
||||
CurrentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
return(CurrentIndex);
|
||||
return CurrentIndex;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -24,48 +24,33 @@
|
|||
|
||||
namespace DiscIO
|
||||
{
|
||||
class CFileSystemGCWii
|
||||
: public IFileSystem
|
||||
|
||||
class CFileSystemGCWii : public IFileSystem
|
||||
{
|
||||
public:
|
||||
|
||||
CFileSystemGCWii(const IVolume *_rVolume);
|
||||
|
||||
virtual ~CFileSystemGCWii();
|
||||
|
||||
virtual bool IsInitialized();
|
||||
|
||||
virtual size_t GetFileSize(const char* _rFullPath);
|
||||
|
||||
virtual const char* GetFileName(u64 _Address);
|
||||
|
||||
virtual size_t ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize);
|
||||
|
||||
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename);
|
||||
|
||||
virtual bool ExportAllFiles(const char* _rFullPath);
|
||||
public:
|
||||
CFileSystemGCWii(const IVolume *_rVolume);
|
||||
virtual ~CFileSystemGCWii();
|
||||
virtual bool IsInitialized() const;
|
||||
virtual size_t GetFileSize(const char* _rFullPath) const;
|
||||
virtual const char* GetFileName(u64 _Address) const;
|
||||
virtual size_t ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const;
|
||||
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) const;
|
||||
virtual bool ExportAllFiles(const char* _rFullPath) const;
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
std::vector <SFileInfo> m_FileInfoVector;
|
||||
|
||||
std::vector<SFileInfo *> m_FileInfoVector;
|
||||
|
||||
bool m_Initialized;
|
||||
|
||||
u32 m_OffsetShift; // WII offsets are all shifted
|
||||
|
||||
u32 Read32(u64 _Offset) const;
|
||||
|
||||
virtual size_t GetFileList(std::vector<SFileInfo *> &_rFilenames);
|
||||
|
||||
void GetStringFromOffset(u64 _Offset, char* Filename) const;
|
||||
|
||||
const SFileInfo* FindFileInfo(const char* _rFullPath) const;
|
||||
|
||||
bool InitFileSystem();
|
||||
|
||||
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset);
|
||||
bool m_Initialized;
|
||||
u32 m_OffsetShift; // WII offsets are all shifted
|
||||
u32 Read32(u64 _Offset) const;
|
||||
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) const;
|
||||
void GetStringFromOffset(u64 _Offset, char* Filename) const;
|
||||
const SFileInfo* FindFileInfo(const char* _rFullPath) const;
|
||||
bool InitFileSystem();
|
||||
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,15 +36,15 @@ IFileSystem* CreateFileSystem(const IVolume* _rVolume)
|
|||
{
|
||||
IFileSystem* pFileSystem = new CFileSystemGCWii(_rVolume);
|
||||
|
||||
if (pFileSystem)
|
||||
if (!pFileSystem)
|
||||
return 0;
|
||||
|
||||
if (!pFileSystem->IsInitialized())
|
||||
{
|
||||
if (!pFileSystem->IsInitialized())
|
||||
{
|
||||
delete pFileSystem;
|
||||
pFileSystem = NULL;
|
||||
}
|
||||
delete pFileSystem;
|
||||
pFileSystem = NULL;
|
||||
}
|
||||
|
||||
return(pFileSystem);
|
||||
return pFileSystem;
|
||||
}
|
||||
} // namespace
|
||||
|
|
|
@ -31,10 +31,10 @@ struct SFileInfo
|
|||
u32 m_FileSize;
|
||||
char m_FullPath[512];
|
||||
|
||||
bool IsDirectory() {return((m_NameOffset& 0xFF000000) != 0 ? true : false);}
|
||||
bool IsDirectory() const { return (m_NameOffset & 0xFF000000) != 0 ? true : false; }
|
||||
|
||||
SFileInfo() : m_NameOffset(0), m_Offset(0), m_FileSize(0) {
|
||||
memset(m_FullPath, 0, 512);
|
||||
memset(m_FullPath, 0, sizeof(m_FullPath));
|
||||
}
|
||||
|
||||
SFileInfo(const SFileInfo &rhs) : m_NameOffset(rhs.m_NameOffset),
|
||||
|
@ -42,39 +42,29 @@ struct SFileInfo
|
|||
strcpy(m_FullPath, rhs.m_FullPath);
|
||||
}
|
||||
};
|
||||
|
||||
class IFileSystem
|
||||
{
|
||||
public:
|
||||
public:
|
||||
IFileSystem(const IVolume *_rVolume);
|
||||
|
||||
IFileSystem(const IVolume *_rVolume);
|
||||
virtual ~IFileSystem();
|
||||
virtual bool IsInitialized() const = 0;
|
||||
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) const = 0;
|
||||
virtual size_t GetFileSize(const char* _rFullPath) const = 0;
|
||||
|
||||
virtual ~IFileSystem();
|
||||
virtual size_t ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const = 0;
|
||||
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) const = 0;
|
||||
virtual bool ExportAllFiles(const char* _rFullPath) const = 0;
|
||||
virtual const char* GetFileName(u64 _Address) const = 0;
|
||||
|
||||
virtual bool IsInitialized() = 0;
|
||||
|
||||
|
||||
virtual size_t GetFileList(std::vector<SFileInfo *> &_rFilenames) = 0;
|
||||
|
||||
virtual size_t GetFileSize(const char* _rFullPath) = 0;
|
||||
|
||||
virtual size_t ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) = 0;
|
||||
|
||||
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) = 0;
|
||||
|
||||
virtual bool ExportAllFiles(const char* _rFullPath) = 0;
|
||||
|
||||
virtual const char* GetFileName(u64 _Address) = 0;
|
||||
|
||||
|
||||
virtual const IVolume *GetVolume() {return(m_rVolume);}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
const IVolume *m_rVolume;
|
||||
virtual const IVolume *GetVolume() const { return m_rVolume; }
|
||||
protected:
|
||||
const IVolume *m_rVolume;
|
||||
};
|
||||
|
||||
IFileSystem* CreateFileSystem(const IVolume *_rVolume);
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
class CISOFile;
|
||||
class GameListItem;
|
||||
|
||||
namespace BootManager
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ DiscIO::IFileSystem* pFileSystem = NULL;
|
|||
CFilesystemViewer::CFilesystemViewer(const std::string fileName, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
|
||||
: wxDialog(parent, id, title, position, size, style)
|
||||
{
|
||||
std::vector<DiscIO::SFileInfo *> Our_Files;
|
||||
std::vector<const DiscIO::SFileInfo *> Our_Files;
|
||||
|
||||
OpenIso = DiscIO::CreateVolumeFromFilename(fileName);
|
||||
pFileSystem = DiscIO::CreateFileSystem(OpenIso);
|
||||
|
|
|
@ -36,8 +36,9 @@
|
|||
#include "../resources/Flag_USA.xpm"
|
||||
#endif // USE_XPM_BITMAPS
|
||||
|
||||
int currentColumn ;
|
||||
bool operator < (const CISOFile &one, const CISOFile &other)
|
||||
static int currentColumn = 0;
|
||||
|
||||
bool operator < (const GameListItem &one, const GameListItem &other)
|
||||
{
|
||||
switch(currentColumn)
|
||||
{
|
||||
|
@ -46,7 +47,7 @@ bool operator < (const CISOFile &one, const CISOFile &other)
|
|||
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());
|
||||
default: return strcasecmp(one.GetName().c_str(), other.GetName().c_str()) < 0;
|
||||
default: return strcasecmp(one.GetName().c_str(), other.GetName().c_str()) < 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,7 +190,7 @@ wxString NiceSizeFormat(s64 _size)
|
|||
|
||||
void CGameListCtrl::InsertItemInReportView(long _Index)
|
||||
{
|
||||
CISOFile& rISOFile = m_ISOFiles[_Index];
|
||||
GameListItem& rISOFile = m_ISOFiles[_Index];
|
||||
|
||||
int ImageIndex = -1;
|
||||
|
||||
|
@ -284,7 +285,7 @@ bool CGameListCtrl::MSWDrawSubItem(wxPaintDC& rPaintDC, int item, int subitem)
|
|||
|
||||
if (Index < m_ISOFiles.size())
|
||||
{
|
||||
const CISOFile& rISO = m_ISOFiles[Index];
|
||||
const GameListItem& rISO = m_ISOFiles[Index];
|
||||
wxRect SubItemRect;
|
||||
this->GetSubItemRect(item, subitem, SubItemRect);
|
||||
m_imageListSmall->Draw(m_FlagImageIndex[rISO.GetCountry()], rPaintDC, SubItemRect.GetLeft(), SubItemRect.GetTop());
|
||||
|
@ -364,7 +365,7 @@ void CGameListCtrl::ScanForISOs()
|
|||
break;
|
||||
}
|
||||
|
||||
CISOFile ISOFile(rFilenames[i]);
|
||||
GameListItem ISOFile(rFilenames[i]);
|
||||
|
||||
if (ISOFile.IsValid())
|
||||
m_ISOFiles.push_back(ISOFile);
|
||||
|
@ -382,7 +383,7 @@ void CGameListCtrl::OnColBeginDrag(wxListEvent& event)
|
|||
event.Veto();
|
||||
}
|
||||
|
||||
const CISOFile * CGameListCtrl::GetISO(int index) const
|
||||
const GameListItem *CGameListCtrl::GetISO(int index) const
|
||||
{
|
||||
return &m_ISOFiles[index];
|
||||
}
|
||||
|
@ -393,14 +394,14 @@ int wxCALLBACK wxListCompare(long item1, long item2, long sortData)
|
|||
//return 1 if item1 > item2
|
||||
//return -1 if item1 < item2
|
||||
//0 for identity
|
||||
const CISOFile *iso1 = caller->GetISO(item1);
|
||||
const CISOFile *iso2 = caller->GetISO(item2);
|
||||
const GameListItem *iso1 = caller->GetISO(item1);
|
||||
const GameListItem *iso2 = caller->GetISO(item2);
|
||||
|
||||
int t = 1;
|
||||
|
||||
if(sortData<0)
|
||||
if (sortData < 0)
|
||||
{
|
||||
t=-1;
|
||||
t = -1;
|
||||
sortData = -sortData;
|
||||
}
|
||||
|
||||
|
@ -463,7 +464,7 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
|
|||
SetItemState(item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
|
||||
wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
||||
}
|
||||
const CISOFile *selected_iso = GetSelectedISO();
|
||||
const GameListItem *selected_iso = GetSelectedISO();
|
||||
if (selected_iso)
|
||||
{
|
||||
std::string unique_id = selected_iso->GetUniqueID();
|
||||
|
@ -496,13 +497,13 @@ void CGameListCtrl::OnActivated(wxListEvent& event)
|
|||
size_t Index = event.GetData();
|
||||
if (Index < m_ISOFiles.size())
|
||||
{
|
||||
const CISOFile& rISOFile = m_ISOFiles[Index];
|
||||
const GameListItem& rISOFile = m_ISOFiles[Index];
|
||||
BootManager::BootCore(rISOFile.GetFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const CISOFile * CGameListCtrl::GetSelectedISO() const
|
||||
const GameListItem * CGameListCtrl::GetSelectedISO() const
|
||||
{
|
||||
int item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (item == -1)
|
||||
|
@ -512,7 +513,7 @@ const CISOFile * CGameListCtrl::GetSelectedISO() const
|
|||
}
|
||||
|
||||
void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) {
|
||||
const CISOFile *iso = GetSelectedISO();
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
std::string path;
|
||||
|
@ -521,7 +522,7 @@ void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) {
|
|||
}
|
||||
|
||||
void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||
const CISOFile *iso = GetSelectedISO();
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM = iso->GetFileName();
|
||||
|
@ -529,7 +530,7 @@ void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
|
|||
}
|
||||
|
||||
void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||
const CISOFile *iso = GetSelectedISO();
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
if (wxMessageBox("Are you sure you want to delete this file?", wxMessageBoxCaptionStr, wxYES_NO) == wxYES)
|
||||
|
@ -539,7 +540,7 @@ void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event)) {
|
|||
}
|
||||
|
||||
void CGameListCtrl::OnFilesystemViewer(wxCommandEvent& WXUNUSED (event)) {
|
||||
const CISOFile *iso = GetSelectedISO();
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
CFilesystemViewer FSViewer(iso->GetFileName(), this);
|
||||
|
@ -553,7 +554,7 @@ void CGameListCtrl::CompressCB(const char* text, float percent, void* arg)
|
|||
}
|
||||
|
||||
void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||
const CISOFile *iso = GetSelectedISO();
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
|
||||
|
@ -624,7 +625,7 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) {
|
|||
|
||||
void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
const CISOFile *iso = GetSelectedISO();
|
||||
const GameListItem *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
std::string filename = "Patches/" + iso->GetUniqueID() + ".ini";
|
||||
|
@ -644,6 +645,7 @@ void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
|
|||
|
||||
void CGameListCtrl::OnSelected(wxListEvent& WXUNUSED (event))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CGameListCtrl::OnSize(wxSizeEvent& event)
|
||||
|
|
|
@ -33,8 +33,8 @@ class CGameListCtrl : public wxListCtrl
|
|||
|
||||
void Update();
|
||||
void BrowseForDirectory();
|
||||
const CISOFile *GetSelectedISO() const;
|
||||
const CISOFile *GetISO(int index) const;
|
||||
const GameListItem *GetSelectedISO() const;
|
||||
const GameListItem *GetISO(int index) const;
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -50,8 +50,8 @@ class CGameListCtrl : public wxListCtrl
|
|||
|
||||
private:
|
||||
|
||||
std::vector<int>m_FlagImageIndex;
|
||||
std::vector<CISOFile> m_ISOFiles;
|
||||
std::vector<int> m_FlagImageIndex;
|
||||
std::vector<GameListItem> m_ISOFiles;
|
||||
|
||||
int last_column;
|
||||
int last_sort;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
static u32 g_ImageTemp[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT];
|
||||
|
||||
CISOFile::CISOFile(const std::string& _rFileName)
|
||||
GameListItem::GameListItem(const std::string& _rFileName)
|
||||
: m_FileName(_rFileName),
|
||||
m_FileSize(0),
|
||||
m_Valid(false),
|
||||
|
@ -65,7 +65,6 @@ CISOFile::CISOFile(const std::string& _rFileName)
|
|||
pBannerLoader->GetName(m_Name, 0); //m_Country == DiscIO::IVolume::COUNTRY_JAP ? 1 : 0);
|
||||
pBannerLoader->GetCompany(m_Company);
|
||||
pBannerLoader->GetDescription(m_Description);
|
||||
|
||||
if (pBannerLoader->GetBanner(g_ImageTemp))
|
||||
{
|
||||
unsigned char* pImage = (unsigned char*)malloc(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT * 3);
|
||||
|
@ -83,6 +82,7 @@ CISOFile::CISOFile(const std::string& _rFileName)
|
|||
else
|
||||
{
|
||||
// default banner
|
||||
|
||||
}
|
||||
|
||||
delete pBannerLoader;
|
||||
|
@ -98,7 +98,7 @@ CISOFile::CISOFile(const std::string& _rFileName)
|
|||
}
|
||||
|
||||
|
||||
CISOFile::~CISOFile()
|
||||
GameListItem::~GameListItem()
|
||||
{}
|
||||
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
#include "Volume.h"
|
||||
|
||||
class CISOFile
|
||||
class GameListItem
|
||||
{
|
||||
public:
|
||||
CISOFile(const std::string& _rFileName);
|
||||
~CISOFile();
|
||||
GameListItem(const std::string& _rFileName);
|
||||
~GameListItem();
|
||||
|
||||
bool IsValid() const {return m_Valid;}
|
||||
const std::string& GetFileName() const {return m_FileName;}
|
||||
|
|
|
@ -51,6 +51,11 @@ Display* GXdsp;
|
|||
bool KeyStatus[23];
|
||||
#endif
|
||||
|
||||
void __Log(int, const char *fmt, ...)
|
||||
{
|
||||
//DebugLog(fmt);
|
||||
}
|
||||
|
||||
// controls
|
||||
enum
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue