aboutsummaryrefslogtreecommitdiff
path: root/src/courtroom.cpp
diff options
context:
space:
mode:
authorin1tiate <32779090+in1tiate@users.noreply.github.com>2024-05-20 09:12:47 -0500
committerin1tiate <32779090+in1tiate@users.noreply.github.com>2024-05-20 09:12:47 -0500
commit5d90088b5c01c3933e5d1ccf497e7733b03195f2 (patch)
treecb92f4ec64aa8b8a2559f7db434bbac5a2093368 /src/courtroom.cpp
parenta23614059b67f57d7a2d66ad67aec6770dd3788d (diff)
clang-format pass
Diffstat (limited to 'src/courtroom.cpp')
-rw-r--r--src/courtroom.cpp323
1 files changed, 164 insertions, 159 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 2f7e3ed5..ba76604e 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -779,11 +779,9 @@ void Courtroom::set_widgets()
ui_vp_sideplayer_char->combo_resize(ui_viewport->width(), ui_viewport->height());
ui_vp_dummy_char->move_and_center(0, 0);
- ui_vp_dummy_char->combo_resize(ui_viewport->width(),
- ui_viewport->height());
+ ui_vp_dummy_char->combo_resize(ui_viewport->width(), ui_viewport->height());
ui_vp_sidedummy_char->move_and_center(0, 0);
- ui_vp_sidedummy_char->combo_resize(ui_viewport->width(),
- ui_viewport->height());
+ ui_vp_sidedummy_char->combo_resize(ui_viewport->width(), ui_viewport->height());
// the AO2 desk element
ui_vp_desk->move_and_center(0, 0);
@@ -1422,9 +1420,10 @@ void Courtroom::set_background(QString p_background, bool display)
QString real_pos = pos.split(":")[0];
QStringList overrides = {"def", "wit", "pro"};
if ((file_exists(ao_app->get_image_suffix(ao_app->get_background_path(real_pos)))) || // Normal check, OR
- (overrides.contains(pos) && // It's one of our subpos overrides, AND
- file_exists(ao_app->get_image_suffix(ao_app->get_background_path("court"))) && // the "court" default image exists, AND
- !ao_app->read_design_ini("court:" + pos + "/pos_center", ao_app->get_background_path("design.ini")).isEmpty())) { // config exists for this pos
+ (overrides.contains(pos) && // It's one of our subpos overrides, AND
+ file_exists(ao_app->get_image_suffix(ao_app->get_background_path("court"))) && // the "court" default image exists, AND
+ !ao_app->read_design_ini("court:" + pos + "/pos_center", ao_app->get_background_path("design.ini")).isEmpty()))
+ { // config exists for this pos
pos_list.append(pos);
}
}
@@ -2303,7 +2302,8 @@ void Courtroom::on_chat_return_pressed()
}
}
- if (ao_app->m_serverdata.get_feature(server::BASE_FEATURE_SET::CUSTOM_BLIPS)) {
+ if (ao_app->m_serverdata.get_feature(server::BASE_FEATURE_SET::CUSTOM_BLIPS))
+ {
packet_contents.append(ao_app->get_blipname(current_char, current_emote));
}
packet_contents.append(ui_slide_enable->isChecked() ? "1" : "0"); // just let the server figure out what to do with this
@@ -2966,194 +2966,200 @@ void Courtroom::do_screenshake()
screenshake_animation_group->start();
}
-void Courtroom::do_transition(QString p_desk_mod, QString old_pos, QString new_pos) {
+void Courtroom::do_transition(QString p_desk_mod, QString old_pos, QString new_pos)
+{
+ if (m_chatmessage[EMOTE] != "")
+ display_character();
- if (m_chatmessage[EMOTE] != "")
- display_character();
-
- const QStringList legacy_pos = {"def", "wit", "pro"};
- QString t_old_pos = old_pos;
- QString t_new_pos = new_pos;
- if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path("court")))) {
- if (legacy_pos.contains(old_pos)) {
- t_old_pos = "court:" + old_pos;
- }
- if (legacy_pos.contains(new_pos)) {
- t_new_pos = "court:" + new_pos;
- }
+ const QStringList legacy_pos = {"def", "wit", "pro"};
+ QString t_old_pos = old_pos;
+ QString t_new_pos = new_pos;
+ if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path("court"))))
+ {
+ if (legacy_pos.contains(old_pos))
+ {
+ t_old_pos = "court:" + old_pos;
}
+ if (legacy_pos.contains(new_pos))
+ {
+ t_new_pos = "court:" + new_pos;
+ }
+ }
- QPair<QString, int> old_pos_pair = ao_app->get_pos_path(t_old_pos);
- QPair<QString, int> new_pos_pair = ao_app->get_pos_path(t_new_pos);
+ QPair<QString, int> old_pos_pair = ao_app->get_pos_path(t_old_pos);
+ QPair<QString, int> new_pos_pair = ao_app->get_pos_path(t_new_pos);
- int duration = ao_app->get_pos_transition_duration(t_old_pos, t_new_pos);
+ int duration = ao_app->get_pos_transition_duration(t_old_pos, t_new_pos);
- // conditions to stop slide
- if (old_pos == new_pos ||
- old_pos_pair.first != new_pos_pair.first ||
- new_pos_pair.second == -1 ||
- !Options::getInstance().slidesEnabled() ||
- m_chatmessage[SLIDE] != "1" ||
- duration == -1 ||
- m_chatmessage[EMOTE_MOD].toInt() == ZOOM ||
- m_chatmessage[EMOTE_MOD].toInt() == PREANIM_ZOOM) {
+ // conditions to stop slide
+ if (old_pos == new_pos || old_pos_pair.first != new_pos_pair.first || new_pos_pair.second == -1 || !Options::getInstance().slidesEnabled() || m_chatmessage[SLIDE] != "1" || duration == -1 || m_chatmessage[EMOTE_MOD].toInt() == ZOOM || m_chatmessage[EMOTE_MOD].toInt() == PREANIM_ZOOM)
+ {
#ifdef DEBUG_TRANSITION
- qDebug() << "skipping transition - not applicable";
+ qDebug() << "skipping transition - not applicable";
#endif
- post_transition_cleanup();
- return;
- }
+ post_transition_cleanup();
+ return;
+ }
#ifdef DEBUG_TRANSITION
- // for debugging animation
- ui_vp_sideplayer_char->setStyleSheet("background-color:rgba(0, 0, 255, 128);");
- ui_vp_dummy_char->setStyleSheet("background-color:rgba(255, 0, 0, 128);");
- ui_vp_sidedummy_char->setStyleSheet("background-color:rgba(0, 255, 0, 128);");
+ // for debugging animation
+ ui_vp_sideplayer_char->setStyleSheet("background-color:rgba(0, 0, 255, 128);");
+ ui_vp_dummy_char->setStyleSheet("background-color:rgba(255, 0, 0, 128);");
+ ui_vp_sidedummy_char->setStyleSheet("background-color:rgba(0, 255, 0, 128);");
- qDebug() << "STARTING TRANSITION, CURRENT TIME:" << transition_animation_group->currentTime();
+ qDebug() << "STARTING TRANSITION, CURRENT TIME:" << transition_animation_group->currentTime();
#endif
- set_scene(p_desk_mod.toInt(), old_pos);
+ set_scene(p_desk_mod.toInt(), old_pos);
- QList<AOLayer *> affected_list = {ui_vp_background, ui_vp_desk, ui_vp_player_char};
+ QList<AOLayer *> affected_list = {ui_vp_background, ui_vp_desk, ui_vp_player_char};
- bool paired = false;
- if (!ui_vp_sideplayer_char->isHidden()) {
- affected_list.append(ui_vp_sideplayer_char);
- paired = true;
- }
+ bool paired = false;
+ if (!ui_vp_sideplayer_char->isHidden())
+ {
+ affected_list.append(ui_vp_sideplayer_char);
+ paired = true;
+ }
- // Set up the background, desk, and player objects' animations
+ // Set up the background, desk, and player objects' animations
- float scaling_factor = ui_vp_background->get_scaling_factor();
- int offset = (float(old_pos_pair.second) * scaling_factor) - (float(new_pos_pair.second) * scaling_factor);
+ float scaling_factor = ui_vp_background->get_scaling_factor();
+ int offset = (float(old_pos_pair.second) * scaling_factor) - (float(new_pos_pair.second) * scaling_factor);
- for (AOLayer *ui_element : affected_list) {
- QPropertyAnimation *transition_animation = new QPropertyAnimation(ui_element, "pos", this);
- transition_animation->setStartValue(ui_element->pos());
- transition_animation->setDuration(duration);
- transition_animation->setEndValue(QPoint(ui_element->pos().x() + offset, ui_element->pos().y()));
- transition_animation->setEasingCurve(QEasingCurve::InOutCubic);
- transition_animation_group->addAnimation(transition_animation);
- }
+ for (AOLayer *ui_element : affected_list)
+ {
+ QPropertyAnimation *transition_animation = new QPropertyAnimation(ui_element, "pos", this);
+ transition_animation->setStartValue(ui_element->pos());
+ transition_animation->setDuration(duration);
+ transition_animation->setEndValue(QPoint(ui_element->pos().x() + offset, ui_element->pos().y()));
+ transition_animation->setEasingCurve(QEasingCurve::InOutCubic);
+ transition_animation_group->addAnimation(transition_animation);
+ }
- // Setting up the dummy characters to work for us as our stand-in for the next characters
- // This should be easy. But it isn't
+ // Setting up the dummy characters to work for us as our stand-in for the next characters
+ // This should be easy. But it isn't
- QString slide_emote;
- if (m_chatmessage[OBJECTION_MOD].contains("4") || m_chatmessage[OBJECTION_MOD].toInt() == 2) {
- slide_emote = "(a)" + ao_app->read_char_ini(m_chatmessage[CHAR_NAME], "objection_pose", "Options");
- if (slide_emote == "(a)") {
- slide_emote = "(a)" + m_chatmessage[EMOTE];
- }
+ QString slide_emote;
+ if (m_chatmessage[OBJECTION_MOD].contains("4") || m_chatmessage[OBJECTION_MOD].toInt() == 2)
+ {
+ slide_emote = "(a)" + ao_app->read_char_ini(m_chatmessage[CHAR_NAME], "objection_pose", "Options");
+ if (slide_emote == "(a)")
+ {
+ slide_emote = "(a)" + m_chatmessage[EMOTE];
}
- else
- slide_emote = "(a)" + m_chatmessage[EMOTE];
+ }
+ else
+ slide_emote = "(a)" + m_chatmessage[EMOTE];
- QString other_slide_emote = "(a)" + m_chatmessage[OTHER_EMOTE];
+ QString other_slide_emote = "(a)" + m_chatmessage[OTHER_EMOTE];
- // Load the image we're going to use to get scaling information, and move it into the final position for animation data
- ui_vp_dummy_char->set_flipped(m_chatmessage[FLIP].toInt());
- ui_vp_dummy_char->load_image(slide_emote, m_chatmessage[CHAR_NAME], 0, false);
- set_self_offset(m_chatmessage[SELF_OFFSET], ui_vp_dummy_char);
+ // Load the image we're going to use to get scaling information, and move it into the final position for animation data
+ ui_vp_dummy_char->set_flipped(m_chatmessage[FLIP].toInt());
+ ui_vp_dummy_char->load_image(slide_emote, m_chatmessage[CHAR_NAME], 0, false);
+ set_self_offset(m_chatmessage[SELF_OFFSET], ui_vp_dummy_char);
- QPoint starting_position = QPoint(ui_vp_player_char->pos().x() - offset, ui_vp_player_char->pos().y());
- QPropertyAnimation *ui_vp_dummy_animation = new QPropertyAnimation(ui_vp_dummy_char, "pos", this);
+ QPoint starting_position = QPoint(ui_vp_player_char->pos().x() - offset, ui_vp_player_char->pos().y());
+ QPropertyAnimation *ui_vp_dummy_animation = new QPropertyAnimation(ui_vp_dummy_char, "pos", this);
- ui_vp_dummy_animation->setDuration(duration);
- ui_vp_dummy_animation->setStartValue(starting_position);
- ui_vp_dummy_animation->setEndValue(ui_vp_dummy_char->pos());
- ui_vp_dummy_animation->setEasingCurve(QEasingCurve::InOutCubic);
- transition_animation_group->addAnimation(ui_vp_dummy_animation);
+ ui_vp_dummy_animation->setDuration(duration);
+ ui_vp_dummy_animation->setStartValue(starting_position);
+ ui_vp_dummy_animation->setEndValue(ui_vp_dummy_char->pos());
+ ui_vp_dummy_animation->setEasingCurve(QEasingCurve::InOutCubic);
+ transition_animation_group->addAnimation(ui_vp_dummy_animation);
- ui_vp_dummy_char->move(starting_position.x(), starting_position.y());
+ ui_vp_dummy_char->move(starting_position.x(), starting_position.y());
- // If the new message is paired, do it all again for the pair character. Yippee!
- if (m_chatmessage[OTHER_CHARID].toInt() != -1 && !m_chatmessage[OTHER_NAME].isEmpty()) {
- ui_vp_sidedummy_char->set_flipped(m_chatmessage[OTHER_FLIP].toInt());
- ui_vp_sidedummy_char->load_image(other_slide_emote, m_chatmessage[OTHER_NAME], 0, false);
- set_self_offset(m_chatmessage[OTHER_OFFSET], ui_vp_sidedummy_char);
- QStringList args = m_chatmessage[OTHER_CHARID].split("^");
- if (args.size() > 1)
- {
- // Change the order of appearance based on the pair order variable
- int order = args.at(1).toInt();
- switch (order) {
- case 0: // Our character is in front
- ui_vp_sidedummy_char->stackUnder(ui_vp_dummy_char);
- break;
- case 1: // Our character is behind
- ui_vp_dummy_char->stackUnder(ui_vp_sidedummy_char);
- break;
- default:
- break;
- }
- }
+ // If the new message is paired, do it all again for the pair character. Yippee!
+ if (m_chatmessage[OTHER_CHARID].toInt() != -1 && !m_chatmessage[OTHER_NAME].isEmpty())
+ {
+ ui_vp_sidedummy_char->set_flipped(m_chatmessage[OTHER_FLIP].toInt());
+ ui_vp_sidedummy_char->load_image(other_slide_emote, m_chatmessage[OTHER_NAME], 0, false);
+ set_self_offset(m_chatmessage[OTHER_OFFSET], ui_vp_sidedummy_char);
+ QStringList args = m_chatmessage[OTHER_CHARID].split("^");
+ if (args.size() > 1)
+ {
+ // Change the order of appearance based on the pair order variable
+ int order = args.at(1).toInt();
+ switch (order)
+ {
+ case 0: // Our character is in front
+ ui_vp_sidedummy_char->stackUnder(ui_vp_dummy_char);
+ break;
+ case 1: // Our character is behind
+ ui_vp_dummy_char->stackUnder(ui_vp_sidedummy_char);
+ break;
+ default:
+ break;
+ }
+ }
- QPoint other_starting_position = QPoint(ui_vp_sideplayer_char->pos().x() - offset, ui_vp_sideplayer_char->pos().y());
- QPropertyAnimation *ui_vp_sidedummy_animation = new QPropertyAnimation(ui_vp_sidedummy_char, "pos", this);
+ QPoint other_starting_position = QPoint(ui_vp_sideplayer_char->pos().x() - offset, ui_vp_sideplayer_char->pos().y());
+ QPropertyAnimation *ui_vp_sidedummy_animation = new QPropertyAnimation(ui_vp_sidedummy_char, "pos", this);
- ui_vp_sidedummy_animation->setDuration(duration);
- ui_vp_sidedummy_animation->setStartValue(starting_position);
- ui_vp_sidedummy_animation->setEndValue(ui_vp_sidedummy_char->pos());
- ui_vp_sidedummy_animation->setEasingCurve(QEasingCurve::InOutCubic);
- transition_animation_group->addAnimation(ui_vp_sidedummy_animation);
+ ui_vp_sidedummy_animation->setDuration(duration);
+ ui_vp_sidedummy_animation->setStartValue(starting_position);
+ ui_vp_sidedummy_animation->setEndValue(ui_vp_sidedummy_char->pos());
+ ui_vp_sidedummy_animation->setEasingCurve(QEasingCurve::InOutCubic);
+ transition_animation_group->addAnimation(ui_vp_sidedummy_animation);
- ui_vp_sidedummy_char->move(starting_position.x(), starting_position.y());
- }
- else {
- ui_vp_sidedummy_char->stop();
- }
+ ui_vp_sidedummy_char->move(starting_position.x(), starting_position.y());
+ }
+ else
+ {
+ ui_vp_sidedummy_char->stop();
+ }
- ui_vp_player_char->freeze();
- ui_vp_player_char->show();
- if (paired) {
- ui_vp_sideplayer_char->freeze();
- ui_vp_sideplayer_char->show();
- }
- else {
- ui_vp_sideplayer_char->stop();
- }
- ui_vp_dummy_char->freeze();
- ui_vp_sidedummy_char->freeze();
- QTimer::singleShot(TRANSITION_BOOKEND_DELAY, transition_animation_group, SLOT(start()));
+ ui_vp_player_char->freeze();
+ ui_vp_player_char->show();
+ if (paired)
+ {
+ ui_vp_sideplayer_char->freeze();
+ ui_vp_sideplayer_char->show();
+ }
+ else
+ {
+ ui_vp_sideplayer_char->stop();
+ }
+ ui_vp_dummy_char->freeze();
+ ui_vp_sidedummy_char->freeze();
+ QTimer::singleShot(TRANSITION_BOOKEND_DELAY, transition_animation_group, SLOT(start()));
}
-
-void Courtroom::on_transition_finish() {
- transition_animation_group->clear();
- transition_animation_group->setCurrentTime(0);
- QTimer::singleShot(TRANSITION_BOOKEND_DELAY, this, SLOT(post_transition_cleanup()));
+void Courtroom::on_transition_finish()
+{
+ transition_animation_group->clear();
+ transition_animation_group->setCurrentTime(0);
+ QTimer::singleShot(TRANSITION_BOOKEND_DELAY, this, SLOT(post_transition_cleanup()));
}
-void Courtroom::post_transition_cleanup() {
-
- set_scene(m_chatmessage[DESK_MOD].toInt(), m_chatmessage[SIDE]);
-
- // Move the character on the viewport according to the offsets
- set_self_offset(m_chatmessage[SELF_OFFSET], ui_vp_player_char);
+void Courtroom::post_transition_cleanup()
+{
+ set_scene(m_chatmessage[DESK_MOD].toInt(), m_chatmessage[SIDE]);
- int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
- bool immediate = m_chatmessage[IMMEDIATE].toInt() == 1;
+ // Move the character on the viewport according to the offsets
+ set_self_offset(m_chatmessage[SELF_OFFSET], ui_vp_player_char);
+ int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
+ bool immediate = m_chatmessage[IMMEDIATE].toInt() == 1;
- // Reset the pair character
- ui_vp_sideplayer_char->stop();
- ui_vp_sideplayer_char->move_and_center(0, 0);
+ // Reset the pair character
+ ui_vp_sideplayer_char->stop();
+ ui_vp_sideplayer_char->move_and_center(0, 0);
- // If the emote_mod is not zooming
- if (emote_mod != ZOOM && emote_rows != PREANIM_ZOOM) {
- // Display the pair character
- display_pair_character(m_chatmessage[OTHER_CHARID], m_chatmessage[OTHER_OFFSET]);
- }
+ // If the emote_mod is not zooming
+ if (emote_mod != ZOOM && emote_rows != PREANIM_ZOOM)
+ {
+ // Display the pair character
+ display_pair_character(m_chatmessage[OTHER_CHARID], m_chatmessage[OTHER_OFFSET]);
+ }
- // Reset tweedle dee and tweedle dummy
- ui_vp_dummy_char->stop();
- ui_vp_dummy_char->move_and_center(0,0);
- ui_vp_sidedummy_char->stop();
- ui_vp_sidedummy_char->move_and_center(0,0);
+ // Reset tweedle dee and tweedle dummy
+ ui_vp_dummy_char->stop();
+ ui_vp_dummy_char->move_and_center(0, 0);
+ ui_vp_sidedummy_char->stop();
+ ui_vp_sidedummy_char->move_and_center(0, 0);
- // Parse the emote_mod part of the chat message
- handle_emote_mod(emote_mod, immediate);
+ // Parse the emote_mod part of the chat message
+ handle_emote_mod(emote_mod, immediate);
}
void Courtroom::do_flash()
@@ -4547,7 +4553,7 @@ void Courtroom::set_scene(bool show_desk, const QString f_side)
}
}
-void Courtroom::set_self_offset(const QString& p_list, AOLayer* p_layer)
+void Courtroom::set_self_offset(const QString &p_list, AOLayer *p_layer)
{
QStringList self_offsets = p_list.split("&");
int self_offset = self_offsets[0].toInt();
@@ -6418,7 +6424,6 @@ void Courtroom::on_settings_clicked()
ao_app->call_settings_menu();
}
-
void Courtroom::on_additive_clicked()
{
if (ui_additive->isChecked())