diff --git a/aotextarea.cpp b/aotextarea.cpp index d49f03e..40cc314 100644 --- a/aotextarea.cpp +++ b/aotextarea.cpp @@ -28,7 +28,6 @@ void AOTextArea::append_chatmessage(QString p_name, QString p_message) this->insertHtml(result); this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); - this->auto_truncate(); } void AOTextArea::append_error(QString p_message) @@ -47,7 +46,6 @@ void AOTextArea::append_error(QString p_message) this->insertHtml("" + result + ""); this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); - this->auto_truncate(); } void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value, bool is_scrolled_down) @@ -65,15 +63,3 @@ void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value, bo this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum()); } } - -void AOTextArea::auto_truncate() -{ - QTextCursor temp_cursor = this->textCursor(); - - if (this->document()->characterCount() > 500000) - { - temp_cursor.movePosition(QTextCursor::Start); - temp_cursor.select(QTextCursor::LineUnderCursor); - temp_cursor.removeSelectedText(); - } -} diff --git a/aotextarea.h b/aotextarea.h index 46b9bcc..32635fd 100644 --- a/aotextarea.h +++ b/aotextarea.h @@ -15,7 +15,6 @@ private: const QRegExp omnis_dank_url_regex = QRegExp("\\b(https?://\\S+\\.\\S+)\\b"); void auto_scroll(QTextCursor old_cursor, int scrollbar_value, bool is_scrolled_down); - void auto_truncate(); }; #endif // AOTEXTAREA_H diff --git a/courtroom.cpp b/courtroom.cpp index 97d1f71..1b4fd63 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -12,6 +12,7 @@ #include #include #include +#include Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() { @@ -80,7 +81,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_vp_wtce = new AOMovie(this, ao_app); ui_vp_objection = new AOMovie(this, ao_app); - ui_ic_chatlog = new QPlainTextEdit(this); + ui_ic_chatlog = new QTextEdit(this); ui_ic_chatlog->setReadOnly(true); ui_ms_chatlog = new AOTextArea(this); @@ -963,7 +964,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) ui_evidence_present->set_image("present_disabled.png"); } - append_ic_text("" + f_showname.toHtmlEscaped() + ": " + m_chatmessage[MESSAGE].toHtmlEscaped()); + append_ic_text(": " + m_chatmessage[MESSAGE], f_showname); previous_ic_message = f_message; @@ -1147,17 +1148,20 @@ void Courtroom::handle_chatmessage_3() } -void Courtroom::append_ic_text(QString p_text) +void Courtroom::append_ic_text(QString p_text, QString p_name) { + 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(); const bool is_scrolled_up = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->minimum(); - ui_ic_chatlog->moveCursor(QTextCursor::Start); - - ui_ic_chatlog->textCursor().insertHtml(p_text); - ui_ic_chatlog->textCursor().insertHtml("
"); + ui_ic_chatlog->moveCursor(QTextCursor::Start); + ui_ic_chatlog->textCursor().insertText(p_name, bold); + ui_ic_chatlog->textCursor().insertText(p_text + '\n', normal); if (old_cursor.hasSelection() || !is_scrolled_up) { @@ -1527,7 +1531,7 @@ void Courtroom::handle_song(QStringList *p_contents) if (!mute_map.value(n_char)) { - append_ic_text("" + str_char + " has played a song: " + f_song); + append_ic_text(" has played a song: " + f_song, str_char); music_player->play(f_song); } } diff --git a/courtroom.h b/courtroom.h index 4e7e191..f21e62a 100644 --- a/courtroom.h +++ b/courtroom.h @@ -44,17 +44,31 @@ public: void append_evidence(evi_type p_evi){evidence_list.append(p_evi);} void append_music(QString f_music){music_list.append(f_music);} + //sets position of widgets based on theme ini files void set_widgets(); + //sets font size based on theme ini files void set_font(QWidget *widget, QString p_identifier); + //helper function that calls above function on the relevant widgets void set_fonts(); + void set_window_title(QString p_title); + + //reads theme inis and sets size and pos based on the identifier void set_size_and_pos(QWidget *p_widget, QString p_identifier); + + //sets status as taken on character with cid n_char and places proper shading on charselect void set_taken(int n_char, bool p_taken); + + //sets the current background to argument. also does some checks to see if it's a legacy bg void set_background(QString p_background); + + //sets the evidence list member variable to argument void set_evidence_list(QVector &p_evi_list); + //called when a DONE#% from the server was received void done_received(); + //sets the local mute list based on characters available on the server void set_mute_list(); //sets desk and bg based on pos in chatmessage @@ -63,35 +77,58 @@ public: //sets text color based on text color in chatmessage void set_text_color(); + //takes in serverD-formatted IP list as prints a converted version to server OOC + //admittedly poorly named void set_ip_list(QString p_list); + //disables chat if current cid matches second argument + //enables if p_muted is false void set_mute(bool p_muted, int p_cid); + + //send a message that the player is banned and quits the server void set_ban(int p_cid); //implementations in path_functions.cpp QString get_background_path(); QString get_default_background_path(); + //cid = character id, returns the cid of the currently selected character int get_cid() {return m_cid;} QString get_current_char() {return current_char;} + //properly sets up some varibles: resets user state void enter_courtroom(int p_cid); + + //helper function that populates ui_music_list with the contents of music_list void list_music(); + //these are for OOC chat void append_ms_chatmessage(QString f_name, QString f_message); void append_server_chatmessage(QString p_name, QString p_message); + //these functions handle chatmessages sequentially. + //The process itself is very convoluted and merits separate documentation + //But the general idea is objection animation->pre animation->talking->idle void handle_chatmessage(QStringList *p_contents); void handle_chatmessage_2(); void handle_chatmessage_3(); - void append_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 = ""); + //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(); + //plays the witness testimony or cross examination animation based on argument void handle_wtce(QString p_wtce); + + //sets the hp bar of defense(p_bar 1) or pro(p_bar 2) + //state is an number between 0 and 10 inclusive void set_hp_bar(int p_bar, int p_state); void check_connection_received(); @@ -137,9 +174,12 @@ private: //delay before sfx plays QTimer *sfx_delay_timer; + //keeps track of how long realization is visible(it's just a white square and should be visible less than a second) QTimer *realization_timer; + //times how long the blinking testimony should be shown(green one in the corner) QTimer *testimony_show_timer; + //times how long the blinking testimony should be hidden QTimer *testimony_hide_timer; //every time point in char.inis times this equals the final time @@ -236,7 +276,7 @@ private: AOMovie *ui_vp_wtce; AOMovie *ui_vp_objection; - QPlainTextEdit *ui_ic_chatlog; + QTextEdit *ui_ic_chatlog; AOTextArea *ui_ms_chatlog; AOTextArea *ui_server_chatlog;