aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCerapter <cerap@protonmail.com>2018-09-15 12:35:01 +0200
committerCerapter <cerap@protonmail.com>2018-09-15 12:35:01 +0200
commit29c91e63ea44a5e27b90fcf409ad9e4dc1f3f5c2 (patch)
tree4cf85fbb8f8c79127411fc331f2563b2f99671b0
parent0032c36822e149705efa975cd658b1661be2904d (diff)
The IC chatlog can now show both name and showname, and can be exported.
- Toggle the 'Custom shownames' tickbox to switch between real names and custom shownames. - Type `/save_chatlog` in the OOC to export your IC chatlog into a file. - Exporting the chatlog will append the date and time of the message, too.
-rw-r--r--Attorney_Online_remake.pro6
-rw-r--r--chatlogpiece.cpp76
-rw-r--r--chatlogpiece.h31
-rw-r--r--courtroom.cpp65
-rw-r--r--courtroom.h3
5 files changed, 176 insertions, 5 deletions
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro
index 71c14d9f..9e31fa09 100644
--- a/Attorney_Online_remake.pro
+++ b/Attorney_Online_remake.pro
@@ -49,7 +49,8 @@ SOURCES += main.cpp\
aotextedit.cpp \
aoevidencedisplay.cpp \
discord_rich_presence.cpp \
- aooptionsdialog.cpp
+ aooptionsdialog.cpp \
+ chatlogpiece.cpp
HEADERS += lobby.h \
aoimage.h \
@@ -82,7 +83,8 @@ HEADERS += lobby.h \
discord_rich_presence.h \
discord-rpc.h \
aooptionsdialog.h \
- text_file_functions.h
+ text_file_functions.h \
+ chatlogpiece.h
# 1. You need to get BASS and put the x86 bass DLL/headers in the project root folder
# AND the compilation output folder. If you want a static link, you'll probably
diff --git a/chatlogpiece.cpp b/chatlogpiece.cpp
new file mode 100644
index 00000000..6c861f01
--- /dev/null
+++ b/chatlogpiece.cpp
@@ -0,0 +1,76 @@
+#include "chatlogpiece.h"
+
+chatlogpiece::chatlogpiece()
+{
+ name = "UNKNOWN";
+ showname = "UNKNOWN";
+ message = "UNKNOWN";
+ is_song = false;
+ datetime = QDateTime::currentDateTime().toUTC();
+}
+
+chatlogpiece::chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song)
+{
+ name = p_name;
+ showname = p_showname;
+ message = p_message;
+ is_song = p_song;
+ datetime = QDateTime::currentDateTime().toUTC();
+}
+
+chatlogpiece::chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song, QDateTime p_datetime)
+{
+ name = p_name;
+ showname = p_showname;
+ message = p_message;
+ is_song = p_song;
+ 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;
+}
+
+bool chatlogpiece::get_is_song()
+{
+ return is_song;
+}
+
+QString chatlogpiece::get_datetime_as_string()
+{
+ return datetime.toString();
+}
+
+
+QString chatlogpiece::get_full()
+{
+ QString full = "[";
+
+ full.append(get_datetime_as_string());
+ full.append(" UTC] ");
+ full.append(get_showname());
+ full.append(" (");
+ full.append(get_name());
+ full.append(")");
+ if (is_song)
+ full.append(" has played a song: ");
+ full.append(get_message());
+
+ return full;
+}
diff --git a/chatlogpiece.h b/chatlogpiece.h
new file mode 100644
index 00000000..34c5926b
--- /dev/null
+++ b/chatlogpiece.h
@@ -0,0 +1,31 @@
+#ifndef CHATLOGPIECE_H
+#define CHATLOGPIECE_H
+
+#include <QString>
+#include <QDateTime>
+
+class chatlogpiece
+{
+public:
+ chatlogpiece();
+ chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song);
+ chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song, QDateTime p_datetime);
+
+ QString get_name();
+ QString get_showname();
+ QString get_message();
+ bool get_is_song();
+ QDateTime get_datetime();
+ QString get_datetime_as_string();
+
+ QString get_full();
+
+private:
+ QString name;
+ QString showname;
+ QString message;
+ QDateTime datetime;
+ bool is_song;
+};
+
+#endif // CHATLOGPIECE_H
diff --git a/courtroom.cpp b/courtroom.cpp
index 6c66c3f1..2eb7d94e 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -1268,6 +1268,14 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
ui_evidence_present->set_image("present_disabled.png");
}
+ chatlogpiece* temp = new chatlogpiece(ao_app->get_showname(char_list.at(f_char_id).name), f_showname, ": " + m_chatmessage[MESSAGE], false);
+ ic_chatlog_history.append(*temp);
+
+ while(ic_chatlog_history.size() > log_maximum_blocks)
+ {
+ ic_chatlog_history.removeFirst();
+ }
+
append_ic_text(": " + m_chatmessage[MESSAGE], f_showname);
previous_ic_message = f_message;
@@ -2555,16 +2563,24 @@ void Courtroom::handle_song(QStringList *p_contents)
else
{
QString str_char = char_list.at(n_char).name;
+ QString str_show = char_list.at(n_char).name;
if (p_contents->length() > 2)
{
- if (ui_showname_enable->isChecked())
- str_char = p_contents->at(2);
+ str_show = p_contents->at(2);
}
if (!mute_map.value(n_char))
{
- append_ic_songchange(f_song_clear, str_char);
+ chatlogpiece* temp = new chatlogpiece(str_char, str_show, f_song, true);
+ ic_chatlog_history.append(*temp);
+
+ while(ic_chatlog_history.size() > log_maximum_blocks)
+ {
+ ic_chatlog_history.removeFirst();
+ }
+
+ append_ic_songchange(f_song_clear, str_show);
music_player->play(f_song);
}
}
@@ -2768,6 +2784,29 @@ void Courtroom::on_ooc_return_pressed()
ui_ooc_chat_message->clear();
return;
}
+ else if (ooc_message.startsWith("/save_chatlog"))
+ {
+ QFile file("chatlog.txt");
+
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
+ {
+ append_server_chatmessage("CLIENT", "Couldn't open chatlog.txt to write into.", "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+
+ QTextStream out(&file);
+
+ foreach (chatlogpiece item, ic_chatlog_history) {
+ out << item.get_full() << '\n';
+ }
+
+ file.close();
+
+ append_server_chatmessage("CLIENT", "The IC chatlog has been saved.", "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
QStringList packet_contents;
packet_contents.append(ui_ooc_chat_name->text());
@@ -3295,6 +3334,26 @@ void Courtroom::on_guard_clicked()
void Courtroom::on_showname_enable_clicked()
{
+ ui_ic_chatlog->clear();
+ first_message_sent = false;
+
+ foreach (chatlogpiece item, ic_chatlog_history) {
+ if (ui_showname_enable->isChecked())
+ {
+ if (item.get_is_song())
+ append_ic_songchange(item.get_message(), item.get_showname());
+ else
+ append_ic_text(item.get_message(), item.get_showname());
+ }
+ else
+ {
+ if (item.get_is_song())
+ append_ic_songchange(item.get_message(), item.get_name());
+ else
+ append_ic_text(item.get_message(), item.get_name());
+ }
+ }
+
ui_ic_chat_message->setFocus();
}
diff --git a/courtroom.h b/courtroom.h
index 341d6dfd..1115e369 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -18,6 +18,7 @@
#include "aotextedit.h"
#include "aoevidencedisplay.h"
#include "datatypes.h"
+#include "chatlogpiece.h"
#include <QMainWindow>
#include <QLineEdit>
@@ -257,6 +258,8 @@ private:
QSignalMapper *char_button_mapper;
+ QVector<chatlogpiece> ic_chatlog_history;
+
// These map music row items and area row items to their actual IDs.
QVector<int> music_row_to_number;
QVector<int> area_row_to_number;