diff options
Diffstat (limited to 'include/courtroom.h')
| -rw-r--r-- | include/courtroom.h | 154 |
1 files changed, 120 insertions, 34 deletions
diff --git a/include/courtroom.h b/include/courtroom.h index a4245a7d..0dcc53de 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -5,17 +5,16 @@ #include "aoblipplayer.h" #include "aobutton.h" #include "aocharbutton.h" -#include "aocharmovie.h" +#include "aoclocklabel.h" #include "aoemotebutton.h" #include "aoevidencebutton.h" #include "aoevidencedisplay.h" #include "aoimage.h" +#include "aolayer.h" #include "aolineedit.h" -#include "aomovie.h" #include "aomusicplayer.h" #include "aooptionsdialog.h" #include "aopacket.h" -#include "aoscene.h" #include "aosfxplayer.h" #include "aotextarea.h" #include "aotextedit.h" @@ -41,6 +40,7 @@ #include <QTextBrowser> #include <QTreeWidget> #include <QVector> +#include <QQueue> #include <QBrush> #include <QDebug> @@ -56,7 +56,7 @@ #include <QScrollBar> #include <QTextBoundaryFinder> #include <QTextCharFormat> -//#include <QRandomGenerator> +#include <QElapsedTimer> #include <algorithm> #include <stack> @@ -150,6 +150,9 @@ public: // reads theme inis and sets size and pos based on the identifier void set_size_and_pos(QWidget *p_widget, QString p_identifier); + // reads theme and char inis and sets size and pos based on the identifier + void set_size_and_pos(QWidget *p_widget, QString p_identifier, QString p_char); + // reads theme inis and returns the size and pos as defined by it QPoint get_theme_pos(QString p_identifier); @@ -217,19 +220,56 @@ public: void append_server_chatmessage(QString p_name, QString p_message, QString p_color); - // 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(); + // Add the message packet to the stack + void chatmessage_enqueue(QStringList p_contents); + + // Parse the chat message packet and unpack it into the m_chatmessage[ITEM] format + void unpack_chatmessage(QStringList p_contents); + + enum LogMode { + IO_ONLY, + DISPLAY_ONLY, + DISPLAY_AND_IO + }; + // Log the message contents and information such as evidence presenting etc. into the log file, the IC log, or both. + void log_chatmessage(QString f_message, int f_char_id, QString f_showname = "", int f_color = 0, LogMode f_log_mode=IO_ONLY); + + // Log the message contents and information such as evidence presenting etc. into the IC logs + void handle_callwords(); + + // Handle the objection logic, if it's interrupting the currently parsing message. + // Returns true if this message has an objection, otherwise returns false. The result decides when to call handle_ic_message() + bool handle_objection(); + + // Display the evidence image box when presenting evidence in IC + void display_evidence_image(); + + // Handle the stuff that comes when the character appears on screen and starts animating (preanims etc.) + void handle_ic_message(); + + // Display the character. + void display_character(); + + // Display the character's pair if present. + void display_pair_character(QString other_charid, QString other_offset); + + // Handle the emote modifier value and proceed through the logic accordingly. + void handle_emote_mod(int emote_mod, bool p_immediate); + + // Initialize the chatbox image, showname shenanigans, custom chatboxes, etc. + void initialize_chatbox(); + + // Finally start displaying the chatbox we initialized, display the evidence, and play the talking or idle emote for the character. + // Callwords are also handled here. + void handle_ic_speaking(); // This function filters out the common CC inline text trickery, for appending // to the IC chatlog. QString filter_ic_text(QString p_text, bool colorize = false, int pos = -1, int default_color = 0); - void log_ic_text(QString p_name, QString p_showname, QString p_message, QString p_action="", int p_color=0); + void log_ic_text(QString p_name, QString p_showname, QString p_message, + QString p_action = "", int p_color = 0); // 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 @@ -261,11 +301,18 @@ public: void check_connection_received(); + void start_clock(int id); + void start_clock(int id, qint64 msecs); + void set_clock(int id, qint64 msecs); + void pause_clock(int id); + void stop_clock(int id); + void set_clock_visibility(int id, bool visible); + + qint64 pong(); // Truncates text so it fits within theme-specified boundaries and sets the tooltip to the full string void truncate_label_text(QWidget* p_widget, QString p_identifier); ~Courtroom(); - private: AOApplication *ao_app; @@ -314,12 +361,20 @@ private: QVector<QString> arup_locks; QVector<chatlogpiece> ic_chatlog_history; + QString last_ic_message = ""; + + QQueue<QStringList> chatmessage_queue; - // triggers ping_server() every 60 seconds + // triggers ping_server() every 45 seconds QTimer *keepalive_timer; // determines how fast messages tick onto screen QTimer *chat_tick_timer; + + // count up timer to check how long it took for us to get a response from ping_server() + QElapsedTimer ping_timer; + bool is_pinging = false; + // int chat_tick_interval = 60; // which tick position(character in chat message) we are at int tick_pos = 0; @@ -342,7 +397,8 @@ private: // True, if log should display colors. bool log_colors = true; - // True, if the log should display the message like name<br>text instead of name: text + // True, if the log should display the message like name<br>text instead of + // name: text bool log_newline = false; // True, if the log should include RP actions like interjections, showing evidence, etc. @@ -354,8 +410,14 @@ private: // True, if the log should have a timestamp. bool log_timestamp = false; + // How long in miliseconds should the objection wait before appearing. + int objection_threshold = 1500; + // delay before chat messages starts ticking QTimer *text_delay_timer; + + // delay before the next queue entry is going to be processed + QTimer *text_queue_timer; // delay before sfx plays QTimer *sfx_delay_timer; @@ -364,16 +426,21 @@ private: const int time_mod = 40; // the amount of time non-animated objection/hold it/takethat images stay - // onscreen for in ms - const int shout_stay_time = 724; + // onscreen for in ms, and the maximum amount of time any interjections are + // allowed to play + const int shout_static_time = 724; + const int shout_max_time = 1500; // the amount of time non-animated guilty/not guilty images stay onscreen for - // in ms - const int verdict_stay_time = 3000; + // in ms, and the maximum amount of time g/ng images are allowed to play + const int verdict_static_time = 3000; + const int verdict_max_time = 4000; // the amount of time non-animated witness testimony/cross-examination images - // stay onscreen for in ms - const int wtce_stay_time = 1500; + // stay onscreen for in ms, and the maximum time any wt/ce image is allowed to + // play + const int wtce_static_time = 1500; + const int wtce_max_time = 4000; // characters we consider punctuation const QString punctuation_chars = ".,?!:;"; @@ -397,7 +464,7 @@ private: bool is_muted = false; // state of animation, 0 = objecting, 1 = preanim, 2 = talking, 3 = idle, 4 = - // noniterrupting preanim + // noniterrupting preanim, 5 = (c) animation int anim_state = 3; // whether or not current color is a talking one @@ -460,8 +527,15 @@ private: // List of all currently available pos QStringList pos_dropdown_list; + // Current list file sorted line by line + QStringList sound_list; + + // Current SFX the user put in for the sfx dropdown list + QString custom_sfx = ""; + // is the message we're about to send supposed to present evidence? bool is_presenting_evidence = false; + bool c_played = false; // whether we've played a (c)-style postanimation yet // have we already presented evidence for this message? bool evidence_presented = false; @@ -529,21 +603,20 @@ private: AOImage *ui_background; QWidget *ui_viewport; - AOScene *ui_vp_background; - AOMovie *ui_vp_speedlines; - AOCharMovie *ui_vp_player_char; - AOCharMovie *ui_vp_sideplayer_char; - AOScene *ui_vp_desk; - AOScene *ui_vp_legacy_desk; + BackgroundLayer *ui_vp_background; + ForegroundLayer *ui_vp_speedlines; + CharLayer *ui_vp_player_char; + CharLayer *ui_vp_sideplayer_char; + BackgroundLayer *ui_vp_desk; AOEvidenceDisplay *ui_vp_evidence_display; AOImage *ui_vp_chatbox; QLabel *ui_vp_showname; - AOMovie *ui_vp_chat_arrow; + InterfaceLayer *ui_vp_chat_arrow; QTextEdit *ui_vp_message; - AOMovie *ui_vp_effect; - AOMovie *ui_vp_testimony; - AOMovie *ui_vp_wtce; - AOMovie *ui_vp_objection; + EffectLayer *ui_vp_effect; + InterfaceLayer *ui_vp_testimony; + InterjectionLayer *ui_vp_wtce; + InterjectionLayer *ui_vp_objection; QTextEdit *ui_ic_chatlog; @@ -555,7 +628,12 @@ private: QTreeWidget *ui_music_list; ScrollText *ui_music_name; - AOMovie *ui_music_display; + InterfaceLayer *ui_music_display; + + StickerLayer *ui_vp_sticker; + + static const int max_clocks = 5; + AOClockLabel *ui_clock[max_clocks]; AOButton *ui_pair_button; QListWidget *ui_pair_list; @@ -665,6 +743,9 @@ private: AOImage *ui_char_select_background; + // pretty list of characters + QTreeWidget *ui_char_list; + // abstract widget to hold char buttons QWidget *ui_char_buttons; @@ -701,12 +782,12 @@ private: void refresh_evidence(); void set_evidence_page(); - void reset_ic(); void reset_ui(); void regenerate_ic_chatlog(); public slots: void objection_done(); + void effect_done(); void preanim_done(); void do_screenshake(); void do_flash(); @@ -762,6 +843,7 @@ private slots: void on_iniswap_remove_clicked(); void on_sfx_dropdown_changed(int p_index); + void on_sfx_dropdown_custom(QString p_sfx); void set_sfx_dropdown(); void on_sfx_context_menu_requested(const QPoint &pos); void on_sfx_edit_requested(); @@ -858,6 +940,7 @@ private slots: void on_back_to_lobby_clicked(); + void on_char_list_double_clicked(QTreeWidgetItem *p_item, int column); void on_char_select_left_clicked(); void on_char_select_right_clicked(); void on_char_search_changed(); @@ -871,6 +954,9 @@ private slots: void on_casing_clicked(); void ping_server(); + + // Proceed to parse the oldest chatmessage and remove it from the stack + void chatmessage_dequeue(); }; #endif // COURTROOM_H |
