Clean up logic in handle_chatmessage()
This commit is contained in:
parent
079ce93b85
commit
507180d164
@ -1804,29 +1804,27 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
|
|||||||
if (f_displayname.trimmed().isEmpty())
|
if (f_displayname.trimmed().isEmpty())
|
||||||
f_displayname = ao_app->get_showname(char_list.at(f_char_id).name);
|
f_displayname = ao_app->get_showname(char_list.at(f_char_id).name);
|
||||||
|
|
||||||
QString f_message = f_displayname + ": " + m_chatmessage[MESSAGE] + '\n';
|
// Check if a custom objection is in use
|
||||||
|
int objection_mod = 0;
|
||||||
bool ok;
|
|
||||||
int objection_mod = m_chatmessage[OBJECTION_MOD].toInt(
|
|
||||||
&ok, 10); // checks if its a custom obj.
|
|
||||||
QString custom_objection = "";
|
QString custom_objection = "";
|
||||||
if (!ok && m_chatmessage[OBJECTION_MOD].contains("4&")) {
|
if (m_chatmessage[OBJECTION_MOD].contains("4&")) {
|
||||||
objection_mod = 4;
|
objection_mod = 4;
|
||||||
custom_objection = m_chatmessage[OBJECTION_MOD].split(
|
custom_objection = m_chatmessage[OBJECTION_MOD].split("4&")[1]; // takes the name of custom objection.
|
||||||
"4&")[1]; // takes the name of custom objection.
|
}
|
||||||
|
else{
|
||||||
|
objection_mod = m_chatmessage[OBJECTION_MOD].toInt();
|
||||||
}
|
}
|
||||||
// Stop the chat arrow from animating
|
|
||||||
ui_vp_chat_arrow->stop();
|
|
||||||
|
|
||||||
|
// Reset IC display
|
||||||
|
ui_vp_chat_arrow->stop();
|
||||||
text_state = 0;
|
text_state = 0;
|
||||||
anim_state = 0;
|
anim_state = 0;
|
||||||
ui_vp_objection->stop();
|
ui_vp_objection->stop();
|
||||||
chat_tick_timer->stop();
|
chat_tick_timer->stop();
|
||||||
ui_vp_evidence_display->reset();
|
ui_vp_evidence_display->reset();
|
||||||
|
|
||||||
// Hey, our message showed up! Cool!
|
// Reset UI elements after client message gets sent
|
||||||
if (m_chatmessage[MESSAGE] == ui_ic_chat_message->text().remove("\n") &&
|
if (m_chatmessage[CHAR_ID].toInt() == m_cid) {
|
||||||
m_chatmessage[CHAR_ID].toInt() == m_cid) {
|
|
||||||
ui_ic_chat_message->clear();
|
ui_ic_chat_message->clear();
|
||||||
if (ui_additive->isChecked())
|
if (ui_additive->isChecked())
|
||||||
ui_ic_chat_message->insert(" ");
|
ui_ic_chat_message->insert(" ");
|
||||||
@ -1848,12 +1846,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
|
|||||||
// Let the server handle actually checking if they're allowed to do this.
|
// Let the server handle actually checking if they're allowed to do this.
|
||||||
is_additive = m_chatmessage[ADDITIVE].toInt() == 1;
|
is_additive = m_chatmessage[ADDITIVE].toInt() == 1;
|
||||||
|
|
||||||
QString f_charname = "";
|
|
||||||
if (f_char_id >= 0)
|
|
||||||
f_charname = ao_app->get_showname(char_list.at(f_char_id).name);
|
|
||||||
|
|
||||||
chatlogpiece *temp =
|
chatlogpiece *temp =
|
||||||
new chatlogpiece(f_charname, f_displayname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt());
|
new chatlogpiece(f_displayname, f_displayname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt());
|
||||||
ic_chatlog_history.append(*temp);
|
ic_chatlog_history.append(*temp);
|
||||||
if (ao_app->get_auto_logging_enabled())
|
if (ao_app->get_auto_logging_enabled())
|
||||||
ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true);
|
ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true);
|
||||||
@ -1888,26 +1882,17 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
|
|||||||
// case 4 is AO2 only
|
// case 4 is AO2 only
|
||||||
case 4:
|
case 4:
|
||||||
if (custom_objection != "") {
|
if (custom_objection != "") {
|
||||||
ui_vp_objection->play("custom_objections/" + custom_objection, f_char,
|
ui_vp_objection->play("custom_objections/" + custom_objection, f_char, f_custom_theme, shout_stay_time);
|
||||||
f_custom_theme, shout_stay_time);
|
objection_player->play("custom_objections/" + custom_objection.split('.')[0], f_char, f_custom_theme);
|
||||||
objection_player->play("custom_objections/" +
|
|
||||||
custom_objection.split('.')[0],
|
|
||||||
f_char, f_custom_theme);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui_vp_objection->play("custom", f_char, f_custom_theme,
|
ui_vp_objection->play("custom", f_char, f_custom_theme, shout_stay_time);
|
||||||
shout_stay_time);
|
|
||||||
objection_player->play("custom", f_char, f_custom_theme);
|
objection_player->play("custom", f_char, f_custom_theme);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
m_chatmessage[EMOTE_MOD] = 1;
|
||||||
qDebug() << "W: Logic error in objection switch statement!";
|
|
||||||
}
|
}
|
||||||
sfx_player->clear(); // Objection played! Cut all sfx.
|
sfx_player->clear(); // Objection played! Cut all sfx.
|
||||||
int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
|
|
||||||
|
|
||||||
if (emote_mod == 0)
|
|
||||||
m_chatmessage[EMOTE_MOD] = 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
handle_chatmessage_2();
|
handle_chatmessage_2();
|
||||||
|
Loading…
Reference in New Issue
Block a user