[Feature] Add support for custom playerlist formatting, show all users when authenticated (#1046)
* Playerlist QoL * Remove excessive whitespaces * Add placeholder when displayname is unavailable
This commit is contained in:
parent
851b8c6a69
commit
0c10f03150
@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
<enum>Qt::ContextMenuPolicy::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
@ -20,7 +20,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="settings_tabs">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
<enum>Qt::FocusPolicy::NoFocus</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
@ -39,9 +39,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-385</y>
|
||||
<y>-585</y>
|
||||
<width>394</width>
|
||||
<height>878</height>
|
||||
<height>902</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
@ -131,10 +131,10 @@
|
||||
<item row="6" column="1">
|
||||
<widget class="QFrame" name="theme_log_divider">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
<enum>QFrame::Shape::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
<enum>QFrame::Shadow::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -198,7 +198,7 @@
|
||||
<string>Chat Rate Limit:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
<enum>Qt::TextFormat::AutoText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -215,10 +215,10 @@
|
||||
<item row="11" column="1">
|
||||
<widget class="QFrame" name="log_names_divider">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
<enum>QFrame::Shape::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
<enum>QFrame::Shadow::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -272,10 +272,10 @@
|
||||
<item row="15" column="1">
|
||||
<widget class="QFrame" name="net_divider">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
<enum>QFrame::Shape::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
<enum>QFrame::Shadow::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -560,23 +560,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="35" column="1">
|
||||
<widget class="QCheckBox" name="restoreposition_cb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="35" column="0">
|
||||
<widget class="QLabel" name="restoreposition_lbl">
|
||||
<property name="toolTip">
|
||||
<string>If ticked, some windows restore their last known position where they were closed.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restore Window Position</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="19" column="0">
|
||||
<widget class="QLabel" name="resize_lbl">
|
||||
<property name="toolTip">
|
||||
@ -609,6 +592,33 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="34" column="0">
|
||||
<widget class="QLabel" name="restoreposition_lbl">
|
||||
<property name="toolTip">
|
||||
<string>If ticked, some windows restore their last known position where they were closed.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restore Window Position</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="34" column="1">
|
||||
<widget class="QCheckBox" name="restoreposition_cb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="35" column="0">
|
||||
<widget class="QLabel" name="playerlist_format_lbl">
|
||||
<property name="text">
|
||||
<string>Playerlist Format:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="35" column="1">
|
||||
<widget class="QLineEdit" name="playerlist_format_edit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -653,10 +663,10 @@
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QFrame" name="audio_volume_divider">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
<enum>QFrame::Shape::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
<enum>QFrame::Shadow::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -683,10 +693,10 @@
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QFrame" name="volume_blip_divider">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
<enum>QFrame::Shape::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
<enum>QFrame::Shadow::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -819,7 +829,7 @@
|
||||
<item row="2" column="5">
|
||||
<spacer name="mount_buttons_spacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@ -858,10 +868,10 @@
|
||||
<item row="2" column="2">
|
||||
<spacer name="mount_buttons_spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
<enum>QSizePolicy::Policy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@ -1116,10 +1126,10 @@ Default: 0.</string>
|
||||
<item>
|
||||
<widget class="QFrame" name="privacy_separator">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
<enum>QFrame::Shape::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
<enum>QFrame::Shadow::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -166,6 +166,12 @@ void AOApplication::call_settings_menu()
|
||||
if (is_lobby_constructed())
|
||||
{}
|
||||
l_dialog->exec();
|
||||
|
||||
if (is_courtroom_constructed())
|
||||
{
|
||||
w_courtroom->playerList()->reloadPlayers();
|
||||
}
|
||||
|
||||
delete l_dialog;
|
||||
}
|
||||
|
||||
|
@ -638,6 +638,16 @@ void Options::setCallwords(QStringList value)
|
||||
config.setValue("callwords", value);
|
||||
}
|
||||
|
||||
QString Options::playerlistFormatString() const
|
||||
{
|
||||
return config.value("visuals/playerlist_format", "[{id}] {character} {displayname} {username}").toString();
|
||||
}
|
||||
|
||||
void Options::setPlayerlistFormatString(QString value)
|
||||
{
|
||||
config.setValue("visuals/playerlist_format", value);
|
||||
}
|
||||
|
||||
void Options::clearConfig()
|
||||
{
|
||||
config.clear();
|
||||
|
@ -257,6 +257,9 @@ public:
|
||||
QStringList callwords() const;
|
||||
void setCallwords(QStringList value);
|
||||
|
||||
QString playerlistFormatString() const;
|
||||
void setPlayerlistFormatString(QString value);
|
||||
|
||||
// Clears the configuration file. Essentially restoring it to default.
|
||||
void clearConfig();
|
||||
|
||||
|
@ -309,7 +309,6 @@ void AOOptionsDialog::setupUI()
|
||||
qWarning() << "Unable to open file " << l_uiFile.fileName();
|
||||
return;
|
||||
}
|
||||
|
||||
ui_settings_widget = l_loader.load(&l_uiFile, this);
|
||||
|
||||
auto l_layout = new QVBoxLayout(this);
|
||||
@ -372,6 +371,7 @@ void AOOptionsDialog::setupUI()
|
||||
FROM_UI(QCheckBox, evidence_double_click_cb);
|
||||
FROM_UI(QCheckBox, slides_cb);
|
||||
FROM_UI(QCheckBox, restoreposition_cb);
|
||||
FROM_UI(QLineEdit, playerlist_format_edit);
|
||||
|
||||
registerOption<QSpinBox, int>("theme_scaling_factor_sb", &Options::themeScalingFactor, &Options::setThemeScalingFactor);
|
||||
registerOption<QCheckBox, bool>("animated_theme_cb", &Options::animatedThemeEnabled, &Options::setAnimatedThemeEnabled);
|
||||
@ -410,6 +410,7 @@ void AOOptionsDialog::setupUI()
|
||||
registerOption<QCheckBox, bool>("evidence_double_click_cb", &Options::evidenceDoubleClickEdit, &Options::setEvidenceDoubleClickEdit);
|
||||
registerOption<QCheckBox, bool>("slides_cb", &Options::slidesEnabled, &Options::setSlidesEnabled);
|
||||
registerOption<QCheckBox, bool>("restoreposition_cb", &Options::restoreWindowPositionEnabled, &Options::setRestoreWindowPositionEnabled);
|
||||
registerOption<QLineEdit, QString>("playerlist_format_edit", &Options::playerlistFormatString, &Options::setPlayerlistFormatString);
|
||||
|
||||
// Callwords tab. This could just be a QLineEdit, but no, we decided to allow
|
||||
// people to put a billion entries in.
|
||||
|
@ -48,7 +48,6 @@ private:
|
||||
QPushButton *ui_theme_folder_button;
|
||||
QCheckBox *ui_evidence_double_click_cb;
|
||||
QCheckBox *ui_slides_cb;
|
||||
QCheckBox *ui_restoreposition_cb;
|
||||
QCheckBox *ui_animated_theme_cb;
|
||||
QSpinBox *ui_stay_time_spinbox;
|
||||
QCheckBox *ui_instant_objection_cb;
|
||||
@ -76,6 +75,8 @@ private:
|
||||
QCheckBox *ui_continuous_cb;
|
||||
QCheckBox *ui_category_stop_cb;
|
||||
QCheckBox *ui_sfx_on_idle_cb;
|
||||
QCheckBox *ui_restoreposition_cb;
|
||||
QLineEdit *ui_playerlist_format_edit;
|
||||
|
||||
// The callwords tab
|
||||
QPlainTextEdit *ui_callwords_textbox;
|
||||
|
@ -70,12 +70,21 @@ void PlayerListWidget::updatePlayer(const PlayerUpdate &update)
|
||||
filterPlayerList();
|
||||
}
|
||||
|
||||
void PlayerListWidget::reloadPlayers()
|
||||
{
|
||||
for (const PlayerData &player : qAsConst(m_player_map))
|
||||
{
|
||||
updatePlayer(player.id, false);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerListWidget::setAuthenticated(bool f_state)
|
||||
{
|
||||
m_is_authenticated = f_state;
|
||||
for (const PlayerData &data : qAsConst(m_player_map))
|
||||
{
|
||||
updatePlayer(data.id, false);
|
||||
filterPlayerList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +157,7 @@ void PlayerListWidget::filterPlayerList()
|
||||
qWarning() << "Trying to filter item that does not exist. This indicates either a broken server-implementation or a bad demo file.";
|
||||
break;
|
||||
}
|
||||
item->setHidden(m_player_map[item->data(Qt::UserRole).toInt()].area_id != area_id);
|
||||
item->setHidden(m_player_map[item->data(Qt::UserRole).toInt()].area_id != area_id && !m_is_authenticated);
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,9 +195,6 @@ void PlayerListWidget::updatePlayer(int playerId, bool updateIcon)
|
||||
|
||||
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();
|
||||
QString format = Options::getInstance().playerlistFormatString();
|
||||
return format.replace("{id}", QString::number(data.id)).replace("{character}", data.character).replace("{displayname}", data.character_name.isEmpty() ? "No Data" : data.character_name).replace("{username}", m_is_authenticated ? data.name : "").simplified();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ public:
|
||||
|
||||
void registerPlayer(const PlayerRegister &update);
|
||||
void updatePlayer(const PlayerUpdate &update);
|
||||
void reloadPlayers();
|
||||
|
||||
void setAuthenticated(bool f_state);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user