VFSManagerDialog::VFSManagerDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, "Virtual File System Manager", wxDefaultPosition) { m_list = new wxListView(this); wxBoxSizer& s_main(*new wxBoxSizer(wxVERTICAL)); s_main.Add(m_list, 1, wxEXPAND); SetSizerAndFit(&s_main); SetSize(800, 600); m_list->InsertColumn(0, "Path"); m_list->InsertColumn(1, "Device path"); m_list->InsertColumn(2, "Path to Device"); m_list->InsertColumn(3, "Device"); Connect(m_list->GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); Connect(m_list->GetId(), wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(VFSManagerDialog::OnRightClick)); Connect(id_add, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnAdd)); Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnRemove)); Connect(id_config, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VFSManagerDialog::OnClose)); LoadEntries(); UpdateList(); }
VFSManagerDialog::VFSManagerDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, "Virtual File System Manager") { m_list = new wxListView(this); wxBoxSizer* s_btns = new wxBoxSizer(wxHORIZONTAL); s_btns->Add(new wxButton(this, wxID_OK)); s_btns->AddSpacer(30); s_btns->Add(new wxButton(this, wxID_CANCEL)); wxBoxSizer* s_main = new wxBoxSizer(wxVERTICAL); s_main->Add(m_list, 1, wxEXPAND); s_main->Add(s_btns, 0, wxALL | wxCENTER, 10); SetSizerAndFit(s_main); SetSize(800, 600); m_list->InsertColumn(0, "Path"); m_list->InsertColumn(1, "Device path"); m_list->InsertColumn(2, "Path to Device"); m_list->InsertColumn(3, "Device"); m_list->Bind(wxEVT_LIST_ITEM_ACTIVATED, &VFSManagerDialog::OnEntryConfig, this); m_list->Bind(wxEVT_RIGHT_DOWN, &VFSManagerDialog::OnRightClick, this); Bind(wxEVT_MENU, &VFSManagerDialog::OnAdd, this, id_add); Bind(wxEVT_MENU, &VFSManagerDialog::OnRemove, this, id_remove); Bind(wxEVT_MENU, &VFSManagerDialog::OnEntryConfig, this, id_config); Bind(wxEVT_BUTTON, &VFSManagerDialog::OnOK, this, wxID_OK); LoadEntries(); UpdateList(); }
VFSManagerDialog::VFSManagerDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, "Virtual File System Manager") { m_list = new wxListView(this); wxBoxSizer* s_main = new wxBoxSizer(wxVERTICAL); s_main->Add(m_list, 1, wxEXPAND); SetSizerAndFit(s_main); SetSize(800, 600); m_list->InsertColumn(0, "Path"); m_list->InsertColumn(1, "Device path"); m_list->InsertColumn(2, "Path to Device"); m_list->InsertColumn(3, "Device"); m_list->Bind(wxEVT_LIST_ITEM_ACTIVATED, &VFSManagerDialog::OnEntryConfig, this); m_list->Bind(wxEVT_RIGHT_DOWN, &VFSManagerDialog::OnRightClick, this); Bind(wxEVT_MENU, &VFSManagerDialog::OnAdd, this, id_add); Bind(wxEVT_MENU, &VFSManagerDialog::OnRemove, this, id_remove); Bind(wxEVT_MENU, &VFSManagerDialog::OnEntryConfig, this, id_config); Bind(wxEVT_CLOSE_WINDOW, &VFSManagerDialog::OnClose, this); LoadEntries(); UpdateList(); }
DWORD CArchiveFS::GetFileIndex(char* szFileName) { // PRE: szFileName must be the filename only (no paths!) if (!m_bEntriesLoaded) LoadEntries(); CHAR szFileNameLC[MAX_PATH]; strcpy(szFileNameLC, szFileName); _strlwr(szFileNameLC); DWORD dwHash = this->HashString(szFileNameLC); DWORD dwIndex = GetFileIndex(dwHash); #ifdef _DEBUG if (dwIndex != FS_INVALID_FILE) { CHAR szDebugMsg[1024]; sprintf(szDebugMsg, "ArchiveFS: Requested file: %s...\n", szFileNameLC); OutputDebugString(szDebugMsg); } #endif return dwIndex; }
DWORD CArchiveFS::GetFileIndex(DWORD dwFileHash) { if (!m_bEntriesLoaded) LoadEntries(); AFS_ENTRYBT_NODE* node = m_EntryBTreeRoot.FindEntry(dwFileHash); if (node == NULL) { return FS_INVALID_FILE; } SAA_ENTRY saaEntry = *(node->pEntry); // Always make a copy of saaEntry before decrypting it // Otherwise, the data decryption will get messed up saaEntry.dwDataBlock = UNOBFUSCATE_DATA(saaEntry.dwDataBlock) ^ (saaEntry.dwFileNameHash & this->m_dwObfsMask); if (node->pEntry == &(m_pEntries[saaEntry.dwPrevEntry])) return FS_INVALID_FILE; // Okay, we got a file. // TODO: It might be wise at this point to start a thread to decrypt the data // Chances are if the index was requested, data for it will be requested. // Painfully evil conversion from SAA_ENTRY* to DWORD DWORD* ppEntry = reinterpret_cast<DWORD*>(&node); return *ppEntry; }
//Show up the savedata list, either to choose one to save/load or to manage saves. //I suggest to use function callbacks to give save data list or get save data entry. (Not implemented or stubbed) SaveDataListDialog::SaveDataListDialog(wxWindow* parent, bool enable_manage) : wxDialog(parent, wxID_ANY, "Save Data Utility") { SetMinSize(wxSize(400, 400)); wxBoxSizer* s_main = new wxBoxSizer(wxVERTICAL); wxStaticText* s_description = new wxStaticText(this, wxID_ANY, "This is only a stub for now. This doesn't work yet due to related functions not being implemented.", wxDefaultPosition, wxDefaultSize, 0); s_description->Wrap(400); s_main->Add(s_description, 0, wxALL, 5); m_list = new wxListView(this); m_list->InsertColumn(0, "Game ID"); m_list->InsertColumn(1, "Save ID"); m_list->InsertColumn(2, "Detail"); m_list->Bind(wxEVT_LIST_ITEM_ACTIVATED, &SaveDataListDialog::OnEntryInfo, this); m_list->Bind(wxEVT_RIGHT_DOWN, &SaveDataListDialog::OnRightClick, this); s_main->Add(m_list, 1, wxALL | wxEXPAND, 5); wxBoxSizer* s_action = new wxBoxSizer(wxHORIZONTAL); //If do not need manage, hide it, like just a save data picker. if (!enable_manage) { wxButton *m_select = new wxButton(this, wxID_OK, wxT("&Select"), wxDefaultPosition, wxDefaultSize, 0); m_select->Bind(wxEVT_BUTTON, &SaveDataListDialog::OnSelect, this); s_action->Add(m_select, 0, wxALL, 5); SetTitle("Save Data Chooser"); } else { wxButton *m_manage = new wxButton(this, wxID_ANY, wxT("&Manage"), wxDefaultPosition, wxDefaultSize, 0); m_manage->Bind(wxEVT_BUTTON, &SaveDataListDialog::OnManage, this); s_action->Add(m_manage, 0, wxALL, 5); } s_action->Add(0, 0, 1, wxEXPAND, 5); s_action->Add(new wxButton(this, wxID_CANCEL, wxT("&Close"), wxDefaultPosition, wxDefaultSize, 0), 0, wxALL, 5); s_main->Add(s_action, 0, wxEXPAND, 5); Bind(wxEVT_MENU, &SaveDataListDialog::OnEntryCopy, this, id_copy); Bind(wxEVT_MENU, &SaveDataListDialog::OnEntryRemove, this, id_remove); Bind(wxEVT_MENU, &SaveDataListDialog::OnEntryInfo, this, id_info); //Looks stupid, isn't it. I can't find Bind for range use.. Bind(wxEVT_MENU, &SaveDataListDialog::OnSort, this, 0); Bind(wxEVT_MENU, &SaveDataListDialog::OnSort, this, 1); Bind(wxEVT_MENU, &SaveDataListDialog::OnSort, this, 2); SetSizerAndFit(s_main); Layout(); Centre(wxBOTH); LoadEntries(); UpdateList(); }
//TODO::Get the enable configuration from ini. AutoPauseManagerDialog::AutoPauseManagerDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, "Auto Pause Manager") { SetMinSize(wxSize(400, 360)); wxBoxSizer* s_main = new wxBoxSizer(wxVERTICAL); m_entry_convert.clear(); m_entry_convert.str(""); m_entry_convert << "To use auto pause: enter the ID(s) of a function or a system call. Restart of the game is required to apply. You can enable/disable this in the settings."; wxStaticText* s_description = new wxStaticText(this, wxID_ANY, m_entry_convert.str(),wxDefaultPosition, wxDefaultSize, 0); s_description->Wrap(400); s_main->Add(s_description, 0, wxALL, 5); m_list = new wxListView(this); m_list->InsertColumn(0, "Call ID"); m_list->InsertColumn(1, "Type"); m_list->Bind(wxEVT_LIST_ITEM_ACTIVATED, &AutoPauseManagerDialog::OnEntryConfig, this); m_list->Bind(wxEVT_RIGHT_DOWN, &AutoPauseManagerDialog::OnRightClick, this); s_main->Add(m_list, 1, wxALL | wxEXPAND, 5); wxBoxSizer* s_action = new wxBoxSizer(wxHORIZONTAL); s_action->Add(new wxButton(this, wxID_CLEAR, wxT("Cl&ear"), wxDefaultPosition, wxDefaultSize, 0), 0, wxALL, 5); s_action->Add(new wxButton(this, wxID_REFRESH, wxT("&Reload"), wxDefaultPosition, wxDefaultSize, 0), 0, wxALL, 5); s_action->Add(new wxButton(this, wxID_SAVE, wxT("&Save"), wxDefaultPosition, wxDefaultSize, 0), 0, wxALL, 5); s_action->Add(new wxButton(this, wxID_CANCEL, wxT("&Close"), wxDefaultPosition, wxDefaultSize, 0), 0, wxALL, 5); s_main->Add(s_action, 0, wxALL, 5); Bind(wxEVT_MENU, &AutoPauseManagerDialog::OnAdd, this, id_add); Bind(wxEVT_MENU, &AutoPauseManagerDialog::OnRemove, this, id_remove); Bind(wxEVT_MENU, &AutoPauseManagerDialog::OnEntryConfig, this, id_config); Bind(wxEVT_BUTTON, &AutoPauseManagerDialog::OnClear, this, wxID_CLEAR); Bind(wxEVT_BUTTON, &AutoPauseManagerDialog::OnReload, this, wxID_REFRESH); Bind(wxEVT_BUTTON, &AutoPauseManagerDialog::OnSave, this, wxID_SAVE); Emu.Stop(); LoadEntries(); UpdateList(); SetSizerAndFit(s_main); Layout(); Centre(wxBOTH); }
int Unpack(wxFile& pkg_f, std::string src, std::string dst) { PKGHeader* m_header = (PKGHeader*) malloc (sizeof(PKGHeader)); wxFile dec_pkg_f; std::string decryptedFile = wxGetCwd() + "/dev_hdd1/" + src + ".dec"; dec_pkg_f.Create(decryptedFile, true); if (Decrypt(pkg_f, dec_pkg_f, m_header) < 0) return -1; dec_pkg_f.Close(); wxFile n_dec_pkg_f(decryptedFile, wxFile::read); std::vector<PKGEntry> m_entries; m_entries.resize(m_header->file_count); PKGEntry *m_entries_ptr = &m_entries[0]; if (!LoadEntries(n_dec_pkg_f, m_header, m_entries_ptr)) return -1; wxProgressDialog pdlg("PKG Decrypter / Installer", "Please wait, unpacking...", m_entries.size(), 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL); for (const PKGEntry& entry : m_entries) { UnpackEntry(n_dec_pkg_f, entry, dst + src + "/"); pdlg.Update(pdlg.GetValue() + 1); } pdlg.Update(m_entries.size()); n_dec_pkg_f.Close(); wxRemoveFile(decryptedFile); return 0; }
void AutoPauseManagerDialog::OnReload(wxCommandEvent& event) { LoadEntries(); UpdateList(); }