Allow translations and custom names in GameFile::GetNetPlayName
There is no longer any major reason for why this function would need to return the same result for all players.
This commit is contained in:
parent
a41166bb37
commit
5cad82137d
|
@ -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);
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
bool HasMultipleSelected() const;
|
||||
std::shared_ptr<const UICommon::GameFile> FindGame(const std::string& path) const;
|
||||
std::shared_ptr<const UICommon::GameFile> FindSecondDisc(const UICommon::GameFile& game) const;
|
||||
std::string GetNetPlayName(const UICommon::GameFile& game) const;
|
||||
|
||||
void SetListView() { SetPreferredView(true); }
|
||||
void SetGridView() { SetPreferredView(false); }
|
||||
|
|
|
@ -313,6 +313,11 @@ std::shared_ptr<const UICommon::GameFile> 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<const UICommon::GameFile>& game)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), m_games.size(), m_games.size());
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
int columnCount(const QModelIndex& parent) const override;
|
||||
|
||||
std::shared_ptr<const UICommon::GameFile> GetGameFile(int index) const;
|
||||
std::string GetNetPlayName(const UICommon::GameFile& game) const;
|
||||
bool ShouldDisplayGameListItem(int index) const;
|
||||
void SetSearchTerm(const QString& term);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -55,7 +55,8 @@ void GameListDialog::PopulateGameList()
|
|||
{
|
||||
std::shared_ptr<const UICommon::GameFile> 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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -363,7 +363,8 @@ void NetPlaySetupDialog::PopulateGameList()
|
|||
{
|
||||
std::shared_ptr<const UICommon::GameFile> 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);
|
||||
}
|
||||
|
|
|
@ -535,7 +535,7 @@ std::vector<DiscIO::Language> GameFile::GetLanguages() const
|
|||
return languages;
|
||||
}
|
||||
|
||||
std::string GameFile::GetNetPlayName() const
|
||||
std::string GameFile::GetNetPlayName(const Core::TitleDatabase& title_database) const
|
||||
{
|
||||
std::vector<std::string> 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;
|
||||
|
||||
|
|
|
@ -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<u8, 20> GetSyncHash() const;
|
||||
|
|
Loading…
Reference in New Issue