diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/aoapplication.h | 54 | ||||
| -rw-r--r-- | include/aocharmovie.h | 125 | ||||
| -rw-r--r-- | include/aoclocklabel.h | 29 | ||||
| -rw-r--r-- | include/aoevidencedisplay.h | 4 | ||||
| -rw-r--r-- | include/aolayer.h | 221 | ||||
| -rw-r--r-- | include/aomovie.h | 36 | ||||
| -rw-r--r-- | include/aooptionsdialog.h | 8 | ||||
| -rw-r--r-- | include/aopacket.h | 2 | ||||
| -rw-r--r-- | include/aoscene.h | 42 | ||||
| -rw-r--r-- | include/courtroom.h | 154 | ||||
| -rw-r--r-- | include/demoserver.h | 55 |
11 files changed, 484 insertions, 246 deletions
diff --git a/include/aoapplication.h b/include/aoapplication.h index 095ea18f..c217dad7 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -1,8 +1,11 @@ #ifndef AOAPPLICATION_H #define AOAPPLICATION_H +#define UNUSED(x) (void)(x) + #include "aopacket.h" #include "datatypes.h" +#include "demoserver.h" #include "discord_rich_presence.h" #include "bass.h" @@ -26,6 +29,9 @@ #include <QScreen> #include <QStringList> #include <QTextStream> +#include <QTime> + +#include <QElapsedTimer> class NetworkManager; class Lobby; @@ -61,6 +67,9 @@ public: void call_settings_menu(); void call_announce_menu(Courtroom *court); + qint64 latency = 0; + QString window_title; + /////////////////server metadata////////////////// bool yellow_text_enabled = false; @@ -125,6 +134,7 @@ public: QString get_default_theme_path(QString p_file); QString get_custom_theme_path(QString p_theme, QString p_file); QString get_character_path(QString p_char, QString p_file); + QString get_misc_path(QString p_misc, QString p_file); QString get_sounds_path(QString p_file); QString get_music_path(QString p_song); QString get_background_path(QString p_file); @@ -166,6 +176,14 @@ public: // Returns the value of default_blip in config.ini int get_default_blip(); + // Returns the value if objections interrupt and skip the message queue + // from the config.ini. + bool is_instant_objection_enabled(); + + // returns if log will show messages as-received, while viewport will parse according to the queue (Text Stay Time) + // from the config.ini + bool is_desyncrhonized_logs_enabled(); + // Returns the value of whether Discord should be enabled on startup // from the config.ini. bool is_discord_enabled(); @@ -208,6 +226,12 @@ public: // may contain, from config.ini. int get_max_log_size(); + // Current wait time between messages for the queue system + int stay_time(); + + // Returns Minimum amount of time (in miliseconds) that must pass before the next Enter key press will send your IC message. (new behaviour) + int get_chat_ratelimit(); + // Returns whether the log should go upwards (new behaviour) // or downwards (vanilla behaviour). bool get_log_goes_downwards(); @@ -250,6 +274,9 @@ public: // directory if it doesn't exist. bool append_to_file(QString p_text, QString p_file, bool make_dir = false); + // Append to the currently open demo file if there is one + void append_to_demofile(QString packet_string); + // Appends the argument string to serverlist.txt void write_to_serverlist_txt(QString p_line); @@ -279,14 +306,14 @@ public: // Returns the color with p_identifier from p_file QColor get_color(QString p_identifier, QString p_file); - // Returns the markdown symbol used for specified p_identifier such as colors - QString get_chat_markdown(QString p_identifier, QString p_file); + // Returns the markup symbol used for specified p_identifier such as colors + QString get_chat_markup(QString p_identifier, QString p_file); // Returns the color from the misc folder. QColor get_chat_color(QString p_identifier, QString p_chat); // Returns the sfx with p_identifier from sounds.ini in the current theme path - QString get_sfx(QString p_identifier); + QString get_sfx(QString p_identifier, QString p_misc="default"); // Figure out if we can opus this or if we should fall back to wav QString get_sfx_suffix(QString sound_to_check); @@ -322,6 +349,9 @@ public: // Returns the showname from the ini of p_char QString get_showname(QString p_char); + // Returns the category of this character + QString get_category(QString p_char); + // Returns the value of chat image from the specific p_char's ini file QString get_chat(QString p_char); @@ -355,9 +385,9 @@ public: // t QString get_effect(QString effect, QString p_char, QString p_folder); - // Return the effect sound associated with the fx_name in the - // misc/effects/<char-defined>/sounds.ini, or theme/effects/sounds.ini. - QString get_effect_sound(QString fx_name, QString p_char); + // Return p_property of fx_name. If p_property is "sound", return + // the value associated with fx_name, otherwise use fx_name + '_' + p_property. + QString get_effect_property(QString fx_name, QString p_char, QString p_property); // Returns the custom realisation used by the character. QString get_custom_realization(QString p_char); @@ -407,6 +437,15 @@ public: // Returns p_char's blips (previously called their "gender") QString get_blips(QString p_char); + // Get a property of a given emote, or get it from "options" if emote doesn't have it + QString get_emote_property(QString p_char, QString p_emote, QString p_property); + + // Return a transformation mode from a string ("smooth" for smooth, anything else for fast) + Qt::TransformationMode get_scaling(QString p_scaling); + + // Returns the scaling type for p_miscname + Qt::TransformationMode get_misc_scaling(QString p_miscname); + // ====== // These are all casing-related settings. // ====== @@ -447,6 +486,9 @@ public: void *user); static void doBASSreset(); + QElapsedTimer demo_timer; + DemoServer* demo_server = nullptr; + private: const int RELEASE = 2; const int MAJOR_VERSION = 9; diff --git a/include/aocharmovie.h b/include/aocharmovie.h deleted file mode 100644 index 2dda0ec2..00000000 --- a/include/aocharmovie.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef AOCHARMOVIE_H -#define AOCHARMOVIE_H - -#include <QDebug> -#include <QElapsedTimer> -#include <QImageReader> -#include <QLabel> -#include <QTimer> - -class AOApplication; - -class AOCharMovie : public QLabel { - Q_OBJECT - -public: - AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app); - - // Play a hat.gif - style preanimation - void play_pre(QString p_char, QString p_emote, int duration); - - // Play a (b)normal.gif - style animation (talking) - void play_talking(QString p_char, QString p_emote); - - // Play an (a)normal.gif - style animation (not talking) - void play_idle(QString p_char, QString p_emote); - - // Stop the movie, clearing the image - void stop(); - - // Set the m_flipped variable to true/false - void set_flipped(bool p_flipped) { m_flipped = p_flipped; } - - // Set the movie's playback speed (between 10% and 1000%) - void set_speed(int modifier) { speed = qMax(10, qMin(modifier, 1000)); } - - // Move the label itself around - void move(int ax, int ay); - - // This is somewhat pointless now as there's no "QMovie" object to resize, aka - // no "combo" to speak of - void combo_resize(int w, int h); - - // Return the frame delay adjusted for speed - int get_frame_delay(int delay); - - QStringList network_strings; - - QString m_char; - QString m_emote; - -private: - AOApplication *ao_app; - - QVector<QPixmap> movie_frames; - QVector<int> movie_delays; - - // Effects such as sfx, screenshakes and realization flashes are stored in - // here. QString entry format: "sfx^[sfx_name]", "shake", "flash". The program - // uses the QVector index as reference. - QVector<QVector<QString>> movie_effects; - - QTimer *preanim_timer; - QTimer *ticker; - QString last_path; - QImageReader *m_reader = new QImageReader(); - - QElapsedTimer actual_time; - - // Usually used to turn seconds into milliseconds such as for [Time] tag in - // char.ini - const int time_mod = 60; - - // These are the X and Y values before they are fixed based on the sprite's - // width. - int x = 0; - int y = 0; - // These are the width and height values before they are fixed based on the - // sprite's width. - int f_w = 0; - int f_h = 0; - - int frame = 0; - int max_frames = 0; - - int speed = 100; - - bool m_flipped = false; - bool play_once = true; - - // Set the movie's image to provided paths, preparing for playback. - void load_image(QString p_char, QString p_emote, QString emote_prefix); - - // Start playback of the movie (if animated). - void play(); - - // Play a frame-specific effect, if there's any defined for that specific - // frame. - void play_frame_effect(int frame); - - // Retreive a pixmap adjused for mirroring/aspect ratio shenanigans from a - // provided QImage - QPixmap get_pixmap(QImage image); - - // Set the movie's frame to provided pixmap - void set_frame(QPixmap f_pixmap); - - // Initialize the frame-specific effects from the char.ini - void load_effects(); - - // Initialize the frame-specific effects from the provided network_strings, - // this is only initialized if network_strings has size more than 0. - void load_network_effects(); - -signals: - void done(); - void shake(); - void flash(); - void play_sfx(QString sfx); - -private slots: - void preanim_done(); - void movie_ticker(); -}; - -#endif // AOCHARMOVIE_H diff --git a/include/aoclocklabel.h b/include/aoclocklabel.h new file mode 100644 index 00000000..b5d07945 --- /dev/null +++ b/include/aoclocklabel.h @@ -0,0 +1,29 @@ +#ifndef AOCLOCKLABEL_H +#define AOCLOCKLABEL_H + +#include <QLabel> +#include <QBasicTimer> +#include <QTimerEvent> +#include <QTime> +#include <QDebug> + +class AOClockLabel : public QLabel { + Q_OBJECT + +public: + AOClockLabel(QWidget *parent); + void start(); + void start(int msecs); + void set(int msecs, bool update_text = false); + void pause(); + void stop(); + +protected: + void timerEvent(QTimerEvent *event) override; + +private: + QBasicTimer timer; + QTime target_time; +}; + +#endif // AOCLOCKLABEL_H diff --git a/include/aoevidencedisplay.h b/include/aoevidencedisplay.h index 979a754e..ff448c91 100644 --- a/include/aoevidencedisplay.h +++ b/include/aoevidencedisplay.h @@ -2,7 +2,7 @@ #define AOEVIDENCEDISPLAY_H #include "aoapplication.h" -#include "aomovie.h" +#include "aolayer.h" #include "aosfxplayer.h" #include <QDebug> @@ -21,7 +21,7 @@ public: private: AOApplication *ao_app; - AOMovie *evidence_movie; + InterfaceLayer *evidence_movie; QLabel *evidence_icon; AOSfxPlayer *sfx_player; diff --git a/include/aolayer.h b/include/aolayer.h new file mode 100644 index 00000000..6265cec6 --- /dev/null +++ b/include/aolayer.h @@ -0,0 +1,221 @@ +#ifndef AOLAYER_H +#define AOLAYER_H + +#include <QDebug> +#include <QElapsedTimer> +#include <QImageReader> +#include <QLabel> +#include <QTimer> +#include <QBitmap> + +class AOApplication; + +class AOLayer : public QLabel { + Q_OBJECT + +public: + AOLayer(QWidget *p_parent, AOApplication *p_ao_app); + + QString filename; // file name without extension, i.e. "witnesstestimony" + int static_duration; // time in ms for static images to be displayed, if + // applicable. set to 0 for infinite + int max_duration; // maximum duration in ms, image will be culled if it is + // exceeded. set this to 0 for infinite duration + bool play_once = false; // Whether to loop this animation or not + bool cull_image = true; // if we're done playing this animation, should we + // hide it? also controls durational culling + Qt::TransformationMode transform_mode = Qt::FastTransformation; // transformation mode to use for this image + bool stretch = false; // Should we stretch/squash this image to fill the screen? + + // Set the movie's image to provided paths, preparing for playback. + void start_playback(QString p_image); + + void set_play_once(bool p_play_once); + void set_cull_image(bool p_cull_image); + void set_static_duration(int p_static_duration); + void set_max_duration(int p_max_duration); + + // Stop the movie, clearing the image + void stop(); + + // Set the m_flipped variable to true/false + void set_flipped(bool p_flipped) { m_flipped = p_flipped; } + + // Set the movie's playback speed (between 10% and 1000%) + void set_speed(int modifier) { speed = qMax(10, qMin(modifier, 1000)); } + + // Move the label itself around + void move(int ax, int ay); + + // This is somewhat pointless now as there's no "QMovie" object to resize, aka + // no "combo" to speak of + void combo_resize(int w, int h); + + // Return the frame delay adjusted for speed + int get_frame_delay(int delay); + + // iterate through a list of paths and return the first entry that exists. if + // none exist, return NULL (safe because we check again for existence later) + QString find_image(QList<QString> p_list); + +protected: + AOApplication *ao_app; + QVector<QPixmap> movie_frames; + QVector<int> movie_delays; + + QTimer *preanim_timer; + QTimer *shfx_timer; + QTimer *ticker; + QString last_path; + QImageReader m_reader; + + QElapsedTimer actual_time; + + // Usually used to turn seconds into milliseconds such as for [Time] tag in + // char.ini + const int tick_ms = 60; + + // These are the X and Y values before they are fixed based on the sprite's + // width. + int x = 0; + int y = 0; + // These are the width and height values before they are fixed based on the + // sprite's width. + int f_w = 0; + int f_h = 0; + + int frame = 0; + int max_frames = 0; + int last_max_frames = 0; + + int speed = 100; + + bool m_flipped = false; + // Are we loading this from the same frame we left off on? TODO: actually make + // this work + bool continuous = false; + // Whether or not to forcibly bypass the simple check done by start_playback + // and use the existent value of continuous instead + bool force_continuous = false; + + int duration = 0; + + // Start playback of the movie (if animated). + void play(); + + // Freeze the movie at the current frame. + void freeze(); + + // Retreive a pixmap adjused for mirroring/aspect ratio shenanigans from a + // provided QImage + QPixmap get_pixmap(QImage image); + + // Set the movie's frame to provided pixmap + void set_frame(QPixmap f_pixmap); + +signals: + void done(); + +protected slots: + virtual void preanim_done(); + void shfx_timer_done(); + virtual void movie_ticker(); +}; + +class BackgroundLayer : public AOLayer { + Q_OBJECT +public: + BackgroundLayer(QWidget *p_parent, AOApplication *p_ao_app); + void load_image(QString p_filename); +}; + +class ForegroundLayer : public AOLayer { + Q_OBJECT +public: + ForegroundLayer(QWidget *p_parent, AOApplication *p_ao_app); + QString miscname; //'misc' folder to search. we fetch this based on p_charname below + void load_image(QString p_filename, QString p_charname); +}; + +class CharLayer : public AOLayer { + Q_OBJECT +public: + CharLayer(QWidget *p_parent, AOApplication *p_ao_app); + QString current_emote = ""; // name of the emote we're using + bool is_preanim; // equivalent to the old play_once, if true we don't want + // to loop this + QString prefix = ""; // prefix, left blank if it's a preanim + + void load_image(QString p_filename, QString p_charname, int p_duration, bool p_is_preanim); + void play(); // overloaded so we can play effects + + // networked frame fx string + QStringList network_strings; + +private: + QString last_char; // name of the last character we used + QString last_emote; // name of the last animation we used + QString last_prefix; // prefix of the last animation we played + bool was_preanim = false; // whether is_preanim was true last time + + // Effects such as sfx, screenshakes and realization flashes are stored in + // here. QString entry format: "sfx^[sfx_name]", "shake", "flash". The program + // uses the QVector index as reference. + QVector<QVector<QString>> movie_effects; + + // used for effect loading + QString m_char = ""; + QString m_emote = ""; + + // overloaded for effects reasons + void start_playback(QString p_image); + + // Initialize the frame-specific effects from the char.ini + void load_effects(); + + // Initialize the frame-specific effects from the provided network_strings, + // this is only initialized if network_strings has size more than 0. + void load_network_effects(); + + // Play a frame-specific effect, if there's any defined for that specific + // frame. + void play_frame_effect(int p_frame); + +private slots: + void preanim_done() override; // overridden so we don't accidentally cull characters + void movie_ticker() override; // overridden so we can play effects + +signals: + void shake(); + void flash(); + void play_sfx(QString sfx); +}; + +class InterjectionLayer : public AOLayer { + Q_OBJECT +public: + InterjectionLayer(QWidget *p_parent, AOApplication *p_ao_app); + void load_image(QString p_filename, QString p_charname, QString p_miscname); +}; + +class EffectLayer : public AOLayer { + Q_OBJECT +public: + EffectLayer(QWidget *p_parent, AOApplication *p_ao_app); + void load_image(QString p_filename, bool p_looping); +}; + +class InterfaceLayer : public AOLayer { + Q_OBJECT +public: + InterfaceLayer(QWidget *p_parent, AOApplication *p_ao_app); + void load_image(QString p_filename, QString p_miscname); +}; + +class StickerLayer : public AOLayer { + Q_OBJECT +public: + StickerLayer(QWidget *p_parent, AOApplication *p_ao_app); + void load_image(QString p_charname); +}; +#endif // AOLAYER_H diff --git a/include/aomovie.h b/include/aomovie.h deleted file mode 100644 index eb7f7a53..00000000 --- a/include/aomovie.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef AOMOVIE_H -#define AOMOVIE_H - -#include <QLabel> -#include <QMovie> - -class Courtroom; -class AOApplication; - -class AOMovie : public QLabel { - Q_OBJECT - -public: - AOMovie(QWidget *p_parent, AOApplication *p_ao_app); - - void set_play_once(bool p_play_once); - void play(QString p_image, QString p_char = "", QString p_custom_theme = "", - int default_duration = 0); - void combo_resize(int w, int h); - void stop(); - -private: - QMovie *m_movie; - AOApplication *ao_app; - QTimer *timer; - bool play_once = true; - -signals: - void done(); - -private slots: - void frame_change(int n_frame); - void timer_done(); -}; - -#endif // AOMOVIE_H diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h index 2e2d7b8a..74fc9af7 100644 --- a/include/aooptionsdialog.h +++ b/include/aooptionsdialog.h @@ -52,6 +52,14 @@ private: QSpinBox *ui_log_margin_spinbox; QLabel *ui_log_timestamp_lbl; QCheckBox *ui_log_timestamp_cb; + QLabel *ui_stay_time_lbl; + QSpinBox *ui_stay_time_spinbox; + QLabel *ui_desync_logs_lbl; + QCheckBox *ui_desync_logs_cb; + QLabel *ui_instant_objection_lbl; + QCheckBox *ui_instant_objection_cb; + QLabel *ui_chat_ratelimit_lbl; + QSpinBox *ui_chat_ratelimit_spinbox; QLabel *ui_log_ic_actions_lbl; QCheckBox *ui_log_ic_actions_cb; QFrame *ui_log_names_divider; diff --git a/include/aopacket.h b/include/aopacket.h index 6d1debad..794025c5 100644 --- a/include/aopacket.h +++ b/include/aopacket.h @@ -12,7 +12,7 @@ public: QString get_header() { return m_header; } QStringList &get_contents() { return m_contents; } - QString to_string(); + QString to_string(bool encoded = false); void net_encode(); void net_decode(); diff --git a/include/aoscene.h b/include/aoscene.h deleted file mode 100644 index 726e2641..00000000 --- a/include/aoscene.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef AOSCENE_H -#define AOSCENE_H - -#include <QDebug> -#include <QLabel> -#include <QMovie> - -class Courtroom; -class AOApplication; - -class AOScene : public QLabel { - Q_OBJECT -public: - explicit AOScene(QWidget *parent, AOApplication *p_ao_app); - - void set_image(QString p_image); - void set_legacy_desk(QString p_image); - - // Move the label itself around - void move(int ax, int ay); - - // This is somewhat pointless now as there's no "QMovie" object to resize, aka - // no "combo" to speak of - void combo_resize(int w, int h); - -private: - QWidget *m_parent; - QMovie *m_movie; - AOApplication *ao_app; - QString last_image; - - // These are the X and Y values before they are fixed based on the sprite's - // width. - int x = 0; - int y = 0; - // These are the width and height values before they are fixed based on the - // sprite's width. - int f_w = 0; - int f_h = 0; -}; - -#endif // AOSCENE_H 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 diff --git a/include/demoserver.h b/include/demoserver.h new file mode 100644 index 00000000..b21811b7 --- /dev/null +++ b/include/demoserver.h @@ -0,0 +1,55 @@ +#ifndef DEMOSERVER_H +#define DEMOSERVER_H + +#include "aopacket.h" + +#include <QDebug> +#include <QObject> +#include <QQueue> +#include <QTcpServer> +#include <QTcpSocket> +#include <QTimer> +#include <QFileDialog> + +class DemoServer : public QObject +{ + Q_OBJECT +public: + explicit DemoServer(QObject *parent = nullptr); + + bool server_started = false; + int port = 27088; + int max_wait = -1; + int min_wait = -1; + +private: + void handle_packet(AOPacket packet); + void load_demo(QString filename); + + QTcpServer* tcp_server; + QTcpSocket* client_sock = nullptr; + bool client_connected = false; + bool partial_packet = false; + QString temp_packet = ""; + QQueue<QString> demo_data; + QString sc_packet; + int num_chars = 0; + QString p_path; + QTimer *timer; + int elapsed_time = 0; + +private slots: + void accept_connection(); + void destroy_connection(); + void recv_data(); + void client_disconnect(); + void playback(); + +public slots: + void start_server(); + +signals: + +}; + +#endif // DEMOSERVER_H |
