Add possibility for custom use text besides just "played music"

Implemented "presented evidence" message
This commit is contained in:
Crystalwarrior 2020-04-13 17:16:26 +03:00
parent e0ae7c0eb5
commit dfac0652c8
2 changed files with 25 additions and 10 deletions

View File

@ -221,7 +221,7 @@ public:
//adds text to the IC chatlog. p_name first as bold then p_text then a newlin //adds text to the IC chatlog. p_name first as bold then p_text then a newlin
//this function keeps the chatlog scrolled to the top unless there's text selected //this function keeps the chatlog scrolled to the top unless there's text selected
// or the user isn't already scrolled to the top // or the user isn't already scrolled to the top
void append_ic_text(QString p_text, QString p_name = "", bool is_songchange = false); void append_ic_text(QString p_text, QString p_name = "", QString action = "");
//prints who played the song to IC chat and plays said song(if found on local filesystem) //prints who played the song to IC chat and plays said song(if found on local filesystem)
//takes in a list where the first element is the song name and the second is the char id of who played it //takes in a list where the first element is the song name and the second is the char id of who played it

View File

@ -2036,13 +2036,28 @@ void Courtroom::handle_chatmessage_3()
int f_evi_id = m_chatmessage[EVIDENCE_ID].toInt(); int f_evi_id = m_chatmessage[EVIDENCE_ID].toInt();
QString f_side = m_chatmessage[SIDE]; QString f_side = m_chatmessage[SIDE];
QString f_showname;
int f_char_id = m_chatmessage[CHAR_ID].toInt();
if (f_char_id > 0 && (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked()))
{
f_showname = ao_app->get_showname(char_list.at(f_char_id).name);
}
else
{
f_showname = m_chatmessage[SHOWNAME];
}
if(f_showname.trimmed().isEmpty()) //Pure whitespace showname, get outta here.
f_showname = m_chatmessage[CHAR_NAME];
if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size()) if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size())
{ {
//shifted by 1 because 0 is no evidence per legacy standards //shifted by 1 because 0 is no evidence per legacy standards
QString f_image = local_evidence_list.at(f_evi_id - 1).image; QString f_image = local_evidence_list.at(f_evi_id - 1).image;
QString f_name = local_evidence_list.at(f_evi_id - 1).name;
//def jud and hlp should display the evidence icon on the RIGHT side //def jud and hlp should display the evidence icon on the RIGHT side
bool is_left_side = !(f_side == "def" || f_side == "hlp" || f_side == "jud" || f_side == "jur"); bool is_left_side = !(f_side == "def" || f_side == "hlp" || f_side == "jud" || f_side == "jur");
ui_vp_evidence_display->show_evidence(f_image, is_left_side, ui_sfx_slider->value()); ui_vp_evidence_display->show_evidence(f_image, is_left_side, ui_sfx_slider->value());
append_ic_text(f_name, f_showname, "has presented evidence");
} }
int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
@ -2353,7 +2368,7 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int
return p_text_escaped; return p_text_escaped;
} }
void Courtroom::append_ic_text(QString p_text, QString p_name, bool is_songchange) void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action)
{ {
QTextCharFormat bold; QTextCharFormat bold;
QTextCharFormat normal; QTextCharFormat normal;
@ -2364,7 +2379,7 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, bool is_songchang
const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
if (!is_songchange) if (p_action == "")
p_text = filter_ic_text(p_text, ao_app->is_colorlog_enabled(), -1, m_chatmessage[TEXT_COLOR].toInt()); p_text = filter_ic_text(p_text, ao_app->is_colorlog_enabled(), -1, m_chatmessage[TEXT_COLOR].toInt());
if (log_goes_downwards) if (log_goes_downwards)
@ -2383,9 +2398,9 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, bool is_songchang
ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold); ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold);
} }
if (is_songchange) if (p_action != "")
{ {
ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal); ui_ic_chatlog->textCursor().insertText(" " + p_action + ": ", normal);
ui_ic_chatlog->textCursor().insertText(p_text + ".", italics); ui_ic_chatlog->textCursor().insertText(p_text + ".", italics);
} }
else else
@ -2424,9 +2439,9 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, bool is_songchang
ui_ic_chatlog->textCursor().insertText(p_name, bold); ui_ic_chatlog->textCursor().insertText(p_name, bold);
if (is_songchange) if (p_action != "")
{ {
ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal); ui_ic_chatlog->textCursor().insertText(" " + p_action + ": ", normal);
ui_ic_chatlog->textCursor().insertText(p_text + "." + '\n', italics); ui_ic_chatlog->textCursor().insertText(p_text + "." + '\n', italics);
} }
else else
@ -2956,7 +2971,7 @@ void Courtroom::handle_song(QStringList *p_contents)
ic_chatlog_history.removeFirst(); ic_chatlog_history.removeFirst();
} }
append_ic_text(f_song_clear, str_show, true); append_ic_text(f_song_clear, str_show, "has played a song");
music_player->play(f_song, channel, looping, effect_flags); music_player->play(f_song, channel, looping, effect_flags);
if (channel == 0) if (channel == 0)
@ -4399,14 +4414,14 @@ void Courtroom::on_showname_enable_clicked()
if (ui_showname_enable->isChecked()) if (ui_showname_enable->isChecked())
{ {
if (item.is_song()) if (item.is_song())
append_ic_text(item.get_message(), item.get_showname(), true); append_ic_text(item.get_message(), item.get_showname(), "has played a song");
else else
append_ic_text(item.get_message(), item.get_showname()); append_ic_text(item.get_message(), item.get_showname());
} }
else else
{ {
if (item.is_song()) if (item.is_song())
append_ic_text(item.get_message(), item.get_name(), true); append_ic_text(item.get_message(), item.get_name(), "has played a song");
else else
append_ic_text(item.get_message(), item.get_name()); append_ic_text(item.get_message(), item.get_name());
} }