DolphinWX: Sync custom title changes on game list rescan

This commit is contained in:
JosJuice 2017-06-26 22:19:51 +02:00
parent 7d60f03acb
commit d5bf6f1bbc
3 changed files with 25 additions and 13 deletions

View File

@ -421,7 +421,7 @@ void GameListCtrl::RefreshList()
std::unique_lock<std::mutex> lk(m_title_database_mutex); std::unique_lock<std::mutex> lk(m_title_database_mutex);
for (const auto& drive : cdio_get_devices()) for (const auto& drive : cdio_get_devices())
{ {
auto file = std::make_shared<GameListItem>(drive, m_title_database); auto file = std::make_shared<GameListItem>(drive);
if (file->IsValid()) if (file->IsValid())
m_shown_files.push_back(file); m_shown_files.push_back(file);
} }
@ -780,7 +780,7 @@ void GameListCtrl::RescanList()
} }
for (const auto& path : new_paths) for (const auto& path : new_paths)
{ {
auto file = std::make_shared<GameListItem>(path, m_title_database); auto file = std::make_shared<GameListItem>(path);
if (file->IsValid()) if (file->IsValid())
{ {
cache_changed = true; cache_changed = true;
@ -804,7 +804,8 @@ void GameListCtrl::RescanList()
{ {
bool emu_state_changed = file->EmuStateChanged(); bool emu_state_changed = file->EmuStateChanged();
bool banner_changed = file->BannerChanged(); 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; cache_changed = refresh_needed = true;
auto copy = std::make_shared<GameListItem>(*file); auto copy = std::make_shared<GameListItem>(*file);
@ -812,6 +813,8 @@ void GameListCtrl::RescanList()
copy->EmuStateCommit(); copy->EmuStateCommit();
if (banner_changed) if (banner_changed)
copy->BannerCommit(); copy->BannerCommit();
if (custom_title_changed)
copy->CustomNameCommit();
file = std::move(copy); file = std::move(copy);
} }
} }

View File

@ -61,7 +61,7 @@ static std::string GetLanguageString(DiscIO::Language language,
return ""; 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_file_name(filename), m_region(DiscIO::Region::UNKNOWN_REGION),
m_country(DiscIO::Country::COUNTRY_UNKNOWN) 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) if (m_company.empty() && m_game_id.size() >= 6)
m_company = DiscIO::GetCompanyFromID(m_game_id.substr(4, 2)); 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()) if (!IsValid() && IsElfOrDol())
{ {
m_valid = true; m_valid = true;
@ -147,6 +139,20 @@ bool GameListItem::IsValid() const
return true; 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() bool GameListItem::EmuStateChanged()
{ {
IniFile ini = SConfig::LoadGameIni(m_game_id, m_revision); IniFile ini = SConfig::LoadGameIni(m_game_id, m_revision);

View File

@ -33,7 +33,7 @@ class GameListItem
{ {
public: public:
GameListItem() = default; GameListItem() = default;
GameListItem(const std::string& file_name, const Core::TitleDatabase& title_database); explicit GameListItem(const std::string& file_name);
~GameListItem() = default; ~GameListItem() = default;
bool IsValid() const; bool IsValid() const;
@ -67,6 +67,8 @@ public:
void BannerCommit(); void BannerCommit();
bool EmuStateChanged(); bool EmuStateChanged();
void EmuStateCommit(); void EmuStateCommit();
bool CustomNameChanged(const Core::TitleDatabase& title_database);
void CustomNameCommit();
private: private:
struct EmuState struct EmuState
@ -132,5 +134,6 @@ private:
{ {
EmuState emu_state; EmuState emu_state;
Banner banner; Banner banner;
std::string custom_name;
} m_pending{}; } m_pending{};
}; };