Skip to content

Commit 6605e57

Browse files
committed
Merge remote-tracking branch 'vanilla/master' into feature/ms_json
2 parents b315e9b + a8156ed commit 6605e57

File tree

3 files changed

+24
-42
lines changed

3 files changed

+24
-42
lines changed

src/courtroom.cpp

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app)
129129
log_timestamp = Options::getInstance().logTimestampEnabled();
130130
log_timestamp_format = Options::getInstance().logTimestampFormat();
131131

132+
custom_shownames = Options::getInstance().customShownameEnabled();
133+
132134
ui_debug_log = new AOTextArea(Options::getInstance().maxLogSize(), this);
133135
ui_debug_log->setReadOnly(true);
134136
ui_debug_log->setOpenExternalLinks(true);
@@ -321,11 +323,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app)
321323
ui_additive->hide();
322324
ui_additive->setObjectName("ui_additive");
323325

324-
ui_showname_enable = new QCheckBox(this);
325-
ui_showname_enable->setChecked(Options::getInstance().customShownameEnabled());
326-
ui_showname_enable->setText(tr("Shownames"));
327-
ui_showname_enable->setObjectName("ui_showname_enable");
328-
329326
ui_slide_enable = new QCheckBox(this);
330327
ui_slide_enable->setChecked(false);
331328
ui_slide_enable->setText(tr("Slide"));
@@ -508,8 +505,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app)
508505
connect(ui_guard, &AOButton::clicked, this, &Courtroom::focus_ic_input);
509506
connect(ui_slide_enable, &AOButton::clicked, this, &Courtroom::focus_ic_input);
510507

511-
connect(ui_showname_enable, &AOButton::clicked, this, &Courtroom::on_showname_enable_clicked);
512-
513508
connect(ui_pair_button, &AOButton::clicked, this, &Courtroom::on_pair_clicked);
514509
connect(ui_pair_list, &QListWidget::clicked, this, &Courtroom::on_pair_list_clicked);
515510
connect(ui_pair_offset_spinbox, QOverload<int>::of(&QSpinBox::valueChanged), this, &Courtroom::on_pair_offset_changed);
@@ -751,15 +746,13 @@ void Courtroom::set_widgets()
751746
{
752747
ui_pair_button->show();
753748
ui_immediate->show();
754-
ui_showname_enable->show();
755749
ui_ic_chat_name->show();
756750
ui_ic_chat_name->setEnabled(true);
757751
}
758752
else
759753
{
760754
ui_pair_button->hide();
761755
ui_immediate->hide();
762-
ui_showname_enable->hide();
763756
ui_ic_chat_name->hide();
764757
ui_ic_chat_name->setEnabled(false);
765758
}
@@ -815,13 +808,15 @@ void Courtroom::set_widgets()
815808

816809
log_maximum_blocks = Options::getInstance().maxLogSize();
817810

