aboutsummaryrefslogtreecommitdiff
path: root/src/courtroom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/courtroom.cpp')
-rw-r--r--src/courtroom.cpp218
1 files changed, 112 insertions, 106 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 507acc1..8a346a2 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -46,7 +46,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_background = new BackgroundLayer(ui_viewport, ao_app);
ui_vp_speedlines = new SplashLayer(ui_viewport, ao_app);
ui_vp_player_char = new CharLayer(ui_viewport, ao_app);
+ ui_vp_player_char->masked = false;
ui_vp_sideplayer_char = new CharLayer(ui_viewport, ao_app);
+ ui_vp_sideplayer_char->masked = false;
ui_vp_sideplayer_char->hide();
ui_vp_desk = new BackgroundLayer(ui_viewport, ao_app);
@@ -171,17 +173,21 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
initialize_emotes();
ui_pos_dropdown = new QComboBox(this);
+ ui_pos_dropdown->view()->setTextElideMode(Qt::ElideLeft);
ui_pos_remove = new AOButton(this, ao_app);
ui_iniswap_dropdown = new QComboBox(this);
ui_iniswap_dropdown->setContextMenuPolicy(Qt::CustomContextMenu);
+ ui_iniswap_dropdown->view()->setTextElideMode(Qt::ElideLeft);
ui_iniswap_remove = new AOButton(this, ao_app);
ui_sfx_dropdown = new QComboBox(this);
ui_sfx_dropdown->setContextMenuPolicy(Qt::CustomContextMenu);
+ ui_sfx_dropdown->view()->setTextElideMode(Qt::ElideLeft);
ui_sfx_remove = new AOButton(this, ao_app);
ui_effects_dropdown = new QComboBox(this);
+ ui_effects_dropdown->view()->setTextElideMode(Qt::ElideLeft);
ui_effects_dropdown->setContextMenuPolicy(Qt::CustomContextMenu);
ui_defense_bar = new AOImage(this, ao_app);
@@ -1638,6 +1644,11 @@ 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_auto_logging_enabled() && !ao_app->log_filename.isEmpty()) {
+ QString full = "[OOC][" + QDateTime::currentDateTime().toUTC().toString() + "] " + p_name + ": " + p_message;
+ ao_app->append_to_file(full, ao_app->log_filename, true);
+ }
}
void Courtroom::on_authentication_state_received(int p_state)
@@ -1660,7 +1671,7 @@ void Courtroom::on_chat_return_pressed()
if (is_muted)
return;
- if ((anim_state < 3 || text_state < 2) && objection_state == 0)
+ if (text_state < 2 && objection_state == 0)
return;
ui_ic_chat_message->blockSignals(true);
@@ -1987,15 +1998,6 @@ void Courtroom::chatmessage_enqueue(QStringList p_contents)
void Courtroom::chatmessage_dequeue()
{
- // Chat stopped being processed, indicate that the user can post their message now.
- QString f_custom_theme;
- if (ao_app->is_customchat_enabled()) {
- QString f_char = m_chatmessage[CHAR_NAME];
- f_custom_theme = ao_app->get_chat(f_char);
- }
- ui_vp_chat_arrow->transform_mode = ao_app->get_misc_scaling(f_custom_theme);
- ui_vp_chat_arrow->load_image("chat_arrow", f_custom_theme);
-
// Nothing to parse in the queue
if (chatmessage_queue.isEmpty())
return;
@@ -2188,8 +2190,6 @@ bool Courtroom::handle_objection()
objection_mod = m_chatmessage[OBJECTION_MOD].toInt();
}
-
-
// if an objection is used
if (objection_mod <= 4 && objection_mod >= 1) {
ui_vp_objection->set_static_duration(shout_static_time);
@@ -2233,8 +2233,10 @@ bool Courtroom::handle_objection()
filename, m_chatmessage[CHAR_NAME],
ao_app->get_chat(m_chatmessage[CHAR_NAME]));
sfx_player->clear(); // Objection played! Cut all sfx.
+ ui_vp_player_char->set_play_once(true);
return true;
}
+ if (m_chatmessage[EMOTE] != "")
display_character();
return false;
}
@@ -2393,22 +2395,31 @@ void Courtroom::handle_ic_message()
// Update the chatbox information
initialize_chatbox();
- // Display our own character
- display_character();
+ int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
+ bool immediate = m_chatmessage[IMMEDIATE].toInt() == 1;
+ if (m_chatmessage[EMOTE] != "") {
+ // Display our own character
+ display_character();
- // Reset the pair character
- ui_vp_sideplayer_char->stop();
- ui_vp_sideplayer_char->move(0, 0);
+ // Reset the pair character
+ ui_vp_sideplayer_char->stop();
+ ui_vp_sideplayer_char->move(0, 0);
- // If the emote_mod is not zooming
- int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
- if (emote_mod != 5 && emote_mod != 6) {
- // 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 != 5 && emote_mod != 6) {
+ // Display the pair character
+ display_pair_character(m_chatmessage[OTHER_CHARID], m_chatmessage[OTHER_OFFSET]);
+ }
- // Parse the emote_mod part of the chat message
- handle_emote_mod(m_chatmessage[EMOTE_MOD].toInt(), m_chatmessage[IMMEDIATE].toInt() == 1);
+ // Parse the emote_mod part of the chat message
+ handle_emote_mod(emote_mod, immediate);
+ }
+ else
+ {
+ start_chat_ticking();
+ if (emote_mod == 1 || emote_mod == 2 || emote_mod == 6 || immediate)
+ play_sfx();
+ }
// 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)
@@ -2525,7 +2536,6 @@ void Courtroom::initialize_chatbox()
if (f_charid >= 0 && f_charid < char_list.size() &&
(m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) {
QString real_name = char_list.at(f_charid).name;
- ui_vp_player_char->set_static_duration(0);
QString f_showname = ao_app->get_showname(real_name);
ui_vp_showname->setText(f_showname);
@@ -2554,19 +2564,6 @@ void Courtroom::initialize_chatbox()
if (!ui_vp_chatbox->set_image("chat", p_misc))
ui_vp_chatbox->set_image("chatbox", p_misc);
- // This should probably be called only if any change from the last chat
- // arrow was actually detected.
- pos_size_type design_ini_result = ao_app->get_element_dimensions(
- "chat_arrow", "courtroom_design.ini", p_misc);
- if (design_ini_result.width < 0 || design_ini_result.height < 0) {
- qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini";
- ui_vp_chat_arrow->hide();
- }
- else {
- ui_vp_chat_arrow->move(design_ini_result.x + ui_vp_chatbox->x(), design_ini_result.y + ui_vp_chatbox->y());
- ui_vp_chat_arrow->combo_resize(design_ini_result.width,
- design_ini_result.height);
- }
// Remember to set the showname font before the font metrics check.
set_font(ui_vp_showname, "", "showname", customchar);
@@ -2622,6 +2619,20 @@ void Courtroom::initialize_chatbox()
}
}
+ // This should probably be called only if any change from the last chat
+ // arrow was actually detected.
+ pos_size_type design_ini_result = ao_app->get_element_dimensions(
+ "chat_arrow", "courtroom_design.ini", p_misc);
+ if (design_ini_result.width < 0 || design_ini_result.height < 0) {
+ qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini";
+ ui_vp_chat_arrow->hide();
+ }
+ else {
+ ui_vp_chat_arrow->move(design_ini_result.x + ui_vp_chatbox->x(), design_ini_result.y + ui_vp_chatbox->y());
+ ui_vp_chat_arrow->combo_resize(design_ini_result.width,
+ design_ini_result.height);
+ }
+
QString font_name;
QString chatfont = ao_app->get_chat_font(m_chatmessage[CHAR_NAME]);
if (chatfont != "")
@@ -2672,8 +2683,6 @@ void Courtroom::display_evidence_image()
void Courtroom::handle_ic_speaking()
{
- // Display the evidence
- display_evidence_image();
QString side = m_chatmessage[SIDE];
int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
// emote_mod 5 is zoom and emote_mod 6 is zoom w/ preanim.
@@ -3183,6 +3192,9 @@ void Courtroom::play_preanim(bool immediate)
void Courtroom::preanim_done()
{
+ // Currently, someone's talking over us mid-preanim...
+ if (anim_state != 1 && anim_state != 4)
+ return;
anim_state = 1;
switch(m_chatmessage[DESK_MOD].toInt()) {
case 4:
@@ -3212,6 +3224,9 @@ void Courtroom::start_chat_ticking()
if (text_state != 0)
return;
+ // Display the evidence
+ display_evidence_image();
+
if (m_chatmessage[EFFECTS] != "") {
QStringList fx_list = m_chatmessage[EFFECTS].split("|");
QString fx = fx_list[0];
@@ -3243,6 +3258,10 @@ void Courtroom::start_chat_ticking()
ui_vp_chatbox->show();
ui_vp_message->show();
}
+ else {
+ ui_vp_chatbox->hide();
+ ui_vp_message->hide();
+ }
// 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();
if (delay > 0 && !text_queue_timer->isActive())
@@ -3300,26 +3319,31 @@ void Courtroom::chat_tick()
if (tick_pos >= f_message.size()) {
text_state = 2;
- if (anim_state < 3) {
- QStringList c_paths = {
- ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)" + m_chatmessage[EMOTE])),
- ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)/" + m_chatmessage[EMOTE]))
- };
- // if there is a (c) animation for this emote and we haven't played it already
- if (file_exists(ui_vp_player_char->find_image(c_paths)) &&(!c_played)) {
- anim_state = 5;
- ui_vp_player_char->set_play_once(true);
- filename = "(c)" + m_chatmessage[EMOTE];
- c_played = true;
- }
- else {
- anim_state = 3;
- ui_vp_player_char->set_play_once(false);
- filename = "(a)" + m_chatmessage[EMOTE];
+ // Check if we're a narrator msg
+ if (m_chatmessage[EMOTE] != "") {
+ if (anim_state < 3) {
+ QStringList c_paths = {
+ ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)" + m_chatmessage[EMOTE])),
+ ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)/" + m_chatmessage[EMOTE]))
+ };
+ // if there is a (c) animation for this emote and we haven't played it already
+ if (file_exists(ui_vp_player_char->find_image(c_paths)) &&(!c_played)) {
+ anim_state = 5;
+ ui_vp_player_char->set_play_once(true);
+ filename = "(c)" + m_chatmessage[EMOTE];
+ c_played = true;
+ }
+ else {
+ anim_state = 3;
+ ui_vp_player_char->set_play_once(false);
+ filename = "(a)" + m_chatmessage[EMOTE];
+ }
+ ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
+ false);
}
- ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
- false);
}
+ else // We're a narrator msg
+ anim_state = 3;
QString f_char;
QString f_custom_theme;
if (ao_app->is_customchat_enabled()) {
@@ -3362,21 +3386,8 @@ void Courtroom::chat_tick()
// Alignment characters
if (tick_pos < 2) {
- if (f_rest.startsWith("~~")) {
- tick_pos = f_rest.indexOf("~~");
- f_rest.remove(tick_pos, 2);
- tick_pos += 2;
- }
- else if (f_rest.startsWith("~>")) {
- tick_pos = f_rest.indexOf("~>");
- f_rest.remove(tick_pos, 2);
- tick_pos += 2;
- }
- else if (f_rest.startsWith("<>")) {
- tick_pos = f_rest.indexOf("<>");
- f_rest.remove(tick_pos, 2);
+ if (f_rest.startsWith("~~") || f_rest.startsWith("~>") || f_rest.startsWith("<>"))
tick_pos += 2;
- }
}
f_rest.remove(0, tick_pos);
QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_rest);
@@ -3520,28 +3531,30 @@ void Courtroom::chat_tick()
msg_delay = qMin(max_delay, msg_delay * punctuation_modifier);
}
- // If this color is talking
- if (color_is_talking && anim_state != 2 &&
- anim_state <
- 4) // Set it to talking as we're not on that already (though we have
- // to avoid interrupting a non-interrupted preanim)
- {
- ui_vp_player_char->stop();
- ui_vp_player_char->set_play_once(false);
- filename = "(b)" + m_chatmessage[EMOTE];
- ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
- false);
- anim_state = 2;
- }
- else if (!color_is_talking && anim_state < 3 &&
- anim_state != 3) // Set it to idle as we're not on that already
- {
- ui_vp_player_char->stop();
- ui_vp_player_char->set_play_once(false);
- filename = "(a)" + m_chatmessage[EMOTE];
- ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
- false);
- anim_state = 3;
+ if (m_chatmessage[EMOTE] != "") {
+ // If this color is talking
+ if (color_is_talking && anim_state != 2 &&
+ anim_state <
+ 4) // Set it to talking as we're not on that already (though we have
+ // to avoid interrupting a non-interrupted preanim)
+ {
+ ui_vp_player_char->stop();
+ ui_vp_player_char->set_play_once(false);
+ filename = "(b)" + m_chatmessage[EMOTE];
+ ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
+ false);
+ anim_state = 2;
+ }
+ else if (!color_is_talking && anim_state < 3 &&
+ anim_state != 3) // Set it to idle as we're not on that already
+ {
+ ui_vp_player_char->stop();
+ ui_vp_player_char->set_play_once(false);
+ filename = "(a)" + m_chatmessage[EMOTE];
+ ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
+ false);
+ anim_state = 3;
+ }
}
// Continue ticking
chat_tick_timer->start(msg_delay);
@@ -3892,14 +3905,8 @@ void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur,
{
if (ui_casing->isChecked()) {
ui_server_chatlog->append(msg);
- if ((ao_app->get_casing_defence_enabled() && def) ||
- (ao_app->get_casing_prosecution_enabled() && pro) ||
- (ao_app->get_casing_judge_enabled() && jud) ||
- (ao_app->get_casing_juror_enabled() && jur) ||
- (ao_app->get_casing_steno_enabled() && steno)) {
- modcall_player->play(ao_app->get_court_sfx("case_call"));
- ao_app->alert(this);
- }
+ modcall_player->play(ao_app->get_court_sfx("case_call"));
+ ao_app->alert(this);
}
}
@@ -4799,7 +4806,7 @@ void Courtroom::music_random()
QTreeWidgetItemIterator::NotHidden |
QTreeWidgetItemIterator::NoChildren);
while (*it) {
- if ((*it)->parent()->isExpanded()) {
+ if (!(*it)->parent() || (*it)->parent()->isExpanded()) { // add top level songs and songs in expanded categories
clist += (*it);
}
++it;
@@ -5259,9 +5266,8 @@ void Courtroom::on_reload_theme_clicked()
set_widgets();
update_character(m_cid);
enter_courtroom();
+ gen_char_rgb_list(ao_app->get_chat(current_char));
- anim_state = 4;
- text_state = 3;
objection_custom = "";
// to update status on the background