aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwindrammer <31085911+likeawindrammer@users.noreply.github.com>2020-07-29 16:08:39 -0600
committerGitHub <noreply@github.com>2020-07-29 17:08:39 -0500
commitfc9fe6b34b98dfc3a3b3aa3e342a638019071f45 (patch)
tree95dffc3a3fbf695166b7f44143328bf256cfc16a
parent58180371efb781c247304452cd282b853dc97dad (diff)
Fix colors not persisting when refreshing IC log (#204)
Co-authored-by: Cents02 <Cents02@Cents0.me>
-rw-r--r--include/chatlogpiece.h7
-rw-r--r--include/courtroom.h2
-rw-r--r--src/chatlogpiece.cpp10
-rw-r--r--src/courtroom.cpp14
4 files changed, 20 insertions, 13 deletions
diff --git a/include/chatlogpiece.h b/include/chatlogpiece.h
index f3a9dc8b..14d4b349 100644
--- a/include/chatlogpiece.h
+++ b/include/chatlogpiece.h
@@ -10,9 +10,9 @@ class chatlogpiece {
public:
chatlogpiece();
chatlogpiece(QString p_name, QString p_showname, QString p_message,
- bool p_song);
+ bool p_song,int color);
chatlogpiece(QString p_name, QString p_showname, QString p_message,
- bool p_song, QDateTime p_datetime);
+ bool p_song, int color, QDateTime p_datetime);
QString get_name();
QString get_showname();
@@ -20,7 +20,7 @@ public:
bool is_song();
QDateTime get_datetime();
QString get_datetime_as_string();
-
+ int get_chat_color();
QString get_full();
private:
@@ -28,6 +28,7 @@ private:
QString showname;
QString message;
QDateTime datetime;
+ int color;
bool p_is_song;
};
diff --git a/include/courtroom.h b/include/courtroom.h
index ee682ba8..1862c772 100644
--- a/include/courtroom.h
+++ b/include/courtroom.h
@@ -221,7 +221,7 @@ public:
// 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 = "");
+ void append_ic_text(QString p_text, QString p_name = "", QString action = "", int color = 0);
// 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
diff --git a/src/chatlogpiece.cpp b/src/chatlogpiece.cpp
index ec964b91..2a041f13 100644
--- a/src/chatlogpiece.cpp
+++ b/src/chatlogpiece.cpp
@@ -5,27 +5,31 @@ chatlogpiece::chatlogpiece()
name = tr("UNKNOWN");
showname = tr("UNKNOWN");
message = tr("UNKNOWN");
+ color = 0;
p_is_song = false;
datetime = QDateTime::currentDateTime().toUTC();
}
chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
- QString p_message, bool p_song)
+ QString p_message, bool p_song, int p_color)
{
name = p_name;
showname = p_showname;
message = p_message;
p_is_song = p_song;
+ color = p_color;
datetime = QDateTime::currentDateTime().toUTC();
}
chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
- QString p_message, bool p_song, QDateTime p_datetime)
+ QString p_message, bool p_song, int p_color,
+ QDateTime p_datetime)
{
name = p_name;
showname = p_showname;
message = p_message;
p_is_song = p_song;
+ color = p_color;
datetime = p_datetime.toUTC();
}
@@ -41,6 +45,8 @@ bool chatlogpiece::is_song() { return p_is_song; }
QString chatlogpiece::get_datetime_as_string() { return datetime.toString(); }
+int chatlogpiece::get_chat_color() { return color; }
+
QString chatlogpiece::get_full()
{
QString full = "[";
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 0991a52a..2e2f2a5a 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -1787,7 +1787,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
f_charname = ao_app->get_showname(char_list.at(f_char_id).name);
chatlogpiece *temp =
- new chatlogpiece(f_charname, f_showname, m_chatmessage[MESSAGE], false);
+ new chatlogpiece(f_charname, f_showname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt());
ic_chatlog_history.append(*temp);
ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true);
@@ -1796,7 +1796,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
ic_chatlog_history.removeFirst();
}
- append_ic_text(m_chatmessage[MESSAGE], f_showname);
+ append_ic_text(m_chatmessage[MESSAGE], f_showname, "", m_chatmessage[TEXT_COLOR].toInt());
int objection_mod = m_chatmessage[OBJECTION_MOD].toInt();
QString f_char = m_chatmessage[CHAR_NAME];
@@ -2482,7 +2482,7 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
return p_text_escaped;
}
-void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action)
+void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, int color)
{
QTextCharFormat bold;
QTextCharFormat normal;
@@ -2495,7 +2495,7 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action)
if (p_action == "")
p_text = filter_ic_text(p_text, ao_app->is_colorlog_enabled(), -1,
- m_chatmessage[TEXT_COLOR].toInt());
+ color);
if (log_goes_downwards) {
const bool is_scrolled_down =
@@ -3080,7 +3080,7 @@ void Courtroom::handle_song(QStringList *p_contents)
}
if (!mute_map.value(n_char)) {
- chatlogpiece *temp = new chatlogpiece(str_char, str_show, f_song, true);
+ chatlogpiece *temp = new chatlogpiece(str_char, str_show, f_song, true, m_chatmessage[TEXT_COLOR].toInt());
ic_chatlog_history.append(*temp);
ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true);
@@ -4516,14 +4516,14 @@ void Courtroom::on_showname_enable_clicked()
append_ic_text(item.get_message(), item.get_showname(),
tr("has played a song"));
else
- append_ic_text(item.get_message(), item.get_showname());
+ append_ic_text(item.get_message(), item.get_showname(), "", item.get_chat_color());
}
else {
if (item.is_song())
append_ic_text(item.get_message(), item.get_name(),
tr("has played a song"));
else
- append_ic_text(item.get_message(), item.get_name());
+ append_ic_text(item.get_message(), item.get_name(), "", item.get_chat_color());
}
}