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.
This commit is contained in:
		
							parent
							
								
									0032c36822
								
							
						
					
					
						commit
						29c91e63ea
					
				@ -49,7 +49,8 @@ SOURCES += main.cpp\
 | 
				
			|||||||
    aotextedit.cpp \
 | 
					    aotextedit.cpp \
 | 
				
			||||||
    aoevidencedisplay.cpp \
 | 
					    aoevidencedisplay.cpp \
 | 
				
			||||||
    discord_rich_presence.cpp \
 | 
					    discord_rich_presence.cpp \
 | 
				
			||||||
    aooptionsdialog.cpp
 | 
					    aooptionsdialog.cpp \
 | 
				
			||||||
 | 
					    chatlogpiece.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HEADERS  += lobby.h \
 | 
					HEADERS  += lobby.h \
 | 
				
			||||||
    aoimage.h \
 | 
					    aoimage.h \
 | 
				
			||||||
@ -82,7 +83,8 @@ HEADERS  += lobby.h \
 | 
				
			|||||||
    discord_rich_presence.h \
 | 
					    discord_rich_presence.h \
 | 
				
			||||||
    discord-rpc.h \
 | 
					    discord-rpc.h \
 | 
				
			||||||
    aooptionsdialog.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
 | 
					# 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
 | 
					#    AND the compilation output folder. If you want a static link, you'll probably
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										76
									
								
								chatlogpiece.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								chatlogpiece.cpp
									
									
									
									
									
										Normal file
									
								
							@ -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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										31
									
								
								chatlogpiece.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								chatlogpiece.h
									
									
									
									
									
										Normal file
									
								
							@ -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
 | 
				
			||||||
@ -1268,6 +1268,14 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
 | 
				
			|||||||
    ui_evidence_present->set_image("present_disabled.png");
 | 
					    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);
 | 
					  append_ic_text(": " + m_chatmessage[MESSAGE], f_showname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  previous_ic_message = f_message;
 | 
					  previous_ic_message = f_message;
 | 
				
			||||||
@ -2555,16 +2563,24 @@ void Courtroom::handle_song(QStringList *p_contents)
 | 
				
			|||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    QString str_char = char_list.at(n_char).name;
 | 
					    QString str_char = char_list.at(n_char).name;
 | 
				
			||||||
 | 
					    QString str_show = char_list.at(n_char).name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (p_contents->length() > 2)
 | 
					    if (p_contents->length() > 2)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      if (ui_showname_enable->isChecked())
 | 
					        str_show = p_contents->at(2);
 | 
				
			||||||
        str_char = p_contents->at(2);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!mute_map.value(n_char))
 | 
					    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);
 | 
					      music_player->play(f_song);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -2768,6 +2784,29 @@ void Courtroom::on_ooc_return_pressed()
 | 
				
			|||||||
    ui_ooc_chat_message->clear();
 | 
					    ui_ooc_chat_message->clear();
 | 
				
			||||||
    return;
 | 
					    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;
 | 
					  QStringList packet_contents;
 | 
				
			||||||
  packet_contents.append(ui_ooc_chat_name->text());
 | 
					  packet_contents.append(ui_ooc_chat_name->text());
 | 
				
			||||||
@ -3295,6 +3334,26 @@ void Courtroom::on_guard_clicked()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Courtroom::on_showname_enable_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();
 | 
					  ui_ic_chat_message->setFocus();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -18,6 +18,7 @@
 | 
				
			|||||||
#include "aotextedit.h"
 | 
					#include "aotextedit.h"
 | 
				
			||||||
#include "aoevidencedisplay.h"
 | 
					#include "aoevidencedisplay.h"
 | 
				
			||||||
#include "datatypes.h"
 | 
					#include "datatypes.h"
 | 
				
			||||||
 | 
					#include "chatlogpiece.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QMainWindow>
 | 
					#include <QMainWindow>
 | 
				
			||||||
#include <QLineEdit>
 | 
					#include <QLineEdit>
 | 
				
			||||||
@ -257,6 +258,8 @@ private:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  QSignalMapper *char_button_mapper;
 | 
					  QSignalMapper *char_button_mapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QVector<chatlogpiece> ic_chatlog_history;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // These map music row items and area row items to their actual IDs.
 | 
					  // These map music row items and area row items to their actual IDs.
 | 
				
			||||||
  QVector<int> music_row_to_number;
 | 
					  QVector<int> music_row_to_number;
 | 
				
			||||||
  QVector<int> area_row_to_number;
 | 
					  QVector<int> area_row_to_number;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user