diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index 722bdb6912..b465f55168 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -743,6 +743,11 @@ GameList::FindSecondDisc(const UICommon::GameFile& game) const return m_model->FindSecondDisc(game); } +std::string GameList::GetNetPlayName(const UICommon::GameFile& game) const +{ + return m_model->GetNetPlayName(game); +} + void GameList::SetViewColumn(int col, bool view) { m_list->setColumnHidden(col, !view); diff --git a/Source/Core/DolphinQt/GameList/GameList.h b/Source/Core/DolphinQt/GameList/GameList.h index 429f8796d7..ec92ea08e0 100644 --- a/Source/Core/DolphinQt/GameList/GameList.h +++ b/Source/Core/DolphinQt/GameList/GameList.h @@ -32,6 +32,7 @@ public: bool HasMultipleSelected() const; std::shared_ptr FindGame(const std::string& path) const; std::shared_ptr FindSecondDisc(const UICommon::GameFile& game) const; + std::string GetNetPlayName(const UICommon::GameFile& game) const; void SetListView() { SetPreferredView(true); } void SetGridView() { SetPreferredView(false); } diff --git a/Source/Core/DolphinQt/GameList/GameListModel.cpp b/Source/Core/DolphinQt/GameList/GameListModel.cpp index c184c2ef60..d470bf3b37 100644 --- a/Source/Core/DolphinQt/GameList/GameListModel.cpp +++ b/Source/Core/DolphinQt/GameList/GameListModel.cpp @@ -313,6 +313,11 @@ std::shared_ptr GameListModel::GetGameFile(int index) return m_games[index]; } +std::string GameListModel::GetNetPlayName(const UICommon::GameFile& game) const +{ + return game.GetNetPlayName(m_title_database); +} + void GameListModel::AddGame(const std::shared_ptr& game) { beginInsertRows(QModelIndex(), m_games.size(), m_games.size()); diff --git a/Source/Core/DolphinQt/GameList/GameListModel.h b/Source/Core/DolphinQt/GameList/GameListModel.h index a476ebae82..0fab145fca 100644 --- a/Source/Core/DolphinQt/GameList/GameListModel.h +++ b/Source/Core/DolphinQt/GameList/GameListModel.h @@ -37,6 +37,7 @@ public: int columnCount(const QModelIndex& parent) const override; std::shared_ptr GetGameFile(int index) const; + std::string GetNetPlayName(const UICommon::GameFile& game) const; bool ShouldDisplayGameListItem(int index) const; void SetSearchTerm(const QString& term); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index e579db3dea..d9b6203009 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -1420,7 +1420,7 @@ bool MainWindow::NetPlayHost(const UICommon::GameFile& game) } Settings::Instance().GetNetPlayServer()->ChangeGame(game.GetSyncIdentifier(), - game.GetNetPlayName()); + m_game_list->GetNetPlayName(game)); // Join our local server return NetPlayJoin(); diff --git a/Source/Core/DolphinQt/NetPlay/GameListDialog.cpp b/Source/Core/DolphinQt/NetPlay/GameListDialog.cpp index 4ada80cc73..d0723d3766 100644 --- a/Source/Core/DolphinQt/NetPlay/GameListDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/GameListDialog.cpp @@ -55,7 +55,8 @@ void GameListDialog::PopulateGameList() { std::shared_ptr game = game_list_model->GetGameFile(i); - auto* item = new QListWidgetItem(QString::fromStdString(game->GetNetPlayName())); + auto* item = + new QListWidgetItem(QString::fromStdString(game_list_model->GetNetPlayName(*game))); item->setData(Qt::UserRole, QVariant::fromValue(std::move(game))); m_game_list->addItem(item); } diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp index 82d2f0b141..dd3be6cc65 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp @@ -325,9 +325,12 @@ void NetPlayDialog::ConnectWidgets() GameListDialog gld(this); if (gld.exec() == QDialog::Accepted) { + Settings& settings = Settings::Instance(); + const UICommon::GameFile& game = gld.GetSelectedGame(); - const std::string netplay_name = game.GetNetPlayName(); - Settings::Instance().GetNetPlayServer()->ChangeGame(game.GetSyncIdentifier(), netplay_name); + const std::string netplay_name = settings.GetGameListModel()->GetNetPlayName(game); + + settings.GetNetPlayServer()->ChangeGame(game.GetSyncIdentifier(), netplay_name); Settings::GetQSettings().setValue(QStringLiteral("netplay/hostgame"), QString::fromStdString(netplay_name)); } diff --git a/Source/Core/DolphinQt/NetPlay/NetPlaySetupDialog.cpp b/Source/Core/DolphinQt/NetPlay/NetPlaySetupDialog.cpp index 5f51f4a7cd..adcfa3faf3 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlaySetupDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlaySetupDialog.cpp @@ -363,7 +363,8 @@ void NetPlaySetupDialog::PopulateGameList() { std::shared_ptr game = m_game_list_model->GetGameFile(i); - auto* item = new QListWidgetItem(QString::fromStdString(game->GetNetPlayName())); + auto* item = + new QListWidgetItem(QString::fromStdString(m_game_list_model->GetNetPlayName(*game))); item->setData(Qt::UserRole, QVariant::fromValue(std::move(game))); m_host_games->addItem(item); } diff --git a/Source/Core/UICommon/GameFile.cpp b/Source/Core/UICommon/GameFile.cpp index bd9f621f28..30641d58e5 100644 --- a/Source/Core/UICommon/GameFile.cpp +++ b/Source/Core/UICommon/GameFile.cpp @@ -535,7 +535,7 @@ std::vector GameFile::GetLanguages() const return languages; } -std::string GameFile::GetNetPlayName() const +std::string GameFile::GetNetPlayName(const Core::TitleDatabase& title_database) const { std::vector info; if (!GetGameID().empty()) @@ -543,12 +543,7 @@ std::string GameFile::GetNetPlayName() const if (GetRevision() != 0) info.push_back("Revision " + std::to_string(GetRevision())); - std::string name = GetLongName(DiscIO::Language::English); - if (name.empty()) - { - // Use the file name as a fallback. Not necessarily consistent, but it's the best we have - name = m_file_name; - } + const std::string name = GetName(title_database); int disc_number = GetDiscNumber() + 1; diff --git a/Source/Core/UICommon/GameFile.h b/Source/Core/UICommon/GameFile.h index 68ad21dec6..9366b33f2e 100644 --- a/Source/Core/UICommon/GameFile.h +++ b/Source/Core/UICommon/GameFile.h @@ -82,7 +82,7 @@ public: u16 GetRevision() const { return m_revision; } // 0 is the first disc, 1 is the second disc u8 GetDiscNumber() const { return m_disc_number; } - std::string GetNetPlayName() const; + std::string GetNetPlayName(const Core::TitleDatabase& title_database) const; // This function is slow std::array GetSyncHash() const;