From 1dcdb0f5d8fd350f7863842035e4c8842cd035ce Mon Sep 17 00:00:00 2001 From: Cerapter Date: Wed, 12 Dec 2018 18:54:50 +0100 Subject: [PATCH 1/5] Added defaults to the inline colouring system. --- text_file_functions.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/text_file_functions.cpp b/text_file_functions.cpp index ff40c9c..afe8fc3 100644 --- a/text_file_functions.cpp +++ b/text_file_functions.cpp @@ -268,12 +268,49 @@ QColor AOApplication::get_color(QString p_identifier, QString p_file) QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat) { + QColor return_color(255, 255, 255); + + if (p_identifier == "_inline_grey") + { + return_color = QColor(187, 187, 187); + } + else + { + switch (p_identifier.toInt()) { + case 1: + return_color = QColor(0, 255, 0); + break; + case 2: + return_color = QColor(255, 0, 0); + break; + case 3: + return_color = QColor(255, 165, 0); + break; + case 4: + return_color = QColor(45, 150, 255); + break; + case 5: + return_color = QColor(255, 255, 0); + break; + case 7: + return_color = QColor(255, 192, 203); + break; + case 8: + return_color = QColor(0, 255, 255); + break; + case 0: + case 6: // 6 is rainbow. + default: + return_color = QColor(255, 255, 255); + break; + } + } + p_identifier = p_identifier.prepend("c"); QString design_ini_path = get_base_path() + "misc/" + p_chat + "/config.ini"; QString default_path = get_base_path() + "misc/default/config.ini"; QString f_result = read_design_ini(p_identifier, design_ini_path); - QColor return_color(255, 255, 255); if (f_result == "") { f_result = read_design_ini(p_identifier, default_path); From 941a32d99caf4406d86b9fc85440c875d4ca5207 Mon Sep 17 00:00:00 2001 From: Cerapter Date: Wed, 12 Dec 2018 18:55:16 +0100 Subject: [PATCH 2/5] Fixed a bug where your chatlog would completely erase if you had a limit of 0. A limit of zero otherwise means infinite, so no log limit. --- courtroom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/courtroom.cpp b/courtroom.cpp index 66e29ca..3da69ad 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -1309,7 +1309,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) 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) + while(ic_chatlog_history.size() > log_maximum_blocks && log_maximum_blocks > 0) { ic_chatlog_history.removeFirst(); } @@ -2611,7 +2611,7 @@ void Courtroom::handle_song(QStringList *p_contents) chatlogpiece* temp = new chatlogpiece(str_char, str_show, f_song, true); ic_chatlog_history.append(*temp); - while(ic_chatlog_history.size() > log_maximum_blocks) + while(ic_chatlog_history.size() > log_maximum_blocks && log_maximum_blocks > 0) { ic_chatlog_history.removeFirst(); } From f217c68f85156e5ea816c10a7c4723a6c55c0b77 Mon Sep 17 00:00:00 2001 From: Cerapter Date: Wed, 12 Dec 2018 19:22:34 +0100 Subject: [PATCH 3/5] The charselect's "shadows" correctly update based on what chars are taken. This was purely a graphical bug. The characters were correctly recognised as taken by the client, but there was no way to update the "taken-shadow" over their icons. Which meant that they were locked into the way they were when the user first joined the server. As a result of this, a `CharsCheck` package from the server will correctly display the taken characters to the client in the character selection. --- aocharbutton.cpp | 11 ++++++++++- aocharbutton.h | 4 +++- charselect.cpp | 9 +++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/aocharbutton.cpp b/aocharbutton.cpp index 23fd0c6..7661027 100644 --- a/aocharbutton.cpp +++ b/aocharbutton.cpp @@ -40,13 +40,22 @@ void AOCharButton::reset() ui_selector->hide(); } -void AOCharButton::set_taken() +void AOCharButton::set_taken(bool is_taken) +{ + taken = is_taken; +} + +void AOCharButton::apply_taken_image() { if (taken) { ui_taken->move(0,0); ui_taken->show(); } + else + { + ui_taken->hide(); + } } void AOCharButton::set_passworded() diff --git a/aocharbutton.h b/aocharbutton.h index 6e5e50e..f372cdf 100644 --- a/aocharbutton.h +++ b/aocharbutton.h @@ -20,9 +20,11 @@ public: void refresh(); void reset(); - void set_taken(); + void set_taken(bool is_taken); void set_passworded(); + void apply_taken_image(); + void set_image(QString p_character); private: diff --git a/charselect.cpp b/charselect.cpp index 01b6ae7..8e1b912 100644 --- a/charselect.cpp +++ b/charselect.cpp @@ -168,8 +168,7 @@ void Courtroom::put_button_in_place(int starting, int chars_on_this_page) ui_char_button_list_filtered.at(n)->move(x_pos, y_pos); ui_char_button_list_filtered.at(n)->show(); - - ui_char_button_list_filtered.at(n)->set_taken(); + ui_char_button_list_filtered.at(n)->apply_taken_image(); ++x_mod_count; @@ -240,6 +239,12 @@ void Courtroom::filter_character_list() if (!char_list.at(i).name.contains(ui_char_search->text(), Qt::CaseInsensitive)) continue; + // We only really need to update the fact that a character is taken + // for the buttons that actually appear. + // You'd also update the passwordedness and etc. here later. + current_char->reset(); + current_char->set_taken(char_list.at(i).taken); + ui_char_button_list_filtered.append(current_char); } From c5d983033ec967b644e7ed9bd1a0f5a1b4f428c3 Mon Sep 17 00:00:00 2001 From: Cerapter Date: Wed, 12 Dec 2018 19:46:13 +0100 Subject: [PATCH 4/5] Merged some duplicate functions. Also brought in another function that specifically filters out inline formatting characters, so that the append IC text function is a bit more understandable. --- courtroom.cpp | 169 ++++++++++++-------------------------------------- courtroom.h | 12 ++-- 2 files changed, 45 insertions(+), 136 deletions(-) diff --git a/courtroom.cpp b/courtroom.cpp index 3da69ad..7a9d3c5 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -1565,13 +1565,13 @@ void Courtroom::handle_chatmessage_2() switch (emote_mod) { case 1: case 2: case 6: - play_preanim(); + play_preanim(false); break; case 0: case 5: if (m_chatmessage[NONINTERRUPTING_PRE].toInt() == 0) handle_chatmessage_3(); else - play_noninterrupting_preanim(); + play_preanim(true); break; default: qDebug() << "W: invalid emote mod: " << QString::number(emote_mod); @@ -1674,15 +1674,8 @@ void Courtroom::handle_chatmessage_3() } -void Courtroom::append_ic_text(QString p_text, QString p_name) +QString Courtroom::filter_ic_text(QString p_text) { - QTextCharFormat bold; - QTextCharFormat normal; - bold.setFontWeight(QFont::Bold); - normal.setFontWeight(QFont::Normal); - const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); - const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); - // Get rid of centering. if(p_text.startsWith(": ~~")) { @@ -1815,85 +1808,10 @@ void Courtroom::append_ic_text(QString p_text, QString p_name) } } - // After all of that, let's jot down the message into the IC chatlog. - - if (log_goes_downwards) - { - const bool is_scrolled_down = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->maximum(); - - ui_ic_chatlog->moveCursor(QTextCursor::End); - - if (!first_message_sent) - { - ui_ic_chatlog->textCursor().insertText(p_name, bold); - first_message_sent = true; - } - else - { - ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold); - } - - ui_ic_chatlog->textCursor().insertText(p_text, normal); - - // If we got too many blocks in the current log, delete some from the top. - while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0) - { - ui_ic_chatlog->moveCursor(QTextCursor::Start); - ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor); - ui_ic_chatlog->textCursor().removeSelectedText(); - ui_ic_chatlog->textCursor().deleteChar(); - //qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks; - } - - if (old_cursor.hasSelection() || !is_scrolled_down) - { - // The user has selected text or scrolled away from the bottom: maintain position. - ui_ic_chatlog->setTextCursor(old_cursor); - ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value); - } - else - { - // The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom. - ui_ic_chatlog->moveCursor(QTextCursor::End); - ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->maximum()); - } - } - else - { - const bool is_scrolled_up = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->minimum(); - - ui_ic_chatlog->moveCursor(QTextCursor::Start); - - ui_ic_chatlog->textCursor().insertText(p_name, bold); - ui_ic_chatlog->textCursor().insertText(p_text + '\n', normal); - - // If we got too many blocks in the current log, delete some from the bottom. - while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0) - { - ui_ic_chatlog->moveCursor(QTextCursor::End); - ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor); - ui_ic_chatlog->textCursor().removeSelectedText(); - ui_ic_chatlog->textCursor().deletePreviousChar(); - //qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks; - } - - if (old_cursor.hasSelection() || !is_scrolled_up) - { - // The user has selected text or scrolled away from the top: maintain position. - ui_ic_chatlog->setTextCursor(old_cursor); - ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value); - } - else - { - // The user hasn't selected any text and the scrollbar is at the top: scroll to the top. - ui_ic_chatlog->moveCursor(QTextCursor::Start); - ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->minimum()); - } - } + return p_text; } -// Call it ugly, call it a hack, but I wanted to do something special with the songname changes. -void Courtroom::append_ic_songchange(QString p_songname, QString p_name) +void Courtroom::append_ic_text(QString p_text, QString p_name, bool is_songchange) { QTextCharFormat bold; QTextCharFormat normal; @@ -1904,6 +1822,9 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name) const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); + if (!is_songchange) + p_text = filter_ic_text(p_text); + if (log_goes_downwards) { const bool is_scrolled_down = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->maximum(); @@ -1920,8 +1841,15 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name) ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold); } - ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal); - ui_ic_chatlog->textCursor().insertText(p_songname + ".", italics); + if (is_songchange) + { + ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal); + ui_ic_chatlog->textCursor().insertText(p_text + ".", italics); + } + else + { + ui_ic_chatlog->textCursor().insertText(p_text, normal); + } // If we got too many blocks in the current log, delete some from the top. while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0) @@ -1954,8 +1882,15 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name) ui_ic_chatlog->textCursor().insertText(p_name, bold); - ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal); - ui_ic_chatlog->textCursor().insertText(p_songname + "." + '\n', italics); + if (is_songchange) + { + ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal); + ui_ic_chatlog->textCursor().insertText(p_text + "." + '\n', italics); + } + else + { + ui_ic_chatlog->textCursor().insertText(p_text + '\n', normal); + } // If we got too many blocks in the current log, delete some from the bottom. while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0) @@ -1982,7 +1917,7 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name) } } -void Courtroom::play_preanim() +void Courtroom::play_preanim(bool noninterrupting) { QString f_char = m_chatmessage[CHAR_NAME]; QString f_preanim = m_chatmessage[PRE_EMOTE]; @@ -2004,53 +1939,27 @@ void Courtroom::play_preanim() if (!file_exists(anim_to_find) || preanim_duration < 0) { - anim_state = 1; + if (noninterrupting) + anim_state = 4; + else + anim_state = 1; preanim_done(); qDebug() << "could not find " + anim_to_find; return; } ui_vp_player_char->play_pre(f_char, f_preanim, preanim_duration); - anim_state = 1; - if (text_delay >= 0) - text_delay_timer->start(text_delay); -} - -void Courtroom::play_noninterrupting_preanim() -{ - QString f_char = m_chatmessage[CHAR_NAME]; - QString f_preanim = m_chatmessage[PRE_EMOTE]; - - //all time values in char.inis are multiplied by a constant(time_mod) to get the actual time - int ao2_duration = ao_app->get_ao2_preanim_duration(f_char, f_preanim); - int text_delay = ao_app->get_text_delay(f_char, f_preanim) * time_mod; - int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * 60; - - int preanim_duration; - - if (ao2_duration < 0) - preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim); - else - preanim_duration = ao2_duration; - - sfx_delay_timer->start(sfx_delay); - QString anim_to_find = ao_app->get_image_suffix(ao_app->get_character_path(f_char, f_preanim)); - if (!file_exists(anim_to_find) || - preanim_duration < 0) - { + if (noninterrupting) anim_state = 4; - preanim_done(); - qDebug() << "could not find " + anim_to_find; - return; - } + else + anim_state = 1; - ui_vp_player_char->play_pre(f_char, f_preanim, preanim_duration); - anim_state = 4; if (text_delay >= 0) text_delay_timer->start(text_delay); - handle_chatmessage_3(); + if (noninterrupting) + handle_chatmessage_3(); } void Courtroom::preanim_done() @@ -2616,7 +2525,7 @@ void Courtroom::handle_song(QStringList *p_contents) ic_chatlog_history.removeFirst(); } - append_ic_songchange(f_song_clear, str_show); + append_ic_text(f_song_clear, str_show, true); music_player->play(f_song); } } @@ -3476,14 +3385,14 @@ void Courtroom::on_showname_enable_clicked() if (ui_showname_enable->isChecked()) { if (item.get_is_song()) - append_ic_songchange(item.get_message(), item.get_showname()); + append_ic_text(item.get_message(), item.get_showname(), true); 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()); + append_ic_text(item.get_message(), item.get_name(), true); else append_ic_text(item.get_message(), item.get_name()); } diff --git a/courtroom.h b/courtroom.h index 85c454a..0b5c0ea 100644 --- a/courtroom.h +++ b/courtroom.h @@ -179,20 +179,20 @@ public: void handle_chatmessage_2(); void handle_chatmessage_3(); + //This function filters out the common CC inline text trickery, for appending to + //the IC chatlog. + QString filter_ic_text(QString p_text); + //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 selected // or the user isn't already scrolled to the top - void append_ic_text(QString p_text, QString p_name = ""); - - // This is essentially the same as the above, but specifically for song changes. - void append_ic_songchange(QString p_songname, QString p_name = ""); + void append_ic_text(QString p_text, QString p_name = "", bool is_songchange = false); //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 second is the char id of who played it void handle_song(QStringList *p_contents); - void play_preanim(); - void play_noninterrupting_preanim(); + void play_preanim(bool noninterrupting); //plays the witness testimony or cross examination animation based on argument void handle_wtce(QString p_wtce, int variant); From 171196885d88360c8c06def67ae398c8187dfd89 Mon Sep 17 00:00:00 2001 From: Cerapter Date: Wed, 12 Dec 2018 19:47:54 +0100 Subject: [PATCH 5/5] Fixed a bug where the `misc/` bubbles would be preferred over the characters' own. --- aomovie.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aomovie.cpp b/aomovie.cpp index 97ee248..edf5bdb 100644 --- a/aomovie.cpp +++ b/aomovie.cpp @@ -39,10 +39,10 @@ void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme) QString placeholder_path = ao_app->get_theme_path("placeholder.gif"); QString default_placeholder_path = ao_app->get_default_theme_path("placeholder.gif"); - if (file_exists(misc_path)) - gif_path = misc_path; - else if (file_exists(custom_path)) + if (file_exists(custom_path)) gif_path = custom_path; + else if (file_exists(misc_path)) + gif_path = misc_path; else if (file_exists(custom_theme_path)) gif_path = custom_theme_path; else if (file_exists(theme_path))