From eb65601f90173d7567656540621c91bc0c5c222f Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Thu, 9 Oct 2008 05:33:24 +0000 Subject: [PATCH] updated the filesystemviewer. maybe someone can help and explain why the treectrl doesn't work for me in non-debug builds? git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@807 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DiscIO/Src/Volume.h | 5 +- Source/Core/DiscIO/Src/VolumeDirectory.cpp | 54 +++++++---- Source/Core/DiscIO/Src/VolumeDirectory.h | 10 +- Source/Core/DiscIO/Src/VolumeGC.cpp | 65 ++++++++++--- Source/Core/DiscIO/Src/VolumeGC.h | 5 +- Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp | 96 +++++++++++++++---- Source/Core/DiscIO/Src/VolumeWiiCrypted.h | 5 +- .../Core/DolphinWX/Src/FilesystemViewer.cpp | 88 ++++++++++++----- Source/Core/DolphinWX/Src/FilesystemViewer.h | 1 - 9 files changed, 247 insertions(+), 82 deletions(-) diff --git a/Source/Core/DiscIO/Src/Volume.h b/Source/Core/DiscIO/Src/Volume.h index 075addc815..0fe201b8ba 100644 --- a/Source/Core/DiscIO/Src/Volume.h +++ b/Source/Core/DiscIO/Src/Volume.h @@ -38,8 +38,11 @@ class IVolume virtual bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const = 0; - virtual std::string GetName() const = 0; virtual std::string GetUniqueID() const = 0; + virtual std::string GetMakerID() const = 0; + virtual std::string GetName() const = 0; + virtual u32 GetFSTSize() const = 0; + virtual std::string GetApploaderDate() const = 0; enum ECountry diff --git a/Source/Core/DiscIO/Src/VolumeDirectory.cpp b/Source/Core/DiscIO/Src/VolumeDirectory.cpp index 1d609266ec..0b9396fa61 100644 --- a/Source/Core/DiscIO/Src/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/Src/VolumeDirectory.cpp @@ -129,26 +129,6 @@ bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const return true; } - -std::string CVolumeDirectory::GetName() const -{ - _dbg_assert_(DVDINTERFACE, m_diskHeader); - std::string name = (char*)(m_diskHeader + 0x20); - return name; -} - -void CVolumeDirectory::SetName(std::string _Name) -{ - _dbg_assert_(DVDINTERFACE, m_diskHeader); - - u32 length = _Name.length(); - if(length > MAX_NAME_LENGTH) - length = MAX_NAME_LENGTH; - - memcpy(m_diskHeader + 0x20, _Name.c_str(), length); - m_diskHeader[length + 0x20] = 0; -} - std::string CVolumeDirectory::GetUniqueID() const { _dbg_assert_(DVDINTERFACE, m_diskHeader); @@ -222,6 +202,40 @@ IVolume::ECountry CVolumeDirectory::GetCountry() const return(country); } +std::string CVolumeDirectory::GetMakerID() const +{ + return "VOID"; +} + +std::string CVolumeDirectory::GetName() const +{ + _dbg_assert_(DVDINTERFACE, m_diskHeader); + std::string name = (char*)(m_diskHeader + 0x20); + return name; +} + +void CVolumeDirectory::SetName(std::string _Name) +{ + _dbg_assert_(DVDINTERFACE, m_diskHeader); + + u32 length = _Name.length(); + if(length > MAX_NAME_LENGTH) + length = MAX_NAME_LENGTH; + + memcpy(m_diskHeader + 0x20, _Name.c_str(), length); + m_diskHeader[length + 0x20] = 0; +} + +u32 CVolumeDirectory::GetFSTSize() const +{ + return 0; +} + +std::string CVolumeDirectory::GetApploaderDate() const +{ + return "VOID"; +} + u64 CVolumeDirectory::GetSize() const { return 0; diff --git a/Source/Core/DiscIO/Src/VolumeDirectory.h b/Source/Core/DiscIO/Src/VolumeDirectory.h index 7642839632..1466b77b43 100644 --- a/Source/Core/DiscIO/Src/VolumeDirectory.h +++ b/Source/Core/DiscIO/Src/VolumeDirectory.h @@ -43,11 +43,17 @@ class CVolumeDirectory bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const; + std::string GetUniqueID() const; + void SetUniqueID(std::string _ID); + + std::string GetMakerID() const; + std::string GetName() const; void SetName(std::string); - std::string GetUniqueID() const; - void SetUniqueID(std::string _ID); + u32 GetFSTSize() const; + + std::string GetApploaderDate() const; ECountry GetCountry() const; diff --git a/Source/Core/DiscIO/Src/VolumeGC.cpp b/Source/Core/DiscIO/Src/VolumeGC.cpp index f942898e42..b10319c7cb 100644 --- a/Source/Core/DiscIO/Src/VolumeGC.cpp +++ b/Source/Core/DiscIO/Src/VolumeGC.cpp @@ -38,18 +38,6 @@ bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const return m_pReader->Read(_Offset, _Length, _pBuffer); } -std::string CVolumeGC::GetName() const -{ - if (m_pReader == NULL) - return false; - - char Name[128]; - if (!Read(0x20, 0x60, (u8*)&Name)) - return false; - - return Name; -} - std::string CVolumeGC::GetUniqueID() const { static const std::string NO_UID("NO_UID"); @@ -96,7 +84,7 @@ IVolume::ECountry CVolumeGC::GetCountry() const case 'X': country = COUNTRY_EUROPE; - break; // XIII <- uses X but is PAL rip + break; // XIII <- uses X but is PAL case 'E': country = COUNTRY_USA; @@ -119,6 +107,57 @@ IVolume::ECountry CVolumeGC::GetCountry() const return(country); } +std::string CVolumeGC::GetMakerID() const +{ + if (m_pReader == NULL) + return false; + + char makerID[3]; + if (!Read(0x4, 0x2, (u8*)&makerID)) + return false; + makerID[2] = 0; + + return makerID; +} + +std::string CVolumeGC::GetName() const +{ + if (m_pReader == NULL) + return false; + + char name[128]; + if (!Read(0x20, 0x60, (u8*)&name)) + return false; + + return name; +} + +u32 CVolumeGC::GetFSTSize() const +{ + if (m_pReader == NULL) + return false; + + u32 size; + if (!Read(0x428, 0x4, (u8*)&size)) + return false; + + return Common::swap32(size); +} + +std::string CVolumeGC::GetApploaderDate() const +{ + if (m_pReader == NULL) + return false; + + char date[16]; + if (!Read(0x2440, 0x10, (u8*)&date)) + return false; + // Should be 0 already, but just in case + date[10] = 0; + + return date; +} + u64 CVolumeGC::GetSize() const { if (m_pReader) diff --git a/Source/Core/DiscIO/Src/VolumeGC.h b/Source/Core/DiscIO/Src/VolumeGC.h index a29f30db29..e4f3b2f1fc 100644 --- a/Source/Core/DiscIO/Src/VolumeGC.h +++ b/Source/Core/DiscIO/Src/VolumeGC.h @@ -30,8 +30,11 @@ public: CVolumeGC(IBlobReader* _pReader); ~CVolumeGC(); bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const; - std::string GetName() const; std::string GetUniqueID() const; + std::string GetMakerID() const; + std::string GetName() const; + u32 GetFSTSize() const; + std::string GetApploaderDate() const; ECountry GetCountry() const; u64 GetSize() const; diff --git a/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp b/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp index bbab62c531..549664f9b0 100644 --- a/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp +++ b/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp @@ -86,26 +86,6 @@ CVolumeWiiCrypted::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer) const return(true); } - -std::string -CVolumeWiiCrypted::GetName() const -{ - if (m_pReader == NULL) - { - return(false); - } - - char Name[0xFF]; - - if (!Read(0x20, 0x60, (u8*)&Name)) - { - return(false); - } - - return(Name); -} - - std::string CVolumeWiiCrypted::GetUniqueID() const { @@ -182,6 +162,82 @@ CVolumeWiiCrypted::GetCountry() const return(country); } +std::string +CVolumeWiiCrypted::GetMakerID() const +{ + if (m_pReader == NULL) + { + return(false); + } + + char makerID[3]; + + if (!Read(0x4, 0x2, (u8*)&makerID)) + { + return(false); + } + + makerID[2] = 0; + + return(makerID); +} + +std::string +CVolumeWiiCrypted::GetName() const +{ + if (m_pReader == NULL) + { + return(false); + } + + char name[0xFF]; + + if (!Read(0x20, 0x60, (u8*)&name)) + { + return(false); + } + + return(name); +} + +u32 +CVolumeWiiCrypted::GetFSTSize() const +{ + if (m_pReader == NULL) + { + return(false); + } + + u32 size; + + if (!Read(0x428, 0x4, (u8*)&size)) + { + return(false); + } + + return(size); +} + +std::string +CVolumeWiiCrypted::GetApploaderDate() const +{ + if (m_pReader == NULL) + { + return(false); + } + + char date[16]; + + if (!Read(0x2440, 0x10, (u8*)&date)) + { + return(false); + } + + date[10] = 0; + + return(date); +} + u64 CVolumeWiiCrypted::GetSize() const diff --git a/Source/Core/DiscIO/Src/VolumeWiiCrypted.h b/Source/Core/DiscIO/Src/VolumeWiiCrypted.h index 63e9cad76e..4d2aa0ab90 100644 --- a/Source/Core/DiscIO/Src/VolumeWiiCrypted.h +++ b/Source/Core/DiscIO/Src/VolumeWiiCrypted.h @@ -32,8 +32,11 @@ public: CVolumeWiiCrypted(IBlobReader* _pReader, u64 _VolumeOffset, const unsigned char* _pVolumeKey); ~CVolumeWiiCrypted(); bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const; - std::string GetName() const; std::string GetUniqueID() const; + std::string GetMakerID() const; + std::string GetName() const; + u32 GetFSTSize() const; + std::string GetApploaderDate() const; ECountry GetCountry() const; u64 GetSize() const; diff --git a/Source/Core/DolphinWX/Src/FilesystemViewer.cpp b/Source/Core/DolphinWX/Src/FilesystemViewer.cpp index 33084c85fd..118edb881e 100644 --- a/Source/Core/DolphinWX/Src/FilesystemViewer.cpp +++ b/Source/Core/DolphinWX/Src/FilesystemViewer.cpp @@ -17,9 +17,9 @@ #include "Globals.h" +#include "ISOFile.h" #include "VolumeCreator.h" #include "Filesystem.h" -//#include "BannerLoader.h" #include "FilesystemViewer.h" BEGIN_EVENT_TABLE(CFilesystemViewer, wxDialog) @@ -33,27 +33,70 @@ BEGIN_EVENT_TABLE(CFilesystemViewer, wxDialog) EVT_MENU(IDM_REPLACEFILE, CFilesystemViewer::OnReplaceFile) EVT_MENU(IDM_RENAMEFILE, CFilesystemViewer::OnRenameFile) END_EVENT_TABLE() -DiscIO::IVolume* OpenIso = NULL; -DiscIO::IFileSystem* pFileSystem = NULL; + +DiscIO::IVolume *OpenISO = NULL; +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 Our_Files; - OpenIso = DiscIO::CreateVolumeFromFilename(fileName); - pFileSystem = DiscIO::CreateFileSystem(OpenIso); + OpenISO = DiscIO::CreateVolumeFromFilename(fileName); + pFileSystem = DiscIO::CreateFileSystem(OpenISO); pFileSystem->GetFileList(Our_Files); + + GameListItem OpenISO_(fileName); + CreateGUIControls(); - + + // shuffle2: things only appear in the tree for me when using debug build; why? :< + // TODO: make proper looking dirs + wxTreeItemId dirId = NULL; for(u32 a = 1; a < Our_Files.size(); ++a) - m_Treectrl->AppendItem(RootId, wxString::FromAscii(Our_Files[a]->m_FullPath));//printf("%d dir? %s '%s'\n", a, Our_Files[a].IsDirectory() ? "True" : "False", Our_Files[a].m_FullPath); + { + m_Treectrl->AppendItem(RootId, wxString::Format("%s", Our_Files[a]->m_FullPath)); + + //if(Our_Files[a]->IsDirectory()) + } + m_Treectrl->Expand(RootId); + + // Disk header and apploader + m_Name->SetValue(wxString(OpenISO->GetName().c_str(), wxConvUTF8)); + m_Serial->SetValue(wxString(OpenISO->GetUniqueID().c_str(), wxConvUTF8)); + switch (OpenISO->GetCountry()) + { + case OpenISO->COUNTRY_EUROPE: + case OpenISO->COUNTRY_FRANCE: + m_Country->SetValue(wxString::FromAscii("EUR")); + break; + case OpenISO->COUNTRY_USA: + m_Country->SetValue(wxString::FromAscii("USA")); + break; + case OpenISO->COUNTRY_JAP: + m_Country->SetValue(wxString::FromAscii("JAP")); + break; + default: + m_Country->SetValue(wxString::FromAscii("UNKNOWN")); + break; + } + m_MakerID->SetValue(wxString::Format("0x%s", OpenISO->GetMakerID().c_str())); + m_Date->SetValue(wxString(OpenISO->GetApploaderDate().c_str(), wxConvUTF8)); + m_TOC->SetValue(wxString::Format("%u", OpenISO->GetFSTSize())); + + // Banner + // ...all the BannerLoader functions are bool...gross + //m_Version; + m_ShortName->SetValue(wxString(OpenISO_.GetName().c_str(), wxConvUTF8)); + //m_LongName->SetValue(wxString(OpenISO_.GetLongName().c_str(), wxConvUTF8)); + m_Maker->SetValue(wxString(OpenISO_.GetCompany().c_str(), wxConvUTF8));//dev too + m_Comment->SetValue(wxString(OpenISO_.GetDescription().c_str(), wxConvUTF8)); } CFilesystemViewer::~CFilesystemViewer() { delete pFileSystem; - delete OpenIso; + delete OpenISO; } void CFilesystemViewer::CreateGUIControls() @@ -76,17 +119,17 @@ void CFilesystemViewer::CreateGUIControls() m_TOCText = new wxStaticText(this, ID_TOC_TEXT, wxT("TOC Size:"), wxDefaultPosition, wxDefaultSize); m_TOC = new wxTextCtrl(this, ID_TOC, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); - sISODetails->Add(m_NameText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5); + sISODetails->Add(m_NameText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sISODetails->Add(m_Name, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); - sISODetails->Add(m_SerialText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5); + sISODetails->Add(m_SerialText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sISODetails->Add(m_Serial, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); - sISODetails->Add(m_CountryText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL, 5); + sISODetails->Add(m_CountryText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sISODetails->Add(m_Country, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); - sISODetails->Add(m_MakerIDText, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALL, 5); + sISODetails->Add(m_MakerIDText, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sISODetails->Add(m_MakerID, wxGBPosition(3, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); - sISODetails->Add(m_DateText, wxGBPosition(4, 0), wxGBSpan(1, 1), wxALL, 5); + sISODetails->Add(m_DateText, wxGBPosition(4, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sISODetails->Add(m_Date, wxGBPosition(4, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); - sISODetails->Add(m_TOCText, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALL, 5); + sISODetails->Add(m_TOCText, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sISODetails->Add(m_TOC, wxGBPosition(5, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); sbISODetails->Add(sISODetails, 0, wxEXPAND, 5); @@ -108,20 +151,20 @@ void CFilesystemViewer::CreateGUIControls() m_CommentText = new wxStaticText(this, ID_COMMENT_TEXT, wxT("Comment:"), wxDefaultPosition, wxDefaultSize); m_Comment = new wxTextCtrl(this, ID_COMMENT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); m_BannerText = new wxStaticText(this, ID_BANNER_TEXT, wxT("Banner:"), wxDefaultPosition, wxDefaultSize); - //needs to be image: + // Needs to be image: m_Banner = new wxTextCtrl(this, ID_BANNER, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); m_SaveBNR = new wxButton(this, ID_SAVEBNR, wxT("Save Changes to BNR"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_SaveBNR->Disable(); - sBannerDetails->Add(m_VersionText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5); + sBannerDetails->Add(m_VersionText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sBannerDetails->Add(m_Version, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); - sBannerDetails->Add(m_LangText, wxGBPosition(0, 2), wxGBSpan(1, 1), wxALL, 5); + sBannerDetails->Add(m_LangText, wxGBPosition(0, 2), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sBannerDetails->Add(m_Lang, wxGBPosition(0, 3), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); - sBannerDetails->Add(m_ShortText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5); + sBannerDetails->Add(m_ShortText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sBannerDetails->Add(m_ShortName, wxGBPosition(1, 1), wxGBSpan(1, 3), wxEXPAND|wxALL, 5); - sBannerDetails->Add(m_LongText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL, 5); + sBannerDetails->Add(m_LongText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sBannerDetails->Add(m_LongName, wxGBPosition(2, 1), wxGBSpan(1, 3), wxEXPAND|wxALL, 5); - sBannerDetails->Add(m_MakerText, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALL, 5); + sBannerDetails->Add(m_MakerText, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sBannerDetails->Add(m_Maker, wxGBPosition(3, 1), wxGBSpan(1, 3), wxEXPAND|wxALL, 5); sBannerDetails->Add(m_CommentText, wxGBPosition(4, 0), wxGBSpan(1, 1), wxALL, 5); sBannerDetails->Add(m_Comment, wxGBPosition(4, 1), wxGBSpan(1, 3), wxEXPAND|wxALL, 5); @@ -137,15 +180,14 @@ void CFilesystemViewer::CreateGUIControls() sbTreectrl->Add(m_Treectrl, 1, wxEXPAND); RootId = m_Treectrl->AddRoot(wxT("Root"), -1, -1, 0); - - ///////////// + wxGridBagSizer* sMain; sMain = new wxGridBagSizer(0, 0); sMain->Add(sbISODetails, wxGBPosition(0, 0), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); sMain->Add(sbBannerDetails, wxGBPosition(1, 0), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); sMain->Add(sbTreectrl, wxGBPosition(0, 1), wxGBSpan(2, 1), wxALL, 5); sMain->Add(m_Close, wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT, 5); - + this->SetSizer(sMain); this->Layout(); Fit(); diff --git a/Source/Core/DolphinWX/Src/FilesystemViewer.h b/Source/Core/DolphinWX/Src/FilesystemViewer.h index 040b76768e..1dc2a19636 100644 --- a/Source/Core/DolphinWX/Src/FilesystemViewer.h +++ b/Source/Core/DolphinWX/Src/FilesystemViewer.h @@ -46,7 +46,6 @@ class CFilesystemViewer : public wxDialog wxGridBagSizer *sBannerDetails; wxStaticBoxSizer *sbTreectrl; - wxTreeCtrl *m_Treectrl; wxButton *m_Close;