From a15263968352eb3832cf9f4724ab6dc8ea087fbb Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Thu, 16 Apr 2009 02:32:21 +0000 Subject: [PATCH] add wii detection to ISOFile, gray refresh list menuitem when core is running, some cleanup git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2979 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/Frame.cpp | 1 - Source/Core/DolphinWX/Src/Frame.h | 22 +++---- Source/Core/DolphinWX/Src/FrameTools.cpp | 71 +++++++++++----------- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 4 +- Source/Core/DolphinWX/Src/ISOFile.cpp | 2 + Source/Core/DolphinWX/Src/ISOFile.h | 2 + 6 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index a2324a4c95..729aad6bad 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -305,7 +305,6 @@ CFrame::CFrame(bool showLogWindow, , m_pStatusBar(NULL), bRenderToMain(true) , HaveLeds(false), HaveSpeakers(false) , m_Panel(NULL) - , m_pMenuBar(NULL) , m_fLastClickTime(0), m_iLastMotionTime(0), LastMouseX(0), LastMouseY(0) #if wxUSE_TIMER , m_timer(this) diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index a8ff3ee72d..1e2c1e0daa 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -222,25 +222,19 @@ class CFrame : public wxFrame void OnGameListCtrl_ItemActivated(wxListEvent& event); - // Menu items - wxMenuBar* m_pMenuBar; + // MenuBar + // File - Drive + wxMenuItem* m_pSubMenuDrive; - wxMenuItem* m_pMenuItemOpen; // File - wxMenuItem* m_pMenuItemOpenDrive; // Drive - - wxMenuItem* m_pMenuItemPlay; // Emulation - wxMenuItem* m_pMenuItemStop; - wxMenuItem* m_pMenuChangeDisc; - wxMenuItem* m_pPluginOptions; - wxMenuItem* m_pMenuItemLoad; - wxMenuItem* m_pMenuItemSave; - wxMenuItem* m_pMenuBootWii; - wxToolBarToolBase* m_pToolPlay; + // Emulation + wxMenuItem* m_pSubMenuLoad; + wxMenuItem* m_pSubMenuSave; void BootGame(); // Double click and mouse move options - double m_fLastClickTime, m_iLastMotionTime; int LastMouseX, LastMouseY; + double m_fLastClickTime, m_iLastMotionTime; + int LastMouseX, LastMouseY; #if wxUSE_TIMER void Update(); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index e1ad9aafe1..1291dd0ec6 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -96,15 +96,17 @@ wxCheatsWindow* CheatsWindow; // Create menu items void CFrame::CreateMenu() { - delete m_pMenuBar; - m_pMenuBar = new wxMenuBar(wxMB_DOCKABLE); + if (GetMenuBar()) + GetMenuBar()->Destroy(); + + wxMenuBar* menuBar = new wxMenuBar(wxMB_DOCKABLE); // file menu wxMenu* fileMenu = new wxMenu; - m_pMenuItemOpen = fileMenu->Append(wxID_OPEN, _T("&Open...\tCtrl+O")); + fileMenu->Append(wxID_OPEN, _T("&Open...\tCtrl+O")); wxMenu *externalDrive = new wxMenu; - m_pMenuItemOpenDrive = fileMenu->AppendSubMenu(externalDrive, _T("&Boot from DVD Drive...")); + m_pSubMenuDrive = fileMenu->AppendSubMenu(externalDrive, _T("&Boot from DVD Drive...")); drives = cdio_get_devices(); for (int i = 0; drives[i] != NULL && i < 24; i++) { @@ -118,27 +120,27 @@ void CFrame::CreateMenu() fileMenu->AppendSeparator(); fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Alt+F4")); - m_pMenuBar->Append(fileMenu, _T("&File")); + menuBar->Append(fileMenu, _T("&File")); // Emulation menu wxMenu* emulationMenu = new wxMenu; - m_pMenuItemPlay = emulationMenu->Append(IDM_PLAY, _T("&Play")); - m_pMenuChangeDisc = emulationMenu->Append(IDM_CHANGEDISC, _T("Change Disc")); - m_pMenuItemStop = emulationMenu->Append(IDM_STOP, _T("&Stop")); + emulationMenu->Append(IDM_PLAY, _T("&Play")); + emulationMenu->Append(IDM_CHANGEDISC, _T("Change Disc")); + emulationMenu->Append(IDM_STOP, _T("&Stop")); emulationMenu->AppendSeparator(); wxMenu *saveMenu = new wxMenu; wxMenu *loadMenu = new wxMenu; - m_pMenuItemLoad = emulationMenu->AppendSubMenu(saveMenu, _T("&Load State")); - m_pMenuItemSave = emulationMenu->AppendSubMenu(loadMenu, _T("Sa&ve State")); + m_pSubMenuLoad = emulationMenu->AppendSubMenu(saveMenu, _T("&Load State")); + m_pSubMenuSave = emulationMenu->AppendSubMenu(loadMenu, _T("Sa&ve State")); for (int i = 1; i < 10; i++) { saveMenu->Append(IDM_LOADSLOT1 + i - 1, wxString::Format(_T("Slot %i\tF%i"), i, i)); loadMenu->Append(IDM_SAVESLOT1 + i - 1, wxString::Format(_T("Slot %i\tShift+F%i"), i, i)); } - m_pMenuBar->Append(emulationMenu, _T("&Emulation")); + menuBar->Append(emulationMenu, _T("&Emulation")); // Options menu wxMenu* pOptionsMenu = new wxMenu; - m_pPluginOptions = pOptionsMenu->Append(IDM_CONFIG_MAIN, _T("Co&nfigure...")); + pOptionsMenu->Append(IDM_CONFIG_MAIN, _T("Co&nfigure...")); pOptionsMenu->AppendSeparator(); pOptionsMenu->Append(IDM_CONFIG_GFX_PLUGIN, _T("&Graphics Settings")); pOptionsMenu->Append(IDM_CONFIG_DSP_PLUGIN, _T("&DSP Settings")); @@ -148,7 +150,7 @@ void CFrame::CreateMenu() pOptionsMenu->AppendSeparator(); pOptionsMenu->Append(IDM_TOGGLE_FULLSCREEN, _T("&Fullscreen\tAlt+Enter")); #endif - m_pMenuBar->Append(pOptionsMenu, _T("&Options")); + menuBar->Append(pOptionsMenu, _T("&Options")); // Tools menu wxMenu* toolsMenu = new wxMenu; @@ -167,10 +169,10 @@ void CFrame::CreateMenu() if (DiscIO::CNANDContentManager::Access().GetNANDLoader(FULL_WII_MENU_DIR).IsValid()) { - m_pMenuBootWii = toolsMenu->Append(IDM_LOAD_WII_MENU, _T("Load Wii Menu")); + toolsMenu->Append(IDM_LOAD_WII_MENU, _T("Load Wii Menu")); } - m_pMenuBar->Append(toolsMenu, _T("&Tools")); + menuBar->Append(toolsMenu, _T("&Tools")); // Help menu wxMenu* helpMenu = new wxMenu; @@ -180,10 +182,10 @@ void CFrame::CreateMenu() helpMenu->Append(IDM_HELPGOOGLECODE, _T("Dolphin at &Google Code")); helpMenu->AppendSeparator(); helpMenu->Append(IDM_HELPABOUT, _T("&About...")); - m_pMenuBar->Append(helpMenu, _T("&Help")); + menuBar->Append(helpMenu, _T("&Help")); // Associate the menu bar with the frame - SetMenuBar(m_pMenuBar); + SetMenuBar(menuBar); } @@ -199,7 +201,7 @@ void CFrame::PopulateToolbar(wxToolBar* toolBar) toolBar->AddTool(IDM_BROWSE, _T("Browse"), m_Bitmaps[Toolbar_Browse], _T("Browse for an ISO directory...")); toolBar->AddSeparator(); - m_pToolPlay = toolBar->AddTool(IDM_PLAY, _T("Play"), m_Bitmaps[Toolbar_Play], _T("Play")); + toolBar->AddTool(IDM_PLAY, _T("Play"), m_Bitmaps[Toolbar_Play], _T("Play")); toolBar->AddTool(IDM_STOP, _T("Stop"), m_Bitmaps[Toolbar_Stop], _T("Stop")); @@ -826,40 +828,41 @@ void CFrame::UpdateGUI() } // File - m_pMenuItemOpen->Enable(!initialized); - m_pMenuItemOpenDrive->Enable(!initialized); + GetMenuBar()->FindItem(wxID_OPEN)->Enable(!initialized); + m_pSubMenuDrive->Enable(!initialized); + GetMenuBar()->FindItem(wxID_REFRESH)->Enable(!initialized); // Emulation - m_pMenuItemStop->Enable(running || paused); - m_pMenuItemLoad->Enable(initialized); - m_pMenuItemSave->Enable(initialized); - m_pPluginOptions->Enable(!running && !paused); + GetMenuBar()->FindItem(IDM_STOP)->Enable(running || paused); + m_pSubMenuLoad->Enable(initialized); + m_pSubMenuSave->Enable(initialized); + GetMenuBar()->FindItem(IDM_CONFIG_MAIN)->Enable(!running && !paused); // Misc - m_pMenuChangeDisc->Enable(initialized); + GetMenuBar()->FindItem(IDM_CHANGEDISC)->Enable(initialized); if (DiscIO::CNANDContentManager::Access().GetNANDLoader(FULL_WII_MENU_DIR).IsValid()) - m_pMenuBootWii->Enable(!initialized); + GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(!initialized); if (running) { if (GetToolBar() != NULL) { - m_pToolPlay->SetNormalBitmap(m_Bitmaps[Toolbar_Pause]); - m_pToolPlay->SetShortHelp(_("Pause")); - m_pToolPlay->SetLabel(_("Pause")); + GetToolBar()->FindById(IDM_PLAY)->SetNormalBitmap(m_Bitmaps[Toolbar_Pause]); + GetToolBar()->FindById(IDM_PLAY)->SetShortHelp(_("Pause")); + GetToolBar()->FindById(IDM_PLAY)->SetLabel(_("Pause")); } - m_pMenuItemPlay->SetText(_("&Pause")); + GetMenuBar()->FindItem(IDM_PLAY)->SetText(_("&Pause")); } else { if (GetToolBar() != NULL) { - m_pToolPlay->SetNormalBitmap(m_Bitmaps[Toolbar_Play]); - m_pToolPlay->SetShortHelp(_("Play")); - m_pToolPlay->SetLabel(_("Play")); + GetToolBar()->FindById(IDM_PLAY)->SetNormalBitmap(m_Bitmaps[Toolbar_Play]); + GetToolBar()->FindById(IDM_PLAY)->SetShortHelp(_("Play")); + GetToolBar()->FindById(IDM_PLAY)->SetLabel(_("Play")); } - m_pMenuItemPlay->SetText(_("&Play")); + GetMenuBar()->FindItem(IDM_PLAY)->SetText(_("&Play")); } if (GetToolBar() != NULL) diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 7a03e3dba2..d5c20fa9a2 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -775,7 +775,7 @@ void CGameListCtrl::CompressSelection(bool _compress) std::string OutputFileName; BuildCompleteFilename(OutputFileName, (const char *)browseDialog.GetPath().mb_str(wxConvUTF8), FileName); - DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), OutputFileName.c_str(), 0, 16384, &MultiCompressCB, &progressDialog); + DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), OutputFileName.c_str(), iso->IsWii() ? 1 : 0, 16384, &MultiCompressCB, &progressDialog); } else if (iso->IsCompressed() && !_compress) { @@ -868,7 +868,7 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) if (iso->IsCompressed()) DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(), path.char_str(), &CompressCB, &dialog); else - DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), path.char_str(), 0, 16384, &CompressCB, &dialog); + DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), path.char_str(), iso->IsWii() ? 1 : 0, 16384, &CompressCB, &dialog); Update(); } diff --git a/Source/Core/DolphinWX/Src/ISOFile.cpp b/Source/Core/DolphinWX/Src/ISOFile.cpp index aaada8f96a..9ae7dbdb3b 100644 --- a/Source/Core/DolphinWX/Src/ISOFile.cpp +++ b/Source/Core/DolphinWX/Src/ISOFile.cpp @@ -46,6 +46,7 @@ GameListItem::GameListItem(const std::string& _rFileName) , m_BlobCompressed(false) , m_pImage(NULL) , m_ImageSize(0) + , m_IsWii(false) { if (LoadFromCache()) @@ -58,6 +59,7 @@ GameListItem::GameListItem(const std::string& _rFileName) if (pVolume != NULL) { + m_IsWii = DiscIO::IsVolumeWiiDisc(pVolume); m_Company = "N/A"; for (int i = 0; i < 6; i++) { diff --git a/Source/Core/DolphinWX/Src/ISOFile.h b/Source/Core/DolphinWX/Src/ISOFile.h index 09e6e7a7fc..3819c42181 100644 --- a/Source/Core/DolphinWX/Src/ISOFile.h +++ b/Source/Core/DolphinWX/Src/ISOFile.h @@ -36,6 +36,7 @@ public: DiscIO::IVolume::ECountry GetCountry() const {return m_Country;} const std::string& GetIssues() const {return m_Issues;} bool IsCompressed() const {return m_BlobCompressed;} + bool IsWii() const {return m_IsWii;} u64 GetFileSize() const {return m_FileSize;} u64 GetVolumeSize() const {return m_VolumeSize;} #if defined(HAVE_WX) && HAVE_WX @@ -63,6 +64,7 @@ private: bool m_BlobCompressed; u8* m_pImage; u32 m_ImageSize; + bool m_IsWii; bool LoadFromCache(); void SaveToCache();