Skip to content

Commit 129b28a

Browse files
authored
Merge pull request #1130 from AttorneyOnline/callwords-sfx-to-config
Added callword sfx filepath to options
2 parents 7271997 + 57e1cd4 commit 129b28a

6 files changed

Lines changed: 66 additions & 11 deletions

File tree

data/ui/options_dialog.ui

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>450</width>
9+
<width>478</width>
1010
<height>415</height>
1111
</rect>
1212
</property>
@@ -39,8 +39,8 @@
3939
<property name="geometry">
4040
<rect>
4141
<x>0</x>
42-
<y>-585</y>
43-
<width>394</width>
42+
<y>0</y>
43+
<width>422</width>
4444
<height>902</height>
4545
</rect>
4646
</property>
@@ -104,10 +104,10 @@
104104
<item row="4" column="1">
105105
<widget class="QDoubleSpinBox" name="theme_scaling_factor_sb">
106106
<property name="minimum">
107-
<number>1</number>
107+
<double>1.000000000000000</double>
108108
</property>
109109
<property name="maximum">
110-
<number>8</number>
110+
<double>8.000000000000000</double>
111111
</property>
112112
</widget>
113113
</item>
@@ -623,11 +623,8 @@
623623
<attribute name="title">
624624
<string>Callwords</string>
625625
</attribute>
626-
<layout class="QVBoxLayout" name="verticalLayout_5">
627-
<item>
628-
<widget class="QPlainTextEdit" name="callwords_textbox"/>
629-
</item>
630-
<item>
626+
<layout class="QFormLayout" name="formLayout_4">
627+
<item row="0" column="0" colspan="2">
631628
<widget class="QLabel" name="callwords_explain_lbl">
632629
<property name="text">
633630
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter as many callwords as you would like. These are case insensitive. Make sure to leave every callword in its own line!&lt;br/&gt;&lt;br/&gt;Do not leave a line with a space at the end -- you will be alerted everytime someone uses a space in their messages.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@@ -637,6 +634,33 @@
637634
</property>
638635
</widget>
639636
</item>
637+
<item row="1" column="0" colspan="2">
638+
<widget class="QPlainTextEdit" name="callwords_textbox"/>
639+
</item>
640+
<item row="2" column="0">
641+
<widget class="QLabel" name="callwords_sfx_lbl">
642+
<property name="text">
643+
<string>Sound</string>
644+
</property>
645+
</widget>
646+
</item>
647+
<item row="2" column="1">
648+
<widget class="QLineEdit" name="callwords_sfx">
649+
<property name="placeholderText">
650+
<string>Filepath</string>
651+
</property>
652+
</widget>
653+
</item>
654+
<item row="3" column="0" colspan="2">
655+
<widget class="QLabel" name="callwords_sfx_explain">
656+
<property name="text">
657+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When a callword is triggered, the sound provided will be played instead of a general alert beep.&lt;/p&gt;&lt;p&gt;If the sound's filepath is invalid, the current theme's callword sound will be played instead.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
658+
</property>
659+
<property name="wordWrap">
660+
<bool>true</bool>
661+
</property>
662+
</widget>
663+
</item>
640664
</layout>
641665
</widget>
642666
<widget class="QWidget" name="audio_tab">
@@ -816,6 +840,9 @@
816840
<layout class="QGridLayout" name="mount_buttons_layout">
817841
<item row="2" column="5">
818842
<spacer name="mount_buttons_spacer_2">
843+
<property name="orientation">
844+
<enum>Qt::Vertical</enum>
845+
</property>
819846
<property name="sizeHint" stdset="0">
820847
<size>
821848
<width>40</width>
@@ -852,6 +879,9 @@
852879
</item>
853880
<item row="2" column="2">
854881
<spacer name="mount_buttons_spacer">
882+
<property name="orientation">
883+
<enum>Qt::Vertical</enum>
884+
</property>
855885
<property name="sizeType">
856886
<enum>QSizePolicy::Fixed</enum>
857887
</property>

src/courtroom.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3421,7 +3421,16 @@ void Courtroom::handle_callwords()
34213421
if (f_message.contains(word, Qt::CaseInsensitive))
34223422
{
34233423
// Play the call word sfx on the modcall_player sound container
3424-
modcall_player->findAndPlaySfx(ao_app->get_court_sfx("word_call"));
3424+
QString l_filepath = ao_app->get_sfx(Options::getInstance().callwordSfx());
3425+
if (file_exists(l_filepath))
3426+
{
3427+
modcall_player->play(l_filepath);
3428+
}
3429+
else
3430+
{
3431+
modcall_player->findAndPlaySfx(ao_app->get_court_sfx("word_call"));
3432+
}
3433+
34253434
// Make the window flash
34263435
QApplication::alert(this);
34273436
// Break the loop so we don't spam sound effects

src/options.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,16 @@ void Options::setCallwords(QStringList value)
634634
config.setValue("callwords", value);
635635
}
636636

637+
QString Options::callwordSfx() const
638+
{
639+
return config.value("callword_sfx").toString();
640+
}
641+
642+
void Options::setCallwordSfx(QString value)
643+
{
644+
config.setValue("callword_sfx", value);
645+
}
646+
637647
QString Options::playerlistFormatString() const
638648
{
639649
return config.value("visuals/playerlist_format", "[{id}] {character} {displayname} {username}").toString();

src/options.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ class Options
257257
QStringList callwords() const;
258258
void setCallwords(QStringList value);
259259

260+
QString callwordSfx() const;
261+
void setCallwordSfx(QString value);
262+
260263
QString playerlistFormatString() const;
261264
void setPlayerlistFormatString(QString value);
262265

src/widgets/aooptionsdialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ void AOOptionsDialog::setupUI()
430430
// people to put a billion entries in.
431431
FROM_UI(QPlainTextEdit, callwords_textbox);
432432
registerOption<QPlainTextEdit, QStringList>("callwords_textbox", &Options::callwords, &Options::setCallwords);
433+
FROM_UI(QLineEdit, callwords_sfx);
434+
registerOption<QLineEdit, QString>("callwords_sfx", &Options::callwordSfx, &Options::setCallwordSfx);
433435

434436
// Audio tab.
435437
FROM_UI(QComboBox, audio_device_combobox);

src/widgets/aooptionsdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class AOOptionsDialog : public QDialog
8181
// The callwords tab
8282
QPlainTextEdit *ui_callwords_textbox;
8383
QCheckBox *ui_callwords_char_textbox;
84+
QLineEdit *ui_callwords_sfx;
8485

8586
// The audio tab
8687
QWidget *ui_audio_tab;

0 commit comments

Comments
 (0)