818-
bool regenerate = log_goes_downwards != Options::getInstance().logDirectionDownwards() || log_colors != Options::getInstance().colorLogEnabled() || log_newline != Options::getInstance().logNewline() || log_margin != Options::getInstance().logMargin() || log_timestamp != Options::getInstance().logTimestampEnabled() || log_timestamp_format != Options::getInstance().logTimestampFormat();
811+
bool regenerate = log_goes_downwards != Options::getInstance().logDirectionDownwards() || log_colors != Options::getInstance().colorLogEnabled() || log_newline != Options::getInstance().logNewline() || log_margin != Options::getInstance().logMargin() || log_timestamp != Options::getInstance().logTimestampEnabled() || log_timestamp_format != Options::getInstance().logTimestampFormat() || custom_shownames != Options::getInstance().customShownameEnabled();
819812
log_goes_downwards = Options::getInstance().logDirectionDownwards();
820813
log_colors = Options::getInstance().colorLogEnabled();
821814
log_newline = Options::getInstance().logNewline();
822815
log_margin = Options::getInstance().logMargin();
823816
log_timestamp = Options::getInstance().logTimestampEnabled();
824817
log_timestamp_format = Options::getInstance().logTimestampFormat();
818+
819+
custom_shownames = Options::getInstance().customShownameEnabled();
825820
if (regenerate)
826821
{
827822
regenerate_ic_chatlog();
@@ -1096,9 +1091,6 @@ void Courtroom::set_widgets()
10961091
ui_guard->setToolTip(tr("Do not listen to mod calls when checked, preventing them from "
10971092
"playing sounds or focusing attention on the window."));
10981093

1099-
set_size_and_pos(ui_showname_enable, "showname_enable");
1100-
ui_showname_enable->setToolTip(tr("Display customized shownames for all users when checked."));
1101-
11021094
set_size_and_pos(ui_slide_enable, "slide_enable");
11031095
ui_slide_enable->setToolTip(tr("Allow your messages to trigger slide animations when checked."));
11041096
ui_slide_enable->show();
@@ -1173,7 +1165,6 @@ void Courtroom::set_widgets()
11731165
truncate_label_text(ui_guard, "guard");
11741166
truncate_label_text(ui_pre, "pre");
11751167
truncate_label_text(ui_flip, "flip");
1176-
truncate_label_text(ui_showname_enable, "showname_enable");
11771168
truncate_label_text(ui_slide_enable, "slide_enable");
11781169

11791170
// QLabel
@@ -2505,15 +2496,15 @@ void Courtroom::log_chatmessage(const ms2::OldMSFlatData &f_message, LogMode f_l
25052496
break;
25062497
case DISPLAY_AND_IO:
25072498
log_ic_text(f_message.m_char_name, l_displayedName, shout_message, tr("shouts"));
2508-
append_ic_text(shout_message, l_displayedName, tr("shouts"), 0, selfname, QDateTime::currentDateTime(), false);
2499+
append_ic_text(shout_message, l_displayedName, f_message.m_char_name, tr("shouts"), 0, selfname, QDateTime::currentDateTime(), false);
25092500
break;
25102501
case DISPLAY_ONLY:
25112502
case QUEUED:
25122503
if (!ghost && sender)
25132504
{
25142505
pop_ic_ghost();
25152506
}
2516-
append_ic_text(shout_message, l_displayedName, tr("shouts"), 0, selfname, QDateTime::currentDateTime(), ghost);
2507+
append_ic_text(shout_message, l_displayedName, f_message.m_char_name, tr("shouts"), 0, selfname, QDateTime::currentDateTime(), ghost);
25172508
break;
25182509
}
25192510
}
@@ -2531,15 +2522,15 @@ void Courtroom::log_chatmessage(const ms2::OldMSFlatData &f_message, LogMode f_l
25312522
break;
25322523
case DISPLAY_AND_IO:
25332524
log_ic_text(f_message.m_char_name, l_displayedName, f_evi_name, tr("has presented evidence"));
2534-
append_ic_text(f_evi_name, l_displayedName, tr("has presented evidence"), 0, selfname, QDateTime::currentDateTime(), false);
2525+
append_ic_text(f_evi_name, l_displayedName, f_message.m_char_name, tr("has presented evidence"), 0, selfname, QDateTime::currentDateTime(), false);
25352526
break;
25362527
case DISPLAY_ONLY:
25372528
case QUEUED:
25382529
if (!ghost && sender)
25392530
{
25402531
pop_ic_ghost();
25412532
}
2542-
append_ic_text(f_evi_name, l_displayedName, tr("has presented evidence"), 0, selfname, QDateTime::currentDateTime(), ghost);
2533+
append_ic_text(f_evi_name, l_displayedName, f_message.m_char_name, tr("has presented evidence"), 0, selfname, QDateTime::currentDateTime(), ghost);
25432534
break;
25442535
}
25452536
}
@@ -2563,15 +2554,15 @@ void Courtroom::log_chatmessage(const ms2::OldMSFlatData &f_message, LogMode f_l
25632554
break;
25642555
case DISPLAY_AND_IO:
25652556
log_ic_text(f_message.m_char_name, l_displayedName, f_message.m_message_text, "", f_message.m_text_colour, selfname);
2566-
append_ic_text(f_message.m_message_text, l_displayedName, "", f_message.m_text_colour, selfname, QDateTime::currentDateTime(), false);
2557+
append_ic_text(f_message.m_message_text, l_displayedName, f_message.m_char_name, "", f_message.m_text_colour, selfname, QDateTime::currentDateTime(), false);
25672558
break;
25682559
case DISPLAY_ONLY:
25692560
case QUEUED:
25702561
if (!ghost && sender)
25712562
{
25722563
pop_ic_ghost();
25732564
}
2574-
append_ic_text(f_message.m_message_text, l_displayedName, "", f_message.m_text_colour, selfname, QDateTime::currentDateTime(), ghost);
2565+
append_ic_text(f_message.m_message_text, l_displayedName, f_message.m_char_name, "", f_message.m_text_colour, selfname, QDateTime::currentDateTime(), ghost);
25752566
break;
25762567
}
25772568
}
@@ -3083,7 +3074,7 @@ void Courtroom::play_char_sfx(QString sfx_name)
30833074

