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
This commit is contained in:
Salanto 2024-08-25 16:31:16 +02:00 committed by GitHub
parent 50204ec2e2
commit 552ccc38d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -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();
}

View File

@ -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: