Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions include/chatlogpiece.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@ class chatlogpiece {
public:
chatlogpiece();
chatlogpiece(QString p_name, QString p_showname, QString p_message,
QString p_action,int color);
QString p_action,int color, bool selfname);
chatlogpiece(QString p_name, QString p_showname, QString p_message,
QString p_action, int color, QDateTime p_datetime);
QString p_action, int color, bool selfname, QDateTime p_datetime);

QString get_name();
QString get_showname();
QString get_message();
QString get_action();
QDateTime get_datetime();
QString get_datetime_as_string();
int get_chat_color();
QString get_name() { return name; };
QString get_showname() { return showname; };
QString get_message() { return message; };
QString get_action() { return action; };
bool get_selfname() const { return selfname; };
QDateTime get_datetime() { return datetime; };
QString get_datetime_as_string() { return datetime.toString(); };
int get_chat_color() const { return color; };
QString get_full();

private:
QString name;
QString showname;
QString message;
QString action;
bool selfname;
QDateTime datetime;
int color;
};
Expand Down
4 changes: 2 additions & 2 deletions include/courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,14 @@ class Courtroom : public QMainWindow {
int default_color = 0);

void log_ic_text(QString p_name, QString p_showname, QString p_message,
QString p_action = "", int p_color = 0);
QString p_action = "", int p_color = 0, bool p_selfname = false);

// 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
// or the user isn't already scrolled to the top
void append_ic_text(QString p_text, QString p_name = "", QString action = "",
int color = 0, QDateTime timestamp = QDateTime::currentDateTime());
int color = 0, bool selfname = false, QDateTime timestamp = QDateTime::currentDateTime());

// 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
Expand Down
20 changes: 4 additions & 16 deletions src/chatlogpiece.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,30 @@ chatlogpiece::chatlogpiece()
}

chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
QString p_message, QString p_action, int p_color)
QString p_message, QString p_action, int p_color, bool p_selfname)
{
name = p_name;
showname = p_showname;
message = p_message;
action = p_action;
color = p_color;
selfname = p_selfname;
datetime = QDateTime::currentDateTimeUtc();
}

chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
QString p_message, QString p_action, int p_color,
QString p_message, QString p_action, int p_color, bool p_selfname,
QDateTime p_datetime)
{
name = p_name;
showname = p_showname;
message = p_message;
action = p_action;
color = p_color;
selfname = p_selfname;
datetime = p_datetime.toUTC();
}

QString chatlogpiece::get_name() { return name; }

QString chatlogpiece::get_showname() { return showname; }

QString chatlogpiece::get_message() { return message; }

QDateTime chatlogpiece::get_datetime() { return datetime; }

QString chatlogpiece::get_action() { return action; }

QString chatlogpiece::get_datetime_as_string() { return datetime.toString(); }

int chatlogpiece::get_chat_color() { return color; }

QString chatlogpiece::get_full()
{
QString full = "[";
Expand Down
46 changes: 28 additions & 18 deletions src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2201,6 +2201,8 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show
if (f_displayname.trimmed().isEmpty())
f_displayname = f_showname;

bool selfname = f_char_id == m_cid;

if (log_ic_actions) {
// Check if a custom objection is in use
int objection_mod = 0;
Expand Down Expand Up @@ -2249,13 +2251,13 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show
}
switch (f_log_mode) {
case IO_ONLY:
log_ic_text(f_char, f_displayname, shout_message, tr("shouts"));
log_ic_text(f_char, f_displayname, shout_message, tr("shouts"), 0, selfname);
break;
case DISPLAY_AND_IO:
log_ic_text(f_char, f_displayname, shout_message, tr("shouts"));
log_ic_text(f_char, f_displayname, shout_message, tr("shouts"), 0, selfname);
[[fallthrough]];
case DISPLAY_ONLY:
append_ic_text(shout_message, f_displayname, tr("shouts"));
append_ic_text(shout_message, f_displayname, tr("shouts"), 0, selfname);
break;
}
}
Expand All @@ -2266,13 +2268,13 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show
QString f_evi_name = local_evidence_list.at(f_evi_id - 1).name;
switch (f_log_mode) {
case IO_ONLY:
log_ic_text(f_showname, f_displayname, f_evi_name, tr("has presented evidence"));
log_ic_text(f_showname, f_displayname, f_evi_name, tr("has presented evidence"), 0, selfname);
break;
case DISPLAY_AND_IO:
log_ic_text(f_showname, f_displayname, f_evi_name, tr("has presented evidence"));
log_ic_text(f_showname, f_displayname, f_evi_name, tr("has presented evidence"), 0, selfname);
[[fallthrough]];
case DISPLAY_ONLY:
append_ic_text(f_evi_name, f_displayname, tr("has presented evidence"));
append_ic_text(f_evi_name, f_displayname, tr("has presented evidence"), 0, selfname);
break;
}
}
Expand All @@ -2286,13 +2288,13 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show
return; // Skip adding message
switch (f_log_mode) {
case IO_ONLY:
log_ic_text(f_showname, f_displayname, f_message, "",f_color);
log_ic_text(f_showname, f_displayname, f_message, "", f_color, selfname);
break;
case DISPLAY_AND_IO:
log_ic_text(f_showname, f_displayname, f_message, "",f_color);
log_ic_text(f_showname, f_displayname, f_message, "", f_color, selfname);
[[fallthrough]];
case DISPLAY_ONLY:
append_ic_text(f_message, f_displayname, "",f_color);
append_ic_text(f_message, f_displayname, "", f_color, selfname);
break;
}
if (!ui_showname_enable->isChecked())
Expand Down Expand Up @@ -3100,9 +3102,9 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
}

