aboutsummaryrefslogtreecommitdiff
path: root/src/aooptionsdialog.cpp
blob: 55f7583f26534dfeb24c8670ebebdca792f2d24c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
#include "aooptionsdialog.h"
#include "aoapplication.h"

AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDialog(parent)
{
    ao_app = p_ao_app;

    // Setting up the basics.
    // setAttribute(Qt::WA_DeleteOnClose);
    setWindowTitle(tr("Settings"));
    resize(398, 320);

    ui_settings_buttons = new QDialogButtonBox(this);

    QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Fixed);
    sizePolicy1.setHorizontalStretch(0);
    sizePolicy1.setVerticalStretch(0);
    sizePolicy1.setHeightForWidth(ui_settings_buttons->sizePolicy().hasHeightForWidth());
    ui_settings_buttons->setSizePolicy(sizePolicy1);
    ui_settings_buttons->setOrientation(Qt::Horizontal);
    ui_settings_buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save);

    QObject::connect(ui_settings_buttons, SIGNAL(accepted()), this, SLOT(save_pressed()));
    QObject::connect(ui_settings_buttons, SIGNAL(rejected()), this, SLOT(discard_pressed()));

    // We'll stop updates so that the window won't flicker while it's being made.
    setUpdatesEnabled(false);

    // First of all, we want a tabbed dialog, so let's add some layout.
    ui_vertical_layout = new QVBoxLayout(this);
    ui_settings_tabs = new QTabWidget(this);

    ui_vertical_layout->addWidget(ui_settings_tabs);
    ui_vertical_layout->addWidget(ui_settings_buttons);

    // Let's add the tabs one by one.
    // First, we'll start with 'Gameplay'.
    ui_gameplay_tab = new QWidget();
    ui_settings_tabs->addTab(ui_gameplay_tab, tr("Gameplay"));

    ui_form_layout_widget = new QWidget(ui_gameplay_tab);
    ui_form_layout_widget->setGeometry(QRect(10, 10, 361, 211));

    ui_gameplay_form = new QFormLayout(ui_form_layout_widget);
    ui_gameplay_form->setLabelAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
    ui_gameplay_form->setFormAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
    ui_gameplay_form->setContentsMargins(0, 0, 0, 0);

    ui_theme_label = new QLabel(ui_form_layout_widget);
    ui_theme_label->setText(tr("Theme:"));
    ui_theme_label->setToolTip(tr("Sets the theme used in-game. If the new theme changes "
                                  "the lobby's look as well, you'll need to reload the "
                                  "lobby for the changes to take effect, such as by joining "
                                  "a server and leaving it."));
    ui_gameplay_form->setWidget(0, QFormLayout::LabelRole, ui_theme_label);

    ui_theme_combobox = new QComboBox(ui_form_layout_widget);

    // Fill the combobox with the names of the themes.
    QDirIterator it(p_ao_app->get_base_path() + "themes", QDir::Dirs, QDirIterator::NoIteratorFlags);
    while (it.hasNext())
    {
        QString actualname = QDir(it.next()).dirName();
        if (actualname != "." && actualname != "..")
            ui_theme_combobox->addItem(actualname);
        if (actualname == p_ao_app->read_theme())
            ui_theme_combobox->setCurrentIndex(ui_theme_combobox->count()-1);
    }

    ui_gameplay_form->setWidget(0, QFormLayout::FieldRole, ui_theme_combobox);

    ui_theme_log_divider = new QFrame(ui_form_layout_widget);
    ui_theme_log_divider->setMidLineWidth(0);
    ui_theme_log_divider->setFrameShape(QFrame::HLine);
    ui_theme_log_divider->setFrameShadow(QFrame::Sunken);

    ui_gameplay_form->setWidget(1, QFormLayout::FieldRole, ui_theme_log_divider);

    ui_downwards_lbl = new QLabel(ui_form_layout_widget);
    ui_downwards_lbl->setText(tr("Log goes downwards:"));
    ui_downwards_lbl->setToolTip(tr("If ticked, new messages will appear at "
                                    "the bottom (like the OOC chatlog). The traditional "
                                    "(AO1) behaviour is equivalent to this being unticked."));

    ui_gameplay_form->setWidget(2, QFormLayout::LabelRole, ui_downwards_lbl);

    ui_downwards_cb = new QCheckBox(ui_form_layout_widget);
    ui_downwards_cb->setChecked(p_ao_app->get_log_goes_downwards());

    ui_gameplay_form->setWidget(2, QFormLayout::FieldRole, ui_downwards_cb);

    ui_length_lbl = new QLabel(ui_form_layout_widget);
    ui_length_lbl->setText(tr("Log length:"));
    ui_length_lbl->setToolTip(tr("The amount of messages the IC chatlog will keep before "
                                 "deleting older messages. A value of 0 or below counts as 'infinite'."));

    ui_gameplay_form->setWidget(3, QFormLayout::LabelRole, ui_length_lbl);

    ui_length_spinbox = new QSpinBox(ui_form_layout_widget);
    ui_length_spinbox->setMaximum(10000);
    ui_length_spinbox->setValue(p_ao_app->get_max_log_size());

    ui_gameplay_form->setWidget(3, QFormLayout::FieldRole, ui_length_spinbox);

    ui_log_names_divider = new QFrame(ui_form_layout_widget);
    ui_log_names_divider->setFrameShape(QFrame::HLine);
    ui_log_names_divider->setFrameShadow(QFrame::Sunken);

    ui_gameplay_form->setWidget(4, QFormLayout::FieldRole, ui_log_names_divider);

    ui_username_lbl = new QLabel(ui_form_layout_widget);
    ui_username_lbl->setText(tr("Default username:"));
    ui_username_lbl->setToolTip(tr("Your OOC name will be automatically set to this value "
                                   "when you join a server."));

    ui_gameplay_form->setWidget(5, QFormLayout::LabelRole, ui_username_lbl);

    ui_username_textbox = new QLineEdit(ui_form_layout_widget);
    ui_username_textbox->setMaxLength(30);
    ui_username_textbox->setText(p_ao_app->get_default_username());

    ui_gameplay_form->setWidget(5, QFormLayout::FieldRole, ui_username_textbox);

    ui_showname_lbl = new QLabel(ui_form_layout_widget);
    ui_showname_lbl->setText(tr("Custom shownames:"));
    ui_showname_lbl->setToolTip(tr("Gives the default value for the in-game 'Custom shownames' "
                                   "tickbox, which in turn determines whether the client should "
                                   "display custom in-character names."));

    ui_gameplay_form->setWidget(6, QFormLayout::LabelRole, ui_showname_lbl);

    ui_showname_cb = new QCheckBox(ui_form_layout_widget);
    ui_showname_cb->setChecked(p_ao_app->get_showname_enabled_by_default());

    ui_gameplay_form->setWidget(6, QFormLayout::FieldRole, ui_showname_cb);

    ui_net_divider = new QFrame(ui_form_layout_widget);
    ui_net_divider->setFrameShape(QFrame::HLine);
    ui_net_divider->setFrameShadow(QFrame::Sunken);

    ui_gameplay_form->setWidget(7, QFormLayout::FieldRole, ui_net_divider);

    ui_ms_lbl = new QLabel(ui_form_layout_widget);
    ui_ms_lbl->setText(tr("Backup MS:"));
    ui_ms_lbl->setToolTip(tr("If the built-in server lookups fail, the game will try the "
                             "address given here and use it as a backup master server address."));

    ui_gameplay_form->setWidget(8, QFormLayout::LabelRole, ui_ms_lbl);

    QSettings* configini = ao_app->configini;
    ui_ms_textbox = new QLineEdit(ui_form_layout_widget);
    ui_ms_textbox->setText(configini->value("master", "").value<QString>());

    ui_gameplay_form->setWidget(8, QFormLayout::FieldRole, ui_ms_textbox);

    ui_discord_lbl = new QLabel(ui_form_layout_widget);
    ui_discord_lbl->setText(tr("Discord:"));
    ui_discord_lbl->setToolTip(tr("Allows others on Discord to see what server you are in, "
                                  "what character are you playing, and how long you have "
                                  "been playing for."));

    ui_gameplay_form->setWidget(9, QFormLayout::LabelRole, ui_discord_lbl);

    ui_discord_cb = new QCheckBox(ui_form_layout_widget);
    ui_discord_cb->setChecked(ao_app->is_discord_enabled());

    ui_gameplay_form->setWidget(9, QFormLayout::FieldRole, ui_discord_cb);

    ui_epilepsy_lbl = new QLabel(ui_form_layout_widget);
    ui_epilepsy_lbl->setText(tr("Allow Shake/Flash:"));
    ui_epilepsy_lbl->setToolTip(tr("Allows screenshaking and flashing. Disable this if you have concerns or issues with photosensitivity and/or seizures."));

    ui_gameplay_form->setWidget(10, QFormLayout::LabelRole, ui_epilepsy_lbl);

    ui_epilepsy_cb = new QCheckBox(ui_form_layout_widget);
    ui_epilepsy_cb->setChecked(ao_app->is_shakeandflash_enabled());

    ui_gameplay_form->setWidget(10, QFormLayout::FieldRole, ui_epilepsy_cb);

    ui_language_label = new QLabel(ui_form_layout_widget);
    ui_language_label->setText(tr("Language:"));
    ui_language_label->setToolTip(tr("Sets the language if you don't want to use your system language."));
    ui_gameplay_form->setWidget(11, QFormLayout::LabelRole, ui_language_label);

    ui_language_combobox = new QComboBox(ui_form_layout_widget);
    ui_language_combobox->addItem(configini->value("language", "  ").value<QString>() + " - Keep current setting");
    ui_language_combobox->addItem("   - Default");
    ui_language_combobox->addItem("en - English");
    ui_language_combobox->addItem("de - Deutsch");
    ui_language_combobox->addItem("es - Español");
    ui_language_combobox->addItem("pt - Português");
    ui_language_combobox->addItem("jp - 日本語");
    ui_language_combobox->addItem("ru - Русский");
    ui_gameplay_form->setWidget(11, QFormLayout::FieldRole, ui_language_combobox);

    // Here we start the callwords tab.
    ui_callwords_tab = new QWidget();
    ui_settings_tabs->addTab(ui_callwords_tab, tr("Callwords"));

    ui_callwords_widget = new QWidget(ui_callwords_tab);
    ui_callwords_widget->setGeometry(QRect(10, 10, 361, 211));

    ui_callwords_layout = new QVBoxLayout(ui_callwords_widget);
    ui_callwords_layout->setContentsMargins(0,0,0,0);

    ui_callwords_textbox = new QPlainTextEdit(ui_callwords_widget);
    QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    sizePolicy.setHeightForWidth(ui_callwords_textbox->sizePolicy().hasHeightForWidth());
    ui_callwords_textbox->setSizePolicy(sizePolicy);

    // Let's fill the callwords text edit with the already present callwords.
    ui_callwords_textbox->document()->clear();
    foreach (QString callword, p_ao_app->get_call_words()) {
        ui_callwords_textbox->appendPlainText(callword);
    }

    ui_callwords_layout->addWidget(ui_callwords_textbox);

    ui_callwords_explain_lbl = new QLabel(ui_callwords_widget);
    ui_callwords_explain_lbl->setWordWrap(true);
    ui_callwords_explain_lbl->setText(tr("<html><head/><body>Enter as many callwords as you would like. These are case insensitive. Make sure to leave every callword in its own line!<br>Do not leave a line with a space at the end -- you will be alerted everytime someone uses a space in their messages.</body></html>"));

    ui_callwords_layout->addWidget(ui_callwords_explain_lbl);

    // The audio tab.
    ui_audio_tab = new QWidget();
    ui_settings_tabs->addTab(ui_audio_tab, tr("Audio"));

    ui_audio_widget = new QWidget(ui_audio_tab);
    ui_audio_widget->setGeometry(QRect(10, 10, 361, 211));

    ui_audio_layout = new QFormLayout(ui_audio_widget);
    ui_audio_layout->setLabelAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
    ui_audio_layout->setFormAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
    ui_audio_layout->setContentsMargins(0, 0, 0, 0);

    ui_audio_device_lbl = new QLabel(ui_audio_widget);
    ui_audio_device_lbl->setText(tr("Audio device:"));
    ui_audio_device_lbl->setToolTip(tr("Sets the audio device for all sounds."));

    ui_audio_layout->setWidget(0, QFormLayout::LabelRole, ui_audio_device_lbl);

    ui_audio_device_combobox = new QComboBox(ui_audio_widget);

    // Let's fill out the combobox with the available audio devices. Or don't if there is no audio
    if (needs_default_audiodev())
    {

        ui_audio_device_combobox->addItem("default");

    }
    #ifdef BASSAUDIO
    BASS_DEVICEINFO info;
    int a = 0;
    for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
    {
        ui_audio_device_combobox->addItem(info.name);
        if (p_ao_app->get_audio_output_device() == info.name)
            ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count()-1);
    }
    #elif defined QTAUDIO
    foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput))
    {
        ui_audio_device_combobox->addItem(deviceInfo.deviceName());
        if (p_ao_app->get_audio_output_device() == deviceInfo.deviceName())
            ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count()-1);
    }
    #endif
    ui_audio_layout->setWidget(0, QFormLayout::FieldRole, ui_audio_device_combobox);

    ui_audio_volume_divider = new QFrame(ui_audio_widget);
    ui_audio_volume_divider->setFrameShape(QFrame::HLine);
    ui_audio_volume_divider->setFrameShadow(QFrame::Sunken);

    ui_audio_layout->setWidget(1, QFormLayout::FieldRole, ui_audio_volume_divider);

    ui_music_volume_lbl = new QLabel(ui_audio_widget);
    ui_music_volume_lbl->setText(tr("Music:"));
    ui_music_volume_lbl->setToolTip(tr("Sets the music's default volume."));

    ui_audio_layout->setWidget(2, QFormLayout::LabelRole, ui_music_volume_lbl);

    ui_music_volume_spinbox = new QSpinBox(ui_audio_widget);
    ui_music_volume_spinbox->setValue(p_ao_app->get_default_music());
    ui_music_volume_spinbox->setMaximum(100);
    ui_music_volume_spinbox->setSuffix("%");

    ui_audio_layout->setWidget(2, QFormLayout::FieldRole, ui_music_volume_spinbox);

    ui_sfx_volume_lbl = new QLabel(ui_audio_widget);
    ui_sfx_volume_lbl->setText(tr("SFX:"));
    ui_sfx_volume_lbl->setToolTip(tr("Sets the SFX's default volume. "
                                     "Interjections and actual sound effects count as 'SFX'."));

    ui_audio_layout->setWidget(3, QFormLayout::LabelRole, ui_sfx_volume_lbl);

    ui_sfx_volume_spinbox = new QSpinBox(ui_audio_widget);
    ui_sfx_volume_spinbox->setValue(p_ao_app->get_default_sfx());
    ui_sfx_volume_spinbox->setMaximum(100);
    ui_sfx_volume_spinbox->setSuffix("%");

    ui_audio_layout->setWidget(3, QFormLayout::FieldRole, ui_sfx_volume_spinbox);

    ui_blips_volume_lbl = new QLabel(ui_audio_widget);
    ui_blips_volume_lbl->setText(tr("Blips:"));
    ui_blips_volume_lbl->setToolTip(tr("Sets the volume of the blips, the talking sound effects."));

    ui_audio_layout->setWidget(4, QFormLayout::LabelRole, ui_blips_volume_lbl);

    ui_blips_volume_spinbox = new QSpinBox(ui_audio_widget);
    ui_blips_volume_spinbox->setValue(p_ao_app->get_default_blip());
    ui_blips_volume_spinbox->setMaximum(100);
    ui_blips_volume_spinbox->setSuffix("%");

    ui_audio_layout->setWidget(4, QFormLayout::FieldRole, ui_blips_volume_spinbox);

    ui_volume_blip_divider = new QFrame(ui_audio_widget);
    ui_volume_blip_divider->setFrameShape(QFrame::HLine);
    ui_volume_blip_divider->setFrameShadow(QFrame::Sunken);

    ui_audio_layout->setWidget(5, QFormLayout::FieldRole, ui_volume_blip_divider);

    ui_bliprate_lbl = new QLabel(ui_audio_widget);
    ui_bliprate_lbl->setText(tr("Blip rate:"));
    ui_bliprate_lbl->setToolTip(tr("Sets the delay between playing the blip sounds."));

    ui_audio_layout->setWidget(6, QFormLayout::LabelRole, ui_bliprate_lbl);

    ui_bliprate_spinbox = new QSpinBox(ui_audio_widget);
    ui_bliprate_spinbox->setValue(p_ao_app->read_blip_rate());
    ui_bliprate_spinbox->setMinimum(1);

    ui_audio_layout->setWidget(6, QFormLayout::FieldRole, ui_bliprate_spinbox);

    ui_blank_blips_lbl = new QLabel(ui_audio_widget);
    ui_blank_blips_lbl->setText(tr("Blank blips:"));
    ui_blank_blips_lbl->setToolTip(tr("If true, the game will play a blip sound even "
                                      "when a space is 'being said'."));

    ui_audio_layout->setWidget(7, QFormLayout::LabelRole, ui_blank_blips_lbl);

    ui_blank_blips_cb = new QCheckBox(ui_audio_widget);
    ui_blank_blips_cb->setChecked(p_ao_app->get_blank_blip());

    ui_audio_layout->setWidget(7, QFormLayout::FieldRole, ui_blank_blips_cb);

    ui_loopsfx_lbl = new QLabel(ui_audio_widget);
    ui_loopsfx_lbl->setText(tr("Enable Looping SFX:"));
    ui_loopsfx_lbl->setToolTip(tr("If true, the game will allow looping sound effects to play on preanimations."));

    ui_audio_layout->setWidget(8, QFormLayout::LabelRole, ui_loopsfx_lbl);

    ui_loopsfx_cb = new QCheckBox(ui_audio_widget);
    ui_loopsfx_cb->setChecked(p_ao_app->get_looping_sfx());

    ui_audio_layout->setWidget(8, QFormLayout::FieldRole, ui_loopsfx_cb);


    ui_objectmusic_lbl = new QLabel(ui_audio_widget);
    ui_objectmusic_lbl->setText(tr("Kill Music On Objection:"));
    ui_objectmusic_lbl->setToolTip(tr("If true, the game will stop music when someone objects, like in the actual games."));

    ui_audio_layout->setWidget(9, QFormLayout::LabelRole, ui_objectmusic_lbl);

    ui_objectmusic_cb = new QCheckBox(ui_audio_widget);
    ui_objectmusic_cb->setChecked(p_ao_app->get_objectmusic());

    ui_audio_layout->setWidget(9, QFormLayout::FieldRole, ui_objectmusic_cb);

    // The casing tab!
    ui_casing_tab = new QWidget();
    ui_settings_tabs->addTab(ui_casing_tab, tr("Casing"));

    ui_casing_widget = new QWidget(ui_casing_tab);
    ui_casing_widget->setGeometry(QRect(10,10, 361, 211));

    ui_casing_layout = new QFormLayout(ui_casing_widget);
    ui_casing_layout->setLabelAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
    ui_casing_layout->setFormAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
    ui_casing_layout->setContentsMargins(0, 0, 0, 0);

    // -- SERVER SUPPORTS CASING

    ui_casing_supported_lbl = new QLabel(ui_casing_widget);
    if (ao_app->casing_alerts_enabled)
      ui_casing_supported_lbl->setText(tr("This server supports case alerts."));
    else
      ui_casing_supported_lbl->setText(tr("This server does not support case alerts."));
    ui_casing_supported_lbl->setToolTip(tr("Pretty self-explanatory."));

    ui_casing_layout->setWidget(0, QFormLayout::FieldRole, ui_casing_supported_lbl);

    // -- CASE ANNOUNCEMENTS

    ui_casing_enabled_lbl = new QLabel(ui_casing_widget);
    ui_casing_enabled_lbl->setText(tr("Casing:"));
    ui_casing_enabled_lbl->setToolTip(tr("If checked, you will get alerts about case "
                                         "announcements."));

    ui_casing_layout->setWidget(1, QFormLayout::LabelRole, ui_casing_enabled_lbl);

    ui_casing_enabled_cb = new QCheckBox(ui_casing_widget);
    ui_casing_enabled_cb->setChecked(ao_app->get_casing_enabled());

    ui_casing_layout->setWidget(1, QFormLayout::FieldRole, ui_casing_enabled_cb);

    // -- DEFENSE ANNOUNCEMENTS

    ui_casing_def_lbl = new QLabel(ui_casing_widget);
    ui_casing_def_lbl->setText(tr("Defense:"));
    ui_casing_def_lbl->setToolTip(tr("If checked, you will get alerts about case "
                                     "announcements if a defense spot is open."));

    ui_casing_layout->setWidget(2, QFormLayout::LabelRole, ui_casing_def_lbl);

    ui_casing_def_cb = new QCheckBox(ui_casing_widget);
    ui_casing_def_cb->setChecked(ao_app->get_casing_defence_enabled());

    ui_casing_layout->setWidget(2, QFormLayout::FieldRole, ui_casing_def_cb);

    // -- PROSECUTOR ANNOUNCEMENTS

    ui_casing_pro_lbl = new QLabel(ui_casing_widget);
    ui_casing_pro_lbl->setText(tr("Prosecution:"));
    ui_casing_pro_lbl->setToolTip(tr("If checked, you will get alerts about case "
                                     "announcements if a prosecutor spot is open."));

    ui_casing_layout->setWidget(3, QFormLayout::LabelRole, ui_casing_pro_lbl);

    ui_casing_pro_cb = new QCheckBox(ui_casing_widget);
    ui_casing_pro_cb->setChecked(ao_app->get_casing_prosecution_enabled());

    ui_casing_layout->setWidget(3, QFormLayout::FieldRole, ui_casing_pro_cb);

    // -- JUDGE ANNOUNCEMENTS

    ui_casing_jud_lbl = new QLabel(ui_casing_widget);
    ui_casing_jud_lbl->setText(tr("Judge:"));
    ui_casing_jud_lbl->setToolTip(tr("If checked, you will get alerts about case "
                                     "announcements if the judge spot is open."));

    ui_casing_layout->setWidget(4, QFormLayout::LabelRole, ui_casing_jud_lbl);

    ui_casing_jud_cb = new QCheckBox(ui_casing_widget);
    ui_casing_jud_cb->setChecked(ao_app->get_casing_judge_enabled());

    ui_casing_layout->setWidget(4, QFormLayout::FieldRole, ui_casing_jud_cb);

    // -- JUROR ANNOUNCEMENTS

    ui_casing_jur_lbl = new QLabel(ui_casing_widget);
    ui_casing_jur_lbl->setText(tr("Juror:"));
    ui_casing_jur_lbl->setToolTip(tr("If checked, you will get alerts about case "
                                     "announcements if a juror spot is open."));

    ui_casing_layout->setWidget(5, QFormLayout::LabelRole, ui_casing_jur_lbl);

    ui_casing_jur_cb = new QCheckBox(ui_casing_widget);
    ui_casing_jur_cb->setChecked(ao_app->get_casing_juror_enabled());

    ui_casing_layout->setWidget(5, QFormLayout::FieldRole, ui_casing_jur_cb);

    // -- STENO ANNOUNCEMENTS

    ui_casing_steno_lbl = new QLabel(ui_casing_widget);
    ui_casing_steno_lbl->setText(tr("Stenographer:"));
    ui_casing_steno_lbl->setToolTip(tr("If checked, you will get alerts about case "
                                       "announcements if a stenographer spot is open."));

    ui_casing_layout->setWidget(6, QFormLayout::LabelRole, ui_casing_steno_lbl);

    ui_casing_steno_cb = new QCheckBox(ui_casing_widget);
    ui_casing_steno_cb->setChecked(ao_app->get_casing_steno_enabled());

    ui_casing_layout->setWidget(6, QFormLayout::FieldRole, ui_casing_steno_cb);

    // -- CM ANNOUNCEMENTS

    ui_casing_cm_lbl = new QLabel(ui_casing_widget);
    ui_casing_cm_lbl->setText(tr("CM:"));
    ui_casing_cm_lbl->setToolTip(tr("If checked, you will appear amongst the potential "
                                    "CMs on the server."));

    ui_casing_layout->setWidget(7, QFormLayout::LabelRole, ui_casing_cm_lbl);

    ui_casing_cm_cb = new QCheckBox(ui_casing_widget);
    ui_casing_cm_cb->setChecked(ao_app->get_casing_cm_enabled());

    ui_casing_layout->setWidget(7, QFormLayout::FieldRole, ui_casing_cm_cb);

    ui_casing_wit_lbl = new QLabel(ui_casing_widget);
    ui_casing_wit_lbl->setText(tr("Witness:"));
    ui_casing_wit_lbl->setToolTip(tr("If checked, you will appear amongst the potential "
                                    "witnesses on the server."));

    ui_casing_layout->setWidget(8, QFormLayout::LabelRole, ui_casing_wit_lbl);

    ui_casing_wit_cb = new QCheckBox(ui_casing_widget);
    ui_casing_wit_cb->setChecked(ao_app->get_casing_wit_enabled());

    ui_casing_layout->setWidget(8, QFormLayout::FieldRole, ui_casing_wit_cb);

    // -- CM CASES ANNOUNCEMENTS

    ui_casing_cm_cases_lbl = new QLabel(ui_casing_widget);
    ui_casing_cm_cases_lbl->setText(tr("Hosting cases:"));
    ui_casing_cm_cases_lbl->setToolTip(tr("If you're a CM, enter what cases you are "
                                          "willing to host."));

    ui_casing_layout->setWidget(9, QFormLayout::LabelRole, ui_casing_cm_cases_lbl);

    ui_casing_cm_cases_textbox = new QLineEdit(ui_casing_widget);
    ui_casing_cm_cases_textbox->setText(ao_app->get_casing_can_host_cases());

    ui_casing_layout->setWidget(9, QFormLayout::FieldRole, ui_casing_cm_cases_textbox);

    // When we're done, we should continue the updates!
    setUpdatesEnabled(true);
}

