From 552ccc38d6d5cc0c4956267616cbc3cf9c06d528 Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Sun, 25 Aug 2024 16:31:16 +0200 Subject: [PATCH] Update PlayerList to work more akin to WebAO (#1039) * Add Playerlist label formatter to account for missing args * Make it less of a visual atrocity --- src/widgets/playerlistwidget.cpp | 15 ++++++++++++++- src/widgets/playerlistwidget.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/widgets/playerlistwidget.cpp b/src/widgets/playerlistwidget.cpp index c72b74a..1dabe15 100644 --- a/src/widgets/playerlistwidget.cpp +++ b/src/widgets/playerlistwidget.cpp @@ -73,6 +73,10 @@ void PlayerListWidget::updatePlayer(const PlayerUpdate &update) void PlayerListWidget::setAuthenticated(bool f_state) { m_is_authenticated = f_state; + for (const PlayerData &data : qAsConst(m_player_map)) + { + updatePlayer(data.id, false); + } } void PlayerListWidget::onCustomContextMenuRequested(const QPoint &pos) @@ -159,7 +163,7 @@ void PlayerListWidget::updatePlayer(int playerId, bool updateIcon) return; } - item->setText(data.name.isEmpty() ? QObject::tr("Unnamed Player") : data.name); + item->setText(formatLabel(data)); if (data.character.isEmpty()) { item->setToolTip(QString()); @@ -179,3 +183,12 @@ void PlayerListWidget::updatePlayer(int playerId, bool updateIcon) item->setIcon(QIcon(ao_app->get_image_suffix(ao_app->get_character_path(data.character, "char_icon"), true))); } } + +QString PlayerListWidget::formatLabel(const PlayerData &data) +{ + if (m_is_authenticated) + { + return QString("%1 %2 %3").arg(data.character, data.character_name, data.name).simplified(); + } + return QString("%1 %2").arg(data.character, data.character_name).simplified(); +} diff --git a/src/widgets/playerlistwidget.h b/src/widgets/playerlistwidget.h index e771d7e..217c9f9 100644 --- a/src/widgets/playerlistwidget.h +++ b/src/widgets/playerlistwidget.h @@ -29,6 +29,8 @@ private: void removePlayer(int playerId); void updatePlayer(int playerId, bool updateIcon); + QString formatLabel(const PlayerData &data); + void filterPlayerList(); private Q_SLOTS: