From d5bf6f1bbc89d9e7fad9a09c4c159906f2521e90 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 26 Jun 2017 22:19:51 +0200 Subject: [PATCH 1/3] DolphinWX: Sync custom title changes on game list rescan --- Source/Core/DolphinWX/GameListCtrl.cpp | 9 ++++++--- Source/Core/DolphinWX/ISOFile.cpp | 24 +++++++++++++++--------- Source/Core/DolphinWX/ISOFile.h | 5 ++++- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index 5b68857c01..9a542de2fe 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -421,7 +421,7 @@ void GameListCtrl::RefreshList() std::unique_lock lk(m_title_database_mutex); for (const auto& drive : cdio_get_devices()) { - auto file = std::make_shared(drive, m_title_database); + auto file = std::make_shared(drive); if (file->IsValid()) m_shown_files.push_back(file); } @@ -780,7 +780,7 @@ void GameListCtrl::RescanList() } for (const auto& path : new_paths) { - auto file = std::make_shared(path, m_title_database); + auto file = std::make_shared(path); if (file->IsValid()) { cache_changed = true; @@ -804,7 +804,8 @@ void GameListCtrl::RescanList() { bool emu_state_changed = file->EmuStateChanged(); bool banner_changed = file->BannerChanged(); - if (emu_state_changed || banner_changed) + bool custom_title_changed = file->CustomNameChanged(m_title_database); + if (emu_state_changed || banner_changed || custom_title_changed) { cache_changed = refresh_needed = true; auto copy = std::make_shared(*file); @@ -812,6 +813,8 @@ void GameListCtrl::RescanList() copy->EmuStateCommit(); if (banner_changed) copy->BannerCommit(); + if (custom_title_changed) + copy->CustomNameCommit(); file = std::move(copy); } } diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 5f01889a29..48359e1485 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -61,7 +61,7 @@ static std::string GetLanguageString(DiscIO::Language language, return ""; } -GameListItem::GameListItem(const std::string& filename, const Core::TitleDatabase& title_database) +GameListItem::GameListItem(const std::string& filename) : m_file_name(filename), m_region(DiscIO::Region::UNKNOWN_REGION), m_country(DiscIO::Country::COUNTRY_UNKNOWN) { @@ -100,14 +100,6 @@ GameListItem::GameListItem(const std::string& filename, const Core::TitleDatabas if (m_company.empty() && m_game_id.size() >= 6) m_company = DiscIO::GetCompanyFromID(m_game_id.substr(4, 2)); - if (IsValid()) - { - const auto type = m_platform == DiscIO::Platform::WII_WAD ? - Core::TitleDatabase::TitleType::Channel : - Core::TitleDatabase::TitleType::Other; - m_custom_name = title_database.GetTitleName(m_game_id, type); - } - if (!IsValid() && IsElfOrDol()) { m_valid = true; @@ -147,6 +139,20 @@ bool GameListItem::IsValid() const return true; } +bool GameListItem::CustomNameChanged(const Core::TitleDatabase& title_database) +{ + const auto type = m_platform == DiscIO::Platform::WII_WAD ? + Core::TitleDatabase::TitleType::Channel : + Core::TitleDatabase::TitleType::Other; + m_pending.custom_name = title_database.GetTitleName(m_game_id, type); + return m_custom_name != m_pending.custom_name; +} + +void GameListItem::CustomNameCommit() +{ + m_custom_name = m_pending.custom_name; +} + bool GameListItem::EmuStateChanged() { IniFile ini = SConfig::LoadGameIni(m_game_id, m_revision); diff --git a/Source/Core/DolphinWX/ISOFile.h b/Source/Core/DolphinWX/ISOFile.h index a7b66c5e8e..f3a89562b0 100644 --- a/Source/Core/DolphinWX/ISOFile.h +++ b/Source/Core/DolphinWX/ISOFile.h @@ -33,7 +33,7 @@ class GameListItem { public: GameListItem() = default; - GameListItem(const std::string& file_name, const Core::TitleDatabase& title_database); + explicit GameListItem(const std::string& file_name); ~GameListItem() = default; bool IsValid() const; @@ -67,6 +67,8 @@ public: void BannerCommit(); bool EmuStateChanged(); void EmuStateCommit(); + bool CustomNameChanged(const Core::TitleDatabase& title_database); + void CustomNameCommit(); private: struct EmuState @@ -132,5 +134,6 @@ private: { EmuState emu_state; Banner banner; + std::string custom_name; } m_pending{}; }; From 0ac1562fbdbc122b316570ec58c4b3681c2b5fda Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 26 Jun 2017 22:55:50 +0200 Subject: [PATCH 2/3] DolphinWX: Load EmuState and custom name for actual discs --- Source/Core/DolphinWX/GameListCtrl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index 9a542de2fe..83fd250d62 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -423,7 +423,13 @@ void GameListCtrl::RefreshList() { auto file = std::make_shared(drive); if (file->IsValid()) + { + if (file->EmuStateChanged()) + file->EmuStateCommit(); + if (file->CustomNameChanged(m_title_database)) + file->CustomNameCommit(); m_shown_files.push_back(file); + } } } From 7d801d61dcc71e8f81e6d022e0c60ece2c5a7456 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 27 Jun 2017 10:21:33 +0200 Subject: [PATCH 3/3] DolphinWX: Use std::move when committing in GameListItem --- Source/Core/DolphinWX/ISOFile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 48359e1485..3b607e8cf2 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -150,7 +150,7 @@ bool GameListItem::CustomNameChanged(const Core::TitleDatabase& title_database) void GameListItem::CustomNameCommit() { - m_custom_name = m_pending.custom_name; + m_custom_name = std::move(m_pending.custom_name); } bool GameListItem::EmuStateChanged() @@ -163,7 +163,7 @@ bool GameListItem::EmuStateChanged() void GameListItem::EmuStateCommit() { - m_emu_state = m_pending.emu_state; + m_emu_state = std::move(m_pending.emu_state); } void GameListItem::EmuState::DoState(PointerWrap& p)