void AOOptionsDialog::save_pressed()
{
    // Save everything into the config.ini.
    QSettings* configini = ao_app->configini;

    configini->setValue("theme", ui_theme_combobox->currentText());
    configini->setValue("log_goes_downwards", ui_downwards_cb->isChecked());
    configini->setValue("log_maximum", ui_length_spinbox->value());
    configini->setValue("default_username", ui_username_textbox->text());
    configini->setValue("show_custom_shownames", ui_showname_cb->isChecked());
    configini->setValue("master", ui_ms_textbox->text());
    configini->setValue("discord", ui_discord_cb->isChecked());
    configini->setValue("shakeandflash", ui_epilepsy_cb->isChecked());
    configini->setValue("language", ui_language_combobox->currentText().left(2));

    QFile* callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini");

    if (!callwordsini->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
    {
        // Nevermind!
    }
    else
    {
        QTextStream out(callwordsini);
        out << ui_callwords_textbox->toPlainText();
        callwordsini->close();
    }

    configini->setValue("default_audio_device", ui_audio_device_combobox->currentText());
    configini->setValue("default_music", ui_music_volume_spinbox->value());
    configini->setValue("default_sfx", ui_sfx_volume_spinbox->value());
    configini->setValue("default_blip", ui_blips_volume_spinbox->value());
    configini->setValue("blip_rate", ui_bliprate_spinbox->value());
    configini->setValue("blank_blip", ui_blank_blips_cb->isChecked());
    configini->setValue("looping_sfx", ui_loopsfx_cb->isChecked());
    configini->setValue("kill_music_on_object", ui_objectmusic_cb->isChecked());

    configini->setValue("casing_enabled", ui_casing_enabled_cb->isChecked());
    configini->setValue("casing_defence_enabled", ui_casing_def_cb->isChecked());
    configini->setValue("casing_prosecution_enabled", ui_casing_pro_cb->isChecked());
    configini->setValue("casing_judge_enabled", ui_casing_jud_cb->isChecked());
    configini->setValue("casing_juror_enabled", ui_casing_jur_cb->isChecked());
    configini->setValue("casing_steno_enabled", ui_casing_steno_cb->isChecked());
    configini->setValue("casing_cm_enabled", ui_casing_cm_cb->isChecked());
    configini->setValue("casing_wit_enabled", ui_casing_wit_cb->isChecked());
    configini->setValue("casing_can_host_cases", ui_casing_cm_cases_textbox->text());

    callwordsini->close();
    done(0);
}

void AOOptionsDialog::discard_pressed()
{
    done(0);
}

#if (defined (_WIN32) || defined (_WIN64))
bool AOOptionsDialog::needs_default_audiodev()
{
    return true;
}
#elif (defined (LINUX) || defined (__linux__))
bool AOOptionsDialog::needs_default_audiodev()
{
    return false;
}
#elif defined __APPLE__
bool AOOptionsDialog::needs_default_audiodev()
{
    return true;
}
#else
#error This operating system is not supported.
#endif