Add showname and selfname colors to courtroom_fonts.ini (#672)
Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									aa2a29f091
								
							
						
					
					
						commit
						35fcbdeea8
					
				@ -10,17 +10,18 @@ class chatlogpiece {
 | 
				
			|||||||
public:
 | 
					public:
 | 
				
			||||||
  chatlogpiece();
 | 
					  chatlogpiece();
 | 
				
			||||||
  chatlogpiece(QString p_name, QString p_showname, QString p_message,
 | 
					  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,
 | 
					  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_name() { return name; };
 | 
				
			||||||
  QString get_showname();
 | 
					  QString get_showname() { return showname; };
 | 
				
			||||||
  QString get_message();
 | 
					  QString get_message() { return message; };
 | 
				
			||||||
  QString get_action();
 | 
					  QString get_action() { return action; };
 | 
				
			||||||
  QDateTime get_datetime();
 | 
					  bool get_selfname() const { return selfname; };
 | 
				
			||||||
  QString get_datetime_as_string();
 | 
					  QDateTime get_datetime() { return datetime; };
 | 
				
			||||||
  int get_chat_color();
 | 
					  QString get_datetime_as_string() { return datetime.toString(); };
 | 
				
			||||||
 | 
					  int get_chat_color() const { return color; };
 | 
				
			||||||
  QString get_full();
 | 
					  QString get_full();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
@ -28,6 +29,7 @@ private:
 | 
				
			|||||||
  QString showname;
 | 
					  QString showname;
 | 
				
			||||||
  QString message;
 | 
					  QString message;
 | 
				
			||||||
  QString action;
 | 
					  QString action;
 | 
				
			||||||
 | 
					  bool selfname;
 | 
				
			||||||
  QDateTime datetime;
 | 
					  QDateTime datetime;
 | 
				
			||||||
  int color;
 | 
					  int color;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -279,14 +279,14 @@ public:
 | 
				
			|||||||
                         int default_color = 0);
 | 
					                         int default_color = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void log_ic_text(QString p_name, QString p_showname, QString p_message,
 | 
					  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
 | 
					  // 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
 | 
					  // this function keeps the chatlog scrolled to the top unless there's text
 | 
				
			||||||
  // selected
 | 
					  // 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 = "", QString action = "",
 | 
					  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
 | 
					  // 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
 | 
					  // filesystem) takes in a list where the first element is the song name and
 | 
				
			||||||
 | 
				
			|||||||
@ -11,18 +11,19 @@ chatlogpiece::chatlogpiece()
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
 | 
					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;
 | 
					  name = p_name;
 | 
				
			||||||
  showname = p_showname;
 | 
					  showname = p_showname;
 | 
				
			||||||
  message = p_message;
 | 
					  message = p_message;
 | 
				
			||||||
  action = p_action;
 | 
					  action = p_action;
 | 
				
			||||||
  color = p_color;
 | 
					  color = p_color;
 | 
				
			||||||
 | 
					  selfname = p_selfname;
 | 
				
			||||||
  datetime = QDateTime::currentDateTimeUtc();
 | 
					  datetime = QDateTime::currentDateTimeUtc();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
 | 
					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)
 | 
					                           QDateTime p_datetime)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  name = p_name;
 | 
					  name = p_name;
 | 
				
			||||||
@ -30,23 +31,10 @@ chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
 | 
				
			|||||||
  message = p_message;
 | 
					  message = p_message;
 | 
				
			||||||
  action = p_action;
 | 
					  action = p_action;
 | 
				
			||||||
  color = p_color;
 | 
					  color = p_color;
 | 
				
			||||||
 | 
					  selfname = p_selfname;
 | 
				
			||||||
  datetime = p_datetime.toUTC();
 | 
					  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 chatlogpiece::get_full()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  QString full = "[";
 | 
					  QString full = "[";
 | 
				
			||||||
 | 
				
			|||||||
@ -2206,6 +2206,8 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show
 | 
				
			|||||||
  if (f_displayname.trimmed().isEmpty())
 | 
					  if (f_displayname.trimmed().isEmpty())
 | 
				
			||||||
    f_displayname = f_showname;
 | 
					    f_displayname = f_showname;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool selfname = f_char_id == m_cid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (log_ic_actions) {
 | 
					  if (log_ic_actions) {
 | 
				
			||||||
    // Check if a custom objection is in use
 | 
					    // Check if a custom objection is in use
 | 
				
			||||||
    int objection_mod = 0;
 | 
					    int objection_mod = 0;
 | 
				
			||||||
@ -2254,13 +2256,13 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      switch (f_log_mode) {
 | 
					      switch (f_log_mode) {
 | 
				
			||||||
        case IO_ONLY:
 | 
					        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;
 | 
					          break;
 | 
				
			||||||
        case DISPLAY_AND_IO:
 | 
					        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]];
 | 
					          [[fallthrough]];
 | 
				
			||||||
        case DISPLAY_ONLY:
 | 
					        case DISPLAY_ONLY:
 | 
				
			||||||
          append_ic_text(shout_message, f_displayname, tr("shouts"));
 | 
					          append_ic_text(shout_message, f_displayname, tr("shouts"), 0, selfname);
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -2271,13 +2273,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;
 | 
					      QString f_evi_name = local_evidence_list.at(f_evi_id - 1).name;
 | 
				
			||||||
      switch (f_log_mode) {
 | 
					      switch (f_log_mode) {
 | 
				
			||||||
        case IO_ONLY:
 | 
					        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;
 | 
					          break;
 | 
				
			||||||
        case DISPLAY_AND_IO:
 | 
					        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]];
 | 
					          [[fallthrough]];
 | 
				
			||||||
        case DISPLAY_ONLY:
 | 
					        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;
 | 
					          break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -2291,13 +2293,13 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show
 | 
				
			|||||||
    return; // Skip adding message
 | 
					    return; // Skip adding message
 | 
				
			||||||
  switch (f_log_mode) {
 | 
					  switch (f_log_mode) {
 | 
				
			||||||
    case IO_ONLY:
 | 
					    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;
 | 
					      break;
 | 
				
			||||||
    case DISPLAY_AND_IO:
 | 
					    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]];
 | 
					      [[fallthrough]];
 | 
				
			||||||
    case DISPLAY_ONLY:
 | 
					    case DISPLAY_ONLY:
 | 
				
			||||||
      append_ic_text(f_message, f_displayname, "",f_color);
 | 
					      append_ic_text(f_message, f_displayname, "", f_color, selfname);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (!ui_showname_enable->isChecked())
 | 
					  if (!ui_showname_enable->isChecked())
 | 
				
			||||||
@ -3105,9 +3107,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,
 | 
					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);
 | 
					  ic_chatlog_history.append(log_entry);
 | 
				
			||||||
  if (ao_app->get_text_logging_enabled() && !ao_app->log_filename.isEmpty())
 | 
					  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);
 | 
					    ao_app->append_to_file(log_entry.get_full(), ao_app->log_filename, true);
 | 
				
			||||||
@ -3119,16 +3121,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,
 | 
					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;
 | 
					  last_ic_message = p_name + ":" + p_text;
 | 
				
			||||||
  QTextCharFormat bold;
 | 
					  QTextCharFormat bold;
 | 
				
			||||||
  QTextCharFormat normal;
 | 
					  QTextCharFormat normal;
 | 
				
			||||||
  QTextCharFormat italics;
 | 
					  QTextCharFormat italics;
 | 
				
			||||||
 | 
					  QTextCharFormat own_name;
 | 
				
			||||||
 | 
					  QTextCharFormat other_name;
 | 
				
			||||||
  QTextBlockFormat format;
 | 
					  QTextBlockFormat format;
 | 
				
			||||||
  bold.setFontWeight(QFont::Bold);
 | 
					  bold.setFontWeight(QFont::Bold);
 | 
				
			||||||
  normal.setFontWeight(QFont::Normal);
 | 
					  normal.setFontWeight(QFont::Normal);
 | 
				
			||||||
  italics.setFontItalic(true);
 | 
					  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);
 | 
					  format.setTopMargin(log_margin);
 | 
				
			||||||
  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();
 | 
				
			||||||