30843075
void Courtroom::initialize_chatbox()
30853076
{
3086-
if (m_chatmessage.m_char_id >= 0 && m_chatmessage.m_char_id < char_list.size() && (m_chatmessage.m_showname.isEmpty() || !ui_showname_enable->isChecked()))
3077+
if (m_chatmessage.m_char_id >= 0 && m_chatmessage.m_char_id < char_list.size() && (m_chatmessage.m_showname.isEmpty() || !custom_shownames))
30873078
{
30883079
QString real_name = char_list.at(m_chatmessage.m_char_id).name;
30893080
QString f_showname = ao_app->get_showname(real_name);
@@ -3605,7 +3596,7 @@ void Courtroom::log_ic_text(QString p_name, QString p_showname, QString p_messag
36053596
}
36063597
}
36073598

3608-
void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, int color, bool selfname, QDateTime timestamp, bool ghost)
3599+
void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_char, QString p_action, int color, bool selfname, QDateTime timestamp, bool ghost)
36093600
{
36103601
QColor chatlog_color = ao_app->get_color("ic_chatlog_color", "courtroom_fonts.ini");
36113602
QTextCharFormat bold;
@@ -3631,6 +3622,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
36313622
const bool need_newline = !ui_ic_chatlog->document()->isEmpty();
36323623
const int scrollbar_target_value = log_goes_downwards ? ui_ic_chatlog->verticalScrollBar()->maximum() : ui_ic_chatlog->verticalScrollBar()->minimum();
36333624

3625+
QString displayname = custom_shownames ? p_name : ao_app->get_showname(p_char);
3626+
36343627
if (ghost)
36353628
{
36363629
ghost_blocks++;
@@ -3641,7 +3634,7 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
36413634
}
36423635
else
36433636
{
3644-
last_ic_message = p_name + ":" + p_text;
3637+
last_ic_message = displayname + ":" + p_text;
36453638
}
36463639

36473640
ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::End : QTextCursor::Start);
@@ -3678,7 +3671,7 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
36783671

36793672
// Format the name of the actor
36803673
QTextCharFormat name_format = selfname ? own_name : other_name;
3681-
ui_ic_chatlog->textCursor().insertText(p_name, name_format);
3674+
ui_ic_chatlog->textCursor().insertText(displayname, name_format);
36823675
// Special case for stopping the music
36833676
if (p_action == tr("has stopped the music"))
36843677
{
@@ -4529,12 +4522,12 @@ void Courtroom::handle_song(QStringList *p_contents)
45294522
if (is_stop)
45304523
{
45314524
log_ic_text(str_char, str_show, "", tr("has stopped the music"), 0, selfname);
4532-
append_ic_text("", str_show, tr("has stopped the music"), 0, selfname);
4525+
append_ic_text("", str_show, str_char, tr("has stopped the music"), 0, selfname);
45334526
}
45344527
else
45354528
{
45364529
log_ic_text(str_char, str_show, f_song, tr("has played a song"), 0, selfname);
4537-
append_ic_text(f_song_clear, str_show, tr("has played a song"), 0, selfname);
4530+
append_ic_text(f_song_clear, str_show, str_char, tr("has played a song"), 0, selfname);
45384531
}
45394532
}
45404533
}
@@ -6276,21 +6269,13 @@ void Courtroom::focus_ic_input()
62766269
ui_ic_chat_message->setFocus();
62776270
}
62786271

6279-
void Courtroom::on_showname_enable_clicked()
6280-
{
6281-
regenerate_ic_chatlog();
6282-
focus_ic_input();
6283-
}
6284-
62856272
void Courtroom::regenerate_ic_chatlog()
62866273
{
62876274
ui_ic_chatlog->clear();
62886275
last_ic_message = "";
62896276
foreach (ChatLogPiece item, ic_chatlog_history)
62906277
{
6291-
QString message = item.message;
6292-
QString name = ui_showname_enable->isChecked() ? item.character_name : item.character;
6293-
append_ic_text(message, name, item.action, item.color, item.local_player, item.timestamp.toLocalTime());
6278+
append_ic_text(item.message, item.character_name, item.character, item.action, item.color, item.local_player, item.timestamp.toLocalTime());
62946279
}
62956280
}
62966281

src/courtroom.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class Courtroom : public QMainWindow
253253
// this function keeps the chatlog scrolled to the top unless there's text
254254
// selected
255255
// or the user isn't already scrolled to the top
256-
void append_ic_text(QString p_text, QString p_name = QString(), QString action = QString(), int color = 0, bool selfname = false, QDateTime timestamp = QDateTime::currentDateTime(), bool ghost = false);
256+
void append_ic_text(QString p_text, QString p_name = QString(), QString p_char = QString(), QString action = QString(), int color = 0, bool selfname = false, QDateTime timestamp = QDateTime::currentDateTime(), bool ghost = false);
257257

258258
// clear sent messages that appear on the IC log but haven't been delivered
259259
// yet to other players
@@ -410,6 +410,9 @@ class Courtroom : public QMainWindow
410410
// format string for aforementioned log timestamp
411411
QString log_timestamp_format;
412412

413+
// True, if the log and in-character display should use custom shownames.
414+
bool custom_shownames = true;
415+
413416
// How long in miliseconds should the objection wait before appearing.
414417
int objection_threshold = 1500;
415418

@@ -938,8 +941,6 @@ private Q_SLOTS:
938941
void focus_ic_input();
939942
void on_additive_clicked();
940943

941-
void on_showname_enable_clicked();
942-
943944
void on_evidence_button_clicked();
944945
void on_evidence_context_menu_requested(const QPoint &pos);
945946

src/options.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ Options::Options()
5656
/*! Migrate old configuration keys/values to a relevant format. */
5757
void Options::migrate()
5858
{
59-
if (config.contains("show_custom_shownames"))
60-
{
61-
config.remove("show_custom_shownames");
62-
}
6359
if (QFile::exists(get_base_path() + "callwords.ini"))
6460
{
6561
migrateCallwords();

0 commit comments

Comments
 (0)