Skip to content

Commit

Permalink
Update PlayerList to work more akin to WebAO (#1039)
Browse files Browse the repository at this point in the history
* Add Playerlist label formatter to account for missing args

* Make it less of a visual atrocity
  • Loading branch information
Salanto authored Aug 25, 2024
1 parent 50204ec commit 552ccc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/widgets/playerlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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());
Expand All @@ -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();
}
2 changes: 2 additions & 0 deletions src/widgets/playerlistwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class PlayerListWidget : public QListWidget
void removePlayer(int playerId);
void updatePlayer(int playerId, bool updateIcon);

QString formatLabel(const PlayerData &data);

void filterPlayerList();

private Q_SLOTS:
Expand Down

0 comments on commit 552ccc3

Please sign in to comment.