aboutsummaryrefslogtreecommitdiff
path: root/src/courtroom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/courtroom.cpp')
-rw-r--r--src/courtroom.cpp342
1 files changed, 120 insertions, 222 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index a08b5e13..65c5e1a3 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -1,4 +1,5 @@
#include "courtroom.h"
+#include "options.h"
Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
{
@@ -52,6 +53,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_background->setObjectName("ui_vp_background");
ui_vp_speedlines = new SplashLayer(ui_viewport, ao_app);
ui_vp_speedlines->setObjectName("ui_vp_speedlines");
+ ui_vp_speedlines->stretch = true;
ui_vp_player_char = new CharLayer(ui_viewport, ao_app);
ui_vp_player_char->setObjectName("ui_vp_player_char");
ui_vp_player_char->masked = false;
@@ -114,15 +116,15 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ic_chatlog->setReadOnly(true);
ui_ic_chatlog->setObjectName("ui_ic_chatlog");
- log_maximum_blocks = ao_app->get_max_log_size();
- log_goes_downwards = ao_app->get_log_goes_downwards();
- log_colors = ao_app->is_colorlog_enabled();
- log_newline = ao_app->get_log_newline();
- log_margin = ao_app->get_log_margin();
- log_timestamp = ao_app->get_log_timestamp();
- log_timestamp_format = ao_app->get_log_timestamp_format();
+ log_maximum_blocks = Options::getInstance().maxLogSize();
+ log_goes_downwards = Options::getInstance().logDirectionDownwards();
+ log_colors = Options::getInstance().colorLogEnabled();
+ log_newline = Options::getInstance().logNewline();
+ log_margin = Options::getInstance().logMargin();
+ log_timestamp = Options::getInstance().logTimestampEnabled();
+ log_timestamp_format = Options::getInstance().logTimestampFormat();
- ui_debug_log = new AOTextArea(this, ao_app->get_max_log_size());
+ ui_debug_log = new AOTextArea(this, Options::getInstance().maxLogSize());
ui_debug_log->setReadOnly(true);
ui_debug_log->setOpenExternalLinks(true);
ui_debug_log->hide();
@@ -176,7 +178,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ic_chat_name = new QLineEdit(this);
ui_ic_chat_name->setFrame(false);
ui_ic_chat_name->setPlaceholderText(tr("Showname"));
- ui_ic_chat_name->setText(p_ao_app->get_default_showname());
+ ui_ic_chat_name->setText(Options::getInstance().shownameOnJoin());
ui_ic_chat_name->setObjectName("ui_ic_chat_name");
ui_ic_chat_message = new QLineEdit(this);
@@ -200,7 +202,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ooc_chat_name->setFrame(false);
ui_ooc_chat_name->setPlaceholderText(tr("Name"));
ui_ooc_chat_name->setMaxLength(30);
- ui_ooc_chat_name->setText(p_ao_app->get_default_username());
+ ui_ooc_chat_name->setText(Options::getInstance().username());
ui_ooc_chat_name->setObjectName("ui_ooc_chat_name");
// ui_area_password = new QLineEdit(this);
@@ -290,9 +292,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_settings = new AOButton(this, ao_app);
ui_settings->setObjectName("ui_settings");
- ui_announce_casing = new AOButton(this, ao_app);
- ui_announce_casing->setObjectName("ui_announce_casing");
-
ui_switch_area_music = new AOButton(this, ao_app);
ui_switch_area_music->setObjectName("ui_switch_area_music");
@@ -315,14 +314,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_additive->hide();
ui_additive->setObjectName("ui_additive");
- ui_casing = new QCheckBox(this);
- ui_casing->setChecked(ao_app->get_casing_enabled());
- ui_casing->setText(tr("Casing"));
- ui_casing->hide();
- ui_casing->setObjectName("ui_casing");
-
ui_showname_enable = new QCheckBox(this);
- ui_showname_enable->setChecked(ao_app->get_showname_enabled_by_default());
+ ui_showname_enable->setChecked(Options::getInstance().customShownameEnabled());
ui_showname_enable->setText(tr("Shownames"));
ui_showname_enable->setObjectName("ui_showname_enable");
@@ -365,17 +358,17 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_music_slider = new QSlider(Qt::Horizontal, this);
ui_music_slider->setRange(0, 100);
- ui_music_slider->setValue(ao_app->get_default_music());
+ ui_music_slider->setValue(Options::getInstance().musicVolume());
ui_music_slider->setObjectName("ui_music_slider");
ui_sfx_slider = new QSlider(Qt::Horizontal, this);
ui_sfx_slider->setRange(0, 100);
- ui_sfx_slider->setValue(ao_app->get_default_sfx());
+ ui_sfx_slider->setValue(Options::getInstance().sfxVolume());
ui_sfx_slider->setObjectName("ui_sfx_slider");
ui_blip_slider = new QSlider(Qt::Horizontal, this);
ui_blip_slider->setRange(0, 100);
- ui_blip_slider->setValue(ao_app->get_default_blip());
+ ui_blip_slider->setValue(Options::getInstance().blipVolume());
ui_blip_slider->setObjectName("ui_blip_slider");
ui_mute_list = new QListWidget(this);
@@ -539,8 +532,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
&Courtroom::on_reload_theme_clicked);
connect(ui_call_mod, &AOButton::clicked, this, &Courtroom::on_call_mod_clicked);
connect(ui_settings, &AOButton::clicked, this, &Courtroom::on_settings_clicked);
- connect(ui_announce_casing, &AOButton::clicked, this,
- &Courtroom::on_announce_casing_clicked);
connect(ui_switch_area_music, &AOButton::clicked, this,
&Courtroom::on_switch_area_music_clicked);
@@ -548,7 +539,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(ui_flip, &AOButton::clicked, this, &Courtroom::on_flip_clicked);
connect(ui_additive, &AOButton::clicked, this, &Courtroom::on_additive_clicked);
connect(ui_guard, &AOButton::clicked, this, &Courtroom::on_guard_clicked);
- connect(ui_casing, &AOButton::clicked, this, &Courtroom::on_casing_clicked);
connect(ui_showname_enable, &AOButton::clicked, this,
&Courtroom::on_showname_enable_clicked);
@@ -584,7 +574,7 @@ void Courtroom::on_application_state_changed(Qt::ApplicationState state)
suppress_audio = 0;
if (state != Qt::ApplicationActive) {
// Suppressed audio setting
- suppress_audio = ao_app->get_default_suppress_audio();
+ suppress_audio = Options::getInstance().defaultSuppressAudio();
}
update_audio_volume();
}
@@ -668,9 +658,6 @@ void Courtroom::set_pair_list()
void Courtroom::set_widgets()
{
QString filename = "courtroom_design.ini";
- // Update the default theme from the courtroom_design.ini, if it's not defined it will be 'default'.
- QSettings settings(ao_app->get_real_path(ao_app->get_theme_path(filename, ao_app->current_theme)), QSettings::IniFormat);
- ao_app->default_theme = settings.value("default_theme", "default").toString();
set_fonts();
set_size_and_pos(ui_viewport, "viewport");
@@ -693,15 +680,6 @@ void Courtroom::set_widgets()
ui_ic_chat_name->setEnabled(false);
}
- if (ao_app->casing_alerts_supported) {
- ui_announce_casing->show();
- ui_casing->show();
- }
- else {
- ui_announce_casing->hide();
- ui_casing->hide();
- }
-
// We also show the non-server-dependent client additions.
// Once again, if the theme can't display it, set_move_and_pos will catch
// them.
@@ -748,20 +726,20 @@ void Courtroom::set_widgets()
ui_vp_objection->move_and_center(ui_viewport->x(), ui_viewport->y());
ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height());
- log_maximum_blocks = ao_app->get_max_log_size();
-
- bool regenerate = log_goes_downwards != ao_app->get_log_goes_downwards() ||
- log_colors != ao_app->is_colorlog_enabled() ||
- log_newline != ao_app->get_log_newline() ||
- log_margin != ao_app->get_log_margin() ||
- log_timestamp != ao_app->get_log_timestamp() ||
- log_timestamp_format != ao_app->get_log_timestamp_format();
- log_goes_downwards = ao_app->get_log_goes_downwards();
- log_colors = ao_app->is_colorlog_enabled();
- log_newline = ao_app->get_log_newline();
- log_margin = ao_app->get_log_margin();
- log_timestamp = ao_app->get_log_timestamp();
- log_timestamp_format = ao_app->get_log_timestamp_format();
+ log_maximum_blocks = Options::getInstance().maxLogSize();
+
+ bool regenerate = log_goes_downwards != Options::getInstance().logDirectionDownwards() ||
+ log_colors != Options::getInstance().colorLogEnabled() ||
+ log_newline != Options::getInstance().logNewline() ||
+ log_margin != Options::getInstance().logMargin() ||
+ log_timestamp != Options::getInstance().logTimestampEnabled() ||
+ log_timestamp_format != Options::getInstance().logTimestampFormat();
+ log_goes_downwards = Options::getInstance().logDirectionDownwards();
+ log_colors = Options::getInstance().colorLogEnabled();
+ log_newline = Options::getInstance().logNewline();
+ log_margin = Options::getInstance().logMargin();
+ log_timestamp = Options::getInstance().logTimestampEnabled();
+ log_timestamp_format = Options::getInstance().logTimestampFormat();
if (regenerate) {
regenerate_ic_chatlog();
}
@@ -1014,13 +992,6 @@ void Courtroom::set_widgets()
ui_settings->setToolTip(
tr("Allows you to change various aspects of the client."));
- set_size_and_pos(ui_announce_casing, "casing_button");
- ui_announce_casing->setText(tr("Casing"));
- ui_announce_casing->set_image("casing_button");
- ui_announce_casing->setToolTip(
- tr("An interface to help you announce a case (you have to be a CM first "
- "to be able to announce cases)"));
-
set_size_and_pos(ui_switch_area_music, "switch_area_music");
ui_switch_area_music->setText(tr("A/M"));
ui_switch_area_music->set_image("switch_area_music");
@@ -1061,10 +1032,6 @@ void Courtroom::set_widgets()
tr("Do not listen to mod calls when checked, preventing them from "
"playing sounds or focusing attention on the window."));
- set_size_and_pos(ui_casing, "casing");
- ui_casing->setToolTip(tr("Lets you receive case alerts when enabled.\n"
- "(You can set your preferences in the Settings!)"));
-
set_size_and_pos(ui_showname_enable, "showname_enable");
ui_showname_enable->setToolTip(
tr("Display customized shownames for all users when checked."));
@@ -1390,7 +1357,7 @@ void Courtroom::set_background(QString p_background, bool display)
ui_vp_message->hide();
ui_vp_chatbox->setVisible(chatbox_always_show);
// Show it if chatbox always shows
- if (ao_app->is_sticker_enabled() && chatbox_always_show) {
+ if (Options::getInstance().characterStickerEnabled() && chatbox_always_show) {
ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
}
// Hide the face sticker
@@ -1412,9 +1379,7 @@ void Courtroom::set_background(QString p_background, bool display)
QString f_side = current_side;
if (current_side == "")
f_side = ao_app->get_char_side(current_char);
- set_scene(
- QString::number(ao_app->get_desk_mod(current_char, current_emote)),
- f_side);
+ set_scene(true, f_side);
}
}
@@ -1486,7 +1451,7 @@ void Courtroom::update_character(int p_cid, QString char_name, bool reset_emote)
QString f_char;
if (m_cid == -1) {
- if (ao_app->is_discord_enabled())
+ if (Options::getInstance().discordEnabled())
ao_app->discord->state_spectate();
f_char = "";
}
@@ -1496,7 +1461,7 @@ void Courtroom::update_character(int p_cid, QString char_name, bool reset_emote)
f_char = char_list.at(m_cid).name;
}
- if (ao_app->is_discord_enabled())
+ if (Options::getInstance().discordEnabled())
ao_app->discord->state_character(f_char.toStdString());
}
@@ -1602,11 +1567,6 @@ void Courtroom::enter_courtroom()
else
ui_additive->hide();
- if (ao_app->casing_alerts_supported)
- ui_casing->show();
- else
- ui_casing->hide();
-
list_music();
list_areas();
@@ -1775,6 +1735,7 @@ void Courtroom::list_areas()
void Courtroom::debug_message_handler(QtMsgType type, const QMessageLogContext &context,
const QString &msg)
{
+ Q_UNUSED(context);
const QMap<QtMsgType, QString> colors = {
{QtDebugMsg, "debug"},
{QtInfoMsg, "info"},
@@ -1814,7 +1775,7 @@ void Courtroom::append_server_chatmessage(QString p_name, QString p_message,
ui_server_chatlog->append_chatmessage(p_name, p_message, color);
- if (ao_app->get_text_logging_enabled() && !ao_app->log_filename.isEmpty()) {
+ if (Options::getInstance().logToTextFileEnabled() && !ao_app->log_filename.isEmpty()) {
QString full = "[OOC][" + QDateTime::currentDateTimeUtc().toString() + "] " + p_name + ": " + p_message;
ao_app->append_to_file(full, ao_app->log_filename, true);
}
@@ -1841,7 +1802,7 @@ void Courtroom::on_chat_return_pressed()
return;
ui_ic_chat_message->blockSignals(true);
- QTimer::singleShot(ao_app->get_chat_ratelimit(), this,
+ QTimer::singleShot(Options::getInstance().chatRateLimit(), this,
[this] { ui_ic_chat_message->blockSignals(false); });
// MS#
// deskmod#
@@ -1875,22 +1836,21 @@ void Courtroom::on_chat_return_pressed()
else
f_side = current_side;
- QString f_desk_mod = "chat";
+ int f_desk_mod = DESK_SHOW;
if (ao_app->desk_mod_supported) {
- f_desk_mod =
- QString::number(ao_app->get_desk_mod(current_char, current_emote));
+ f_desk_mod = ao_app->get_desk_mod(current_char, current_emote);
if (!ao_app->expanded_desk_mods_supported) {
- if (f_desk_mod == "2" || f_desk_mod == "4")
- f_desk_mod = "0";
- else if (f_desk_mod == "3" || f_desk_mod == "5")
- f_desk_mod = "1";
+ if (f_desk_mod == DESK_PRE_ONLY_EX || f_desk_mod == DESK_PRE_ONLY)
+ f_desk_mod = DESK_HIDE;
+ else if (f_desk_mod == DESK_EMOTE_ONLY_EX || f_desk_mod == DESK_EMOTE_ONLY)
+ f_desk_mod = DESK_SHOW;
}
- if (f_desk_mod == "-1")
- f_desk_mod = "chat";
+ if (f_desk_mod == -1)
+ f_desk_mod = DESK_SHOW;
}
- packet_contents.append(f_desk_mod);
+ packet_contents.append(QString::number(f_desk_mod));
QString f_pre = ao_app->get_pre_emote(current_char, current_emote);
int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote);
@@ -1945,7 +1905,7 @@ void Courtroom::on_chat_return_pressed()
f_sfx = get_char_sfx();
// We have a custom sfx but we're on idle emotes.
// Turn them into pre so the sound plays if client setting sfx_on_idle is enabled.
- if (ao_app->get_sfx_on_idle() && (f_emote_mod == IDLE || f_emote_mod == ZOOM)) {
+ if (Options::getInstance().playSelectedSFXOnIdle() && (f_emote_mod == IDLE || f_emote_mod == ZOOM)) {
// We turn idle into preanim, but make it not send a pre animation
f_pre = "";
// Set sfx delay to 0 so the sfx plays immediately
@@ -1985,7 +1945,7 @@ void Courtroom::on_chat_return_pressed()
f_obj_state = QString::number(objection_state);
// We're doing an Objection (custom objections not yet supported)
- if (objection_state == 2 && ao_app->objection_stop_music())
+ if (objection_state == 2 && Options::getInstance().objectionStopMusic())
music_stop(true);
packet_contents.append(f_obj_state);
@@ -2078,7 +2038,7 @@ void Courtroom::on_chat_return_pressed()
QString packet;
foreach (QString f_emote, emotes_to_check) {
packet += f_emote;
- if (ao_app->is_frame_network_enabled()) {
+ if (Options::getInstance().networkedFrameSfxEnabled()) {
QString sfx_frames =
ao_app
->read_ini_tags(
@@ -2109,7 +2069,7 @@ void Courtroom::on_chat_return_pressed()
}
packet_contents.append(effect + "|" + p_effect_folder + "|" + fx_sound);
- if (!ao_app->is_stickyeffects_enabled() && !ao_app->get_effect_property(effect, current_char, p_effect_folder, "sticky").startsWith("true")) {
+ if (!Options::getInstance().clearEffectsDropdownOnPlayEnabled() && !ao_app->get_effect_property(effect, current_char, p_effect_folder, "sticky").startsWith("true")) {
ui_effects_dropdown->blockSignals(true);
ui_effects_dropdown->setCurrentIndex(0);
ui_effects_dropdown->blockSignals(false);
@@ -2138,14 +2098,14 @@ void Courtroom::reset_ui()
ui_evidence_present->set_image("present");
// If sticky sounds is disabled and we either have SFX on Idle enabled, or our Preanim checkbox is checked
- if (!ao_app->is_stickysounds_enabled() && (ao_app->get_sfx_on_idle() || ui_pre->isChecked())) {
+ if (!Options::getInstance().clearSoundsDropdownOnPlayEnabled() && (Options::getInstance().playSelectedSFXOnIdle() || ui_pre->isChecked())) {
// Reset the SFX Dropdown to "Default"
ui_sfx_dropdown->setCurrentIndex(0);
ui_sfx_remove->hide();
custom_sfx = "";
}
// If sticky preanims is disabled
- if (!ao_app->is_stickypres_enabled())
+ if (!Options::getInstance().clearPreOnPlayEnabled())
// Turn off our Preanim checkbox
ui_pre->setChecked(false);
}
@@ -2190,17 +2150,17 @@ void Courtroom::chatmessage_enqueue(QStringList p_contents)
reset_ui();
}
// If we determine we sent this message, or we have desync enabled
- if (sender || ao_app->is_desyncrhonized_logs_enabled()) {
+ if (sender || Options::getInstance().desynchronisedLogsEnabled()) {
// Initialize operation "message queue ghost"
log_chatmessage(p_contents[MESSAGE], p_contents[CHAR_ID].toInt(),
p_contents[SHOWNAME], p_contents[CHAR_NAME],
p_contents[OBJECTION_MOD], p_contents[EVIDENCE_ID].toInt(),
- p_contents[TEXT_COLOR].toInt(), QUEUED, sender || ao_app->is_desyncrhonized_logs_enabled());
+ p_contents[TEXT_COLOR].toInt(), QUEUED, sender || Options::getInstance().desynchronisedLogsEnabled());
}
bool is_objection = false;
// If the user wants to clear queue on objection
- if (ao_app->is_instant_objection_enabled())
+ if (Options::getInstance().objectionSkipQueueEnabled())
{
int objection_mod = p_contents[OBJECTION_MOD].split("&")[0].toInt();
is_objection = objection_mod >= 1 && objection_mod <= 5;
@@ -2217,7 +2177,7 @@ void Courtroom::chatmessage_enqueue(QStringList p_contents)
chatmessage_queue.enqueue(p_contents);
// Our settings disabled queue, or no message is being parsed right now and we're not waiting on one
- bool start_queue = ao_app->stay_time() <= 0 || (text_state >= 2 && !text_queue_timer->isActive());
+ bool start_queue = Options::getInstance().textStayTime() <= 0 || (text_state >= 2 && !text_queue_timer->isActive());
// Objections also immediately play the message
if (start_queue || is_objection)
chatmessage_dequeue(); // Process the message instantly
@@ -2242,7 +2202,7 @@ void Courtroom::skip_chatmessage_queue()
while (!chatmessage_queue.isEmpty()) {
QStringList p_contents = chatmessage_queue.dequeue();
// if the char ID matches our client's char ID (most likely, this is our message coming back to us)
- bool sender = ao_app->is_desyncrhonized_logs_enabled() || p_contents[CHAR_ID].toInt() == m_cid;
+ bool sender = Options::getInstance().desynchronisedLogsEnabled() || p_contents[CHAR_ID].toInt() == m_cid;
log_chatmessage(p_contents[MESSAGE], p_contents[CHAR_ID].toInt(), p_contents[SHOWNAME], p_contents[CHAR_NAME], p_contents[OBJECTION_MOD], p_contents[EVIDENCE_ID].toInt(), p_contents[TEXT_COLOR].toInt(), DISPLAY_ONLY, sender);
}
}
@@ -2265,7 +2225,7 @@ void Courtroom::unpack_chatmessage(QStringList p_contents)
}
// if the char ID matches our client's char ID (most likely, this is our message coming back to us)
- bool sender = ao_app->is_desyncrhonized_logs_enabled() || m_chatmessage[CHAR_ID].toInt() == m_cid;
+ bool sender = Options::getInstance().desynchronisedLogsEnabled() || m_chatmessage[CHAR_ID].toInt() == m_cid;
// We have logs displaying as soon as we reach the message in our queue, which is a less confusing but also less accurate experience for the user.
log_chatmessage(m_chatmessage[MESSAGE], m_chatmessage[CHAR_ID].toInt(), m_chatmessage[SHOWNAME], m_chatmessage[CHAR_NAME], m_chatmessage[OBJECTION_MOD], m_chatmessage[EVIDENCE_ID].toInt(), m_chatmessage[TEXT_COLOR].toInt(), DISPLAY_ONLY, sender);
@@ -2501,19 +2461,17 @@ void Courtroom::display_character()
ui_vp_message->hide();
ui_vp_chatbox->setVisible(chatbox_always_show);
// Show it if chatbox always shows
- if (ao_app->is_sticker_enabled() && chatbox_always_show) {
+ if (Options::getInstance().characterStickerEnabled() && chatbox_always_show) {
ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
}
// Hide the face sticker
else {
ui_vp_sticker->stop();
}
- // Initialize the correct pos (called SIDE here for some reason) with DESK_MOD to determine if we should hide the desk or not.
- set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]);
// Arrange the netstrings of the frame SFX for the character to know about
if (!m_chatmessage[FRAME_SFX].isEmpty() &&
- ao_app->is_frame_network_enabled()) {
+ Options::getInstance().networkedFrameSfxEnabled()) {
// ORDER IS IMPORTANT!!
QStringList netstrings = {m_chatmessage[FRAME_SCREENSHAKE],
m_chatmessage[FRAME_REALIZATION],
@@ -2672,7 +2630,7 @@ void Courtroom::handle_ic_message()
}
// if we have instant objections disabled, and queue is not empty, check if next message after this is an objection.
- if (!ao_app->is_instant_objection_enabled() && chatmessage_queue.size() > 0)
+ if (!Options::getInstance().objectionSkipQueueEnabled() && chatmessage_queue.size() > 0)
{
QStringList p_contents = chatmessage_queue.head();
int objection_mod = p_contents[OBJECTION_MOD].split("&")[0].toInt();
@@ -2685,7 +2643,7 @@ void Courtroom::handle_ic_message()
void Courtroom::do_screenshake()
{
- if (!ao_app->is_shake_enabled())
+ if (!Options::getInstance().shakeEnabled())
return;
// This way, the animation is reset in such a way that last played screenshake
@@ -2734,7 +2692,7 @@ void Courtroom::do_screenshake()
void Courtroom::do_flash()
{
- if (!ao_app->is_effects_enabled())
+ if (!Options::getInstance().effectsEnabled())
return;
QString f_char = m_chatmessage[CHAR_NAME];
@@ -2758,7 +2716,7 @@ void Courtroom::do_effect(QString fx_path, QString fx_sound, QString p_char,
}
// Only check if effects are disabled after playing the sound if it exists
- if (!ao_app->is_effects_enabled()) {
+ if (!Options::getInstance().effectsEnabled()) {
return;
}
ui_vp_effect->transform_mode = ao_app->get_scaling(
@@ -2855,7 +2813,7 @@ void Courtroom::initialize_chatbox()
ui_vp_showname->setText(m_chatmessage[SHOWNAME]);
}
QString customchar;
- if (ao_app->is_customchat_enabled())
+ if (Options::getInstance().customChatboxEnabled())
customchar = m_chatmessage[CHAR_NAME];
QString p_misc = ao_app->get_chat(customchar);
@@ -2966,8 +2924,8 @@ void Courtroom::handle_callwords()
{
// Quickly check through the message for the word_call (callwords) sfx
QString f_message = m_chatmessage[MESSAGE];
- // Obtain the current call words (Really? It does File I/O on every single message???)
- QStringList call_words = ao_app->get_call_words();
+ //No more file IO on every message.
+ QStringList call_words = Options::getInstance().callwords();
// Loop through each word in the call words list
for (const QString &word : qAsConst(call_words)) {
// If our message contains that specific call word
@@ -3297,7 +3255,7 @@ void Courtroom::log_ic_text(QString p_name, QString p_showname,
{
chatlogpiece log_entry(p_name, p_showname, p_message, p_action, p_color, p_selfname);
ic_chatlog_history.append(log_entry);
- if (ao_app->get_text_logging_enabled() && !ao_app->log_filename.isEmpty())
+ if (Options::getInstance().logToTextFileEnabled() && !ao_app->log_filename.isEmpty())
ao_app->append_to_file(log_entry.get_full(), ao_app->log_filename, true);
while (ic_chatlog_history.size() > log_maximum_blocks &&
@@ -3512,20 +3470,20 @@ void Courtroom::play_preanim(bool immediate)
ui_vp_player_char->set_play_once(true);
ui_vp_player_char->load_image(f_preanim, f_char, preanim_duration, true);
- switch(m_chatmessage[DESK_MOD].toInt()) {
- case 4:
+ switch (m_chatmessage[DESK_MOD].toInt()) {
+ case DESK_EMOTE_ONLY_EX:
ui_vp_sideplayer_char->hide();
ui_vp_player_char->move_and_center(0, 0);
[[fallthrough]];
- case 2:
- set_scene("0", m_chatmessage[SIDE]);
+ case DESK_EMOTE_ONLY:
+ case DESK_HIDE:
+ set_scene(false, m_chatmessage[SIDE]);
break;
- case 5:
- case 3:
- set_scene("1", m_chatmessage[SIDE]);
- break;
- default:
- set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]);
+
+ case DESK_PRE_ONLY_EX:
+ case DESK_PRE_ONLY:
+ case DESK_SHOW:
+ set_scene(true, m_chatmessage[SIDE]);
break;
}
@@ -3563,21 +3521,21 @@ void Courtroom::start_chat_ticking()
// handle expanded desk mods
switch(m_chatmessage[DESK_MOD].toInt()) {
- case 4:
+ case DESK_EMOTE_ONLY_EX:
set_self_offset(m_chatmessage[SELF_OFFSET]);
[[fallthrough]];
- case 2:
- set_scene("1", m_chatmessage[SIDE]);
+ case DESK_EMOTE_ONLY:
+ case DESK_SHOW:
+ set_scene(true, m_chatmessage[SIDE]);
break;
- case 5:
+
+ case DESK_PRE_ONLY_EX:
ui_vp_sideplayer_char->hide();
ui_vp_player_char->move_and_center(0, 0);
[[fallthrough]];
- case 3:
- set_scene("0", m_chatmessage[SIDE]);
- break;
- default:
- set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]);
+ case DESK_PRE_ONLY:
+ case DESK_HIDE:
+ set_scene(false, m_chatmessage[SIDE]);
break;
}
@@ -3616,7 +3574,7 @@ void Courtroom::start_chat_ticking()
ui_vp_chatbox->setVisible(chatbox_always_show);
ui_vp_message->hide();
// Show it if chatbox always shows
- if (ao_app->is_sticker_enabled() && chatbox_always_show)
+ if (Options::getInstance().characterStickerEnabled() && chatbox_always_show)
ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
// Hide the face sticker
else {
@@ -3624,7 +3582,7 @@ void Courtroom::start_chat_ticking()
}
}
// If we're not already waiting on the next message, start the timer. We could be overriden if there's an objection planned.
- int delay = ao_app->stay_time();
+ int delay = Options::getInstance().textStayTime();
if (delay > 0 && !text_queue_timer->isActive())
text_queue_timer->start(delay);
return;
@@ -3633,7 +3591,7 @@ void Courtroom::start_chat_ticking()
ui_vp_chatbox->show();
ui_vp_message->show();
- if (ao_app->is_sticker_enabled())
+ if (Options::getInstance().characterStickerEnabled())
ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
if (m_chatmessage[ADDITIVE] != "1") {
@@ -3644,9 +3602,9 @@ void Courtroom::start_chat_ticking()
tick_pos = 0;
blip_ticker = 0;
- text_crawl = ao_app->get_text_crawl();
- blip_rate = ao_app->read_blip_rate();
- blank_blip = ao_app->get_blank_blip();
+ text_crawl = Options::getInstance().textCrawlSpeed();
+ blip_rate = Options::getInstance().blipRate();
+ blank_blip = Options::getInstance().blankBlip();
// At the start of every new message, we set the text speed to the default.
current_display_speed = 3;
@@ -3707,7 +3665,7 @@ void Courtroom::chat_tick()
anim_state = 3;
QString f_char;
QString f_custom_theme;
- if (ao_app->is_customchat_enabled()) {
+ if (Options::getInstance().customChatboxEnabled()) {
f_char = m_chatmessage[CHAR_NAME];
f_custom_theme = ao_app->get_chat(f_char);
}
@@ -3723,12 +3681,12 @@ void Courtroom::chat_tick()
// If we're not already waiting on the next message, start the timer. We could be overriden if there's an objection planned.
- int delay = ao_app->stay_time();
+ int delay = Options::getInstance().textStayTime();
if (delay > 0 && !text_queue_timer->isActive())
text_queue_timer->start(delay);
// if we have instant objections disabled, and queue is not empty, check if next message after this is an objection.
- if (!ao_app->is_instant_objection_enabled() && chatmessage_queue.size() > 0)
+ if (!Options::getInstance().objectionSkipQueueEnabled() && chatmessage_queue.size() > 0)
{
QStringList p_contents = chatmessage_queue.head();
int objection_mod = p_contents[OBJECTION_MOD].split("&")[0].toInt();
@@ -3944,24 +3902,20 @@ void Courtroom::play_sfx()
return;
sfx_player->play(sfx_name);
- if (ao_app->get_looping_sfx())
+ if (Options::getInstance().loopingSfx())
sfx_player->set_looping(
ao_app->get_sfx_looping(current_char, current_emote) == "1");
}
-void Courtroom::set_scene(const QString f_desk_mod, const QString f_side)
+void Courtroom::set_scene(bool show_desk, const QString f_side)
{
ui_vp_background->load_image(ao_app->get_pos_path(f_side));
ui_vp_desk->load_image(ao_app->get_pos_path(f_side, true));
- if (f_desk_mod == "0" ||
- (f_desk_mod != "1" &&
- (f_side == "jud" || f_side == "hld" || f_side == "hlp"))) {
- ui_vp_desk->hide();
- }
- else {
+ if (show_desk)
ui_vp_desk->show();
- }
+ else
+ ui_vp_desk->hide();
}
void Courtroom::set_self_offset(const QString& p_list) {
@@ -4245,21 +4199,6 @@ void Courtroom::mod_called(QString p_ip)
}
}
-void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur,
- bool steno)
-{
- Q_UNUSED(def);
- Q_UNUSED(pro);
- Q_UNUSED(jud);
- Q_UNUSED(jur);
- Q_UNUSED(steno);
- if (ui_casing->isChecked()) {
- ui_server_chatlog->append(msg);
- modcall_player->play(ao_app->get_court_sfx("case_call"));
- ao_app->alert(this);
- }
-}
-
void Courtroom::on_ooc_return_pressed()
{
QString ooc_message = ui_ooc_chat_message->text();
@@ -4281,9 +4220,9 @@ void Courtroom::on_ooc_return_pressed()
#else
QStringList command = ooc_message.split(" ", Qt::SkipEmptyParts);
#endif
- QDir casefolder("base/cases");
+ QDir casefolder(get_base_path()+"/cases");
if (!casefolder.exists()) {
- QDir::current().mkdir("base/" + casefolder.dirName());
+ QDir::current().mkdir(get_base_path() + casefolder.dirName());
append_server_chatmessage(
"CLIENT",
tr("You don't have a `base/cases/` folder! It was just made for you, "
@@ -4320,7 +4259,7 @@ void Courtroom::on_ooc_return_pressed()
return;
}
- QSettings casefile("base/cases/" + command[1] + ".ini",
+ QSettings casefile(get_base_path() + "/cases/" + command[1] + ".ini",
QSettings::IniFormat);
QString caseauth = casefile.value("author", "").value<QString>();
@@ -4381,9 +4320,9 @@ void Courtroom::on_ooc_return_pressed()
#else
QStringList command = ooc_message.split(" ", Qt::SkipEmptyParts);
#endif
- QDir casefolder("base/cases");
+ QDir casefolder(get_base_path() + "cases");
if (!casefolder.exists()) {
- QDir::current().mkdir("base/" + casefolder.dirName());
+ QDir(get_base_path()).mkdir(casefolder.dirName());
append_server_chatmessage(
"CLIENT",
tr("You don't have a `base/cases/` folder! It was just made for you, "
@@ -4417,7 +4356,7 @@ void Courtroom::on_ooc_return_pressed()
ui_ooc_chat_message->clear();
return;
}
- QSettings casefile("base/cases/" + command[1] + ".ini",
+ QSettings casefile(get_base_path() + "/cases/" + command[1] + ".ini",
QSettings::IniFormat);
casefile.setValue("author", ui_ooc_chat_name->text());
casefile.setValue("cmdoc", "");
@@ -4637,7 +4576,7 @@ void Courtroom::on_iniswap_dropdown_changed(int p_index)
}
QString p_path = ao_app->get_real_path(VPath("iniswaps.ini"));
if (!file_exists(p_path)) {
- p_path = ao_app->get_base_path() + "iniswaps.ini";
+ p_path = get_base_path() + "iniswaps.ini";
}
ao_app->write_to_file(swaplist.join("\n"), p_path);
ui_iniswap_dropdown->blockSignals(true);
@@ -4787,7 +4726,7 @@ void Courtroom::on_sfx_context_menu_requested(const QPoint &pos)
menu->addSeparator();
menu->addAction(QString("Open base sounds folder"), this,
[=] {
- QString p_path = ao_app->get_base_path() + "sounds/general/";
+ QString p_path = get_base_path() + "sounds/general/";
if (!dir_exists(p_path)) {
return;
}
@@ -4814,7 +4753,7 @@ void Courtroom::on_sfx_edit_requested()
}
if (!file_exists(p_path)) {
- p_path = ao_app->get_base_path() + "soundlist.ini";
+ p_path = get_base_path() + "soundlist.ini";
}
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
}
@@ -5013,7 +4952,7 @@ void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item,
{
if (is_muted)
return;
- if (!ao_app->is_category_stop_enabled() && p_item->parent() == nullptr)
+ if (!Options::getInstance().stopMusicOnCategoryEnabled() && p_item->parent() == nullptr)
return;
column = 1; // Column 1 is always the metadata (which we want)
QString p_song = p_item->text(column);
@@ -5062,7 +5001,7 @@ void Courtroom::on_music_list_context_menu_requested(const QPoint &pos)
menu->addSeparator();
menu->addAction(QString("Open base music folder"), this,
[=] {
- QString p_path = ao_app->get_base_path() + "sounds/music/";
+ QString p_path = get_base_path() + "sounds/music/";
if (!dir_exists(p_path)) {
return;
}
@@ -5388,7 +5327,7 @@ void Courtroom::on_text_color_context_menu_requested(const QPoint &pos)
menu->addAction(QString("Open currently used chat_config.ini"), this,
[=] {
- QString p_path = ao_app->get_asset("chat_config.ini", ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, ao_app->get_chat(current_char));
+ QString p_path = ao_app->get_asset("chat_config.ini", Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, ao_app->get_chat(current_char));
if (!file_exists(p_path)) {
return;
}
@@ -5578,8 +5517,6 @@ void Courtroom::on_change_character_clicked()
void Courtroom::on_reload_theme_clicked()
{
- ao_app->reload_theme();
-
set_courtroom_size();
set_widgets();
update_character(m_cid, ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex()));
@@ -5648,11 +5585,6 @@ void Courtroom::on_call_mod_clicked()
void Courtroom::on_settings_clicked() { ao_app->call_settings_menu(); }
-void Courtroom::on_announce_casing_clicked()
-{
- ao_app->call_announce_menu(this);
-}
-
void Courtroom::on_pre_clicked() { ui_ic_chat_message->setFocus(); }
void Courtroom::on_flip_clicked() { ui_ic_chat_message->setFocus(); }
@@ -5707,7 +5639,7 @@ void Courtroom::on_evidence_context_menu_requested(const QPoint &pos)
QMenu *menu = new QMenu(this);
menu->addAction(QString("Open base evidence folder"), this,
[=] {
- QString p_path = ao_app->get_base_path() + "evidence/";
+ QString p_path = get_base_path() + "evidence/";
if (!dir_exists(p_path)) {
return;
}
@@ -5752,45 +5684,6 @@ qint64 Courtroom::pong()
return ping_timer.elapsed();
}
-void Courtroom::on_casing_clicked()
-{
- if (ao_app->casing_alerts_supported) {
- if (ui_casing->isChecked()) {
- QStringList f_packet;
-
- f_packet.append(ao_app->get_casing_can_host_cases());
- f_packet.append(QString::number(ao_app->get_casing_cm_enabled()));
- f_packet.append(QString::number(ao_app->get_casing_defence_enabled()));
- f_packet.append(
- QString::number(ao_app->get_casing_prosecution_enabled()));
- f_packet.append(QString::number(ao_app->get_casing_judge_enabled()));
- f_packet.append(QString::number(ao_app->get_casing_juror_enabled()));
- f_packet.append(QString::number(ao_app->get_casing_steno_enabled()));
-
- ao_app->send_server_packet(new AOPacket("SETCASE", f_packet));
- }
- else
- ao_app->send_server_packet(new AOPacket("SETCASE", {"","0","0","0","0","0","0"}));
- }
-}
-
-void Courtroom::announce_case(QString title, bool def, bool pro, bool jud,
- bool jur, bool steno)
-{
- if (ao_app->casing_alerts_supported) {
- QStringList f_packet;
-
- f_packet.append(title);
- f_packet.append(QString::number(def));
- f_packet.append(QString::number(pro));
- f_packet.append(QString::number(jud));
- f_packet.append(QString::number(jur));
- f_packet.append(QString::number(steno));
-
- ao_app->send_server_packet(new AOPacket("CASEA", f_packet));
- }
-}
-
void Courtroom::start_clock(int id)
{
if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr)
@@ -5920,6 +5813,11 @@ void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier)
Courtroom::~Courtroom()
{
+ //save sound settings
+ Options::getInstance().setMusicVolume(ui_music_slider->value());
+ Options::getInstance().setSfxVolume(ui_sfx_slider->value());
+ Options::getInstance().setBlipVolume(ui_blip_slider->value());
+
delete music_player;
delete sfx_player;
delete objection_player;