void Courtroom::log_ic_text(QString p_name, QString p_showname,
QString p_message, QString p_action, int p_color)
QString p_message, QString p_action, int p_color, bool p_selfname)
{
chatlogpiece log_entry(p_name, p_showname, p_message, p_action, p_color);
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())
ao_app->append_to_file(log_entry.get_full(), ao_app->log_filename, true);
Expand All @@ -3114,16 +3116,22 @@ void Courtroom::log_ic_text(QString p_name, QString p_showname,
}

void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
int color, QDateTime timestamp)
int color, bool selfname, QDateTime timestamp)
{
last_ic_message = p_name + ":" + p_text;
QTextCharFormat bold;
QTextCharFormat normal;
QTextCharFormat italics;
QTextCharFormat own_name;
QTextCharFormat other_name;
QTextBlockFormat format;
bold.setFontWeight(QFont::Bold);
normal.setFontWeight(QFont::Normal);
italics.setFontItalic(true);
own_name.setFontWeight(QFont::Bold);
own_name.setForeground(ao_app->get_color("ic_chatlog_selfname_color", "courtroom_fonts.ini"));
other_name.setFontWeight(QFont::Bold);
other_name.setForeground(ao_app->get_color("ic_chatlog_showname_color", "courtroom_fonts.ini"));
format.setTopMargin(log_margin);
const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
Expand Down Expand Up @@ -3151,7 +3159,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
}

// Format the name of the actor
ui_ic_chatlog->textCursor().insertText(p_name, bold);
QTextCharFormat name_format = selfname ? own_name : other_name;
ui_ic_chatlog->textCursor().insertText(p_name, name_format);
// Special case for stopping the music
if (p_action == tr("has stopped the music")) {
ui_ic_chatlog->textCursor().insertText(" " + p_action + ".", normal);
Expand Down Expand Up @@ -3862,13 +3871,14 @@ void Courtroom::handle_song(QStringList *p_contents)
}
}
if (!mute_map.value(n_char)) {
bool selfname = n_char == m_cid;
if (is_stop) {
log_ic_text(str_char, str_show, "", tr("has stopped the music"));
append_ic_text("", str_show, tr("has stopped the music"));
log_ic_text(str_char, str_show, "", tr("has stopped the music"), 0, selfname);
append_ic_text("", str_show, tr("has stopped the music"), 0, selfname);
}
else {
log_ic_text(str_char, str_show, f_song, tr("has played a song"));
append_ic_text(f_song_clear, str_show, tr("has played a song"));
log_ic_text(str_char, str_show, f_song, tr("has played a song"), 0, selfname);
append_ic_text(f_song_clear, str_show, tr("has played a song"), 0, selfname);
}
}
}
Expand Down Expand Up @@ -5336,7 +5346,7 @@ void Courtroom::regenerate_ic_chatlog()
append_ic_text(message,
name,
item.get_action(), item.get_chat_color(),
item.get_datetime().toLocalTime());
item.get_selfname(), item.get_datetime().toLocalTime());
}
}

Expand Down