[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>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::NoContextMenu</enum>
|
<enum>Qt::ContextMenuPolicy::NoContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Settings</string>
|
<string>Settings</string>
|
||||||
@ -20,7 +20,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="settings_tabs">
|
<widget class="QTabWidget" name="settings_tabs">
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::FocusPolicy::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@ -39,9 +39,9 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>-385</y>
|
<y>-585</y>
|
||||||
<width>394</width>
|
<width>394</width>
|
||||||
<height>878</height>
|
<height>902</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
@ -131,10 +131,10 @@
|
|||||||
<item row="6" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QFrame" name="theme_log_divider">
|
<widget class="QFrame" name="theme_log_divider">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::HLine</enum>
|
<enum>QFrame::Shape::HLine</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Shadow::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -198,7 +198,7 @@
|
|||||||
<string>Chat Rate Limit:</string>
|
<string>Chat Rate Limit:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat">
|
<property name="textFormat">
|
||||||
<enum>Qt::AutoText</enum>
|
<enum>Qt::TextFormat::AutoText</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -215,10 +215,10 @@
|
|||||||
<item row="11" column="1">
|
<item row="11" column="1">
|
||||||
<widget class="QFrame" name="log_names_divider">
|
<widget class="QFrame" name="log_names_divider">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::HLine</enum>
|
<enum>QFrame::Shape::HLine</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Shadow::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -272,10 +272,10 @@
|
|||||||
<item row="15" column="1">
|
<item row="15" column="1">
|
||||||
<widget class="QFrame" name="net_divider">
|
<widget class="QFrame" name="net_divider">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::HLine</enum>
|
<enum>QFrame::Shape::HLine</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Shadow::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -560,23 +560,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="19" column="0">
|
||||||
<widget class="QLabel" name="resize_lbl">
|
<widget class="QLabel" name="resize_lbl">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@ -609,6 +592,33 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -653,10 +663,10 @@
|
|||||||
<item row="1" column="0" colspan="2">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QFrame" name="audio_volume_divider">
|
<widget class="QFrame" name="audio_volume_divider">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::HLine</enum>
|
<enum>QFrame::Shape::HLine</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Shadow::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -683,10 +693,10 @@
|
|||||||
<item row="3" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QFrame" name="volume_blip_divider">
|
<widget class="QFrame" name="volume_blip_divider">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::HLine</enum>
|
<enum>QFrame::Shape::HLine</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Shadow::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -819,7 +829,7 @@
|
|||||||
<item row="2" column="5">
|
<item row="2" column="5">
|
||||||
<spacer name="mount_buttons_spacer_2">
|
<spacer name="mount_buttons_spacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
@ -858,10 +868,10 @@
|
|||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
<spacer name="mount_buttons_spacer">
|
<spacer name="mount_buttons_spacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
<property name="sizeType">
|
||||||
<enum>QSizePolicy::Expanding</enum>
|
<enum>QSizePolicy::Policy::Expanding</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
@ -1116,10 +1126,10 @@ Default: 0.</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="privacy_separator">
|
<widget class="QFrame" name="privacy_separator">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::HLine</enum>
|
<enum>QFrame::Shape::HLine</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Shadow::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -166,6 +166,12 @@ void AOApplication::call_settings_menu()
|
|||||||
if (is_lobby_constructed())
|
if (is_lobby_constructed())
|
||||||
{}
|
{}
|
||||||
l_dialog->exec();
|
l_dialog->exec();
|
||||||
|
|
||||||
|
if (is_courtroom_constructed())
|
||||||
|
{
|
||||||
|
w_courtroom->playerList()->reloadPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
delete l_dialog;
|
delete l_dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,6 +638,16 @@ void Options::setCallwords(QStringList value)
|
|||||||
config.setValue("callwords", 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()
|
void Options::clearConfig()
|
||||||
{
|
{
|
||||||
config.clear();
|
config.clear();
|
||||||
|
@ -257,6 +257,9 @@ public:
|
|||||||
QStringList callwords() const;
|
QStringList callwords() const;
|
||||||
void setCallwords(QStringList value);
|
void setCallwords(QStringList value);
|
||||||
|
|
||||||
|
QString playerlistFormatString() const;
|
||||||
|
void setPlayerlistFormatString(QString value);
|
||||||
|
|
||||||
// Clears the configuration file. Essentially restoring it to default.
|
// Clears the configuration file. Essentially restoring it to default.
|
||||||
void clearConfig();
|
void clearConfig();
|
||||||
|
|
||||||
|
@ -309,7 +309,6 @@ void AOOptionsDialog::setupUI()
|
|||||||
qWarning() << "Unable to open file " << l_uiFile.fileName();
|
qWarning() << "Unable to open file " << l_uiFile.fileName();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_settings_widget = l_loader.load(&l_uiFile, this);
|
ui_settings_widget = l_loader.load(&l_uiFile, this);
|
||||||
|
|
||||||
auto l_layout = new QVBoxLayout(this);
|
auto l_layout = new QVBoxLayout(this);
|
||||||
@ -372,6 +371,7 @@ void AOOptionsDialog::setupUI()
|
|||||||
FROM_UI(QCheckBox, evidence_double_click_cb);
|
FROM_UI(QCheckBox, evidence_double_click_cb);
|
||||||
FROM_UI(QCheckBox, slides_cb);
|
FROM_UI(QCheckBox, slides_cb);
|
||||||
FROM_UI(QCheckBox, restoreposition_cb);
|
FROM_UI(QCheckBox, restoreposition_cb);
|
||||||
|
FROM_UI(QLineEdit, playerlist_format_edit);
|
||||||
|
|
||||||
registerOption<QSpinBox, int>("theme_scaling_factor_sb", &Options::themeScalingFactor, &Options::setThemeScalingFactor);
|
registerOption<QSpinBox, int>("theme_scaling_factor_sb", &Options::themeScalingFactor, &Options::setThemeScalingFactor);
|
||||||
registerOption<QCheckBox, bool>("animated_theme_cb", &Options::animatedThemeEnabled, &Options::setAnimatedThemeEnabled);
|
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>("evidence_double_click_cb", &Options::evidenceDoubleClickEdit, &Options::setEvidenceDoubleClickEdit);
|
||||||
registerOption<QCheckBox, bool>("slides_cb", &Options::slidesEnabled, &Options::setSlidesEnabled);
|
registerOption<QCheckBox, bool>("slides_cb", &Options::slidesEnabled, &Options::setSlidesEnabled);
|
||||||
registerOption<QCheckBox, bool>("restoreposition_cb", &Options::restoreWindowPositionEnabled, &Options::setRestoreWindowPositionEnabled);
|
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
|
// Callwords tab. This could just be a QLineEdit, but no, we decided to allow
|
||||||
// people to put a billion entries in.
|
// people to put a billion entries in.
|
||||||
|
@ -48,7 +48,6 @@ private:
|
|||||||
QPushButton *ui_theme_folder_button;
|
QPushButton *ui_theme_folder_button;
|
||||||
QCheckBox *ui_evidence_double_click_cb;
|
QCheckBox *ui_evidence_double_click_cb;
|
||||||
QCheckBox *ui_slides_cb;
|
QCheckBox *ui_slides_cb;
|
||||||
QCheckBox *ui_restoreposition_cb;
|
|
||||||
QCheckBox *ui_animated_theme_cb;
|
QCheckBox *ui_animated_theme_cb;
|
||||||
QSpinBox *ui_stay_time_spinbox;
|
QSpinBox *ui_stay_time_spinbox;
|
||||||
QCheckBox *ui_instant_objection_cb;
|
QCheckBox *ui_instant_objection_cb;
|
||||||
@ -76,6 +75,8 @@ private:
|
|||||||
QCheckBox *ui_continuous_cb;
|
QCheckBox *ui_continuous_cb;
|
||||||
QCheckBox *ui_category_stop_cb;
|
QCheckBox *ui_category_stop_cb;
|
||||||
QCheckBox *ui_sfx_on_idle_cb;
|
QCheckBox *ui_sfx_on_idle_cb;
|
||||||
|
QCheckBox *ui_restoreposition_cb;
|
||||||
|
QLineEdit *ui_playerlist_format_edit;
|
||||||
|
|
||||||
// The callwords tab
|
// The callwords tab
|
||||||
QPlainTextEdit *ui_callwords_textbox;
|
QPlainTextEdit *ui_callwords_textbox;
|
||||||
|
@ -70,12 +70,21 @@ void PlayerListWidget::updatePlayer(const PlayerUpdate &update)
|
|||||||
filterPlayerList();
|
filterPlayerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerListWidget::reloadPlayers()
|
||||||
|
{
|
||||||
|
for (const PlayerData &player : qAsConst(m_player_map))
|
||||||
|
{
|
||||||
|
updatePlayer(player.id, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerListWidget::setAuthenticated(bool f_state)
|
void PlayerListWidget::setAuthenticated(bool f_state)
|
||||||
{
|
{
|
||||||
m_is_authenticated = f_state;
|
m_is_authenticated = f_state;
|
||||||
for (const PlayerData &data : qAsConst(m_player_map))
|
for (const PlayerData &data : qAsConst(m_player_map))
|
||||||
{
|
{
|
||||||
updatePlayer(data.id, false);
|
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.";
|
qWarning() << "Trying to filter item that does not exist. This indicates either a broken server-implementation or a bad demo file.";
|
||||||
break;
|
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)
|
QString PlayerListWidget::formatLabel(const PlayerData &data)
|
||||||
{
|
{
|
||||||
if (m_is_authenticated)
|
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();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ public:
|
|||||||
|
|
||||||
void registerPlayer(const PlayerRegister &update);
|
void registerPlayer(const PlayerRegister &update);
|
||||||
void updatePlayer(const PlayerUpdate &update);
|
void updatePlayer(const PlayerUpdate &update);
|
||||||
|
void reloadPlayers();
|
||||||
|
|
||||||
void setAuthenticated(bool f_state);
|
void setAuthenticated(bool f_state);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user