From ffea55d42acb47e393bd631c1716b72a1791a847 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sun, 8 May 2011 02:56:09 +0000 Subject: [PATCH] Consolidate wad installation to one function in the GUI now if you install the sysmenu from a wad in the gamelist the menubar will be updated with the new sysmenu version git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7528 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/Frame.cpp | 3 +- Source/Core/DolphinWX/Src/Frame.h | 1 + Source/Core/DolphinWX/Src/FrameTools.cpp | 79 +++++++++++-------- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 25 +----- Source/Core/DolphinWX/Src/Globals.h | 3 +- .../Src/MemoryCards/WiiSaveCrypted.cpp | 5 +- 6 files changed, 55 insertions(+), 61 deletions(-) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index d2a229d335..f58fd4f1c5 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -270,7 +270,8 @@ EVT_MENU(IDM_MEMCARD, CFrame::OnMemcard) EVT_MENU(IDM_IMPORTSAVE, CFrame::OnImportSave) EVT_MENU(IDM_CHEATS, CFrame::OnShow_CheatsWindow) EVT_MENU(IDM_CHANGEDISC, CFrame::OnChangeDisc) -EVT_MENU(IDM_INSTALLWAD, CFrame::OnLoadWiiMenu) +EVT_MENU(IDM_MENU_INSTALLWAD, CFrame::OnInstallWAD) +EVT_MENU(IDM_LIST_INSTALLWAD, CFrame::OnInstallWAD) EVT_MENU(IDM_LOAD_WII_MENU, CFrame::OnLoadWiiMenu) EVT_MENU(IDM_FIFOPLAYER, CFrame::OnFifoPlayer) diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index 45600ac75d..50199d469b 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -340,6 +340,7 @@ private: void OnShow_CheatsWindow(wxCommandEvent& event); void OnLoadWiiMenu(wxCommandEvent& event); + void OnInstallWAD(wxCommandEvent& event); void OnFifoPlayer(wxCommandEvent& event); void OnConnectWiimote(wxCommandEvent& event); void GameListChanged(wxCommandEvent& event); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 0a06f09d31..a3b45d40e0 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -204,7 +204,7 @@ void CFrame::CreateMenu() toolsMenu->Append(IDM_NETPLAY, _("Start &NetPlay")); - toolsMenu->Append(IDM_INSTALLWAD, _("Install WAD")); + toolsMenu->Append(IDM_MENU_INSTALLWAD, _("Install WAD")); const DiscIO::INANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true); if (SysMenu_Loader.IsValid()) @@ -212,7 +212,7 @@ void CFrame::CreateMenu() int sysmenuVersion = SysMenu_Loader.GetTitleVersion(); char sysmenuRegion = SysMenu_Loader.GetCountryChar(); - toolsMenu->Append(IDM_LOAD_WII_MENU)->SetItemLabel(wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion)); + toolsMenu->Append(IDM_LOAD_WII_MENU, wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion)); } else { @@ -220,8 +220,6 @@ void CFrame::CreateMenu() toolsMenu->Enable(IDM_LOAD_WII_MENU, false); } - - toolsMenu->Append(IDM_FIFOPLAYER, _("Fifo Player")); toolsMenu->AppendSeparator(); @@ -1326,52 +1324,71 @@ void CFrame::OnShow_CheatsWindow(wxCommandEvent& WXUNUSED (event)) g_CheatsWindow->Raise(); } -void CFrame::OnLoadWiiMenu(wxCommandEvent& event) +void CFrame::OnLoadWiiMenu(wxCommandEvent& WXUNUSED(event)) { - if (event.GetId() == IDM_LOAD_WII_MENU) + HLE_IPC_CreateVirtualFATFilesystem(); + BootGame(Common::CreateTitleContentPath(TITLEID_SYSMENU)); +} + +void CFrame::OnInstallWAD(wxCommandEvent& event) +{ + std::string fileName; + + switch(event.GetId()) { - HLE_IPC_CreateVirtualFATFilesystem(); - BootGame(Common::CreateTitleContentPath(TITLEID_SYSMENU)); + case IDM_LIST_INSTALLWAD: + { + const GameListItem *iso = m_GameListCtrl->GetSelectedISO(); + if (!iso) + return; + fileName = iso->GetFileName(); + break; } - else + case IDM_MENU_INSTALLWAD: { - wxString path = wxFileSelector( _("Select a Wii WAD file to install"), wxEmptyString, wxEmptyString, wxEmptyString, _T("Wii WAD file (*.wad)|*.wad"), wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST, this); + fileName = path.mb_str(); + break; + } + default: + return; + } - wxProgressDialog dialog(_("Installing WAD..."), + wxProgressDialog dialog(_("Installing WAD..."), _("Working..."), 1000, // range this, // parent wxPD_APP_MODAL | + wxPD_ELAPSED_TIME | + wxPD_ESTIMATED_TIME | + wxPD_REMAINING_TIME | wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small ); - - dialog.CenterOnParent(); - u64 titleID = CBoot::Install_WiiWAD(path.mb_str()); - if (titleID == TITLEID_SYSMENU) - { - const DiscIO::INANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true); - if (SysMenu_Loader.IsValid()) - { - int sysmenuVersion = SysMenu_Loader.GetTitleVersion(); - char sysmenuRegion = SysMenu_Loader.GetCountryChar(); - - GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(); - GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->SetItemLabel(wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion)); - } - else - { - GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(false); - } - } + dialog.CenterOnParent(); + + u64 titleID = CBoot::Install_WiiWAD(fileName.c_str()); + if (titleID == TITLEID_SYSMENU) + { + const DiscIO::INANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true); + if (SysMenu_Loader.IsValid()) + { + int sysmenuVersion = SysMenu_Loader.GetTitleVersion(); + char sysmenuRegion = SysMenu_Loader.GetCountryChar(); + + GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(); + GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->SetItemLabel(wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion)); + } + else + { + GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(false); + } } - } void CFrame::OnFifoPlayer(wxCommandEvent& WXUNUSED (event)) diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index aa6aa4b89b..38a2bbae16 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -133,7 +133,6 @@ BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl) EVT_MENU(IDM_MULTICOMPRESSGCM, CGameListCtrl::OnMultiCompressGCM) EVT_MENU(IDM_MULTIDECOMPRESSGCM, CGameListCtrl::OnMultiDecompressGCM) EVT_MENU(IDM_DELETEGCM, CGameListCtrl::OnDeleteGCM) - EVT_MENU(IDM_INSTALLWAD, CGameListCtrl::OnInstallWAD) END_EVENT_TABLE() CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const @@ -1006,7 +1005,7 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event) else popupMenu->Append(IDM_COMPRESSGCM, _("Compress ISO...")); } else - popupMenu->Append(IDM_INSTALLWAD, _("Install to Wii Menu")); + popupMenu->Append(IDM_LIST_INSTALLWAD, _("Install to Wii Menu")); PopupMenu(popupMenu); } @@ -1164,28 +1163,6 @@ void CGameListCtrl::OnWiki(wxCommandEvent& WXUNUSED (event)) WxUtils::Launch(wikiUrl.c_str()); } -void CGameListCtrl::OnInstallWAD(wxCommandEvent& WXUNUSED (event)) -{ - const GameListItem *iso = GetSelectedISO(); - if (!iso) - return; - - wxProgressDialog dialog(_("Installing WAD to Wii Menu..."), - _("Working..."), - 1000, // range - this, // parent - wxPD_APP_MODAL | - wxPD_ELAPSED_TIME | - wxPD_ESTIMATED_TIME | - wxPD_REMAINING_TIME | - wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small - ); - - dialog.CenterOnParent(); - - CBoot::Install_WiiWAD(iso->GetFileName().c_str()); -} - void CGameListCtrl::MultiCompressCB(const char* text, float percent, void* arg) { percent = (((float)m_currentItem) + percent) / (float)m_numberItem; diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index 06191ffa5b..98e0b619c8 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -94,6 +94,8 @@ enum IDM_PROPERTIES, IDM_GAMEWIKI, IDM_LOAD_WII_MENU, + IDM_MENU_INSTALLWAD, + IDM_LIST_INSTALLWAD, IDM_FIFOPLAYER, IDM_CONNECT_WIIMOTE1, IDM_CONNECT_WIIMOTE2, @@ -233,7 +235,6 @@ enum IDM_COMPRESSGCM, IDM_MULTICOMPRESSGCM, IDM_MULTIDECOMPRESSGCM, - IDM_INSTALLWAD, IDM_UPDATELOGDISPLAY, IDM_UPDATEDISASMDIALOG, IDM_UPDATEGUI, diff --git a/Source/Core/DolphinWX/Src/MemoryCards/WiiSaveCrypted.cpp b/Source/Core/DolphinWX/Src/MemoryCards/WiiSaveCrypted.cpp index db5deacccf..73b94e9419 100644 --- a/Source/Core/DolphinWX/Src/MemoryCards/WiiSaveCrypted.cpp +++ b/Source/Core/DolphinWX/Src/MemoryCards/WiiSaveCrypted.cpp @@ -248,14 +248,13 @@ void CWiiSaveCrypted::ImportWiiSaveFiles() return; } - int lastpos = HEADER_SZ + BK_SZ; + fpData_bin.Seek(HEADER_SZ + BK_SZ, SEEK_SET); FileHDR _tmpFileHDR; for(u32 i = 0; i < _numberOfFiles; i++) { - fpData_bin.Seek(lastpos, SEEK_SET); memset(&_tmpFileHDR, 0, FILE_HDR_SZ); memset(IV, 0, 0x10); _fileSize = 0; @@ -266,7 +265,6 @@ void CWiiSaveCrypted::ImportWiiSaveFiles() b_valid = false; } - lastpos += FILE_HDR_SZ; if (Common::swap32(_tmpFileHDR.magic) != FILE_HDR_MAGIC) { PanicAlertT("Bad File Header"); @@ -287,7 +285,6 @@ void CWiiSaveCrypted::ImportWiiSaveFiles() { _fileSize = Common::swap32(_tmpFileHDR.size); u32 RoundedFileSize = ROUND_UP(_fileSize, BLOCK_SZ); - lastpos += RoundedFileSize; _encryptedData = new u8[RoundedFileSize]; _data = new u8[RoundedFileSize]; if (!fpData_bin.ReadBytes(_encryptedData, RoundedFileSize))