yuzu-emu
/
yuzu
Archived
1
0
Fork 0

Merge pull request #12852 from Calinou/multiplayer-color-player-counts

Color player counts in the multiplayer public lobby list
This commit is contained in:
liamwhite 2024-02-03 11:10:00 -05:00 committed by GitHub
commit a3c8bb251d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 4 deletions

View File

@ -193,13 +193,30 @@ public:
}
QVariant data(int role) const override {
if (role != Qt::DisplayRole) {
return LobbyItem::data(role);
}
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);
}
}
bool operator<(const QStandardItem& other) const override {
// sort by rooms that have the most players