From 96fcb75c4c836887c80af3ddc1b4c8e1d4622abb Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 12 Jan 2021 13:46:39 +0300 Subject: Make sure blankposts are properly displayed unless repeats, playing nice with view desync --- include/courtroom.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/courtroom.h b/include/courtroom.h index 92b5a03..46da7a3 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -349,6 +349,7 @@ private: QVector arup_locks; QVector ic_chatlog_history; + int ic_chatlog_current = -1; QQueue chatmessage_queue; -- cgit From 2f84055af97859cb877eeafc6d92969e0699fdd9 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Thu, 14 Jan 2021 00:25:24 +0300 Subject: [2.8.6] Demo Recording/Playback (#337) * initial commit with horrible code dupcliation haha lol Set up elapsedtimer to generate wait# stuff between packets recorded * implement groundwork for internal demo server * add core playback functionality * make it work kinda by including SC packet in demo * Add a file dialog for loading a demo file instead of a hardcoded path * Change /play to > in OOC to begin playback or skip to next element Pop up file dialog box *before* establishing the connection, not after. TODO: * Fix having to load the same file *twice* to be able to connect to the demo server for some reason * Fix the segfault caused by calling the playback() function when there's no remaining data, it's almost like demo_data.isEmpty() is ignored for whatever reason??? * Clear demo data when loading a demo file to prevent stacking demos * Properly disconnect the client when sending the request for file browser fails to obtain a good demo file * Fix append_to_file newlining even if file didn't exist prior to calling this function * Add a very scuffed exception to not log or demo record anything that happens in the Demo playback local server * Reduce invalid file spam by checking for non-logging server better Use file_exists() to be more consistent in append_to_file * Fix the client crashing when receiving loading packets etc. at runtime such as SC, SM, CI etc. (TODO: parity???) Remove useless debug stuff * Preserve newlines for demo packets such as "CT", "MS" etc. * Implement /max_wait, /min_wait for adjusting the maximum and minimum wait in milliseconds between wait packets Add /pause or | shorthand to pause playback Re-add /play and keep > as a shorthand Remove clientside restrictions from sending empty OOC messages and sending OOC messages without a name - these should be serverside. * Empty music list Default the character to Spectator char no matter the selection in CSS * Allow -1 character ID or character ID that does not fit into the local Character Select Screen list to still be parsed corectly, using the character folder in the MS packet as reference. Allow servers with no selectable characters to still be properly loaded Bypass the Character Select Screen when joining a server with no character select screen and automatically become a spectator * Properly handle demo files without SC packet to dictate which chars exist Add a /load command letting you load a demo file without rejoining the demo server (the CS packet will not be properly handled but I cannot think of a single tangible problem this causes lol) Make sure all DEMO CT messages are colored properly * Fix logs bleeding into each other if you disabled logging or you joined a demo server after leaving another * Prevent logging even if log_filename is defined because a user might disable auto logging when running the game * Fix custom shownames not appearing in the IC logs * Set up new logic for max_wait, meaning that dead air being skipped is prioritized with MS (IC chat) packets being used as the anchor. * Better logic for min_wait to only affect important packets (IC Chat) * Fix encoding not being performed on packets that are saved to the .demo file, resulting in characters having something like "#1" in their message breaking that specific message * Fix a weird setup in courtroom.cpp that happened out of the merge and bugged the code Fix aopacket being busted up as well * add missing feature flags to the demoserver * use random port * move writing to the demo file to a function * only listen on localhost Co-authored-by: oldmud0 * remove copypasta * add a help to the demo server * fix empty demo disconnecting the server * tell the user how to begin Co-authored-by: scatterflower Co-authored-by: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Co-authored-by: stonedDiscord Co-authored-by: oldmud0 --- include/aoapplication.h | 9 ++++++++ include/aopacket.h | 2 +- include/demoserver.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 include/demoserver.h (limited to 'include') diff --git a/include/aoapplication.h b/include/aoapplication.h index 0e003a8..e96fefb 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -3,6 +3,7 @@ #include "aopacket.h" #include "datatypes.h" +#include "demoserver.h" #include "discord_rich_presence.h" #include "bass.h" @@ -27,6 +28,8 @@ #include #include +#include + class NetworkManager; class Lobby; class Courtroom; @@ -261,6 +264,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); @@ -458,6 +464,9 @@ public: void *user); static void doBASSreset(); + QElapsedTimer demo_timer; + DemoServer* demo_server = nullptr; + private: const int RELEASE = 2; const int MAJOR_VERSION = 8; diff --git a/include/aopacket.h b/include/aopacket.h index 6d1deba..794025c 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/demoserver.h b/include/demoserver.h new file mode 100644 index 0000000..b21811b --- /dev/null +++ b/include/demoserver.h @@ -0,0 +1,55 @@ +#ifndef DEMOSERVER_H +#define DEMOSERVER_H + +#include "aopacket.h" + +#include +#include +#include +#include +#include +#include +#include + +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 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 -- cgit From 147892bae917ea1f99fba312db87a31140b3ba37 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Thu, 14 Jan 2021 01:34:20 +0300 Subject: Overhaul sound lists to introduce aliases, rethink editing behavior (#389) * Resolve https://github.com/AttorneyOnline/AO2-Client/issues/275 by adding a "Nothing" option to play no SFX even when playing a preanimation that behaves similar to the Default option * Overhaul sound list: * Allow aliases. .ini file syntax is "filename = alias". * Do not allow editing the .ini files from the client anymore. * The sound list dropdown is still editable, but all it does is play your custom sfx without adding it to any files. * Overhaul get_char_sfx * Fix aliases not working properly with a rather tricky solution * save character soundlist in base and drop the character_ from the filename Co-authored-by: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> --- include/courtroom.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/courtroom.h b/include/courtroom.h index 92b5a03..d7bd696 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -503,6 +503,12 @@ 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; @@ -804,6 +810,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(); -- cgit From c42496e20479edd72ab57860967aed8592bd383b Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 15 Jan 2021 00:45:30 +0300 Subject: Make chat rate limit configurable (#398) Co-authored-by: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> --- include/aoapplication.h | 3 +++ include/aooptionsdialog.h | 2 ++ 2 files changed, 5 insertions(+) (limited to 'include') diff --git a/include/aoapplication.h b/include/aoapplication.h index e96fefb..5a02c3b 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -222,6 +222,9 @@ public: // 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(); diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h index 93b6677..74fc9af 100644 --- a/include/aooptionsdialog.h +++ b/include/aooptionsdialog.h @@ -58,6 +58,8 @@ private: 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; -- cgit From ea94644cf5bbd11f507b318677a7360433a0ae92 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Mon, 18 Jan 2021 17:56:21 +0300 Subject: Attempt a theoretically safer method of tracking last displayed message --- include/courtroom.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/courtroom.h b/include/courtroom.h index 46da7a3..92b5a03 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -349,7 +349,6 @@ private: QVector arup_locks; QVector ic_chatlog_history; - int ic_chatlog_current = -1; QQueue chatmessage_queue; -- cgit From 78777391467556b1312a00bdf1618619f771476e Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Mon, 18 Jan 2021 18:54:11 +0300 Subject: Simplify the logic behind last message = blankpost detection I need to stop overcomplicating things. --- include/courtroom.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/courtroom.h b/include/courtroom.h index 92b5a03..4cf42e1 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -349,6 +349,7 @@ private: QVector arup_locks; QVector ic_chatlog_history; + QString last_ic_message = ""; QQueue chatmessage_queue; -- cgit From d41ec17fe72dbcf1b5277ab7b33b6374a9fb9e60 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Mon, 18 Jan 2021 14:10:45 -0600 Subject: Add a new "char_list" QTreeWidget that allows for categorizing characters (#399) * initial commit * use a "category" value instead * add filtering and taken indicator * hide serverlist header * set the items to disabled in place of the [X] text Co-authored-by: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> --- include/aoapplication.h | 3 +++ include/courtroom.h | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'include') diff --git a/include/aoapplication.h b/include/aoapplication.h index 5a02c3b..4607fa6 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -342,6 +342,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); diff --git a/include/courtroom.h b/include/courtroom.h index 31b90c9..e86330e 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -715,6 +715,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; @@ -908,6 +911,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(); -- cgit From 21b4aa5072755923f5f555605ef4dc2b01857579 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Tue, 19 Jan 2021 05:30:56 -0600 Subject: unused macro and update QTime to QElapsedTimer (#417) --- include/aoapplication.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/aoapplication.h b/include/aoapplication.h index 4607fa6..9b7cef1 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -1,6 +1,8 @@ #ifndef AOAPPLICATION_H #define AOAPPLICATION_H +#define UNUSED(x) (void)(x) + #include "aopacket.h" #include "datatypes.h" #include "demoserver.h" -- cgit From 894b2b2a0e6bb2744e92a2d8ed363a39d7ae59b1 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Tue, 19 Jan 2021 05:32:11 -0600 Subject: Consolidate AOScene, AOMovie, and AOCharMovie into one class, add support for (c) animations, implement emote continuity, add scaling overrides to all layer types, allow for stretch-to-fill images, allow for additional effect configuration (#302) * Rewrite AOScene and remove the need for AOMovie and AOCharMovie by consolidation * Rename AOScene to AOLayer, apply suggestions to improve functionality * Implement suggested change to allocation * Switch from pointer to field, fix ui_vp_player_char not resetting play_once * Use the variable gif_name instead of the string "gif_name" Oops. * Total rewrite of AOLayer (again) * Add support for (c) animations, do some housekeeping * allow themes to override misc chatboxes * add support for pulling InterfaceLayer elements from theme/misc * mistakes were made * move all frame fx functionality to CharLayer subclass * virtual functions are cool mkay * remove evidence of my incompetence * allow themes to override font design inis under theme/misc * Proper support for theme/misc chatbox, fixes * Fix chatbox dimensions not updating and inline color causing missingnos * rename chat markdown to chat markup * add missing misc overrides * quick hotfix for chatblank and misc overrides * Fix oversight with backgrounds causing them to be culled * Same as last commit but for FG layer * amend comment to explain impossible shenanigans * Adjust ForegroundLayer to take charname rather than miscname, allow for checking in char folder * fix an incredibly embarrassing pathing bug * add scaling overrides for all layer types, parent orphaned viewport elements to the viewport * stupid fix because themes use "custom.png" as a button * switch to .append() * Revert "Merge branch 'aoscene_rewrite' of https://github.com/AttorneyOnline/AO2-Client into aoscene_rewrite" This reverts commit bdeb1bff7639d522031aab3c133a83b0e2a291df, reversing changes made to 125ee63b97a6f6c156e69525d88fddc625e7a978. * switch to .append() (again) * move function call to fix showname length calculation error * fix nonlooping character animations being broken Again * unparent elements from the viewport and do fancy masking arithmetic instead * use override keyword * move scaling override to char.ini, allow stretching, restructure effect property loading * fix some redundancy * unparent chat_arrow from chatbox to prevent accidental masking * at no point do we want a frozen gif to display * overhaul how wtce is handled * oops * also let sounds be pulled from theme miscs * i should probably compile before i push * actually make it work * don't check a default bg * readd 1x1 stretch thing * actually the 1x1 thing was a bad idea * Add missing parenthesis * Use load_image instead of play play is a nonexistent method now * Remote shout_message and usages because it does nothing * Remove multiple redefinitions * Add in missing brackets and indent to fix build I have know idea what this does but it brings fear * fix build error * fix chat arrow and remove duped code * remove more duped code and fix misc themes * only update chat_arrow when needed * consolidate log_chatmessage and display_log_chatmessage Co-authored-by: scatterflower Co-authored-by: Skye Deving <76892045+skyedeving@users.noreply.github.com> Co-authored-by: oldmud0 --- include/aoapplication.h | 22 +++-- include/aocharmovie.h | 125 -------------------------- include/aoevidencedisplay.h | 4 +- include/aolayer.h | 214 ++++++++++++++++++++++++++++++++++++++++++++ include/aomovie.h | 36 -------- include/aoscene.h | 42 --------- include/courtroom.h | 69 ++++++++------ 7 files changed, 272 insertions(+), 240 deletions(-) delete mode 100644 include/aocharmovie.h create mode 100644 include/aolayer.h delete mode 100644 include/aomovie.h delete mode 100644 include/aoscene.h (limited to 'include') diff --git a/include/aoapplication.h b/include/aoapplication.h index 9b7cef1..c0c3ba3 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -130,6 +130,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); @@ -301,14 +302,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); @@ -380,9 +381,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//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); @@ -432,6 +433,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. // ====== diff --git a/include/aocharmovie.h b/include/aocharmovie.h deleted file mode 100644 index 2dda0ec..0000000 --- a/include/aocharmovie.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef AOCHARMOVIE_H -#define AOCHARMOVIE_H - -#include -#include -#include -#include -#include - -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 movie_frames; - QVector 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> 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/aoevidencedisplay.h b/include/aoevidencedisplay.h index 979a754..ff448c9 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 @@ -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 0000000..2e0510a --- /dev/null +++ b/include/aolayer.h @@ -0,0 +1,214 @@ +#ifndef AOLAYER_H +#define AOLAYER_H + +#include +#include +#include +#include +#include +#include + +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 p_list); + +protected: + AOApplication *ao_app; + QVector movie_frames; + QVector 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> 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); +}; +#endif // AOLAYER_H diff --git a/include/aomovie.h b/include/aomovie.h deleted file mode 100644 index eb7f7a5..0000000 --- a/include/aomovie.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef AOMOVIE_H -#define AOMOVIE_H - -#include -#include - -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/aoscene.h b/include/aoscene.h deleted file mode 100644 index 726e264..0000000 --- a/include/aoscene.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef AOSCENE_H -#define AOSCENE_H - -#include -#include -#include - -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 e86330e..5ad6fa6 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -5,17 +5,15 @@ #include "aoblipplayer.h" #include "aobutton.h" #include "aocharbutton.h" -#include "aocharmovie.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" @@ -151,6 +149,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); @@ -224,11 +225,13 @@ public: // Parse the chat message packet and unpack it into the m_chatmessage[ITEM] format void unpack_chatmessage(QStringList p_contents); - // Log the message contents and information such as evidence presenting etc. into the log file - void log_chatmessage(QString f_message, int f_char_id, QString f_showname = "", int f_color = 0); - - // Display the message contents and information such as evidence presenting etc. in the IC logs - void display_log_chatmessage(QString f_message, int f_char_id, QString f_showname = "", int f_color = 0); + 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(); @@ -264,7 +267,8 @@ public: 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 @@ -380,7 +384,8 @@ private: // True, if log should display colors. bool log_colors = true; - // True, if the log should display the message like name
text instead of name: text + // True, if the log should display the message like name
text instead of + // name: text bool log_newline = false; // True, if the log should include RP actions like interjections, showing evidence, etc. @@ -408,16 +413,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 = ".,?!:;"; @@ -441,7 +451,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 @@ -512,6 +522,7 @@ private: // 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; @@ -579,21 +590,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; @@ -605,7 +615,7 @@ private: QTreeWidget *ui_music_list; ScrollText *ui_music_name; - AOMovie *ui_music_display; + InterfaceLayer *ui_music_display; AOButton *ui_pair_button; QListWidget *ui_pair_list; @@ -759,6 +769,7 @@ private: void regenerate_ic_chatlog(); public slots: void objection_done(); + void effect_done(); void preanim_done(); void do_screenshake(); void do_flash(); -- cgit From 0926f3c15842a71002c0ec374fd54832469036d8 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 19 Jan 2021 16:02:28 +0300 Subject: Implement sticker logic with animated image support (#414) * Implement sticker logic with animated image support (will probably be remade in a much better way for AOLayers) * port to aolayer Co-authored-by: in1tiate --- include/aolayer.h | 7 +++++++ include/courtroom.h | 2 ++ 2 files changed, 9 insertions(+) (limited to 'include') diff --git a/include/aolayer.h b/include/aolayer.h index 2e0510a..6265cec 100644 --- a/include/aolayer.h +++ b/include/aolayer.h @@ -211,4 +211,11 @@ 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/courtroom.h b/include/courtroom.h index 5ad6fa6..f12b47f 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -617,6 +617,8 @@ private: ScrollText *ui_music_name; InterfaceLayer *ui_music_display; + StickerLayer *ui_vp_sticker; + AOButton *ui_pair_button; QListWidget *ui_pair_list; QSpinBox *ui_pair_offset_spinbox; -- cgit