summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2024-02-03 17:10:00 +0100
committerGitHub <noreply@github.com>2024-02-03 17:10:00 +0100
commita3c8bb251d07f69e62b01914c5e0df88d2dad93c (patch)
treeef2ffc58a7059550d13d237de86207992833808d /src
parentMerge pull request #12851 from Calinou/multiplayer-persist-filters (diff)
parentColor player counts in the multiplayer public lobby list (diff)
downloadyuzu-a3c8bb251d07f69e62b01914c5e0df88d2dad93c.tar
yuzu-a3c8bb251d07f69e62b01914c5e0df88d2dad93c.tar.gz
yuzu-a3c8bb251d07f69e62b01914c5e0df88d2dad93c.tar.bz2
yuzu-a3c8bb251d07f69e62b01914c5e0df88d2dad93c.tar.lz
yuzu-a3c8bb251d07f69e62b01914c5e0df88d2dad93c.tar.xz
yuzu-a3c8bb251d07f69e62b01914c5e0df88d2dad93c.tar.zst
yuzu-a3c8bb251d07f69e62b01914c5e0df88d2dad93c.zip
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/multiplayer/lobby_p.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/yuzu/multiplayer/lobby_p.h b/src/yuzu/multiplayer/lobby_p.h
index 068c95aca..398833e7a 100644
--- a/src/yuzu/multiplayer/lobby_p.h
+++ b/src/yuzu/multiplayer/lobby_p.h
@@ -193,12 +193,29 @@ public:
}
QVariant data(int role) const override {
- if (role != Qt::DisplayRole) {
+ switch (role) {
+ case Qt::DisplayRole: {
+ auto members = data(MemberListRole).toList();
+ return QStringLiteral("%1 / %2 ")
+ .arg(QString::number(members.size()), data(MaxPlayerRole).toString());
+ }
+ case Qt::ForegroundRole: {
+ auto members = data(MemberListRole).toList();
+ auto max_players = data(MaxPlayerRole).toInt();
+ if (members.size() >= max_players) {
+ return QBrush(QColor(255, 48, 32));
+ } else if (members.size() == (max_players - 1)) {
+ return QBrush(QColor(255, 140, 32));
+ } else if (members.size() == 0) {
+ return QBrush(QColor(128, 128, 128));
+ }
+ // FIXME: How to return a value that tells Qt not to modify the
+ // text color from the default (as if Qt::ForegroundRole wasn't overridden)?
+ return QBrush(nullptr);
+ }
+ default:
return LobbyItem::data(role);
}
- auto members = data(MemberListRole).toList();
- return QStringLiteral("%1 / %2 ")
- .arg(QString::number(members.size()), data(MaxPlayerRole).toString());
}
bool operator<(const QStandardItem& other) const override {