From 71d105e545fc31e51682b27ee1f6e35a18c4ea9c Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 6 May 2017 17:08:18 +0200 Subject: [PATCH] DolphinWX: Use title ID from ISOFile when possible This skips creating volume objects, which can take a while. --- Source/Core/DolphinWX/FrameTools.cpp | 4 +--- Source/Core/DolphinWX/GameListCtrl.cpp | 22 +++++----------------- Source/Core/DolphinWX/ISOFile.cpp | 11 ++--------- Source/Core/DolphinWX/ISOFile.h | 3 ++- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index d3b26ab99d..09a6e625fa 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -1227,9 +1227,7 @@ void CFrame::OnUninstallWAD(wxCommandEvent&) return; } - const auto volume = DiscIO::CreateVolumeFromFilename(file->GetFileName()); - u64 title_id; - volume->GetTitleID(&title_id); + u64 title_id = file->GetTitleID(); if (!DiscIO::CNANDContentManager::Access().RemoveTitle(title_id, Common::FROM_CONFIGURED_ROOT)) { PanicAlertT("Failed to remove this title from the NAND."); diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index aa40b3dcf9..9910084337 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -959,15 +959,10 @@ void CGameListCtrl::OnLeftClick(wxMouseEvent& event) event.Skip(); } -static bool IsWADInstalled(const std::string& wad_path) +static bool IsWADInstalled(const GameListItem& wad) { - const auto volume = DiscIO::CreateVolumeFromFilename(wad_path); - u64 title_id; - if (!volume || !volume->GetTitleID(&title_id)) - return false; - const std::string content_dir = - Common::GetTitleContentPath(title_id, Common::FromWhichRoot::FROM_CONFIGURED_ROOT); + Common::GetTitleContentPath(wad.GetTitleID(), Common::FromWhichRoot::FROM_CONFIGURED_ROOT); if (!File::IsDirectory(content_dir)) return false; @@ -1055,7 +1050,7 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event) for (auto* menu_item : {install_wad_item, uninstall_wad_item}) menu_item->Enable(!Core::IsRunning() || !SConfig::GetInstance().bWii); - if (!IsWADInstalled(selected_iso->GetFileName())) + if (!IsWADInstalled(*selected_iso)) uninstall_wad_item->Enable(false); } @@ -1140,15 +1135,8 @@ void CGameListCtrl::OnOpenSaveFolder(wxCommandEvent& WXUNUSED(event)) void CGameListCtrl::OnExportSave(wxCommandEvent& WXUNUSED(event)) { const GameListItem* iso = GetSelectedISO(); - if (!iso) - return; - - u64 title_id; - std::unique_ptr volume(DiscIO::CreateVolumeFromFilename(iso->GetFileName())); - if (volume && volume->GetTitleID(&title_id)) - { - CWiiSaveCrypted::ExportWiiSave(title_id); - } + if (iso) + CWiiSaveCrypted::ExportWiiSave(iso->GetTitleID()); } // Save this file as the default file diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 9d6242688b..ac4c901894 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -361,18 +361,11 @@ std::vector GameListItem::GetLanguages() const const std::string GameListItem::GetWiiFSPath() const { - std::unique_ptr iso(DiscIO::CreateVolumeFromFilename(m_FileName)); std::string ret; - if (iso == nullptr) - return ret; - - if (iso->GetVolumeType() != DiscIO::Platform::GAMECUBE_DISC) + if (m_Platform != DiscIO::Platform::GAMECUBE_DISC) { - u64 title_id = 0; - iso->GetTitleID(&title_id); - - const std::string path = Common::GetTitleDataPath(title_id, Common::FROM_CONFIGURED_ROOT); + const std::string path = Common::GetTitleDataPath(m_title_id, Common::FROM_CONFIGURED_ROOT); if (!File::Exists(path)) File::CreateFullPath(path); diff --git a/Source/Core/DolphinWX/ISOFile.h b/Source/Core/DolphinWX/ISOFile.h index f12b710483..2361014e31 100644 --- a/Source/Core/DolphinWX/ISOFile.h +++ b/Source/Core/DolphinWX/ISOFile.h @@ -46,6 +46,7 @@ public: std::string GetCompany() const { return m_company; } u16 GetRevision() const { return m_Revision; } const std::string& GetGameID() const { return m_game_id; } + u64 GetTitleID() const { return m_title_id; } const std::string GetWiiFSPath() const; DiscIO::Region GetRegion() const { return m_region; } DiscIO::Country GetCountry() const { return m_Country; } @@ -70,7 +71,7 @@ private: std::string m_company; std::string m_game_id; - u64 m_title_id; + u64 m_title_id = 0; std::string m_issues; int m_emu_state;