@ -3156,7 +3164,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Format the name of the actor
 | 
					  // 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
 | 
					  // Special case for stopping the music
 | 
				
			||||||
  if (p_action == tr("has stopped the music")) {
 | 
					  if (p_action == tr("has stopped the music")) {
 | 
				
			||||||
    ui_ic_chatlog->textCursor().insertText(" " + p_action + ".", normal);
 | 
					    ui_ic_chatlog->textCursor().insertText(" " + p_action + ".", normal);
 | 
				
			||||||
@ -3885,13 +3894,14 @@ void Courtroom::handle_song(QStringList *p_contents)
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!mute_map.value(n_char)) {
 | 
					    if (!mute_map.value(n_char)) {
 | 
				
			||||||
 | 
					      bool selfname = n_char == m_cid;
 | 
				
			||||||
      if (is_stop) {
 | 
					      if (is_stop) {
 | 
				
			||||||
        log_ic_text(str_char, 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"));
 | 
					        append_ic_text("", str_show, tr("has stopped the music"), 0, selfname);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else {
 | 
					      else {
 | 
				
			||||||
        log_ic_text(str_char, str_show, f_song, 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"));
 | 
					        append_ic_text(f_song_clear, str_show, tr("has played a song"), 0, selfname);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -5367,7 +5377,7 @@ void Courtroom::regenerate_ic_chatlog()
 | 
				
			|||||||
    append_ic_text(message,
 | 
					    append_ic_text(message,
 | 
				
			||||||
                   name,
 | 
					                   name,
 | 
				
			||||||
                   item.get_action(), item.get_chat_color(),
 | 
					                   item.get_action(), item.get_chat_color(),
 | 
				
			||||||
                   item.get_datetime().toLocalTime());
 | 
					                   item.get_selfname(), item.get_datetime().toLocalTime());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user