diff options
author | FearlessTobi <[email protected]> | 2022-08-27 03:31:17 +0200 |
---|---|---|
committer | FearlessTobi <[email protected]> | 2022-08-27 03:31:17 +0200 |
commit | 839e1faf491776f4e2348c46773c248644e260ba (patch) | |
tree | dab0425ff7e8f6817d0c363c59107adb39785ef2 /src/yuzu/multiplayer | |
parent | b961b385c373fd015178f789b3dc6b0565da9056 (diff) | |
download | yuzu-android-839e1faf491776f4e2348c46773c248644e260ba.tar.gz yuzu-android-839e1faf491776f4e2348c46773c248644e260ba.zip |
yuzu: Display current game version in multiplayer room
Makes it easier for users to recognize connection errors caused by different game versions.
Diffstat (limited to 'src/yuzu/multiplayer')
-rw-r--r-- | src/yuzu/multiplayer/chat_room.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/yuzu/multiplayer/chat_room.cpp b/src/yuzu/multiplayer/chat_room.cpp index 51ece1f21..21582b3d6 100644 --- a/src/yuzu/multiplayer/chat_room.cpp +++ b/src/yuzu/multiplayer/chat_room.cpp @@ -122,19 +122,22 @@ public: static const int UsernameRole = Qt::UserRole + 2; static const int AvatarUrlRole = Qt::UserRole + 3; static const int GameNameRole = Qt::UserRole + 4; + static const int GameVersionRole = Qt::UserRole + 5; PlayerListItem() = default; explicit PlayerListItem(const std::string& nickname, const std::string& username, - const std::string& avatar_url, const std::string& game_name) { + const std::string& avatar_url, + const AnnounceMultiplayerRoom::GameInfo& game_info) { setEditable(false); setData(QString::fromStdString(nickname), NicknameRole); setData(QString::fromStdString(username), UsernameRole); setData(QString::fromStdString(avatar_url), AvatarUrlRole); - if (game_name.empty()) { + if (game_info.name.empty()) { setData(QObject::tr("Not playing a game"), GameNameRole); } else { - setData(QString::fromStdString(game_name), GameNameRole); + setData(QString::fromStdString(game_info.name), GameNameRole); } + setData(QString::fromStdString(game_info.version), GameVersionRole); } QVariant data(int role) const override { @@ -149,7 +152,15 @@ public: } else { name = QStringLiteral("%1 (%2)").arg(nickname, username); } - return QStringLiteral("%1\n %2").arg(name, data(GameNameRole).toString()); + const QString version = data(GameVersionRole).toString(); + QString version_string; + if (version.isEmpty()) { + version_string = QString{}; + } else { + version_string = QStringLiteral("(%1)").arg(version); + } + return QStringLiteral("%1\n %2 %3") + .arg(name, data(GameNameRole).toString(), version_string); } }; @@ -366,7 +377,7 @@ void ChatRoom::SetPlayerList(const Network::RoomMember::MemberList& member_list) if (member.nickname.empty()) continue; QStandardItem* name_item = new PlayerListItem(member.nickname, member.username, - member.avatar_url, member.game_info.name); + member.avatar_url, member.game_info); #ifdef ENABLE_WEB_SERVICE if (!icon_cache.count(member.avatar_url) && !member.avatar_url.empty()) { |