diff options
70 files changed, 10787 insertions, 9933 deletions
diff --git a/include/aoapplication.h b/include/aoapplication.h index ff75e4d1..d9e84fa8 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -32,402 +32,415 @@ class Lobby; class Courtroom; class AOApplication : public QApplication { - Q_OBJECT + Q_OBJECT public: - AOApplication(int &argc, char **argv); - ~AOApplication(); + AOApplication(int &argc, char **argv); + ~AOApplication(); - NetworkManager *net_manager; - Lobby *w_lobby; - Courtroom *w_courtroom; - AttorneyOnline::Discord *discord; + NetworkManager *net_manager; + Lobby *w_lobby; + Courtroom *w_courtroom; + AttorneyOnline::Discord *discord; + + bool lobby_constructed = false; + bool courtroom_constructed = false; - bool lobby_constructed = false; - bool courtroom_constructed = false; + void construct_lobby(); + void destruct_lobby(); - void construct_lobby(); - void destruct_lobby(); + void construct_courtroom(); + void destruct_courtroom(); - void construct_courtroom(); - void destruct_courtroom(); + void ms_packet_received(AOPacket *p_packet); + void server_packet_received(AOPacket *p_packet); - void ms_packet_received(AOPacket *p_packet); - void server_packet_received(AOPacket *p_packet); + void send_ms_packet(AOPacket *p_packet); + void send_server_packet(AOPacket *p_packet, bool encoded = true); - void send_ms_packet(AOPacket *p_packet); - void send_server_packet(AOPacket *p_packet, bool encoded = true); + void call_settings_menu(); + void call_announce_menu(Courtroom *court); - void call_settings_menu(); - void call_announce_menu(Courtroom *court); + /////////////////server metadata////////////////// - /////////////////server metadata////////////////// + unsigned int s_decryptor = 5; + bool encryption_needed = true; - unsigned int s_decryptor = 5; - bool encryption_needed = true; + bool yellow_text_enabled = false; + bool prezoom_enabled = false; + bool flipping_enabled = false; + bool custom_objection_enabled = false; + bool improved_loading_enabled = false; + bool desk_mod_enabled = false; + bool evidence_enabled = false; + bool cccc_ic_support_enabled = false; + bool arup_enabled = false; + bool casing_alerts_enabled = false; + bool modcall_reason_enabled = false; + bool looping_sfx_support_enabled = false; + bool additive_enabled = false; + bool effects_enabled = false; - bool yellow_text_enabled = false; - bool prezoom_enabled = false; - bool flipping_enabled = false; - bool custom_objection_enabled = false; - bool improved_loading_enabled = false; - bool desk_mod_enabled = false; - bool evidence_enabled = false; - bool cccc_ic_support_enabled = false; - bool arup_enabled = false; - bool casing_alerts_enabled = false; - bool modcall_reason_enabled = false; - bool looping_sfx_support_enabled = false; - bool additive_enabled = false; - bool effects_enabled = false; + ///////////////loading info/////////////////// - ///////////////loading info/////////////////// + // player number, it's hardly used but might be needed for some old servers + int s_pv = 0; - //player number, it's hardly used but might be needed for some old servers - int s_pv = 0; + QString server_software = ""; - QString server_software = ""; + int char_list_size = 0; + int loaded_chars = 0; + int generated_chars = 0; + int evidence_list_size = 0; + int loaded_evidence = 0; + int music_list_size = 0; + int loaded_music = 0; - int char_list_size = 0; - int loaded_chars = 0; - int generated_chars = 0; - int evidence_list_size = 0; - int loaded_evidence = 0; - int music_list_size = 0; - int loaded_music = 0; + bool courtroom_loaded = false; - bool courtroom_loaded = false; + //////////////////versioning/////////////// - //////////////////versioning/////////////// + int get_release() const { return RELEASE; } + int get_major_version() const { return MAJOR_VERSION; } + int get_minor_version() const { return MINOR_VERSION; } + QString get_version_string(); - int get_release() const { return RELEASE; } - int get_major_version() const { return MAJOR_VERSION; } - int get_minor_version() const { return MINOR_VERSION; } - QString get_version_string(); + /////////////////////////////////////////// - /////////////////////////////////////////// + void set_favorite_list(); + QVector<server_type> &get_favorite_list() { return favorite_list; } + void add_favorite_server(int p_server); - void set_favorite_list(); - QVector<server_type> &get_favorite_list() { return favorite_list; } - void add_favorite_server(int p_server); + void set_server_list(); + QVector<server_type> &get_server_list() { return server_list; } - void set_server_list(); - QVector<server_type> &get_server_list() { return server_list; } + // reads the theme from config.ini and sets it accordingly + void reload_theme(); - //reads the theme from config.ini and sets it accordingly - void reload_theme(); + // Returns the character the player has currently selected + QString get_current_char(); - //Returns the character the player has currently selected - QString get_current_char(); + // implementation in path_functions.cpp + QString get_base_path(); + QString get_data_path(); + QString get_theme_path(QString p_file); + 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_sounds_path(QString p_file); + QString get_music_path(QString p_song); + QString get_background_path(QString p_file); + QString get_default_background_path(QString p_file); + QString get_evidence_path(QString p_file); + QString get_case_sensitive_path(QString p_file); - //implementation in path_functions.cpp - QString get_base_path(); - QString get_data_path(); - QString get_theme_path(QString p_file); - 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_sounds_path(QString p_file); - QString get_music_path(QString p_song); - QString get_background_path(QString p_file); - QString get_default_background_path(QString p_file); - QString get_evidence_path(QString p_file); - QString get_case_sensitive_path(QString p_file); + ////// Functions for reading and writing files ////// + // Implementations file_functions.cpp - ////// Functions for reading and writing files ////// - // Implementations file_functions.cpp + // Instead of reinventing the wheel, we'll use a QSettings class. + QSettings *configini; - // Instead of reinventing the wheel, we'll use a QSettings class. - QSettings *configini; + // Reads the theme from config.ini and loads it into the current_theme + // variable + QString read_theme(); - //Reads the theme from config.ini and loads it into the current_theme variable - QString read_theme(); + // Returns the value of ooc_name in config.ini + QString get_ooc_name(); - //Returns the value of ooc_name in config.ini - QString get_ooc_name(); + // Returns the blip rate from config.ini (once per X symbols) + int read_blip_rate(); - //Returns the blip rate from config.ini (once per X symbols) - int read_blip_rate(); + // Returns true if blank blips is enabled in config.ini and false otherwise + bool get_blank_blip(); - //Returns true if blank blips is enabled in config.ini and false otherwise - bool get_blank_blip(); + // Returns true if looping sound effects are enabled in the config.ini + bool get_looping_sfx(); - //Returns true if looping sound effects are enabled in the config.ini - bool get_looping_sfx(); + // Returns true if stop music on objection is enabled in the config.ini + bool objection_stop_music(); - //Returns true if stop music on objection is enabled in the config.ini - bool objection_stop_music(); + // Returns the value of default_music in config.ini + int get_default_music(); - //Returns the value of default_music in config.ini - int get_default_music(); + // Returns the value of default_sfx in config.ini + int get_default_sfx(); - //Returns the value of default_sfx in config.ini - int get_default_sfx(); + // Returns the value of default_blip in config.ini + int get_default_blip(); - //Returns the value of default_blip in config.ini - int get_default_blip(); + // Returns the value of whether Discord should be enabled on startup + // from the config.ini. + bool is_discord_enabled(); - // Returns the value of whether Discord should be enabled on startup - // from the config.ini. - bool is_discord_enabled(); + // Returns the value of whether shaking should be enabled. + // from the config.ini. + bool is_shake_enabled(); - // Returns the value of whether shaking should be enabled. - // from the config.ini. - bool is_shake_enabled(); + // Returns the value of whether effects should be enabled. + // from the config.ini. + bool is_effects_enabled(); - // Returns the value of whether effects should be enabled. - // from the config.ini. - bool is_effects_enabled(); + // Returns the value of whether frame-specific effects defined in char.ini + // should be sent/received over the network. from the config.ini. + bool is_frame_network_enabled(); - // Returns the value of whether frame-specific effects defined in char.ini should be sent/received over the network. - // from the config.ini. - bool is_frame_network_enabled(); + // Returns the value of whether colored ic log should be a thing. + // from the config.ini. + bool is_colorlog_enabled(); - // Returns the value of whether colored ic log should be a thing. - // from the config.ini. - bool is_colorlog_enabled(); + // Returns the value of whether sticky sounds should be a thing. + // from the config.ini. + bool is_stickysounds_enabled(); - // Returns the value of whether sticky sounds should be a thing. - // from the config.ini. - bool is_stickysounds_enabled(); + // Returns the value of whether sticky effects should be a thing. + // from the config.ini. + bool is_stickyeffects_enabled(); - // Returns the value of whether sticky effects should be a thing. - // from the config.ini. - bool is_stickyeffects_enabled(); + // Returns the value of whether sticky preanims should be a thing. + // from the config.ini. + bool is_stickypres_enabled(); - // Returns the value of whether sticky preanims should be a thing. - // from the config.ini. - bool is_stickypres_enabled(); + // Returns the value of the maximum amount of lines the IC chatlog + // may contain, from config.ini. + int get_max_log_size(); - // Returns the value of the maximum amount of lines the IC chatlog - // may contain, from config.ini. - int get_max_log_size(); + // Returns whether the log should go upwards (new behaviour) + // or downwards (vanilla behaviour). + bool get_log_goes_downwards(); - // Returns whether the log should go upwards (new behaviour) - // or downwards (vanilla behaviour). - bool get_log_goes_downwards(); + // Returns the username the user may have set in config.ini. + QString get_default_username(); - // Returns the username the user may have set in config.ini. - QString get_default_username(); - - // Returns the audio device used for the client. - QString get_audio_output_device(); + // Returns the audio device used for the client. + QString get_audio_output_device(); #ifdef QTAUDIO - QAudioDeviceInfo QtAudioDevice; + QAudioDeviceInfo QtAudioDevice; #endif - // Returns whether the user would like to have custom shownames on by default. - bool get_showname_enabled_by_default(); + // Returns whether the user would like to have custom shownames on by default. + bool get_showname_enabled_by_default(); - //Returns the list of words in callwords.ini - QStringList get_call_words(); + // Returns the list of words in callwords.ini + QStringList get_call_words(); - //returns all of the file's lines in a QStringList - QStringList get_list_file(QString p_file); + // returns all of the file's lines in a QStringList + QStringList get_list_file(QString p_file); - //Process a file and return its text as a QString - QString read_file(QString filename); + // Process a file and return its text as a QString + QString read_file(QString filename); - //Write text to file. make_dir would auto-create the directory if it doesn't exist. - bool write_to_file(QString p_text, QString p_file, bool make_dir = false); + // Write text to file. make_dir would auto-create the directory if it doesn't + // exist. + bool write_to_file(QString p_text, QString p_file, bool make_dir = false); - //Append text to the end of the file. make_dir would auto-create the directory if it doesn't exist. - bool append_to_file(QString p_text, QString p_file, bool make_dir = false); + // Append text to the end of the file. make_dir would auto-create the + // directory if it doesn't exist. + bool append_to_file(QString p_text, QString p_file, bool make_dir = false); - //Appends the argument string to serverlist.txt - void write_to_serverlist_txt(QString p_line); + // Appends the argument string to serverlist.txt + void write_to_serverlist_txt(QString p_line); - //Returns the contents of serverlist.txt - QVector<server_type> read_serverlist_txt(); + // Returns the contents of serverlist.txt + QVector<server_type> read_serverlist_txt(); - //Returns the value of p_identifier in the design.ini file in p_design_path - QString read_design_ini(QString p_identifier, QString p_design_path); + // Returns the value of p_identifier in the design.ini file in p_design_path + QString read_design_ini(QString p_identifier, QString p_design_path); - //Returns the coordinates of widget with p_identifier from p_file - QPoint get_button_spacing(QString p_identifier, QString p_file); + // Returns the coordinates of widget with p_identifier from p_file + QPoint get_button_spacing(QString p_identifier, QString p_file); - //Returns the dimensions of widget with specified identifier from p_file - pos_size_type get_element_dimensions(QString p_identifier, QString p_file, QString p_char = ""); + // Returns the dimensions of widget with specified identifier from p_file + pos_size_type get_element_dimensions(QString p_identifier, QString p_file, + QString p_char = ""); - //Returns the value to you - QString get_design_element(QString p_identifier, QString p_file, QString p_char = ""); + // Returns the value to you + QString get_design_element(QString p_identifier, QString p_file, + QString p_char = ""); - //Returns the name of the font with p_identifier from p_file - QString get_font_name(QString p_identifier, QString p_file); + // Returns the name of the font with p_identifier from p_file + QString get_font_name(QString p_identifier, QString p_file); - //Returns the value of font_size with p_identifier from p_file - int get_font_size(QString p_identifier, QString p_file); + // Returns the value of font_size with p_identifier from p_file + int get_font_size(QString p_identifier, QString p_file); - //Returns the color with p_identifier from p_file - QColor get_color(QString p_identifier, QString p_file); + // 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 markdown symbol used for specified p_identifier such as colors + QString get_chat_markdown(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 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); + // Returns the sfx with p_identifier from sounds.ini in the current theme path + QString get_sfx(QString p_identifier); - //Figure out if we can opus this or if we should fall back to wav - QString get_sfx_suffix(QString sound_to_check); + // Figure out if we can opus this or if we should fall back to wav + QString get_sfx_suffix(QString sound_to_check); - // Can we use APNG for this? If not, WEBP? If not, GIF? If not, fall back to PNG. - QString get_image_suffix(QString path_to_check); + // Can we use APNG for this? If not, WEBP? If not, GIF? If not, fall back to + // PNG. + QString get_image_suffix(QString path_to_check); - // If this image is static and non-animated, return the supported static image formats. Currently only PNG. - QString get_static_image_suffix(QString path_to_check); + // If this image is static and non-animated, return the supported static image + // formats. Currently only PNG. + QString get_static_image_suffix(QString path_to_check); - //Returns the value of p_search_line within target_tag and terminator_tag - QString read_char_ini(QString p_char, QString p_search_line, QString target_tag); + // Returns the value of p_search_line within target_tag and terminator_tag + QString read_char_ini(QString p_char, QString p_search_line, + QString target_tag); - //Returns a QStringList of all key=value definitions on a given tag. - QStringList read_ini_tags(QString p_file, QString target_tag = ""); + // Returns a QStringList of all key=value definitions on a given tag. + QStringList read_ini_tags(QString p_file, QString target_tag = ""); - //Sets the char.ini p_search_line key under tag target_tag to value. - void set_char_ini(QString p_char, QString value, QString p_search_line, QString target_tag); + // Sets the char.ini p_search_line key under tag target_tag to value. + void set_char_ini(QString p_char, QString value, QString p_search_line, + QString target_tag); - //Returns the text between target_tag and terminator_tag in p_file - QString get_stylesheet(QString p_file); + // Returns the text between target_tag and terminator_tag in p_file + QString get_stylesheet(QString p_file); - //Returns the text between target_tag and terminator_tag in p_file - QString get_tagged_stylesheet(QString target_tag, QString p_file); + // Returns the text between target_tag and terminator_tag in p_file + QString get_tagged_stylesheet(QString target_tag, QString p_file); - //Returns the side of the p_char character from that characters ini file - QString get_char_side(QString p_char); + // Returns the side of the p_char character from that characters ini file + QString get_char_side(QString p_char); - //Returns the showname from the ini of p_char - QString get_showname(QString p_char); + // Returns the showname from the ini of p_char + QString get_showname(QString p_char); - //Returns the value of chat image from the specific p_char's ini file - QString get_chat(QString p_char); + // Returns the value of chat image from the specific p_char's ini file + QString get_chat(QString p_char); - //Returns the value of chat font from the specific p_char's ini file - QString get_chat_font(QString p_char); + // Returns the value of chat font from the specific p_char's ini file + QString get_chat_font(QString p_char); - //Returns the value of chat font size from the specific p_char's ini file - int get_chat_size(QString p_char); + // Returns the value of chat font size from the specific p_char's ini file + int get_chat_size(QString p_char); - //Returns the value of shouts from the specified p_char's ini file - QString get_char_shouts(QString p_char); + // Returns the value of shouts from the specified p_char's ini file + QString get_char_shouts(QString p_char); - //Returns the preanim duration of p_char's p_emote - int get_preanim_duration(QString p_char, QString p_emote); + // Returns the preanim duration of p_char's p_emote + int get_preanim_duration(QString p_char, QString p_emote); - //Same as above, but only returns if it has a % in front(refer to Preanims section in the manual) - int get_ao2_preanim_duration(QString p_char, QString p_emote); + // Same as above, but only returns if it has a % in front(refer to Preanims + // section in the manual) + int get_ao2_preanim_duration(QString p_char, QString p_emote); - //Not in use - int get_text_delay(QString p_char, QString p_emote); + // Not in use + int get_text_delay(QString p_char, QString p_emote); - //Get the effects folder referenced by the char.ini, read it and return the list of filenames in a string - QStringList get_theme_effects(); + // Get the effects folder referenced by the char.ini, read it and return the + // list of filenames in a string + QStringList get_theme_effects(); - //Get the theme's effects folder, read it and return the list of filenames in a string - QStringList get_effects(QString p_char); + // Get the theme's effects folder, read it and return the list of filenames in + // a string + QStringList get_effects(QString p_char); - //t - QString get_effect(QString effect, QString p_char, QString p_folder); + // 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 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); - // Returns the custom realisation used by the character. - QString get_custom_realization(QString p_char); + // Returns the custom realisation used by the character. + QString get_custom_realization(QString p_char); - //Returns the name of p_char - QString get_char_name(QString p_char); + // Returns the name of p_char + QString get_char_name(QString p_char); - //Returns the total amount of emotes of p_char - int get_emote_number(QString p_char); + // Returns the total amount of emotes of p_char + int get_emote_number(QString p_char); - //Returns the emote comment of p_char's p_emote - QString get_emote_comment(QString p_char, int p_emote); + // Returns the emote comment of p_char's p_emote + QString get_emote_comment(QString p_char, int p_emote); - //Returns the base name of p_char's p_emote - QString get_emote(QString p_char, int p_emote); + // Returns the base name of p_char's p_emote + QString get_emote(QString p_char, int p_emote); - //Returns the preanimation name of p_char's p_emote - QString get_pre_emote(QString p_char, int p_emote); + // Returns the preanimation name of p_char's p_emote + QString get_pre_emote(QString p_char, int p_emote); - //Returns the sfx of p_char's p_emote - QString get_sfx_name(QString p_char, int p_emote); + // Returns the sfx of p_char's p_emote + QString get_sfx_name(QString p_char, int p_emote); - //Returns the blipsound of p_char's p_emote - QString get_emote_blip(QString p_char, int p_emote); + // Returns the blipsound of p_char's p_emote + QString get_emote_blip(QString p_char, int p_emote); - //Returns if the sfx is defined as looping in char.ini - QString get_sfx_looping(QString p_char, QString p_sfx); + // Returns if the sfx is defined as looping in char.ini + QString get_sfx_looping(QString p_char, QString p_sfx); - //Returns if an emote has a frame specific SFX for it - QString get_sfx_frame(QString p_char, QString p_emote, int n_frame); + // Returns if an emote has a frame specific SFX for it + QString get_sfx_frame(QString p_char, QString p_emote, int n_frame); - //Returns if an emote has a frame specific SFX for it - QString get_flash_frame(QString p_char, QString p_emote, int n_frame); + // Returns if an emote has a frame specific SFX for it + QString get_flash_frame(QString p_char, QString p_emote, int n_frame); - //Returns if an emote has a frame specific SFX for it - QString get_screenshake_frame(QString p_char, QString p_emote, int n_frame); + // Returns if an emote has a frame specific SFX for it + QString get_screenshake_frame(QString p_char, QString p_emote, int n_frame); - //Not in use - int get_sfx_delay(QString p_char, int p_emote); + // Not in use + int get_sfx_delay(QString p_char, int p_emote); - //Returns the modifier for p_char's p_emote - int get_emote_mod(QString p_char, int p_emote); + // Returns the modifier for p_char's p_emote + int get_emote_mod(QString p_char, int p_emote); - //Returns the desk modifier for p_char's p_emote - int get_desk_mod(QString p_char, int p_emote); + // Returns the desk modifier for p_char's p_emote + int get_desk_mod(QString p_char, int p_emote); - //Returns p_char's gender - QString get_gender(QString p_char); + // Returns p_char's gender + QString get_gender(QString p_char); - // ====== - // These are all casing-related settings. - // ====== + // ====== + // These are all casing-related settings. + // ====== - // Returns if the user has casing alerts enabled. - bool get_casing_enabled(); + // Returns if the user has casing alerts enabled. + bool get_casing_enabled(); - // Returns if the user wants to get alerts for the defence role. - bool get_casing_defence_enabled(); + // Returns if the user wants to get alerts for the defence role. + bool get_casing_defence_enabled(); - // Same for prosecution. - bool get_casing_prosecution_enabled(); + // Same for prosecution. + bool get_casing_prosecution_enabled(); - // Same for judge. - bool get_casing_judge_enabled(); + // Same for judge. + bool get_casing_judge_enabled(); - // Same for juror. - bool get_casing_juror_enabled(); + // Same for juror. + bool get_casing_juror_enabled(); - // Same for steno. - bool get_casing_steno_enabled(); + // Same for steno. + bool get_casing_steno_enabled(); - // Same for CM. - bool get_casing_cm_enabled(); + // Same for CM. + bool get_casing_cm_enabled(); - // Get the message for the CM for casing alerts. - QString get_casing_can_host_cases(); + // Get the message for the CM for casing alerts. + QString get_casing_can_host_cases(); - //The file name of the log file in base/logs. - QString log_filename; + // The file name of the log file in base/logs. + QString log_filename; private: - const int RELEASE = 2; - const int MAJOR_VERSION = 8; - const int MINOR_VERSION = 3; + const int RELEASE = 2; + const int MAJOR_VERSION = 8; + const int MINOR_VERSION = 3; - QString current_theme = "default"; + QString current_theme = "default"; - QVector<server_type> server_list; - QVector<server_type> favorite_list; + QVector<server_type> server_list; + QVector<server_type> favorite_list; private slots: - void ms_connect_finished(bool connected, bool will_retry); + void ms_connect_finished(bool connected, bool will_retry); public slots: - void server_disconnected(); - void loading_cancelled(); + void server_disconnected(); + void loading_cancelled(); }; #endif // AOAPPLICATION_H diff --git a/include/aoblipplayer.h b/include/aoblipplayer.h index db6dfce6..3a582a27 100644 --- a/include/aoblipplayer.h +++ b/include/aoblipplayer.h @@ -17,28 +17,28 @@ class AOBlipPlayer { public: - AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app); + AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app); - void set_blips(QString p_sfx); - void blip_tick(); - void set_volume(qreal p_volume); + void set_blips(QString p_sfx); + void blip_tick(); + void set_volume(qreal p_volume); - int m_cycle = 0; + int m_cycle = 0; private: - const int max_blip_ms = 60; + const int max_blip_ms = 60; - QWidget *m_parent; - AOApplication *ao_app; - qreal m_volume; - QElapsedTimer delay; + QWidget *m_parent; + AOApplication *ao_app; + qreal m_volume; + QElapsedTimer delay; - void set_volume_internal(qreal p_volume); + void set_volume_internal(qreal p_volume); #if defined(BASSAUDIO) - HSTREAM m_stream_list[5]; + HSTREAM m_stream_list[5]; #elif defined(QTAUDIO) - QSoundEffect m_blips; + QSoundEffect m_blips; #endif }; diff --git a/include/aobutton.h b/include/aobutton.h index 598d2c0d..f5758856 100644 --- a/include/aobutton.h +++ b/include/aobutton.h @@ -7,15 +7,15 @@ #include <QPushButton> class AOButton : public QPushButton { - Q_OBJECT + Q_OBJECT public: - AOButton(QWidget *parent, AOApplication *p_ao_app); - ~AOButton(); + AOButton(QWidget *parent, AOApplication *p_ao_app); + ~AOButton(); - AOApplication *ao_app; + AOApplication *ao_app; - void set_image(QString p_image); + void set_image(QString p_image); }; #endif // AOBUTTON_H diff --git a/include/aocaseannouncerdialog.h b/include/aocaseannouncerdialog.h index 930fa414..0ac8f074 100644 --- a/include/aocaseannouncerdialog.h +++ b/include/aocaseannouncerdialog.h @@ -13,32 +13,34 @@ #include <QtWidgets/QVBoxLayout> class AOCaseAnnouncerDialog : public QDialog { - Q_OBJECT + Q_OBJECT public: - explicit AOCaseAnnouncerDialog(QWidget *parent = nullptr, AOApplication *p_ao_app = nullptr, Courtroom *p_court = nullptr); + explicit AOCaseAnnouncerDialog(QWidget *parent = nullptr, + AOApplication *p_ao_app = nullptr, + Courtroom *p_court = nullptr); private: - AOApplication *ao_app; - Courtroom *court; + AOApplication *ao_app; + Courtroom *court; - QDialogButtonBox *ui_announcer_buttons; + QDialogButtonBox *ui_announcer_buttons; - QVBoxLayout *ui_vbox_layout; - QFormLayout *ui_form_layout; + QVBoxLayout *ui_vbox_layout; + QFormLayout *ui_form_layout; - QLabel *ui_case_title_label; - QLineEdit *ui_case_title_textbox; + QLabel *ui_case_title_label; + QLineEdit *ui_case_title_textbox; - QCheckBox *ui_defense_needed; - QCheckBox *ui_prosecutor_needed; - QCheckBox *ui_judge_needed; - QCheckBox *ui_juror_needed; - QCheckBox *ui_steno_needed; + QCheckBox *ui_defense_needed; + QCheckBox *ui_prosecutor_needed; + QCheckBox *ui_judge_needed; + QCheckBox *ui_juror_needed; + QCheckBox *ui_steno_needed; public slots: - void ok_pressed(); - void cancel_pressed(); + void ok_pressed(); + void cancel_pressed(); }; #endif // AOCASEANNOUNCERDIALOG_H diff --git a/include/aocharbutton.h b/include/aocharbutton.h index a5367924..dd27e62c 100644 --- a/include/aocharbutton.h +++ b/include/aocharbutton.h @@ -10,34 +10,35 @@ #include <QWidget> class AOCharButton : public QPushButton { - Q_OBJECT + Q_OBJECT public: - AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos, bool is_taken); + AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos, + bool is_taken); - AOApplication *ao_app; + AOApplication *ao_app; - void refresh(); - void reset(); - void set_taken(bool is_taken); - void set_passworded(); + void refresh(); + void reset(); + void set_taken(bool is_taken); + void set_passworded(); - void apply_taken_image(); + void apply_taken_image(); - void set_image(QString p_character); + void set_image(QString p_character); private: - bool taken; + bool taken; - QWidget *m_parent; + QWidget *m_parent; - AOImage *ui_taken; - AOImage *ui_passworded; - AOImage *ui_selector; + AOImage *ui_taken; + AOImage *ui_passworded; + AOImage *ui_selector; protected: - void enterEvent(QEvent *e); - void leaveEvent(QEvent *e); + void enterEvent(QEvent *e); + void leaveEvent(QEvent *e); }; #endif // AOCHARBUTTON_H diff --git a/include/aocharmovie.h b/include/aocharmovie.h index 2a185dd2..2dda0ec2 100644 --- a/include/aocharmovie.h +++ b/include/aocharmovie.h @@ -10,109 +10,116 @@ class AOApplication; class AOCharMovie : public QLabel { - Q_OBJECT + Q_OBJECT public: - AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app); + 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 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 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); + // 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(); + // 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 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)); } + // 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); + // 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); + // 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); + // Return the frame delay adjusted for speed + int get_frame_delay(int delay); - QStringList network_strings; + QStringList network_strings; - QString m_char; - QString m_emote; + QString m_char; + QString m_emote; private: - AOApplication *ao_app; + AOApplication *ao_app; - QVector<QPixmap> movie_frames; - QVector<int> movie_delays; + 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; + // 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(); + QTimer *preanim_timer; + QTimer *ticker; + QString last_path; + QImageReader *m_reader = new QImageReader(); - QElapsedTimer actual_time; + QElapsedTimer actual_time; - //Usually used to turn seconds into milliseconds such as for [Time] tag in char.ini - const int time_mod = 60; + // 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; + // 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 frame = 0; + int max_frames = 0; - int speed = 100; + int speed = 100; - bool m_flipped = false; - bool play_once = true; + 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); + // 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(); + // 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); + // 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); + // 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); + // 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 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(); + // 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); + void done(); + void shake(); + void flash(); + void play_sfx(QString sfx); private slots: - void preanim_done(); - void movie_ticker(); + void preanim_done(); + void movie_ticker(); }; #endif // AOCHARMOVIE_H diff --git a/include/aoemotebutton.h b/include/aoemotebutton.h index 8674bb08..cb46167f 100644 --- a/include/aoemotebutton.h +++ b/include/aoemotebutton.h @@ -7,28 +7,29 @@ #include <QPushButton> class AOEmoteButton : public QPushButton { - Q_OBJECT + Q_OBJECT public: - AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h); + AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y, + int p_w, int p_h); - void set_image(QString p_image, QString p_emote_comment); - void set_char_image(QString p_char, int p_emote, QString suffix); + void set_image(QString p_image, QString p_emote_comment); + void set_char_image(QString p_char, int p_emote, QString suffix); - void set_id(int p_id) { m_id = p_id; } - int get_id() { return m_id; } + void set_id(int p_id) { m_id = p_id; } + int get_id() { return m_id; } private: - QWidget *parent; - AOApplication *ao_app; + QWidget *parent; + AOApplication *ao_app; - int m_id = 0; + int m_id = 0; signals: - void emote_clicked(int p_id); + void emote_clicked(int p_id); private slots: - void on_clicked(); + void on_clicked(); }; #endif // AOEMOTEBUTTON_H diff --git a/include/aoevidencebutton.h b/include/aoevidencebutton.h index 2ac6860b..d7812fe9 100644 --- a/include/aoevidencebutton.h +++ b/include/aoevidencebutton.h @@ -9,42 +9,43 @@ #include <QString> class AOEvidenceButton : public QPushButton { - Q_OBJECT + Q_OBJECT public: - AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h); + AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y, + int p_w, int p_h); - void set_image(QString p_image); - void set_theme_image(QString p_image); - void set_id(int p_id) { m_id = p_id; } + void set_image(QString p_image); + void set_theme_image(QString p_image); + void set_id(int p_id) { m_id = p_id; } - void set_selected(bool p_selected); + void set_selected(bool p_selected); private: - AOApplication *ao_app; - QWidget *m_parent; + AOApplication *ao_app; + QWidget *m_parent; - AOImage *ui_selected; - AOImage *ui_selector; + AOImage *ui_selected; + AOImage *ui_selector; - int m_id = 0; + int m_id = 0; protected: - void enterEvent(QEvent *e); - void leaveEvent(QEvent *e); - void mouseDoubleClickEvent(QMouseEvent *e); - /* - void dragLeaveEvent(QMouseEvent *e); - void dragEnterEvent(QMouseEvent *e); - */ + void enterEvent(QEvent *e); + void leaveEvent(QEvent *e); + void mouseDoubleClickEvent(QMouseEvent *e); + /* +void dragLeaveEvent(QMouseEvent *e); +void dragEnterEvent(QMouseEvent *e); +*/ signals: - void evidence_clicked(int p_id); - void evidence_double_clicked(int p_id); - void on_hover(int p_id, bool p_state); + void evidence_clicked(int p_id); + void evidence_double_clicked(int p_id); + void on_hover(int p_id, bool p_state); private slots: - void on_clicked(); + void on_clicked(); }; #endif // AOEVIDENCEBUTTON_H diff --git a/include/aoevidencedisplay.h b/include/aoevidencedisplay.h index 0315ffcf..979a754e 100644 --- a/include/aoevidencedisplay.h +++ b/include/aoevidencedisplay.h @@ -9,24 +9,24 @@ #include <QLabel> class AOEvidenceDisplay : public QLabel { - Q_OBJECT + Q_OBJECT public: - AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app); + AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app); - void show_evidence(QString p_evidence_image, bool is_left_side, int p_volume); - QLabel *get_evidence_icon(); - void reset(); - void combo_resize(int w, int h); + void show_evidence(QString p_evidence_image, bool is_left_side, int p_volume); + QLabel *get_evidence_icon(); + void reset(); + void combo_resize(int w, int h); private: - AOApplication *ao_app; - AOMovie *evidence_movie; - QLabel *evidence_icon; - AOSfxPlayer *sfx_player; + AOApplication *ao_app; + AOMovie *evidence_movie; + QLabel *evidence_icon; + AOSfxPlayer *sfx_player; private slots: - void show_done(); + void show_done(); }; #endif // AOEVIDENCEDISPLAY_H diff --git a/include/aoimage.h b/include/aoimage.h index a6960de6..01ef8540 100644 --- a/include/aoimage.h +++ b/include/aoimage.h @@ -1,4 +1,4 @@ -//This class represents a static theme-dependent image +// This class represents a static theme-dependent image #ifndef AOIMAGE_H #define AOIMAGE_H @@ -10,15 +10,15 @@ class AOImage : public QLabel { public: - AOImage(QWidget *parent, AOApplication *p_ao_app); - ~AOImage(); + AOImage(QWidget *parent, AOApplication *p_ao_app); + ~AOImage(); - QWidget *m_parent; - AOApplication *ao_app; + QWidget *m_parent; + AOApplication *ao_app; - bool set_image(QString p_image); - bool set_chatbox(QString p_path); - void set_size_and_pos(QString identifier); + bool set_image(QString p_image); + bool set_chatbox(QString p_path); + void set_size_and_pos(QString identifier); }; #endif // AOIMAGE_H diff --git a/include/aolineedit.h b/include/aolineedit.h index 06206a95..5dce3aaa 100644 --- a/include/aolineedit.h +++ b/include/aolineedit.h @@ -5,22 +5,22 @@ #include <QMouseEvent> class AOLineEdit : public QLineEdit { - Q_OBJECT + Q_OBJECT public: - AOLineEdit(QWidget *parent); + AOLineEdit(QWidget *parent); - void preserve_selection(bool toggle) { p_selection = toggle; } + void preserve_selection(bool toggle) { p_selection = toggle; } private: - bool p_selection = false; + bool p_selection = false; protected: - void mouseDoubleClickEvent(QMouseEvent *e); - void focusOutEvent(QFocusEvent *ev); + void mouseDoubleClickEvent(QMouseEvent *e); + void focusOutEvent(QFocusEvent *ev); signals: - void double_clicked(); + void double_clicked(); }; #endif // AOLINEEDIT_H diff --git a/include/aomovie.h b/include/aomovie.h index 8d604423..eb7f7a53 100644 --- a/include/aomovie.h +++ b/include/aomovie.h @@ -8,28 +8,29 @@ class Courtroom; class AOApplication; class AOMovie : public QLabel { - Q_OBJECT + Q_OBJECT public: - AOMovie(QWidget *p_parent, AOApplication *p_ao_app); + 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(); + 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; + QMovie *m_movie; + AOApplication *ao_app; + QTimer *timer; + bool play_once = true; signals: - void done(); + void done(); private slots: - void frame_change(int n_frame); - void timer_done(); + void frame_change(int n_frame); + void timer_done(); }; #endif // AOMOVIE_H diff --git a/include/aomusicplayer.h b/include/aomusicplayer.h index d28a3ed6..5c72649f 100644 --- a/include/aomusicplayer.h +++ b/include/aomusicplayer.h @@ -17,63 +17,64 @@ #if defined(BASSAUDIO) class AOMusicPlayer { public: - AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app); - virtual ~AOMusicPlayer(); - void set_volume(int p_value, int channel = -1); - void set_looping(bool toggle, int channel = 0); + AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app); + virtual ~AOMusicPlayer(); + void set_volume(int p_value, int channel = -1); + void set_looping(bool toggle, int channel = 0); - const int m_channelmax = 4; + const int m_channelmax = 4; - //These have to be public for the stupid sync thing - QWORD loop_start = 0; - QWORD loop_end = 0; + // These have to be public for the stupid sync thing + QWORD loop_start = 0; + QWORD loop_end = 0; public slots: - void play(QString p_song, int channel = 0, bool loop = false, int effect_flags = 0); - void stop(int channel = 0); + void play(QString p_song, int channel = 0, bool loop = false, + int effect_flags = 0); + void stop(int channel = 0); private: - QWidget *m_parent; - AOApplication *ao_app; + QWidget *m_parent; + AOApplication *ao_app; - bool m_looping = false; - int m_volume[4] = {0, 0, 0, 0}; + bool m_looping = false; + int m_volume[4] = {0, 0, 0, 0}; - // Channel 0 = music - // Channel 1 = ambience - // Channel 2 = extra - // Channel 3 = extra - HSTREAM m_stream_list[4]; - HSYNC loop_sync[4]; + // Channel 0 = music + // Channel 1 = ambience + // Channel 2 = extra + // Channel 3 = extra + HSTREAM m_stream_list[4]; + HSYNC loop_sync[4]; }; #elif defined(QTAUDIO) class AOMusicPlayer { public: - AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app); - ~AOMusicPlayer(); + AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app); + ~AOMusicPlayer(); - void play(QString p_song); - void set_volume(int p_value); + void play(QString p_song); + void set_volume(int p_value); private: - QMediaPlayer m_player; - QWidget *m_parent; - AOApplication *ao_app; + QMediaPlayer m_player; + QWidget *m_parent; + AOApplication *ao_app; - int m_volume = 0; + int m_volume = 0; }; #else class AOMusicPlayer { public: - AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app); - ~AOMusicPlayer(); + AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app); + ~AOMusicPlayer(); - void play(QString p_song); - void set_volume(int p_value); + void play(QString p_song); + void set_volume(int p_value); private: - QWidget *m_parent; - AOApplication *ao_app; + QWidget *m_parent; + AOApplication *ao_app; }; #endif diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h index f9c369d2..b89e3174 100644 --- a/include/aooptionsdialog.h +++ b/include/aooptionsdialog.h @@ -31,116 +31,117 @@ #include <QTextStream> class AOOptionsDialog : public QDialog { - Q_OBJECT + Q_OBJECT public: - explicit AOOptionsDialog(QWidget *parent = nullptr, AOApplication *p_ao_app = nullptr); + explicit AOOptionsDialog(QWidget *parent = nullptr, + AOApplication *p_ao_app = nullptr); private: - AOApplication *ao_app; - - QVBoxLayout *ui_vertical_layout; - QTabWidget *ui_settings_tabs; - - QWidget *ui_gameplay_tab; - QWidget *ui_form_layout_widget; - QFormLayout *ui_gameplay_form; - QLabel *ui_theme_label; - QComboBox *ui_theme_combobox; - QFrame *ui_theme_log_divider; - QLabel *ui_downwards_lbl; - QCheckBox *ui_downwards_cb; - QLabel *ui_length_lbl; - QSpinBox *ui_length_spinbox; - QFrame *ui_log_names_divider; - QLineEdit *ui_username_textbox; - QLabel *ui_username_lbl; - QLabel *ui_showname_lbl; - QCheckBox *ui_showname_cb; - QFrame *ui_net_divider; - QLabel *ui_ms_lbl; - QLineEdit *ui_ms_textbox; - QLabel *ui_discord_lbl; - QCheckBox *ui_discord_cb; - QLabel *ui_language_label; - QComboBox *ui_language_combobox; - - QLabel *ui_shake_lbl; - QCheckBox *ui_shake_cb; - QLabel *ui_effects_lbl; - QCheckBox *ui_effects_cb; - QLabel *ui_framenetwork_lbl; - QCheckBox *ui_framenetwork_cb; - - QLabel *ui_colorlog_lbl; - QCheckBox *ui_colorlog_cb; - - QLabel *ui_stickysounds_lbl; - QCheckBox *ui_stickysounds_cb; - - QLabel *ui_stickyeffects_lbl; - QCheckBox *ui_stickyeffects_cb; - - QLabel *ui_stickypres_lbl; - QCheckBox *ui_stickypres_cb; - - QWidget *ui_callwords_tab; - QWidget *ui_callwords_widget; - QVBoxLayout *ui_callwords_layout; - QPlainTextEdit *ui_callwords_textbox; - QLabel *ui_callwords_explain_lbl; - QCheckBox *ui_callwords_char_textbox; - - QWidget *ui_audio_tab; - QWidget *ui_audio_widget; - QFormLayout *ui_audio_layout; - QLabel *ui_audio_device_lbl; - QComboBox *ui_audio_device_combobox; - QFrame *ui_audio_volume_divider; - QSpinBox *ui_music_volume_spinbox; - QLabel *ui_music_volume_lbl; - QSpinBox *ui_sfx_volume_spinbox; - QSpinBox *ui_blips_volume_spinbox; - QLabel *ui_sfx_volume_lbl; - QLabel *ui_blips_volume_lbl; - QFrame *ui_volume_blip_divider; - QSpinBox *ui_bliprate_spinbox; - QLabel *ui_bliprate_lbl; - QCheckBox *ui_blank_blips_cb; - QLabel *ui_blank_blips_lbl; - QLabel *ui_loopsfx_lbl; - QCheckBox *ui_loopsfx_cb; - QLabel *ui_objectmusic_lbl; - QCheckBox *ui_objectmusic_cb; - QDialogButtonBox *ui_settings_buttons; - - QWidget *ui_casing_tab; - QWidget *ui_casing_widget; - QFormLayout *ui_casing_layout; - QLabel *ui_casing_supported_lbl; - QLabel *ui_casing_enabled_lbl; - QCheckBox *ui_casing_enabled_cb; - QLabel *ui_casing_def_lbl; - QCheckBox *ui_casing_def_cb; - QLabel *ui_casing_pro_lbl; - QCheckBox *ui_casing_pro_cb; - QLabel *ui_casing_jud_lbl; - QCheckBox *ui_casing_jud_cb; - QLabel *ui_casing_jur_lbl; - QCheckBox *ui_casing_jur_cb; - QLabel *ui_casing_steno_lbl; - QCheckBox *ui_casing_steno_cb; - QLabel *ui_casing_cm_lbl; - QCheckBox *ui_casing_cm_cb; - QLabel *ui_casing_cm_cases_lbl; - QLineEdit *ui_casing_cm_cases_textbox; - - bool needs_default_audiodev(); + AOApplication *ao_app; + + QVBoxLayout *ui_vertical_layout; + QTabWidget *ui_settings_tabs; + + QWidget *ui_gameplay_tab; + QWidget *ui_form_layout_widget; + QFormLayout *ui_gameplay_form; + QLabel *ui_theme_label; + QComboBox *ui_theme_combobox; + QFrame *ui_theme_log_divider; + QLabel *ui_downwards_lbl; + QCheckBox *ui_downwards_cb; + QLabel *ui_length_lbl; + QSpinBox *ui_length_spinbox; + QFrame *ui_log_names_divider; + QLineEdit *ui_username_textbox; + QLabel *ui_username_lbl; + QLabel *ui_showname_lbl; + QCheckBox *ui_showname_cb; + QFrame *ui_net_divider; + QLabel *ui_ms_lbl; + QLineEdit *ui_ms_textbox; + QLabel *ui_discord_lbl; + QCheckBox *ui_discord_cb; + QLabel *ui_language_label; + QComboBox *ui_language_combobox; + + QLabel *ui_shake_lbl; + QCheckBox *ui_shake_cb; + QLabel *ui_effects_lbl; + QCheckBox *ui_effects_cb; + QLabel *ui_framenetwork_lbl; + QCheckBox *ui_framenetwork_cb; + + QLabel *ui_colorlog_lbl; + QCheckBox *ui_colorlog_cb; + + QLabel *ui_stickysounds_lbl; + QCheckBox *ui_stickysounds_cb; + + QLabel *ui_stickyeffects_lbl; + QCheckBox *ui_stickyeffects_cb; + + QLabel *ui_stickypres_lbl; + QCheckBox *ui_stickypres_cb; + + QWidget *ui_callwords_tab; + QWidget *ui_callwords_widget; + QVBoxLayout *ui_callwords_layout; + QPlainTextEdit *ui_callwords_textbox; + QLabel *ui_callwords_explain_lbl; + QCheckBox *ui_callwords_char_textbox; + + QWidget *ui_audio_tab; + QWidget *ui_audio_widget; + QFormLayout *ui_audio_layout; + QLabel *ui_audio_device_lbl; + QComboBox *ui_audio_device_combobox; + QFrame *ui_audio_volume_divider; + QSpinBox *ui_music_volume_spinbox; + QLabel *ui_music_volume_lbl; + QSpinBox *ui_sfx_volume_spinbox; + QSpinBox *ui_blips_volume_spinbox; + QLabel *ui_sfx_volume_lbl; + QLabel *ui_blips_volume_lbl; + QFrame *ui_volume_blip_divider; + QSpinBox *ui_bliprate_spinbox; + QLabel *ui_bliprate_lbl; + QCheckBox *ui_blank_blips_cb; + QLabel *ui_blank_blips_lbl; + QLabel *ui_loopsfx_lbl; + QCheckBox *ui_loopsfx_cb; + QLabel *ui_objectmusic_lbl; + QCheckBox *ui_objectmusic_cb; + QDialogButtonBox *ui_settings_buttons; + + QWidget *ui_casing_tab; + QWidget *ui_casing_widget; + QFormLayout *ui_casing_layout; + QLabel *ui_casing_supported_lbl; + QLabel *ui_casing_enabled_lbl; + QCheckBox *ui_casing_enabled_cb; + QLabel *ui_casing_def_lbl; + QCheckBox *ui_casing_def_cb; + QLabel *ui_casing_pro_lbl; + QCheckBox *ui_casing_pro_cb; + QLabel *ui_casing_jud_lbl; + QCheckBox *ui_casing_jud_cb; + QLabel *ui_casing_jur_lbl; + QCheckBox *ui_casing_jur_cb; + QLabel *ui_casing_steno_lbl; + QCheckBox *ui_casing_steno_cb; + QLabel *ui_casing_cm_lbl; + QCheckBox *ui_casing_cm_cb; + QLabel *ui_casing_cm_cases_lbl; + QLineEdit *ui_casing_cm_cases_textbox; + + bool needs_default_audiodev(); signals: public slots: - void save_pressed(); - void discard_pressed(); + void save_pressed(); + void discard_pressed(); }; #endif // AOOPTIONSDIALOG_H diff --git a/include/aopacket.h b/include/aopacket.h index 4133fd56..4097be86 100644 --- a/include/aopacket.h +++ b/include/aopacket.h @@ -7,25 +7,25 @@ class AOPacket { public: - AOPacket(QString p_packet_string); - AOPacket(QString header, QStringList &p_contents); - ~AOPacket(); + AOPacket(QString p_packet_string); + AOPacket(QString header, QStringList &p_contents); + ~AOPacket(); - QString get_header() { return m_header; } - QStringList &get_contents() { return m_contents; } - QString to_string(); + QString get_header() { return m_header; } + QStringList &get_contents() { return m_contents; } + QString to_string(); - void encrypt_header(unsigned int p_key); - void decrypt_header(unsigned int p_key); + void encrypt_header(unsigned int p_key); + void decrypt_header(unsigned int p_key); - void net_encode(); - void net_decode(); + void net_encode(); + void net_decode(); private: - bool encrypted = false; + bool encrypted = false; - QString m_header; - QStringList m_contents; + QString m_header; + QStringList m_contents; }; #endif // AOPACKET_H diff --git a/include/aoscene.h b/include/aoscene.h index 3093b0fb..726e2641 100644 --- a/include/aoscene.h +++ b/include/aoscene.h @@ -9,31 +9,34 @@ class Courtroom; class AOApplication; class AOScene : public QLabel { - Q_OBJECT + Q_OBJECT public: - explicit AOScene(QWidget *parent, AOApplication *p_ao_app); + explicit AOScene(QWidget *parent, AOApplication *p_ao_app); - void set_image(QString p_image); - void set_legacy_desk(QString p_image); + void set_image(QString p_image); + void set_legacy_desk(QString p_image); - //Move the label itself around - void move(int ax, int ay); + // 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); + // 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; + 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/aosfxplayer.h b/include/aosfxplayer.h index 4488aa6a..9c9824ab 100644 --- a/include/aosfxplayer.h +++ b/include/aosfxplayer.h @@ -16,29 +16,30 @@ class AOSfxPlayer { public: - AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app); + AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app); - void clear(); - void loop_clear(); - void play(QString p_sfx, QString p_char = "", QString shout = "", int channel = -1); - void stop(int channel = -1); - void set_volume(qreal p_volume); - void set_looping(bool toggle, int channel = -1); - int m_channel = 0; + void clear(); + void loop_clear(); + void play(QString p_sfx, QString p_char = "", QString shout = "", + int channel = -1); + void stop(int channel = -1); + void set_volume(qreal p_volume); + void set_looping(bool toggle, int channel = -1); + int m_channel = 0; private: - QWidget *m_parent; - AOApplication *ao_app; - qreal m_volume = 0; + QWidget *m_parent; + AOApplication *ao_app; + qreal m_volume = 0; - bool m_looping = true; - void set_volume_internal(qreal p_volume); + bool m_looping = true; + void set_volume_internal(qreal p_volume); #if defined(BASSAUDIO) - const int m_channelmax = 5; - HSTREAM m_stream_list[5]; + const int m_channelmax = 5; + HSTREAM m_stream_list[5]; #elif defined(QTAUDIO) - QSoundEffect m_sfx; + QSoundEffect m_sfx; #endif }; diff --git a/include/aotextarea.h b/include/aotextarea.h index 8bf5199b..453e9659 100644 --- a/include/aotextarea.h +++ b/include/aotextarea.h @@ -9,16 +9,17 @@ class AOTextArea : public QTextBrowser { public: - AOTextArea(QWidget *p_parent = nullptr); + AOTextArea(QWidget *p_parent = nullptr); - void append_linked(QString p_message); - void append_chatmessage(QString p_name, QString p_message, QString p_colur); - void append_error(QString p_message); + void append_linked(QString p_message); + void append_chatmessage(QString p_name, QString p_message, QString p_colur); + void append_error(QString p_message); private: - const QRegExp url_parser_regex = QRegExp("\\b(https?://\\S+\\.\\S+)\\b"); + const QRegExp url_parser_regex = QRegExp("\\b(https?://\\S+\\.\\S+)\\b"); - void auto_scroll(QTextCursor old_cursor, int scrollbar_value, bool is_scrolled_down); + void auto_scroll(QTextCursor old_cursor, int scrollbar_value, + bool is_scrolled_down); }; #endif // AOTEXTAREA_H diff --git a/include/aotextedit.h b/include/aotextedit.h index eb2c356d..8d876f17 100644 --- a/include/aotextedit.h +++ b/include/aotextedit.h @@ -4,18 +4,18 @@ #include <QPlainTextEdit> class AOTextEdit : public QPlainTextEdit { - Q_OBJECT + Q_OBJECT public: - AOTextEdit(QWidget *parent); + AOTextEdit(QWidget *parent); protected: - void mouseDoubleClickEvent(QMouseEvent *e); + void mouseDoubleClickEvent(QMouseEvent *e); signals: - void double_clicked(); + void double_clicked(); private slots: - void on_enter_pressed(); + void on_enter_pressed(); }; #endif // AOTEXTEDIT_H diff --git a/include/bass.h b/include/bass.h index 4180a371..ec2c7a29 100644 --- a/include/bass.h +++ b/include/bass.h @@ -1,8 +1,8 @@ /* - BASS 2.4 C/C++ header file - Copyright (c) 1999-2019 Un4seen Developments Ltd. + BASS 2.4 C/C++ header file + Copyright (c) 1999-2019 Un4seen Developments Ltd. - See the BASS.CHM file for more detailed documentation + See the BASS.CHM file for more detailed documentation */ #ifndef BASS_H @@ -152,13 +152,14 @@ typedef DWORD HPLUGIN; // Plugin handle #define BASS_CONFIG_LIBSSL 64 // BASS_Init flags -#define BASS_DEVICE_8BITS 1 // 8 bit -#define BASS_DEVICE_MONO 2 // mono -#define BASS_DEVICE_3D 4 // enable 3D functionality -#define BASS_DEVICE_16BITS 8 // limit output to 16 bit -#define BASS_DEVICE_LATENCY 0x100 // calculate device latency (BASS_INFO struct) -#define BASS_DEVICE_CPSPEAKERS 0x400 // detect speakers via Windows control panel -#define BASS_DEVICE_SPEAKERS 0x800 // force enabling of speaker assignment +#define BASS_DEVICE_8BITS 1 // 8 bit +#define BASS_DEVICE_MONO 2 // mono +#define BASS_DEVICE_3D 4 // enable 3D functionality +#define BASS_DEVICE_16BITS 8 // limit output to 16 bit +#define BASS_DEVICE_LATENCY 0x100 // calculate device latency (BASS_INFO struct) +#define BASS_DEVICE_CPSPEAKERS \ + 0x400 // detect speakers via Windows control panel +#define BASS_DEVICE_SPEAKERS 0x800 // force enabling of speaker assignment #define BASS_DEVICE_NOSPEAKER 0x1000 // ignore speaker arrangement #define BASS_DEVICE_DMIX 0x2000 // use ALSA "dmix" plugin #define BASS_DEVICE_FREQ 0x4000 // set device sample rate @@ -173,14 +174,15 @@ typedef DWORD HPLUGIN; // Plugin handle // Device info structure typedef struct { -#if defined(_WIN32_WCE) || (WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) - const wchar_t *name; // description - const wchar_t *driver; // driver +#if defined(_WIN32_WCE) || \ + (WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) + const wchar_t *name; // description + const wchar_t *driver; // driver #else - const char *name; // description - const char *driver; // driver + const char *name; // description + const char *driver; // driver #endif - DWORD flags; + DWORD flags; } BASS_DEVICEINFO; // BASS_DEVICEINFO flags @@ -206,26 +208,32 @@ typedef struct { #define BASS_DEVICES_AIRPLAY 0x1000000 typedef struct { - DWORD flags; // device capabilities (DSCAPS_xxx flags) - DWORD hwsize; // size of total device hardware memory - DWORD hwfree; // size of free device hardware memory - DWORD freesam; // number of free sample slots in the hardware - DWORD free3d; // number of free 3D sample slots in the hardware - DWORD minrate; // min sample rate supported by the hardware - DWORD maxrate; // max sample rate supported by the hardware - BOOL eax; // device supports EAX? (always FALSE if BASS_DEVICE_3D was not used) - DWORD minbuf; // recommended minimum buffer length in ms (requires BASS_DEVICE_LATENCY) - DWORD dsver; // DirectSound version - DWORD latency; // delay (in ms) before start of playback (requires BASS_DEVICE_LATENCY) - DWORD initflags; // BASS_Init "flags" parameter - DWORD speakers; // number of speakers available - DWORD freq; // current output rate + DWORD flags; // device capabilities (DSCAPS_xxx flags) + DWORD hwsize; // size of total device hardware memory + DWORD hwfree; // size of free device hardware memory + DWORD freesam; // number of free sample slots in the hardware + DWORD free3d; // number of free 3D sample slots in the hardware + DWORD minrate; // min sample rate supported by the hardware + DWORD maxrate; // max sample rate supported by the hardware + BOOL + eax; // device supports EAX? (always FALSE if BASS_DEVICE_3D was not used) + DWORD minbuf; // recommended minimum buffer length in ms (requires + // BASS_DEVICE_LATENCY) + DWORD dsver; // DirectSound version + DWORD latency; // delay (in ms) before start of playback (requires + // BASS_DEVICE_LATENCY) + DWORD initflags; // BASS_Init "flags" parameter + DWORD speakers; // number of speakers available + DWORD freq; // current output rate } BASS_INFO; // BASS_INFO flags (from DSOUND.H) -#define DSCAPS_CONTINUOUSRATE 0x00000010 // supports all sample rates between min/maxrate -#define DSCAPS_EMULDRIVER 0x00000020 // device does NOT have hardware DirectSound support -#define DSCAPS_CERTIFIED 0x00000040 // device driver has been certified by Microsoft +#define DSCAPS_CONTINUOUSRATE \ + 0x00000010 // supports all sample rates between min/maxrate +#define DSCAPS_EMULDRIVER \ + 0x00000020 // device does NOT have hardware DirectSound support +#define DSCAPS_CERTIFIED \ + 0x00000040 // device driver has been certified by Microsoft #define DSCAPS_SECONDARYMONO 0x00000100 // mono #define DSCAPS_SECONDARYSTEREO 0x00000200 // stereo #define DSCAPS_SECONDARY8BIT 0x00000400 // 8 bit @@ -233,16 +241,19 @@ typedef struct { // Recording device info structure typedef struct { - DWORD flags; // device capabilities (DSCCAPS_xxx flags) - DWORD formats; // supported standard formats (WAVE_FORMAT_xxx flags) - DWORD inputs; // number of inputs - BOOL singlein; // TRUE = only 1 input can be set at a time - DWORD freq; // current input rate + DWORD flags; // device capabilities (DSCCAPS_xxx flags) + DWORD formats; // supported standard formats (WAVE_FORMAT_xxx flags) + DWORD inputs; // number of inputs + BOOL singlein; // TRUE = only 1 input can be set at a time + DWORD freq; // current input rate } BASS_RECORDINFO; // BASS_RECORDINFO flags (from DSOUND.H) -#define DSCCAPS_EMULDRIVER DSCAPS_EMULDRIVER // device does NOT have hardware DirectSound recording support -#define DSCCAPS_CERTIFIED DSCAPS_CERTIFIED // device driver has been certified by Microsoft +#define DSCCAPS_EMULDRIVER \ + DSCAPS_EMULDRIVER // device does NOT have hardware DirectSound recording + // support +#define DSCCAPS_CERTIFIED \ + DSCAPS_CERTIFIED // device driver has been certified by Microsoft // defines for formats field of BASS_RECORDINFO (from MMSYSTEM.H) #ifndef WAVE_FORMAT_1M08 @@ -262,46 +273,54 @@ typedef struct { // Sample info structure typedef struct { - DWORD freq; // default playback rate - float volume; // default volume (0-1) - float pan; // default pan (-1=left, 0=middle, 1=right) - DWORD flags; // BASS_SAMPLE_xxx flags - DWORD length; // length (in bytes) - DWORD max; // maximum simultaneous playbacks - DWORD origres; // original resolution - DWORD chans; // number of channels - DWORD mingap; // minimum gap (ms) between creating channels - DWORD mode3d; // BASS_3DMODE_xxx mode - float mindist; // minimum distance - float maxdist; // maximum distance - DWORD iangle; // angle of inside projection cone - DWORD oangle; // angle of outside projection cone - float outvol; // delta-volume outside the projection cone - DWORD vam; // voice allocation/management flags (BASS_VAM_xxx) - DWORD priority; // priority (0=lowest, 0xffffffff=highest) + DWORD freq; // default playback rate + float volume; // default volume (0-1) + float pan; // default pan (-1=left, 0=middle, 1=right) + DWORD flags; // BASS_SAMPLE_xxx flags + DWORD length; // length (in bytes) + DWORD max; // maximum simultaneous playbacks + DWORD origres; // original resolution + DWORD chans; // number of channels + DWORD mingap; // minimum gap (ms) between creating channels + DWORD mode3d; // BASS_3DMODE_xxx mode + float mindist; // minimum distance + float maxdist; // maximum distance + DWORD iangle; // angle of inside projection cone + DWORD oangle; // angle of outside projection cone + float outvol; // delta-volume outside the projection cone + DWORD vam; // voice allocation/management flags (BASS_VAM_xxx) + DWORD priority; // priority (0=lowest, 0xffffffff=highest) } BASS_SAMPLE; -#define BASS_SAMPLE_8BITS 1 // 8 bit -#define BASS_SAMPLE_FLOAT 256 // 32 bit floating-point -#define BASS_SAMPLE_MONO 2 // mono -#define BASS_SAMPLE_LOOP 4 // looped -#define BASS_SAMPLE_3D 8 // 3D functionality -#define BASS_SAMPLE_SOFTWARE 16 // not using hardware mixing -#define BASS_SAMPLE_MUTEMAX 32 // mute at max distance (3D only) -#define BASS_SAMPLE_VAM 64 // DX7 voice allocation & management -#define BASS_SAMPLE_FX 128 // old implementation of DX8 effects -#define BASS_SAMPLE_OVER_VOL 0x10000 // override lowest volume -#define BASS_SAMPLE_OVER_POS 0x20000 // override longest playing -#define BASS_SAMPLE_OVER_DIST 0x30000 // override furthest from listener (3D only) - -#define BASS_STREAM_PRESCAN 0x20000 // enable pin-point seeking/length (MP3/MP2/MP1) -#define BASS_STREAM_AUTOFREE 0x40000 // automatically free the stream when it stop/ends -#define BASS_STREAM_RESTRATE 0x80000 // restrict the download rate of internet file streams -#define BASS_STREAM_BLOCK 0x100000 // download/play internet file stream in small blocks -#define BASS_STREAM_DECODE 0x200000 // don't play the stream, only decode (BASS_ChannelGetData) -#define BASS_STREAM_STATUS 0x800000 // give server status info (HTTP/ICY tags) in DOWNLOADPROC - -#define BASS_MP3_IGNOREDELAY 0x200 // ignore LAME/Xing/VBRI/iTunes delay & padding info +#define BASS_SAMPLE_8BITS 1 // 8 bit +#define BASS_SAMPLE_FLOAT 256 // 32 bit floating-point +#define BASS_SAMPLE_MONO 2 // mono +#define BASS_SAMPLE_LOOP 4 // looped +#define BASS_SAMPLE_3D 8 // 3D functionality +#define BASS_SAMPLE_SOFTWARE 16 // not using hardware mixing +#define BASS_SAMPLE_MUTEMAX 32 // mute at max distance (3D only) +#define BASS_SAMPLE_VAM 64 // DX7 voice allocation & management +#define BASS_SAMPLE_FX 128 // old implementation of DX8 effects +#define BASS_SAMPLE_OVER_VOL 0x10000 // override lowest volume +#define BASS_SAMPLE_OVER_POS 0x20000 // override longest playing +#define BASS_SAMPLE_OVER_DIST \ + 0x30000 // override furthest from listener (3D only) + +#define BASS_STREAM_PRESCAN \ + 0x20000 // enable pin-point seeking/length (MP3/MP2/MP1) +#define BASS_STREAM_AUTOFREE \ + 0x40000 // automatically free the stream when it stop/ends +#define BASS_STREAM_RESTRATE \ + 0x80000 // restrict the download rate of internet file streams +#define BASS_STREAM_BLOCK \ + 0x100000 // download/play internet file stream in small blocks +#define BASS_STREAM_DECODE \ + 0x200000 // don't play the stream, only decode (BASS_ChannelGetData) +#define BASS_STREAM_STATUS \ + 0x800000 // give server status info (HTTP/ICY tags) in DOWNLOADPROC + +#define BASS_MP3_IGNOREDELAY \ + 0x200 // ignore LAME/Xing/VBRI/iTunes delay & padding info #define BASS_MP3_SETPOS BASS_STREAM_PRESCAN #define BASS_MUSIC_FLOAT BASS_SAMPLE_FLOAT @@ -313,19 +332,20 @@ typedef struct { #define BASS_MUSIC_DECODE BASS_STREAM_DECODE #define BASS_MUSIC_PRESCAN BASS_STREAM_PRESCAN // calculate playback length #define BASS_MUSIC_CALCLEN BASS_MUSIC_PRESCAN -#define BASS_MUSIC_RAMP 0x200 // normal ramping -#define BASS_MUSIC_RAMPS 0x400 // sensitive ramping -#define BASS_MUSIC_SURROUND 0x800 // surround sound -#define BASS_MUSIC_SURROUND2 0x1000 // surround sound (mode 2) -#define BASS_MUSIC_FT2PAN 0x2000 // apply FastTracker 2 panning to XM files -#define BASS_MUSIC_FT2MOD 0x2000 // play .MOD as FastTracker 2 does -#define BASS_MUSIC_PT1MOD 0x4000 // play .MOD as ProTracker 1 does -#define BASS_MUSIC_NONINTER 0x10000 // non-interpolated sample mixing -#define BASS_MUSIC_SINCINTER 0x800000 // sinc interpolated sample mixing -#define BASS_MUSIC_POSRESET 0x8000 // stop all notes when moving position -#define BASS_MUSIC_POSRESETEX 0x400000 // stop all notes and reset bmp/etc when moving position -#define BASS_MUSIC_STOPBACK 0x80000 // stop the music on a backwards jump effect -#define BASS_MUSIC_NOSAMPLE 0x100000 // don't load the samples +#define BASS_MUSIC_RAMP 0x200 // normal ramping +#define BASS_MUSIC_RAMPS 0x400 // sensitive ramping +#define BASS_MUSIC_SURROUND 0x800 // surround sound +#define BASS_MUSIC_SURROUND2 0x1000 // surround sound (mode 2) +#define BASS_MUSIC_FT2PAN 0x2000 // apply FastTracker 2 panning to XM files +#define BASS_MUSIC_FT2MOD 0x2000 // play .MOD as FastTracker 2 does +#define BASS_MUSIC_PT1MOD 0x4000 // play .MOD as ProTracker 1 does +#define BASS_MUSIC_NONINTER 0x10000 // non-interpolated sample mixing +#define BASS_MUSIC_SINCINTER 0x800000 // sinc interpolated sample mixing +#define BASS_MUSIC_POSRESET 0x8000 // stop all notes when moving position +#define BASS_MUSIC_POSRESETEX \ + 0x400000 // stop all notes and reset bmp/etc when moving position +#define BASS_MUSIC_STOPBACK 0x80000 // stop the music on a backwards jump effect +#define BASS_MUSIC_NOSAMPLE 0x100000 // don't load the samples // Speaker assignment flags #define BASS_SPEAKER_FRONT 0x1000000 // front speakers @@ -360,14 +380,14 @@ typedef struct { // Channel info structure typedef struct { - DWORD freq; // default playback rate - DWORD chans; // channels - DWORD flags; // BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags - DWORD ctype; // type of channel - DWORD origres; // original resolution - HPLUGIN plugin; // plugin - HSAMPLE sample; // sample - const char *filename; // filename + DWORD freq; // default playback rate + DWORD chans; // channels + DWORD flags; // BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags + DWORD ctype; // type of channel + DWORD origres; // original resolution + HPLUGIN plugin; // plugin + HSAMPLE sample; // sample + const char *filename; // filename } BASS_CHANNELINFO; #define BASS_ORIGRES_FLOAT 0x10000 @@ -397,31 +417,32 @@ typedef struct { #define BASS_CTYPE_MUSIC_MO3 0x00100 // MO3 flag typedef struct { - DWORD ctype; // channel type -#if defined(_WIN32_WCE) || (WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) - const wchar_t *name; // format description - const wchar_t *exts; // file extension filter (*.ext1;*.ext2;etc...) + DWORD ctype; // channel type +#if defined(_WIN32_WCE) || \ + (WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) + const wchar_t *name; // format description + const wchar_t *exts; // file extension filter (*.ext1;*.ext2;etc...) #else - const char *name; // format description - const char *exts; // file extension filter (*.ext1;*.ext2;etc...) + const char *name; // format description + const char *exts; // file extension filter (*.ext1;*.ext2;etc...) #endif } BASS_PLUGINFORM; typedef struct { - DWORD version; // version (same form as BASS_GetVersion) - DWORD formatc; // number of formats - const BASS_PLUGINFORM *formats; // the array of formats + DWORD version; // version (same form as BASS_GetVersion) + DWORD formatc; // number of formats + const BASS_PLUGINFORM *formats; // the array of formats } BASS_PLUGININFO; // 3D vector (for 3D positions/velocities/orientations) typedef struct BASS_3DVECTOR { #ifdef __cplusplus - BASS_3DVECTOR(){}; - BASS_3DVECTOR(float _x, float _y, float _z) : x(_x), y(_y), z(_z){}; + BASS_3DVECTOR(){}; + BASS_3DVECTOR(float _x, float _y, float _z) : x(_x), y(_y), z(_z){}; #endif - float x; // +=right, -=left - float y; // +=up, -=down - float z; // +=front, -=behind + float x; // +=right, -=left + float y; // +=up, -=down + float z; // +=front, -=behind } BASS_3DVECTOR; // 3D channel modes @@ -437,34 +458,34 @@ typedef struct BASS_3DVECTOR { // EAX environments, use with BASS_SetEAXParameters enum { - EAX_ENVIRONMENT_GENERIC, - EAX_ENVIRONMENT_PADDEDCELL, - EAX_ENVIRONMENT_ROOM, - EAX_ENVIRONMENT_BATHROOM, - EAX_ENVIRONMENT_LIVINGROOM, - EAX_ENVIRONMENT_STONEROOM, - EAX_ENVIRONMENT_AUDITORIUM, - EAX_ENVIRONMENT_CONCERTHALL, - EAX_ENVIRONMENT_CAVE, - EAX_ENVIRONMENT_ARENA, - EAX_ENVIRONMENT_HANGAR, - EAX_ENVIRONMENT_CARPETEDHALLWAY, - EAX_ENVIRONMENT_HALLWAY, - EAX_ENVIRONMENT_STONECORRIDOR, - EAX_ENVIRONMENT_ALLEY, - EAX_ENVIRONMENT_FOREST, - EAX_ENVIRONMENT_CITY, - EAX_ENVIRONMENT_MOUNTAINS, - EAX_ENVIRONMENT_QUARRY, - EAX_ENVIRONMENT_PLAIN, - EAX_ENVIRONMENT_PARKINGLOT, - EAX_ENVIRONMENT_SEWERPIPE, - EAX_ENVIRONMENT_UNDERWATER, - EAX_ENVIRONMENT_DRUGGED, - EAX_ENVIRONMENT_DIZZY, - EAX_ENVIRONMENT_PSYCHOTIC, - - EAX_ENVIRONMENT_COUNT // total number of environments + EAX_ENVIRONMENT_GENERIC, + EAX_ENVIRONMENT_PADDEDCELL, + EAX_ENVIRONMENT_ROOM, + EAX_ENVIRONMENT_BATHROOM, + EAX_ENVIRONMENT_LIVINGROOM, + EAX_ENVIRONMENT_STONEROOM, + EAX_ENVIRONMENT_AUDITORIUM, + EAX_ENVIRONMENT_CONCERTHALL, + EAX_ENVIRONMENT_CAVE, + EAX_ENVIRONMENT_ARENA, + EAX_ENVIRONMENT_HANGAR, + EAX_ENVIRONMENT_CARPETEDHALLWAY, + EAX_ENVIRONMENT_HALLWAY, + EAX_ENVIRONMENT_STONECORRIDOR, + EAX_ENVIRONMENT_ALLEY, + EAX_ENVIRONMENT_FOREST, + EAX_ENVIRONMENT_CITY, + EAX_ENVIRONMENT_MOUNTAINS, + EAX_ENVIRONMENT_QUARRY, + EAX_ENVIRONMENT_PLAIN, + EAX_ENVIRONMENT_PARKINGLOT, + EAX_ENVIRONMENT_SEWERPIPE, + EAX_ENVIRONMENT_UNDERWATER, + EAX_ENVIRONMENT_DRUGGED, + EAX_ENVIRONMENT_DIZZY, + EAX_ENVIRONMENT_PSYCHOTIC, + + EAX_ENVIRONMENT_COUNT // total number of environments }; // EAX presets, usage: BASS_SetEAXParameters(EAX_PRESET_xxx) @@ -479,9 +500,11 @@ enum { #define EAX_PRESET_CAVE EAX_ENVIRONMENT_CAVE, 0.5F, 2.886F, 1.304F #define EAX_PRESET_ARENA EAX_ENVIRONMENT_ARENA, 0.361F, 7.284F, 0.332F #define EAX_PRESET_HANGAR EAX_ENVIRONMENT_HANGAR, 0.5F, 10.0F, 0.3F -#define EAX_PRESET_CARPETEDHALLWAY EAX_ENVIRONMENT_CARPETEDHALLWAY, 0.153F, 0.259F, 2.0F +#define EAX_PRESET_CARPETEDHALLWAY \ + EAX_ENVIRONMENT_CARPETEDHALLWAY, 0.153F, 0.259F, 2.0F #define EAX_PRESET_HALLWAY EAX_ENVIRONMENT_HALLWAY, 0.361F, 1.493F, 0.0F -#define EAX_PRESET_STONECORRIDOR EAX_ENVIRONMENT_STONECORRIDOR, 0.444F, 2.697F, 0.638F +#define EAX_PRESET_STONECORRIDOR \ + EAX_ENVIRONMENT_STONECORRIDOR, 0.444F, 2.697F, 0.638F #define EAX_PRESET_ALLEY EAX_ENVIRONMENT_ALLEY, 0.25F, 1.752F, 0.776F #define EAX_PRESET_FOREST EAX_ENVIRONMENT_FOREST, 0.111F, 3.145F, 0.472F #define EAX_PRESET_CITY EAX_ENVIRONMENT_CITY, 0.111F, 2.767F, 0.224F @@ -495,14 +518,14 @@ enum { #define EAX_PRESET_DIZZY EAX_ENVIRONMENT_DIZZY, 0.139F, 17.234F, 0.666F #define EAX_PRESET_PSYCHOTIC EAX_ENVIRONMENT_PSYCHOTIC, 0.486F, 7.563F, 0.806F -typedef DWORD(CALLBACK STREAMPROC)(HSTREAM handle, void *buffer, DWORD length, void *user); -/* User stream callback function. NOTE: A stream function should obviously be as quick -as possible, other streams (and MOD musics) can't be mixed until it's finished. -handle : The stream that needs writing -buffer : Buffer to write the samples in -length : Number of bytes to write -user : The 'user' parameter value given when calling BASS_StreamCreate -RETURN : Number of bytes written. Set the BASS_STREAMPROC_END flag to end the stream. */ +typedef DWORD(CALLBACK STREAMPROC)(HSTREAM handle, void *buffer, DWORD length, + void *user); +/* User stream callback function. NOTE: A stream function should obviously be as +quick as possible, other streams (and MOD musics) can't be mixed until it's +finished. handle : The stream that needs writing buffer : Buffer to write the +samples in length : Number of bytes to write user : The 'user' parameter value +given when calling BASS_StreamCreate RETURN : Number of bytes written. Set the +BASS_STREAMPROC_END flag to end the stream. */ #define BASS_STREAMPROC_END 0x80000000 // end of user stream flag @@ -524,10 +547,10 @@ typedef DWORD(CALLBACK FILEREADPROC)(void *buffer, DWORD length, void *user); typedef BOOL(CALLBACK FILESEEKPROC)(QWORD offset, void *user); typedef struct { - FILECLOSEPROC *close; - FILELENPROC *length; - FILEREADPROC *read; - FILESEEKPROC *seek; + FILECLOSEPROC *close; + FILELENPROC *length; + FILEREADPROC *read; + FILESEEKPROC *seek; } BASS_FILEPROCS; // BASS_StreamPutFileData options @@ -546,7 +569,8 @@ typedef struct { #define BASS_FILEPOS_SIZE 8 #define BASS_FILEPOS_BUFFERING 9 -typedef void(CALLBACK DOWNLOADPROC)(const void *buffer, DWORD length, void *user); +typedef void(CALLBACK DOWNLOADPROC)(const void *buffer, DWORD length, + void *user); /* Internet stream download callback function. buffer : Buffer containing the downloaded data... NULL=end of download length : Number of bytes in the buffer @@ -570,7 +594,8 @@ user : The 'user' parameter value given when calling BASS_StreamCreateURL */ #define BASS_SYNC_MIXTIME 0x40000000 // flag: sync at mixtime, else at playtime #define BASS_SYNC_ONETIME 0x80000000 // flag: sync only once, else continuously -typedef void(CALLBACK SYNCPROC)(HSYNC handle, DWORD channel, DWORD data, void *user); +typedef void(CALLBACK SYNCPROC)(HSYNC handle, DWORD channel, DWORD data, + void *user); /* Sync callback function. NOTE: a sync callback function should be very quick as other syncs can't be processed until it has finished. If the sync is a "mixtime" sync, then other streams and MOD musics can't be mixed until @@ -580,7 +605,8 @@ channel: Channel that the sync occured in data : Additional data associated with the sync's occurance user : The 'user' parameter given when calling BASS_ChannelSetSync */ -typedef void(CALLBACK DSPPROC)(HDSP handle, DWORD channel, void *buffer, DWORD length, void *user); +typedef void(CALLBACK DSPPROC)(HDSP handle, DWORD channel, void *buffer, + DWORD length, void *user); /* DSP callback function. NOTE: A DSP function should obviously be as quick as possible... other DSP functions, streams and MOD musics can not be processed until it's finished. @@ -590,7 +616,8 @@ buffer : Buffer to apply the DSP to length : Number of bytes in the buffer user : The 'user' parameter given when calling BASS_ChannelSetDSP */ -typedef BOOL(CALLBACK RECORDPROC)(HRECORD handle, const void *buffer, DWORD length, void *user); +typedef BOOL(CALLBACK RECORDPROC)(HRECORD handle, const void *buffer, + DWORD length, void *user); /* Recording callback function. handle : The recording handle buffer : Buffer containing the recorded sample data @@ -644,11 +671,12 @@ RETURN : TRUE = continue recording, FALSE = stop */ #define BASS_DATA_FFT8192 0x80000005 // 8192 FFT #define BASS_DATA_FFT16384 0x80000006 // 16384 FFT #define BASS_DATA_FFT32768 0x80000007 // 32768 FFT -#define BASS_DATA_FFT_INDIVIDUAL 0x10 // FFT flag: FFT for each channel, else all combined -#define BASS_DATA_FFT_NOWINDOW 0x20 // FFT flag: no Hanning window -#define BASS_DATA_FFT_REMOVEDC 0x40 // FFT flag: pre-remove DC bias -#define BASS_DATA_FFT_COMPLEX 0x80 // FFT flag: return complex data -#define BASS_DATA_FFT_NYQUIST 0x100 // FFT flag: return extra Nyquist value +#define BASS_DATA_FFT_INDIVIDUAL \ + 0x10 // FFT flag: FFT for each channel, else all combined +#define BASS_DATA_FFT_NOWINDOW 0x20 // FFT flag: no Hanning window +#define BASS_DATA_FFT_REMOVEDC 0x40 // FFT flag: pre-remove DC bias +#define BASS_DATA_FFT_COMPLEX 0x80 // FFT flag: return complex data +#define BASS_DATA_FFT_NYQUIST 0x100 // FFT flag: return extra Nyquist value // BASS_ChannelGetLevelEx flags #define BASS_LEVEL_MONO 1 @@ -657,52 +685,59 @@ RETURN : TRUE = continue recording, FALSE = stop */ #define BASS_LEVEL_VOLPAN 8 // BASS_ChannelGetTags types : what's returned -#define BASS_TAG_ID3 0 // ID3v1 tags : TAG_ID3 structure -#define BASS_TAG_ID3V2 1 // ID3v2 tags : variable length block -#define BASS_TAG_OGG 2 // OGG comments : series of null-terminated UTF-8 strings -#define BASS_TAG_HTTP 3 // HTTP headers : series of null-terminated ANSI strings -#define BASS_TAG_ICY 4 // ICY headers : series of null-terminated ANSI strings -#define BASS_TAG_META 5 // ICY metadata : ANSI string -#define BASS_TAG_APE 6 // APE tags : series of null-terminated UTF-8 strings -#define BASS_TAG_MP4 7 // MP4/iTunes metadata : series of null-terminated UTF-8 strings -#define BASS_TAG_WMA 8 // WMA tags : series of null-terminated UTF-8 strings -#define BASS_TAG_VENDOR 9 // OGG encoder : UTF-8 string -#define BASS_TAG_LYRICS3 10 // Lyric3v2 tag : ASCII string -#define BASS_TAG_CA_CODEC 11 // CoreAudio codec info : TAG_CA_CODEC structure -#define BASS_TAG_MF 13 // Media Foundation tags : series of null-terminated UTF-8 strings -#define BASS_TAG_WAVEFORMAT 14 // WAVE format : WAVEFORMATEEX structure -#define BASS_TAG_AM_MIME 15 // Android Media MIME type : ASCII string -#define BASS_TAG_AM_NAME 16 // Android Media codec name : ASCII string -#define BASS_TAG_RIFF_INFO 0x100 // RIFF "INFO" tags : series of null-terminated ANSI strings -#define BASS_TAG_RIFF_BEXT 0x101 // RIFF/BWF "bext" tags : TAG_BEXT structure -#define BASS_TAG_RIFF_CART 0x102 // RIFF/BWF "cart" tags : TAG_CART structure -#define BASS_TAG_RIFF_DISP 0x103 // RIFF "DISP" text tag : ANSI string -#define BASS_TAG_RIFF_CUE 0x104 // RIFF "cue " chunk : TAG_CUE structure -#define BASS_TAG_RIFF_SMPL 0x105 // RIFF "smpl" chunk : TAG_SMPL structure -#define BASS_TAG_APE_BINARY 0x1000 // + index #, binary APE tag : TAG_APE_BINARY structure +#define BASS_TAG_ID3 0 // ID3v1 tags : TAG_ID3 structure +#define BASS_TAG_ID3V2 1 // ID3v2 tags : variable length block +#define BASS_TAG_OGG 2 // OGG comments : series of null-terminated UTF-8 strings +#define BASS_TAG_HTTP 3 // HTTP headers : series of null-terminated ANSI strings +#define BASS_TAG_ICY 4 // ICY headers : series of null-terminated ANSI strings +#define BASS_TAG_META 5 // ICY metadata : ANSI string +#define BASS_TAG_APE 6 // APE tags : series of null-terminated UTF-8 strings +#define BASS_TAG_MP4 \ + 7 // MP4/iTunes metadata : series of null-terminated UTF-8 strings +#define BASS_TAG_WMA 8 // WMA tags : series of null-terminated UTF-8 strings +#define BASS_TAG_VENDOR 9 // OGG encoder : UTF-8 string +#define BASS_TAG_LYRICS3 10 // Lyric3v2 tag : ASCII string +#define BASS_TAG_CA_CODEC 11 // CoreAudio codec info : TAG_CA_CODEC structure +#define BASS_TAG_MF \ + 13 // Media Foundation tags : series of null-terminated UTF-8 strings +#define BASS_TAG_WAVEFORMAT 14 // WAVE format : WAVEFORMATEEX structure +#define BASS_TAG_AM_MIME 15 // Android Media MIME type : ASCII string +#define BASS_TAG_AM_NAME 16 // Android Media codec name : ASCII string +#define BASS_TAG_RIFF_INFO \ + 0x100 // RIFF "INFO" tags : series of null-terminated ANSI strings +#define BASS_TAG_RIFF_BEXT 0x101 // RIFF/BWF "bext" tags : TAG_BEXT structure +#define BASS_TAG_RIFF_CART 0x102 // RIFF/BWF "cart" tags : TAG_CART structure +#define BASS_TAG_RIFF_DISP 0x103 // RIFF "DISP" text tag : ANSI string +#define BASS_TAG_RIFF_CUE 0x104 // RIFF "cue " chunk : TAG_CUE structure +#define BASS_TAG_RIFF_SMPL 0x105 // RIFF "smpl" chunk : TAG_SMPL structure +#define BASS_TAG_APE_BINARY \ + 0x1000 // + index #, binary APE tag : TAG_APE_BINARY structure #define BASS_TAG_MUSIC_NAME 0x10000 // MOD music name : ANSI string #define BASS_TAG_MUSIC_MESSAGE 0x10001 // MOD message : ANSI string -#define BASS_TAG_MUSIC_ORDERS 0x10002 // MOD order list : BYTE array of pattern numbers -#define BASS_TAG_MUSIC_AUTH 0x10003 // MOD author : UTF-8 string -#define BASS_TAG_MUSIC_INST 0x10100 // + instrument #, MOD instrument name : ANSI string -#define BASS_TAG_MUSIC_SAMPLE 0x10300 // + sample #, MOD sample name : ANSI string +#define BASS_TAG_MUSIC_ORDERS \ + 0x10002 // MOD order list : BYTE array of pattern numbers +#define BASS_TAG_MUSIC_AUTH 0x10003 // MOD author : UTF-8 string +#define BASS_TAG_MUSIC_INST \ + 0x10100 // + instrument #, MOD instrument name : ANSI string +#define BASS_TAG_MUSIC_SAMPLE \ + 0x10300 // + sample #, MOD sample name : ANSI string // ID3v1 tag structure typedef struct { - char id[3]; - char title[30]; - char artist[30]; - char album[30]; - char year[4]; - char comment[30]; - BYTE genre; + char id[3]; + char title[30]; + char artist[30]; + char album[30]; + char year[4]; + char comment[30]; + BYTE genre; } TAG_ID3; // Binary APE tag structure typedef struct { - const char *key; - const void *data; - DWORD length; + const char *key; + const void *data; + DWORD length; } TAG_APE_BINARY; // BWF "bext" tag structure @@ -712,113 +747,107 @@ typedef struct { #endif #pragma pack(push, 1) typedef struct { - char Description[256]; // description - char Originator[32]; // name of the originator - char OriginatorReference[32]; // reference of the originator - char OriginationDate[10]; // date of creation (yyyy-mm-dd) - char OriginationTime[8]; // time of creation (hh-mm-ss) - QWORD TimeReference; // first sample count since midnight (little-endian) - WORD Version; // BWF version (little-endian) - BYTE UMID[64]; // SMPTE UMID - BYTE Reserved[190]; + char Description[256]; // description + char Originator[32]; // name of the originator + char OriginatorReference[32]; // reference of the originator + char OriginationDate[10]; // date of creation (yyyy-mm-dd) + char OriginationTime[8]; // time of creation (hh-mm-ss) + QWORD TimeReference; // first sample count since midnight (little-endian) + WORD Version; // BWF version (little-endian) + BYTE UMID[64]; // SMPTE UMID + BYTE Reserved[190]; #if defined(__GNUC__) && __GNUC__ < 3 - char CodingHistory[0]; // history -#elif 1 // change to 0 if compiler fails the following line - char CodingHistory[]; // history + char CodingHistory[0]; // history +#elif 1 // change to 0 if compiler fails the following line + char CodingHistory[]; // history #else - char CodingHistory[1]; // history + char CodingHistory[1]; // history #endif } TAG_BEXT; #pragma pack(pop) // BWF "cart" tag structures -typedef struct -{ - DWORD dwUsage; // FOURCC timer usage ID - DWORD dwValue; // timer value in samples from head +typedef struct { + DWORD dwUsage; // FOURCC timer usage ID + DWORD dwValue; // timer value in samples from head } TAG_CART_TIMER; -typedef struct -{ - char Version[4]; // version of the data structure - char Title[64]; // title of cart audio sequence - char Artist[64]; // artist or creator name - char CutID[64]; // cut number identification - char ClientID[64]; // client identification - char Category[64]; // category ID, PSA, NEWS, etc - char Classification[64]; // classification or auxiliary key - char OutCue[64]; // out cue text - char StartDate[10]; // yyyy-mm-dd - char StartTime[8]; // hh:mm:ss - char EndDate[10]; // yyyy-mm-dd - char EndTime[8]; // hh:mm:ss - char ProducerAppID[64]; // name of vendor or application - char ProducerAppVersion[64]; // version of producer application - char UserDef[64]; // user defined text - DWORD dwLevelReference; // sample value for 0 dB reference - TAG_CART_TIMER PostTimer[8]; // 8 time markers after head - char Reserved[276]; - char URL[1024]; // uniform resource locator +typedef struct { + char Version[4]; // version of the data structure + char Title[64]; // title of cart audio sequence + char Artist[64]; // artist or creator name + char CutID[64]; // cut number identification + char ClientID[64]; // client identification + char Category[64]; // category ID, PSA, NEWS, etc + char Classification[64]; // classification or auxiliary key + char OutCue[64]; // out cue text + char StartDate[10]; // yyyy-mm-dd + char StartTime[8]; // hh:mm:ss + char EndDate[10]; // yyyy-mm-dd + char EndTime[8]; // hh:mm:ss + char ProducerAppID[64]; // name of vendor or application + char ProducerAppVersion[64]; // version of producer application + char UserDef[64]; // user defined text + DWORD dwLevelReference; // sample value for 0 dB reference + TAG_CART_TIMER PostTimer[8]; // 8 time markers after head + char Reserved[276]; + char URL[1024]; // uniform resource locator #if defined(__GNUC__) && __GNUC__ < 3 - char TagText[0]; // free form text for scripts or tags -#elif 1 // change to 0 if compiler fails the following line - char TagText[]; // free form text for scripts or tags + char TagText[0]; // free form text for scripts or tags +#elif 1 // change to 0 if compiler fails the following line + char TagText[]; // free form text for scripts or tags #else - char TagText[1]; // free form text for scripts or tags + char TagText[1]; // free form text for scripts or tags #endif } TAG_CART; // RIFF "cue " tag structures -typedef struct -{ - DWORD dwName; - DWORD dwPosition; - DWORD fccChunk; - DWORD dwChunkStart; - DWORD dwBlockStart; - DWORD dwSampleOffset; +typedef struct { + DWORD dwName; + DWORD dwPosition; + DWORD fccChunk; + DWORD dwChunkStart; + DWORD dwBlockStart; + DWORD dwSampleOffset; } TAG_CUE_POINT; -typedef struct -{ - DWORD dwCuePoints; +typedef struct { + DWORD dwCuePoints; #if defined(__GNUC__) && __GNUC__ < 3 - TAG_CUE_POINT CuePoints[0]; + TAG_CUE_POINT CuePoints[0]; #elif 1 // change to 0 if compiler fails the following line - TAG_CUE_POINT CuePoints[]; + TAG_CUE_POINT CuePoints[]; #else - TAG_CUE_POINT CuePoints[1]; + TAG_CUE_POINT CuePoints[1]; #endif } TAG_CUE; // RIFF "smpl" tag structures -typedef struct -{ - DWORD dwIdentifier; - DWORD dwType; - DWORD dwStart; - DWORD dwEnd; - DWORD dwFraction; - DWORD dwPlayCount; +typedef struct { + DWORD dwIdentifier; + DWORD dwType; + DWORD dwStart; + DWORD dwEnd; + DWORD dwFraction; + DWORD dwPlayCount; } TAG_SMPL_LOOP; -typedef struct -{ - DWORD dwManufacturer; - DWORD dwProduct; - DWORD dwSamplePeriod; - DWORD dwMIDIUnityNote; - DWORD dwMIDIPitchFraction; - DWORD dwSMPTEFormat; - DWORD dwSMPTEOffset; - DWORD cSampleLoops; - DWORD cbSamplerData; +typedef struct { + DWORD dwManufacturer; + DWORD dwProduct; + DWORD dwSamplePeriod; + DWORD dwMIDIUnityNote; + DWORD dwMIDIPitchFraction; + DWORD dwSMPTEFormat; + DWORD dwSMPTEOffset; + DWORD cSampleLoops; + DWORD cbSamplerData; #if defined(__GNUC__) && __GNUC__ < 3 - TAG_SMPL_LOOP SampleLoops[0]; + TAG_SMPL_LOOP SampleLoops[0]; #elif 1 // change to 0 if compiler fails the following line - TAG_SMPL_LOOP SampleLoops[]; + TAG_SMPL_LOOP SampleLoops[]; #else - TAG_SMPL_LOOP SampleLoops[1]; + TAG_SMPL_LOOP SampleLoops[1]; #endif } TAG_SMPL; #ifdef _MSC_VER @@ -827,37 +856,40 @@ typedef struct // CoreAudio codec info structure typedef struct { - DWORD ftype; // file format - DWORD atype; // audio format - const char *name; // description + DWORD ftype; // file format + DWORD atype; // audio format + const char *name; // description } TAG_CA_CODEC; #ifndef _WAVEFORMATEX_ #define _WAVEFORMATEX_ #pragma pack(push, 1) typedef struct tWAVEFORMATEX { - WORD wFormatTag; - WORD nChannels; - DWORD nSamplesPerSec; - DWORD nAvgBytesPerSec; - WORD nBlockAlign; - WORD wBitsPerSample; - WORD cbSize; + WORD wFormatTag; + WORD nChannels; + DWORD nSamplesPerSec; + DWORD nAvgBytesPerSec; + WORD nBlockAlign; + WORD wBitsPerSample; + WORD cbSize; } WAVEFORMATEX, *PWAVEFORMATEX, *LPWAVEFORMATEX; typedef const WAVEFORMATEX *LPCWAVEFORMATEX; #pragma pack(pop) #endif // BASS_ChannelGetLength/GetPosition/SetPosition modes -#define BASS_POS_BYTE 0 // byte position -#define BASS_POS_MUSIC_ORDER 1 // order.row position, MAKELONG(order,row) -#define BASS_POS_OGG 3 // OGG bitstream number -#define BASS_POS_RESET 0x2000000 // flag: reset user file buffers -#define BASS_POS_RELATIVE 0x4000000 // flag: seek relative to the current position -#define BASS_POS_INEXACT 0x8000000 // flag: allow seeking to inexact position -#define BASS_POS_DECODE 0x10000000 // flag: get the decoding (not playing) position -#define BASS_POS_DECODETO 0x20000000 // flag: decode to the position instead of seeking -#define BASS_POS_SCAN 0x40000000 // flag: scan to the position +#define BASS_POS_BYTE 0 // byte position +#define BASS_POS_MUSIC_ORDER 1 // order.row position, MAKELONG(order,row) +#define BASS_POS_OGG 3 // OGG bitstream number +#define BASS_POS_RESET 0x2000000 // flag: reset user file buffers +#define BASS_POS_RELATIVE \ + 0x4000000 // flag: seek relative to the current position +#define BASS_POS_INEXACT 0x8000000 // flag: allow seeking to inexact position +#define BASS_POS_DECODE \ + 0x10000000 // flag: get the decoding (not playing) position +#define BASS_POS_DECODETO \ + 0x20000000 // flag: decode to the position instead of seeking +#define BASS_POS_SCAN 0x40000000 // flag: scan to the position // BASS_ChannelSetDevice/GetDevice option #define BASS_NODEVICE 0x20000 @@ -892,81 +924,81 @@ typedef const WAVEFORMATEX *LPCWAVEFORMATEX; #define BASS_FX_VOLUME 9 typedef struct { - float fWetDryMix; - float fDepth; - float fFeedback; - float fFrequency; - DWORD lWaveform; // 0=triangle, 1=sine - float fDelay; - DWORD lPhase; // BASS_DX8_PHASE_xxx + float fWetDryMix; + float fDepth; + float fFeedback; + float fFrequency; + DWORD lWaveform; // 0=triangle, 1=sine + float fDelay; + DWORD lPhase; // BASS_DX8_PHASE_xxx } BASS_DX8_CHORUS; typedef struct { - float fGain; - float fAttack; - float fRelease; - float fThreshold; - float fRatio; - float fPredelay; + float fGain; + float fAttack; + float fRelease; + float fThreshold; + float fRatio; + float fPredelay; } BASS_DX8_COMPRESSOR; typedef struct { - float fGain; - float fEdge; - float fPostEQCenterFrequency; - float fPostEQBandwidth; - float fPreLowpassCutoff; + float fGain; + float fEdge; + float fPostEQCenterFrequency; + float fPostEQBandwidth; + float fPreLowpassCutoff; } BASS_DX8_DISTORTION; typedef struct { - float fWetDryMix; - float fFeedback; - float fLeftDelay; - float fRightDelay; - BOOL lPanDelay; + float fWetDryMix; + float fFeedback; + float fLeftDelay; + float fRightDelay; + BOOL lPanDelay; } BASS_DX8_ECHO; typedef struct { - float fWetDryMix; - float fDepth; - float fFeedback; - float fFrequency; - DWORD lWaveform; // 0=triangle, 1=sine - float fDelay; - DWORD lPhase; // BASS_DX8_PHASE_xxx + float fWetDryMix; + float fDepth; + float fFeedback; + float fFrequency; + DWORD lWaveform; // 0=triangle, 1=sine + float fDelay; + DWORD lPhase; // BASS_DX8_PHASE_xxx } BASS_DX8_FLANGER; typedef struct { - DWORD dwRateHz; // Rate of modulation in hz - DWORD dwWaveShape; // 0=triangle, 1=square + DWORD dwRateHz; // Rate of modulation in hz + DWORD dwWaveShape; // 0=triangle, 1=square } BASS_DX8_GARGLE; typedef struct { - int lRoom; // [-10000, 0] default: -1000 mB - int lRoomHF; // [-10000, 0] default: 0 mB - float flRoomRolloffFactor; // [0.0, 10.0] default: 0.0 - float flDecayTime; // [0.1, 20.0] default: 1.49s - float flDecayHFRatio; // [0.1, 2.0] default: 0.83 - int lReflections; // [-10000, 1000] default: -2602 mB - float flReflectionsDelay; // [0.0, 0.3] default: 0.007 s - int lReverb; // [-10000, 2000] default: 200 mB - float flReverbDelay; // [0.0, 0.1] default: 0.011 s - float flDiffusion; // [0.0, 100.0] default: 100.0 % - float flDensity; // [0.0, 100.0] default: 100.0 % - float flHFReference; // [20.0, 20000.0] default: 5000.0 Hz + int lRoom; // [-10000, 0] default: -1000 mB + int lRoomHF; // [-10000, 0] default: 0 mB + float flRoomRolloffFactor; // [0.0, 10.0] default: 0.0 + float flDecayTime; // [0.1, 20.0] default: 1.49s + float flDecayHFRatio; // [0.1, 2.0] default: 0.83 + int lReflections; // [-10000, 1000] default: -2602 mB + float flReflectionsDelay; // [0.0, 0.3] default: 0.007 s + int lReverb; // [-10000, 2000] default: 200 mB + float flReverbDelay; // [0.0, 0.1] default: 0.011 s + float flDiffusion; // [0.0, 100.0] default: 100.0 % + float flDensity; // [0.0, 100.0] default: 100.0 % + float flHFReference; // [20.0, 20000.0] default: 5000.0 Hz } BASS_DX8_I3DL2REVERB; typedef struct { - float fCenter; - float fBandwidth; - float fGain; + float fCenter; + float fBandwidth; + float fGain; } BASS_DX8_PARAMEQ; typedef struct { - float fInGain; // [-96.0,0.0] default: 0.0 dB - float fReverbMix; // [-96.0,0.0] default: 0.0 db - float fReverbTime; // [0.001,3000.0] default: 1000.0 ms - float fHighFreqRTRatio; // [0.001,0.999] default: 0.001 + float fInGain; // [-96.0,0.0] default: 0.0 dB + float fReverbMix; // [-96.0,0.0] default: 0.0 db + float fReverbTime; // [0.001,3000.0] default: 1000.0 ms + float fHighFreqRTRatio; // [0.001,0.999] default: 0.001 } BASS_DX8_REVERB; #define BASS_DX8_PHASE_NEG_180 0 @@ -976,10 +1008,10 @@ typedef struct { #define BASS_DX8_PHASE_180 4 typedef struct { - float fTarget; - float fCurrent; - float fTime; - DWORD lCurve; + float fTarget; + float fCurrent; + float fTime; + DWORD lCurve; } BASS_FX_VOLUME_PARAM; typedef void(CALLBACK IOSNOTIFYPROC)(DWORD status); @@ -996,15 +1028,19 @@ void *BASSDEF(BASS_GetConfigPtr)(DWORD option); DWORD BASSDEF(BASS_GetVersion)(); int BASSDEF(BASS_ErrorGetCode)(); BOOL BASSDEF(BASS_GetDeviceInfo)(DWORD device, BASS_DEVICEINFO *info); -#if defined(_WIN32) && !defined(_WIN32_WCE) && !(WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) -BOOL BASSDEF(BASS_Init)(int device, DWORD freq, DWORD flags, HWND win, const GUID *dsguid); +#if defined(_WIN32) && !defined(_WIN32_WCE) && \ + !(WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) +BOOL BASSDEF(BASS_Init)(int device, DWORD freq, DWORD flags, HWND win, + const GUID *dsguid); #else -BOOL BASSDEF(BASS_Init)(int device, DWORD freq, DWORD flags, void *win, void *dsguid); +BOOL BASSDEF(BASS_Init)(int device, DWORD freq, DWORD flags, void *win, + void *dsguid); #endif BOOL BASSDEF(BASS_SetDevice)(DWORD device); DWORD BASSDEF(BASS_GetDevice)(); BOOL BASSDEF(BASS_Free)(); -#if defined(_WIN32) && !defined(_WIN32_WCE) && !(WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) +#if defined(_WIN32) && !defined(_WIN32_WCE) && \ + !(WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) void *BASSDEF(BASS_GetDSoundObject)(DWORD object); #endif BOOL BASSDEF(BASS_GetInfo)(BASS_INFO *info); @@ -1023,19 +1059,29 @@ const BASS_PLUGININFO *BASSDEF(BASS_PluginGetInfo)(HPLUGIN handle); BOOL BASSDEF(BASS_Set3DFactors)(float distf, float rollf, float doppf); BOOL BASSDEF(BASS_Get3DFactors)(float *distf, float *rollf, float *doppf); -BOOL BASSDEF(BASS_Set3DPosition)(const BASS_3DVECTOR *pos, const BASS_3DVECTOR *vel, const BASS_3DVECTOR *front, const BASS_3DVECTOR *top); -BOOL BASSDEF(BASS_Get3DPosition)(BASS_3DVECTOR *pos, BASS_3DVECTOR *vel, BASS_3DVECTOR *front, BASS_3DVECTOR *top); +BOOL BASSDEF(BASS_Set3DPosition)(const BASS_3DVECTOR *pos, + const BASS_3DVECTOR *vel, + const BASS_3DVECTOR *front, + const BASS_3DVECTOR *top); +BOOL BASSDEF(BASS_Get3DPosition)(BASS_3DVECTOR *pos, BASS_3DVECTOR *vel, + BASS_3DVECTOR *front, BASS_3DVECTOR *top); void BASSDEF(BASS_Apply3D)(); -#if defined(_WIN32) && !defined(_WIN32_WCE) && !(WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) -BOOL BASSDEF(BASS_SetEAXParameters)(int env, float vol, float decay, float damp); -BOOL BASSDEF(BASS_GetEAXParameters)(DWORD *env, float *vol, float *decay, float *damp); +#if defined(_WIN32) && !defined(_WIN32_WCE) && \ + !(WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) +BOOL BASSDEF(BASS_SetEAXParameters)(int env, float vol, float decay, + float damp); +BOOL BASSDEF(BASS_GetEAXParameters)(DWORD *env, float *vol, float *decay, + float *damp); #endif -HMUSIC BASSDEF(BASS_MusicLoad)(BOOL mem, const void *file, QWORD offset, DWORD length, DWORD flags, DWORD freq); +HMUSIC BASSDEF(BASS_MusicLoad)(BOOL mem, const void *file, QWORD offset, + DWORD length, DWORD flags, DWORD freq); BOOL BASSDEF(BASS_MusicFree)(HMUSIC handle); -HSAMPLE BASSDEF(BASS_SampleLoad)(BOOL mem, const void *file, QWORD offset, DWORD length, DWORD max, DWORD flags); -HSAMPLE BASSDEF(BASS_SampleCreate)(DWORD length, DWORD freq, DWORD chans, DWORD max, DWORD flags); +HSAMPLE BASSDEF(BASS_SampleLoad)(BOOL mem, const void *file, QWORD offset, + DWORD length, DWORD max, DWORD flags); +HSAMPLE BASSDEF(BASS_SampleCreate)(DWORD length, DWORD freq, DWORD chans, + DWORD max, DWORD flags); BOOL BASSDEF(BASS_SampleFree)(HSAMPLE handle); BOOL BASSDEF(BASS_SampleSetData)(HSAMPLE handle, const void *buffer); BOOL BASSDEF(BASS_SampleGetData)(HSAMPLE handle, void *buffer); @@ -1045,14 +1091,22 @@ HCHANNEL BASSDEF(BASS_SampleGetChannel)(HSAMPLE handle, BOOL onlynew); DWORD BASSDEF(BASS_SampleGetChannels)(HSAMPLE handle, HCHANNEL *channels); BOOL BASSDEF(BASS_SampleStop)(HSAMPLE handle); -HSTREAM BASSDEF(BASS_StreamCreate)(DWORD freq, DWORD chans, DWORD flags, STREAMPROC *proc, void *user); -HSTREAM BASSDEF(BASS_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags); -HSTREAM BASSDEF(BASS_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user); -HSTREAM BASSDEF(BASS_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *proc, void *user); +HSTREAM BASSDEF(BASS_StreamCreate)(DWORD freq, DWORD chans, DWORD flags, + STREAMPROC *proc, void *user); +HSTREAM BASSDEF(BASS_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, + QWORD length, DWORD flags); +HSTREAM BASSDEF(BASS_StreamCreateURL)(const char *url, DWORD offset, + DWORD flags, DOWNLOADPROC *proc, + void *user); +HSTREAM BASSDEF(BASS_StreamCreateFileUser)(DWORD system, DWORD flags, + const BASS_FILEPROCS *proc, + void *user); BOOL BASSDEF(BASS_StreamFree)(HSTREAM handle); QWORD BASSDEF(BASS_StreamGetFilePosition)(HSTREAM handle, DWORD mode); -DWORD BASSDEF(BASS_StreamPutData)(HSTREAM handle, const void *buffer, DWORD length); -DWORD BASSDEF(BASS_StreamPutFileData)(HSTREAM handle, const void *buffer, DWORD length); +DWORD BASSDEF(BASS_StreamPutData)(HSTREAM handle, const void *buffer, + DWORD length); +DWORD BASSDEF(BASS_StreamPutFileData)(HSTREAM handle, const void *buffer, + DWORD length); BOOL BASSDEF(BASS_RecordGetDeviceInfo)(DWORD device, BASS_DEVICEINFO *info); BOOL BASSDEF(BASS_RecordInit)(int device); @@ -1063,7 +1117,8 @@ BOOL BASSDEF(BASS_RecordGetInfo)(BASS_RECORDINFO *info); const char *BASSDEF(BASS_RecordGetInputName)(int input); BOOL BASSDEF(BASS_RecordSetInput)(int input, DWORD flags, float volume); DWORD BASSDEF(BASS_RecordGetInput)(int input, float *volume); -HRECORD BASSDEF(BASS_RecordStart)(DWORD freq, DWORD chans, DWORD flags, RECORDPROC *proc, void *user); +HRECORD BASSDEF(BASS_RecordStart)(DWORD freq, DWORD chans, DWORD flags, + RECORDPROC *proc, void *user); double BASSDEF(BASS_ChannelBytes2Seconds)(DWORD handle, QWORD pos); QWORD BASSDEF(BASS_ChannelSeconds2Bytes)(DWORD handle, double pos); @@ -1079,24 +1134,39 @@ BOOL BASSDEF(BASS_ChannelPlay)(DWORD handle, BOOL restart); BOOL BASSDEF(BASS_ChannelStop)(DWORD handle); BOOL BASSDEF(BASS_ChannelPause)(DWORD handle); BOOL BASSDEF(BASS_ChannelSetAttribute)(DWORD handle, DWORD attrib, float value); -BOOL BASSDEF(BASS_ChannelGetAttribute)(DWORD handle, DWORD attrib, float *value); -BOOL BASSDEF(BASS_ChannelSlideAttribute)(DWORD handle, DWORD attrib, float value, DWORD time); +BOOL BASSDEF(BASS_ChannelGetAttribute)(DWORD handle, DWORD attrib, + float *value); +BOOL BASSDEF(BASS_ChannelSlideAttribute)(DWORD handle, DWORD attrib, + float value, DWORD time); BOOL BASSDEF(BASS_ChannelIsSliding)(DWORD handle, DWORD attrib); -BOOL BASSDEF(BASS_ChannelSetAttributeEx)(DWORD handle, DWORD attrib, void *value, DWORD size); -DWORD BASSDEF(BASS_ChannelGetAttributeEx)(DWORD handle, DWORD attrib, void *value, DWORD size); -BOOL BASSDEF(BASS_ChannelSet3DAttributes)(DWORD handle, int mode, float min, float max, int iangle, int oangle, float outvol); -BOOL BASSDEF(BASS_ChannelGet3DAttributes)(DWORD handle, DWORD *mode, float *min, float *max, DWORD *iangle, DWORD *oangle, float *outvol); -BOOL BASSDEF(BASS_ChannelSet3DPosition)(DWORD handle, const BASS_3DVECTOR *pos, const BASS_3DVECTOR *orient, const BASS_3DVECTOR *vel); -BOOL BASSDEF(BASS_ChannelGet3DPosition)(DWORD handle, BASS_3DVECTOR *pos, BASS_3DVECTOR *orient, BASS_3DVECTOR *vel); +BOOL BASSDEF(BASS_ChannelSetAttributeEx)(DWORD handle, DWORD attrib, + void *value, DWORD size); +DWORD BASSDEF(BASS_ChannelGetAttributeEx)(DWORD handle, DWORD attrib, + void *value, DWORD size); +BOOL BASSDEF(BASS_ChannelSet3DAttributes)(DWORD handle, int mode, float min, + float max, int iangle, int oangle, + float outvol); +BOOL BASSDEF(BASS_ChannelGet3DAttributes)(DWORD handle, DWORD *mode, float *min, + float *max, DWORD *iangle, + DWORD *oangle, float *outvol); +BOOL BASSDEF(BASS_ChannelSet3DPosition)(DWORD handle, const BASS_3DVECTOR *pos, + const BASS_3DVECTOR *orient, + const BASS_3DVECTOR *vel); +BOOL BASSDEF(BASS_ChannelGet3DPosition)(DWORD handle, BASS_3DVECTOR *pos, + BASS_3DVECTOR *orient, + BASS_3DVECTOR *vel); QWORD BASSDEF(BASS_ChannelGetLength)(DWORD handle, DWORD mode); BOOL BASSDEF(BASS_ChannelSetPosition)(DWORD handle, QWORD pos, DWORD mode); QWORD BASSDEF(BASS_ChannelGetPosition)(DWORD handle, DWORD mode); DWORD BASSDEF(BASS_ChannelGetLevel)(DWORD handle); -BOOL BASSDEF(BASS_ChannelGetLevelEx)(DWORD handle, float *levels, float length, DWORD flags); +BOOL BASSDEF(BASS_ChannelGetLevelEx)(DWORD handle, float *levels, float length, + DWORD flags); DWORD BASSDEF(BASS_ChannelGetData)(DWORD handle, void *buffer, DWORD length); -HSYNC BASSDEF(BASS_ChannelSetSync)(DWORD handle, DWORD type, QWORD param, SYNCPROC *proc, void *user); +HSYNC BASSDEF(BASS_ChannelSetSync)(DWORD handle, DWORD type, QWORD param, + SYNCPROC *proc, void *user); BOOL BASSDEF(BASS_ChannelRemoveSync)(DWORD handle, HSYNC sync); -HDSP BASSDEF(BASS_ChannelSetDSP)(DWORD handle, DSPPROC *proc, void *user, int priority); +HDSP BASSDEF(BASS_ChannelSetDSP)(DWORD handle, DSPPROC *proc, void *user, + int priority); BOOL BASSDEF(BASS_ChannelRemoveDSP)(DWORD handle, HDSP dsp); BOOL BASSDEF(BASS_ChannelSetLink)(DWORD handle, DWORD chan); BOOL BASSDEF(BASS_ChannelRemoveLink)(DWORD handle, DWORD chan); @@ -1114,32 +1184,42 @@ BOOL BASSDEF(BASS_FXSetPriority)(HFX handle, int priority); #if defined(_WIN32) && !defined(NOBASSOVERLOADS) static inline HPLUGIN BASS_PluginLoad(const WCHAR *file, DWORD flags) { - return BASS_PluginLoad((const char *)file, flags | BASS_UNICODE); + return BASS_PluginLoad((const char *)file, flags | BASS_UNICODE); } -static inline HMUSIC BASS_MusicLoad(BOOL mem, const WCHAR *file, QWORD offset, DWORD length, DWORD flags, DWORD freq) +static inline HMUSIC BASS_MusicLoad(BOOL mem, const WCHAR *file, QWORD offset, + DWORD length, DWORD flags, DWORD freq) { - return BASS_MusicLoad(mem, (const void *)file, offset, length, flags | BASS_UNICODE, freq); + return BASS_MusicLoad(mem, (const void *)file, offset, length, + flags | BASS_UNICODE, freq); } -static inline HSAMPLE BASS_SampleLoad(BOOL mem, const WCHAR *file, QWORD offset, DWORD length, DWORD max, DWORD flags) +static inline HSAMPLE BASS_SampleLoad(BOOL mem, const WCHAR *file, QWORD offset, + DWORD length, DWORD max, DWORD flags) { - return BASS_SampleLoad(mem, (const void *)file, offset, length, max, flags | BASS_UNICODE); + return BASS_SampleLoad(mem, (const void *)file, offset, length, max, + flags | BASS_UNICODE); } -static inline HSTREAM BASS_StreamCreateFile(BOOL mem, const WCHAR *file, QWORD offset, QWORD length, DWORD flags) +static inline HSTREAM BASS_StreamCreateFile(BOOL mem, const WCHAR *file, + QWORD offset, QWORD length, + DWORD flags) { - return BASS_StreamCreateFile(mem, (const void *)file, offset, length, flags | BASS_UNICODE); + return BASS_StreamCreateFile(mem, (const void *)file, offset, length, + flags | BASS_UNICODE); } -static inline HSTREAM BASS_StreamCreateURL(const WCHAR *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user) +static inline HSTREAM BASS_StreamCreateURL(const WCHAR *url, DWORD offset, + DWORD flags, DOWNLOADPROC *proc, + void *user) { - return BASS_StreamCreateURL((const char *)url, offset, flags | BASS_UNICODE, proc, user); + return BASS_StreamCreateURL((const char *)url, offset, flags | BASS_UNICODE, + proc, user); } static inline BOOL BASS_SetConfigPtr(DWORD option, const WCHAR *value) { - return BASS_SetConfigPtr(option | BASS_UNICODE, (const void *)value); + return BASS_SetConfigPtr(option | BASS_UNICODE, (const void *)value); } #endif #endif diff --git a/include/bassopus.h b/include/bassopus.h index 757ff70c..3d8b131d 100644 --- a/include/bassopus.h +++ b/include/bassopus.h @@ -1,8 +1,8 @@ /* - BASSOPUS 2.4 C/C++ header file - Copyright (c) 2012-2015 Un4seen Developments Ltd. + BASSOPUS 2.4 C/C++ header file + Copyright (c) 2012-2015 Un4seen Developments Ltd. - See the BASSOPUS.CHM file for more detailed documentation + See the BASSOPUS.CHM file for more detailed documentation */ #ifndef BASSOPUS_H @@ -29,22 +29,34 @@ extern "C" { #define BASS_ATTRIB_OPUS_ORIGFREQ 0x13000 #define BASS_ATTRIB_OPUS_GAIN 0x13001 -HSTREAM BASSOPUSDEF(BASS_OPUS_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags); -HSTREAM BASSOPUSDEF(BASS_OPUS_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user); -HSTREAM BASSOPUSDEF(BASS_OPUS_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user); +HSTREAM BASSOPUSDEF(BASS_OPUS_StreamCreateFile)(BOOL mem, const void *file, + QWORD offset, QWORD length, + DWORD flags); +HSTREAM BASSOPUSDEF(BASS_OPUS_StreamCreateURL)(const char *url, DWORD offset, + DWORD flags, DOWNLOADPROC *proc, + void *user); +HSTREAM BASSOPUSDEF(BASS_OPUS_StreamCreateFileUser)(DWORD system, DWORD flags, + const BASS_FILEPROCS *procs, + void *user); #ifdef __cplusplus } #if defined(_WIN32) && !defined(NOBASSOVERLOADS) -static inline HSTREAM BASS_OPUS_StreamCreateFile(BOOL mem, const WCHAR *file, QWORD offset, QWORD length, DWORD flags) +static inline HSTREAM BASS_OPUS_StreamCreateFile(BOOL mem, const WCHAR *file, + QWORD offset, QWORD length, + DWORD flags) { - return BASS_OPUS_StreamCreateFile(mem, (const void *)file, offset, length, flags | BASS_UNICODE); + return BASS_OPUS_StreamCreateFile(mem, (const void *)file, offset, length, + flags | BASS_UNICODE); } -static inline HSTREAM BASS_OPUS_StreamCreateURL(const WCHAR *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user) +static inline HSTREAM BASS_OPUS_StreamCreateURL(const WCHAR *url, DWORD offset, + DWORD flags, DOWNLOADPROC *proc, + void *user) { - return BASS_OPUS_StreamCreateURL((const char *)url, offset, flags | BASS_UNICODE, proc, user); + return BASS_OPUS_StreamCreateURL((const char *)url, offset, + flags | BASS_UNICODE, proc, user); } #endif #endif diff --git a/include/chatlogpiece.h b/include/chatlogpiece.h index c2d32b24..e6f77c74 100644 --- a/include/chatlogpiece.h +++ b/include/chatlogpiece.h @@ -6,25 +6,27 @@ class chatlogpiece { public: - chatlogpiece(); - chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song); - chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song, QDateTime p_datetime); + chatlogpiece(); + chatlogpiece(QString p_name, QString p_showname, QString p_message, + bool p_song); + chatlogpiece(QString p_name, QString p_showname, QString p_message, + bool p_song, QDateTime p_datetime); - QString get_name(); - QString get_showname(); - QString get_message(); - bool is_song(); - QDateTime get_datetime(); - QString get_datetime_as_string(); + QString get_name(); + QString get_showname(); + QString get_message(); + bool is_song(); + QDateTime get_datetime(); + QString get_datetime_as_string(); - QString get_full(); + QString get_full(); private: - QString name; - QString showname; - QString message; - QDateTime datetime; - bool p_is_song; + QString name; + QString showname; + QString message; + QDateTime datetime; + bool p_is_song; }; #endif // CHATLOGPIECE_H diff --git a/include/courtroom.h b/include/courtroom.h index c3c6b87e..259a7ed5 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -63,723 +63,743 @@ class AOApplication; class Courtroom : public QMainWindow { - Q_OBJECT + Q_OBJECT public: - explicit Courtroom(AOApplication *p_ao_app); - - void append_char(char_type p_char) { char_list.append(p_char); } - void append_evidence(evi_type p_evi) { evidence_list.append(p_evi); } - void append_music(QString f_music) { music_list.append(f_music); } - void append_area(QString f_area) { area_list.append(f_area); } - void clear_music() { music_list.clear(); } - void clear_areas() { area_list.clear(); } - - void fix_last_area() - { - if (area_list.size() > 0) { - QString malplaced = area_list.last(); - area_list.removeLast(); - append_music(malplaced); - } + explicit Courtroom(AOApplication *p_ao_app); + + void append_char(char_type p_char) { char_list.append(p_char); } + void append_evidence(evi_type p_evi) { evidence_list.append(p_evi); } + void append_music(QString f_music) { music_list.append(f_music); } + void append_area(QString f_area) { area_list.append(f_area); } + void clear_music() { music_list.clear(); } + void clear_areas() { area_list.clear(); } + + void fix_last_area() + { + if (area_list.size() > 0) { + QString malplaced = area_list.last(); + area_list.removeLast(); + append_music(malplaced); } - - void arup_append(int players, QString status, QString cm, QString locked) - { - arup_players.append(players); - arup_statuses.append(status); - arup_cms.append(cm); - arup_locks.append(locked); + } + + void arup_append(int players, QString status, QString cm, QString locked) + { + arup_players.append(players); + arup_statuses.append(status); + arup_cms.append(cm); + arup_locks.append(locked); + } + + void arup_modify(int type, int place, QString value) + { + if (type == 0) { + if (arup_players.size() > place) + arup_players[place] = value.toInt(); } - - void arup_modify(int type, int place, QString value) - { - if (type == 0) { - if (arup_players.size() > place) - arup_players[place] = value.toInt(); - } - else if (type == 1) { - if (arup_statuses.size() > place) - arup_statuses[place] = value; - } - else if (type == 2) { - if (arup_cms.size() > place) - arup_cms[place] = value; - } - else if (type == 3) { - if (arup_locks.size() > place) - arup_locks[place] = value; - } - list_areas(); + else if (type == 1) { + if (arup_statuses.size() > place) + arup_statuses[place] = value; + } + else if (type == 2) { + if (arup_cms.size() > place) + arup_cms[place] = value; } + else if (type == 3) { + if (arup_locks.size() > place) + arup_locks[place] = value; + } + list_areas(); + } - void character_loading_finished(); + void character_loading_finished(); - //sets position of widgets based on theme ini files - void set_widgets(); + // 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 class_name, QString p_identifier); + // sets font size based on theme ini files + void set_font(QWidget *widget, QString class_name, QString p_identifier); - //Get the properly constructed font - QFont get_qfont(QString font_name, int f_pointsize, bool antialias = true); + // Get the properly constructed font + QFont get_qfont(QString font_name, int f_pointsize, bool antialias = true); - //actual operation of setting the font on a widget - void set_qfont(QWidget *widget, QString class_name, QFont font, QColor f_color = Qt::black, bool bold = false); + // actual operation of setting the font on a widget + void set_qfont(QWidget *widget, QString class_name, QFont font, + QColor f_color = Qt::black, bool bold = false); - //helper function that calls above function on the relevant widgets - void set_fonts(); + // helper function that calls above function on the relevant widgets + void set_fonts(); - //sets dropdown menu stylesheet - void set_dropdown(QWidget *widget); + // sets dropdown menu stylesheet + void set_dropdown(QWidget *widget); - //helper funciton that call above function on the relevant widgets - void set_dropdowns(); + // helper funciton that call above function on the relevant widgets + void set_dropdowns(); - void set_window_title(QString p_title); + 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); + // 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 inis and returns the size and pos as defined by it - QPoint get_theme_pos(QString p_identifier); + // reads theme inis and returns the size and pos as defined by it + QPoint get_theme_pos(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 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, bool display = false); + // sets the current background to argument. also does some checks to see if + // it's a legacy bg + void set_background(QString p_background, bool display = false); - //sets the local character pos/side to use. - void set_side(QString p_side); + // sets the local character pos/side to use. + void set_side(QString p_side); - //sets the pos dropdown - void set_pos_dropdown(QStringList pos_dropdowns); + // sets the pos dropdown + void set_pos_dropdown(QStringList pos_dropdowns); - //sets the evidence list member variable to argument - void set_evidence_list(QVector<evi_type> &p_evi_list); + // sets the evidence list member variable to argument + void set_evidence_list(QVector<evi_type> &p_evi_list); - //called when a DONE#% from the server was received - void done_received(); + // 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 the local mute list based on characters available on the server + void set_mute_list(); - // Sets the local pair list based on the characters available on the server. - void set_pair_list(); + // Sets the local pair list based on the characters available on the server. + void set_pair_list(); - //sets desk and bg based on pos in chatmessage - void set_scene(QString f_desk_mod, QString f_side); + // sets desk and bg based on pos in chatmessage + void set_scene(QString f_desk_mod, QString f_side); - //takes in serverD-formatted IP list as prints a converted version to server OOC - //admittedly poorly named - void set_ip_list(QString p_list); + // 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); + // 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); + // send a message that the player is banned and quits the server + void set_ban(int p_cid); - //cid = character id, returns the cid of the currently selected character - int get_cid() { return m_cid; } - QString get_current_char() { return current_char; } - QString get_current_background() { return current_background; } + // cid = character id, returns the cid of the currently selected character + int get_cid() { return m_cid; } + QString get_current_char() { return current_char; } + QString get_current_background() { return current_background; } - //updates character to p_cid and updates necessary ui elements - void update_character(int p_cid); + // updates character to p_cid and updates necessary ui elements + void update_character(int p_cid); - //properly sets up some varibles: resets user state - void enter_courtroom(); + // properly sets up some varibles: resets user state + void enter_courtroom(); - //helper function that populates ui_music_list with the contents of music_list - void list_music(); - void list_areas(); + // helper function that populates ui_music_list with the contents of + // music_list + void list_music(); + void list_areas(); - //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, QString p_color); + // 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, + 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(); + // 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(); - //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); + // 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); - //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 = "", QString action = ""); + // 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 = "", QString action = ""); - //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); + // 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(bool noninterrupting); + void play_preanim(bool noninterrupting); - //plays the witness testimony or cross examination animation based on argument - void handle_wtce(QString p_wtce, int variant); + // plays the witness testimony or cross examination animation based on + // argument + void handle_wtce(QString p_wtce, int variant); - //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); + // 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); - //Toggles the judge buttons, whether they should appear or not. - void toggle_judge_buttons(bool is_on); + // Toggles the judge buttons, whether they should appear or not. + void toggle_judge_buttons(bool is_on); - void announce_case(QString title, bool def, bool pro, bool jud, bool jur, bool steno); + void announce_case(QString title, bool def, bool pro, bool jud, bool jur, + bool steno); - void check_connection_received(); + void check_connection_received(); - ~Courtroom(); + ~Courtroom(); private: - AOApplication *ao_app; - - int m_courtroom_width = 714; - int m_courtroom_height = 668; - - int m_viewport_x = 0; - int m_viewport_y = 0; + AOApplication *ao_app; - int m_viewport_width = 256; - int m_viewport_height = 192; + int m_courtroom_width = 714; + int m_courtroom_height = 668; - bool first_message_sent = false; - int maximumMessages = 0; + int m_viewport_x = 0; + int m_viewport_y = 0; - QParallelAnimationGroup *screenshake_animation_group = new QParallelAnimationGroup; + int m_viewport_width = 256; + int m_viewport_height = 192; - bool next_character_is_not_special = false; // If true, write the - // next character as it is. + bool first_message_sent = false; + int maximumMessages = 0; - bool message_is_centered = false; + QParallelAnimationGroup *screenshake_animation_group = + new QParallelAnimationGroup; - int current_display_speed = 3; - int message_display_speed[7] = {0, 10, 25, 40, 50, 70, 90}; + bool next_character_is_not_special = false; // If true, write the + // next character as it is. - // The character ID of the character this user wants to appear alongside with. - int other_charid = -1; + bool message_is_centered = false; - // The offset this user has given if they want to appear alongside someone. - int char_offset = 0; + int current_display_speed = 3; + int message_display_speed[7] = {0, 10, 25, 40, 50, 70, 90}; - // 0 = in front, 1 = behind - int pair_order = 0; + // The character ID of the character this user wants to appear alongside with. + int other_charid = -1; - QVector<char_type> char_list; - QVector<evi_type> evidence_list; - QVector<QString> music_list; - QVector<QString> area_list; + // The offset this user has given if they want to appear alongside someone. + int char_offset = 0; - QVector<int> arup_players; - QVector<QString> arup_statuses; - QVector<QString> arup_cms; - QVector<QString> arup_locks; + // 0 = in front, 1 = behind + int pair_order = 0; - QVector<chatlogpiece> ic_chatlog_history; + QVector<char_type> char_list; + QVector<evi_type> evidence_list; + QVector<QString> music_list; + QVector<QString> area_list; - //triggers ping_server() every 60 seconds - QTimer *keepalive_timer; + QVector<int> arup_players; + QVector<QString> arup_statuses; + QVector<QString> arup_cms; + QVector<QString> arup_locks; - //determines how fast messages tick onto screen - QTimer *chat_tick_timer; - //int chat_tick_interval = 60; - //which tick position(character in chat message) we are at - int tick_pos = 0; - //the actual document tick pos we gotta worry about for making the text scroll better - int real_tick_pos = 0; - //used to determine how often blips sound - int blip_ticker = 0; - int blip_rate = 1; - int rainbow_counter = 0; - bool rainbow_appended = false; - bool blank_blip = false; + QVector<chatlogpiece> ic_chatlog_history; - //Whether or not is this message additive to the previous one - bool is_additive = false; + // triggers ping_server() every 60 seconds + QTimer *keepalive_timer; - // Used for getting the current maximum blocks allowed in the IC chatlog. - int log_maximum_blocks = 0; + // determines how fast messages tick onto screen + QTimer *chat_tick_timer; + // int chat_tick_interval = 60; + // which tick position(character in chat message) we are at + int tick_pos = 0; + // the actual document tick pos we gotta worry about for making the text + // scroll better + int real_tick_pos = 0; + // used to determine how often blips sound + int blip_ticker = 0; + int blip_rate = 1; + int rainbow_counter = 0; + bool rainbow_appended = false; + bool blank_blip = false; - // True, if the log should go downwards. - bool log_goes_downwards = false; + // Whether or not is this message additive to the previous one + bool is_additive = false; - //delay before chat messages starts ticking - QTimer *text_delay_timer; + // Used for getting the current maximum blocks allowed in the IC chatlog. + int log_maximum_blocks = 0; - //delay before sfx plays - QTimer *sfx_delay_timer; + // True, if the log should go downwards. + bool log_goes_downwards = false; - //every time point in char.inis times this equals the final time - const int time_mod = 40; + // delay before chat messages starts ticking + QTimer *text_delay_timer; - //the amount of time non-animated objection/hold it/takethat images stay onscreen for in ms - const int shout_stay_time = 724; + // delay before sfx plays + QTimer *sfx_delay_timer; - //the amount of time non-animated guilty/not guilty images stay onscreen for in ms - const int verdict_stay_time = 3000; + // every time point in char.inis times this equals the final time + const int time_mod = 40; - //the amount of time non-animated witness testimony/cross-examination images stay onscreen for in ms - const int wtce_stay_time = 1500; + // the amount of time non-animated objection/hold it/takethat images stay + // onscreen for in ms + const int shout_stay_time = 724; - //characters we consider punctuation - const QString punctuation_chars = ".,?!:;"; + // the amount of time non-animated guilty/not guilty images stay onscreen for + // in ms + const int verdict_stay_time = 3000; - //amount by which we multiply the delay when we parse punctuation chars - const int punctuation_modifier = 3; + // the amount of time non-animated witness testimony/cross-examination images + // stay onscreen for in ms + const int wtce_stay_time = 1500; - static const int chatmessage_size = 30; - QString m_chatmessage[chatmessage_size]; - bool chatmessage_is_empty = false; + // characters we consider punctuation + const QString punctuation_chars = ".,?!:;"; - QString previous_ic_message = ""; - QString additive_previous = ""; + // amount by which we multiply the delay when we parse punctuation chars + const int punctuation_modifier = 3; - //char id, muted or not - QMap<int, bool> mute_map; + static const int chatmessage_size = 30; + QString m_chatmessage[chatmessage_size]; + bool chatmessage_is_empty = false; - //QVector<int> muted_cids; + QString previous_ic_message = ""; + QString additive_previous = ""; - bool is_muted = false; + // char id, muted or not + QMap<int, bool> mute_map; - //state of animation, 0 = objecting, 1 = preanim, 2 = talking, 3 = idle, 4 = noniterrupting preanim - int anim_state = 3; + // QVector<int> muted_cids; - //whether or not current color is a talking one - bool color_is_talking = true; + bool is_muted = false; - //state of text ticking, 0 = not yet ticking, 1 = ticking in progress, 2 = ticking done - int text_state = 2; + // state of animation, 0 = objecting, 1 = preanim, 2 = talking, 3 = idle, 4 = + // noniterrupting preanim + int anim_state = 3; - //character id, which index of the char_list the player is - int m_cid = -1; - //cid and this may differ in cases of ini-editing - QString current_char = ""; + // whether or not current color is a talking one + bool color_is_talking = true; - int objection_state = 0; - int realization_state = 0; - int screenshake_state = 0; - int text_color = 0; + // state of text ticking, 0 = not yet ticking, 1 = ticking in progress, 2 = + // ticking done + int text_state = 2; - //How many unique user colors are possible - static const int max_colors = 12; + // character id, which index of the char_list the player is + int m_cid = -1; + // cid and this may differ in cases of ini-editing + QString current_char = ""; - //Text Color-related optimization: - //Current color list indexes to real color references - QVector<int> color_row_to_number; + int objection_state = 0; + int realization_state = 0; + int screenshake_state = 0; + int text_color = 0; - //List of associated RGB colors for this color index - QVector<QColor> color_rgb_list; + // How many unique user colors are possible + static const int max_colors = 12; - //List of markdown start characters, their index is tied to the color index - QStringList color_markdown_start_list; + // Text Color-related optimization: + // Current color list indexes to real color references + QVector<int> color_row_to_number; - //List of markdown end characters, their index is tied to the color index - QStringList color_markdown_end_list; + // List of associated RGB colors for this color index + QVector<QColor> color_rgb_list; - //Whether or not we're supposed to remove this char during parsing - QVector<bool> color_markdown_remove_list; + // List of markdown start characters, their index is tied to the color index + QStringList color_markdown_start_list; - //Whether or not this color allows us to play the talking animation - QVector<bool> color_markdown_talking_list; - //Text Color-related optimization END + // List of markdown end characters, their index is tied to the color index + QStringList color_markdown_end_list; - //List of all currently available pos - QStringList pos_dropdown_list; + // Whether or not we're supposed to remove this char during parsing + QVector<bool> color_markdown_remove_list; - bool is_presenting_evidence = false; + // Whether or not this color allows us to play the talking animation + QVector<bool> color_markdown_talking_list; + // Text Color-related optimization END - QString effect = ""; + // List of all currently available pos + QStringList pos_dropdown_list; - //Music effect flags we want to send to server when we play music - int music_flags = 0; + bool is_presenting_evidence = false; - int defense_bar_state = 0; - int prosecution_bar_state = 0; + QString effect = ""; - int current_char_page = 0; - int char_columns = 10; - int char_rows = 9; - int max_chars_on_page = 90; + // Music effect flags we want to send to server when we play music + int music_flags = 0; - const int button_width = 60; - const int button_height = 60; + int defense_bar_state = 0; + int prosecution_bar_state = 0; - int current_emote_page = 0; - int current_emote = 0; - int emote_columns = 5; - int emote_rows = 2; - int max_emotes_on_page = 10; + int current_char_page = 0; + int char_columns = 10; + int char_rows = 9; + int max_chars_on_page = 90; - QVector<evi_type> local_evidence_list; - QVector<evi_type> private_evidence_list; - QVector<evi_type> global_evidence_list; + const int button_width = 60; + const int button_height = 60; - //false = use private_evidence_list - bool current_evidence_global = true; + int current_emote_page = 0; + int current_emote = 0; + int emote_columns = 5; + int emote_rows = 2; + int max_emotes_on_page = 10; - int current_evidence_page = 0; - int current_evidence = 0; - int evidence_columns = 6; - int evidence_rows = 3; - int max_evidence_on_page = 18; + QVector<evi_type> local_evidence_list; + QVector<evi_type> private_evidence_list; + QVector<evi_type> global_evidence_list; - //is set to true if the bg folder contains defensedesk.png, prosecutiondesk.png and stand.png - bool is_ao2_bg = false; + // false = use private_evidence_list + bool current_evidence_global = true; - //whether the ooc chat is server or master chat, true is server - bool server_ooc = true; + int current_evidence_page = 0; + int current_evidence = 0; + int evidence_columns = 6; + int evidence_rows = 3; + int max_evidence_on_page = 18; - QString current_background = "default"; - QString current_side = ""; + // is set to true if the bg folder contains defensedesk.png, + // prosecutiondesk.png and stand.png + bool is_ao2_bg = false; - AOMusicPlayer *music_player; - AOSfxPlayer *sfx_player; - AOSfxPlayer *objection_player; - AOBlipPlayer *blip_player; + // whether the ooc chat is server or master chat, true is server + bool server_ooc = true; - AOSfxPlayer *modcall_player; + QString current_background = "default"; + QString current_side = ""; - AOImage *ui_background; + AOMusicPlayer *music_player; + AOSfxPlayer *sfx_player; + AOSfxPlayer *objection_player; + AOBlipPlayer *blip_player; - 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; - AOEvidenceDisplay *ui_vp_evidence_display; - AOImage *ui_vp_chatbox; - QLabel *ui_vp_showname; - AOMovie *ui_vp_chat_arrow; - QTextEdit *ui_vp_message; - AOMovie *ui_vp_effect; - AOMovie *ui_vp_testimony; - AOMovie *ui_vp_wtce; - AOMovie *ui_vp_objection; + AOSfxPlayer *modcall_player; - QTextEdit *ui_ic_chatlog; + AOImage *ui_background; - AOTextArea *ui_ms_chatlog; - AOTextArea *ui_server_chatlog; + 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; + AOEvidenceDisplay *ui_vp_evidence_display; + AOImage *ui_vp_chatbox; + QLabel *ui_vp_showname; + AOMovie *ui_vp_chat_arrow; + QTextEdit *ui_vp_message; + AOMovie *ui_vp_effect; + AOMovie *ui_vp_testimony; + AOMovie *ui_vp_wtce; + AOMovie *ui_vp_objection; - QListWidget *ui_mute_list; - QTreeWidget *ui_area_list; - QTreeWidget *ui_music_list; + QTextEdit *ui_ic_chatlog; - ScrollText *ui_music_name; - AOMovie *ui_music_display; + AOTextArea *ui_ms_chatlog; + AOTextArea *ui_server_chatlog; - AOButton *ui_pair_button; - QListWidget *ui_pair_list; - QSpinBox *ui_pair_offset_spinbox; + QListWidget *ui_mute_list; + QTreeWidget *ui_area_list; + QTreeWidget *ui_music_list; - QComboBox *ui_pair_order_dropdown; + ScrollText *ui_music_name; + AOMovie *ui_music_display; - AOLineEdit *ui_ic_chat_message; - QLineEdit *ui_ic_chat_name; + AOButton *ui_pair_button; + QListWidget *ui_pair_list; + QSpinBox *ui_pair_offset_spinbox; - QLineEdit *ui_ooc_chat_message; - QLineEdit *ui_ooc_chat_name; + QComboBox *ui_pair_order_dropdown; - //QLineEdit *ui_area_password; - QLineEdit *ui_music_search; + AOLineEdit *ui_ic_chat_message; + QLineEdit *ui_ic_chat_name; - QWidget *ui_emotes; - QVector<AOEmoteButton *> ui_emote_list; - AOButton *ui_emote_left; - AOButton *ui_emote_right; + QLineEdit *ui_ooc_chat_message; + QLineEdit *ui_ooc_chat_name; - QComboBox *ui_emote_dropdown; - QComboBox *ui_pos_dropdown; + // QLineEdit *ui_area_password; + QLineEdit *ui_music_search; - QComboBox *ui_iniswap_dropdown; - AOButton *ui_iniswap_remove; + QWidget *ui_emotes; + QVector<AOEmoteButton *> ui_emote_list; + AOButton *ui_emote_left; + AOButton *ui_emote_right; - QComboBox *ui_sfx_dropdown; - AOButton *ui_sfx_remove; + QComboBox *ui_emote_dropdown; + QComboBox *ui_pos_dropdown; - QComboBox *ui_effects_dropdown; + QComboBox *ui_iniswap_dropdown; + AOButton *ui_iniswap_remove; - AOImage *ui_defense_bar; - AOImage *ui_prosecution_bar; + QComboBox *ui_sfx_dropdown; + AOButton *ui_sfx_remove; - QLabel *ui_music_label; - QLabel *ui_sfx_label; - QLabel *ui_blip_label; + QComboBox *ui_effects_dropdown; + + AOImage *ui_defense_bar; + AOImage *ui_prosecution_bar; + + QLabel *ui_music_label; + QLabel *ui_sfx_label; + QLabel *ui_blip_label; - AOButton *ui_hold_it; - AOButton *ui_objection; - AOButton *ui_take_that; + AOButton *ui_hold_it; + AOButton *ui_objection; + AOButton *ui_take_that; - AOButton *ui_ooc_toggle; + AOButton *ui_ooc_toggle; - AOButton *ui_witness_testimony; - AOButton *ui_cross_examination; - AOButton *ui_guilty; - AOButton *ui_not_guilty; + AOButton *ui_witness_testimony; + AOButton *ui_cross_examination; + AOButton *ui_guilty; + AOButton *ui_not_guilty; - AOButton *ui_change_character; - AOButton *ui_reload_theme; - AOButton *ui_call_mod; - AOButton *ui_settings; - AOButton *ui_announce_casing; - AOButton *ui_switch_area_music; + AOButton *ui_change_character; + AOButton *ui_reload_theme; + AOButton *ui_call_mod; + AOButton *ui_settings; + AOButton *ui_announce_casing; + AOButton *ui_switch_area_music; - QCheckBox *ui_pre; - QCheckBox *ui_flip; - QCheckBox *ui_additive; - QCheckBox *ui_guard; - QCheckBox *ui_casing; + QCheckBox *ui_pre; + QCheckBox *ui_flip; + QCheckBox *ui_additive; + QCheckBox *ui_guard; + QCheckBox *ui_casing; - QCheckBox *ui_pre_non_interrupt; - QCheckBox *ui_showname_enable; + QCheckBox *ui_pre_non_interrupt; + QCheckBox *ui_showname_enable; - AOButton *ui_custom_objection; - AOButton *ui_realization; - AOButton *ui_screenshake; - AOButton *ui_mute; - - AOButton *ui_defense_plus; - AOButton *ui_defense_minus; - - AOButton *ui_prosecution_plus; - AOButton *ui_prosecution_minus; + AOButton *ui_custom_objection; + AOButton *ui_realization; + AOButton *ui_screenshake; + AOButton *ui_mute; + + AOButton *ui_defense_plus; + AOButton *ui_defense_minus; + + AOButton *ui_prosecution_plus; + AOButton *ui_prosecution_minus; - QComboBox *ui_text_color; + QComboBox *ui_text_color; - QSlider *ui_music_slider; - QSlider *ui_sfx_slider; - QSlider *ui_blip_slider; + QSlider *ui_music_slider; + QSlider *ui_sfx_slider; + QSlider *ui_blip_slider; - AOImage *ui_muted; + AOImage *ui_muted; - AOButton *ui_evidence_button; - AOImage *ui_evidence; - AOLineEdit *ui_evidence_name; - QWidget *ui_evidence_buttons; - QVector<AOEvidenceButton *> ui_evidence_list; - AOButton *ui_evidence_left; - AOButton *ui_evidence_right; - AOButton *ui_evidence_present; - AOImage *ui_evidence_overlay; - AOButton *ui_evidence_delete; - AOLineEdit *ui_evidence_image_name; - AOButton *ui_evidence_image_button; - AOButton *ui_evidence_x; - AOButton *ui_evidence_ok; - AOButton *ui_evidence_switch; - AOButton *ui_evidence_transfer; - AOButton *ui_evidence_save; - AOButton *ui_evidence_load; - AOTextEdit *ui_evidence_description; + AOButton *ui_evidence_button; + AOImage *ui_evidence; + AOLineEdit *ui_evidence_name; + QWidget *ui_evidence_buttons; + QVector<AOEvidenceButton *> ui_evidence_list; + AOButton *ui_evidence_left; + AOButton *ui_evidence_right; + AOButton *ui_evidence_present; + AOImage *ui_evidence_overlay; + AOButton *ui_evidence_delete; + AOLineEdit *ui_evidence_image_name; + AOButton *ui_evidence_image_button; + AOButton *ui_evidence_x; + AOButton *ui_evidence_ok; + AOButton *ui_evidence_switch; + AOButton *ui_evidence_transfer; + AOButton *ui_evidence_save; + AOButton *ui_evidence_load; + AOTextEdit *ui_evidence_description; - AOImage *ui_char_select_background; + AOImage *ui_char_select_background; - //abstract widget to hold char buttons - QWidget *ui_char_buttons; + // abstract widget to hold char buttons + QWidget *ui_char_buttons; - QVector<AOCharButton *> ui_char_button_list; - QVector<AOCharButton *> ui_char_button_list_filtered; - AOImage *ui_selector; + QVector<AOCharButton *> ui_char_button_list; + QVector<AOCharButton *> ui_char_button_list_filtered; + AOImage *ui_selector; - AOButton *ui_back_to_lobby; + AOButton *ui_back_to_lobby; - QLineEdit *ui_char_password; + QLineEdit *ui_char_password; - AOButton *ui_char_select_left; - AOButton *ui_char_select_right; + AOButton *ui_char_select_left; + AOButton *ui_char_select_right; - AOButton *ui_spectator; + AOButton *ui_spectator; - QLineEdit *ui_char_search; - QCheckBox *ui_char_passworded; - QCheckBox *ui_char_taken; + QLineEdit *ui_char_search; + QCheckBox *ui_char_passworded; + QCheckBox *ui_char_taken; - void construct_char_select(); - void set_char_select(); - void set_char_select_page(); - void char_clicked(int n_char); - void put_button_in_place(int starting, int chars_on_this_page); - void filter_character_list(); - - void initialize_emotes(); - void refresh_emotes(); - void set_emote_page(); - void set_emote_dropdown(); - - void initialize_evidence(); - void refresh_evidence(); - void set_evidence_page(); + void construct_char_select(); + void set_char_select(); + void set_char_select_page(); + void char_clicked(int n_char); + void put_button_in_place(int starting, int chars_on_this_page); + void filter_character_list(); + + void initialize_emotes(); + void refresh_emotes(); + void set_emote_page(); + void set_emote_dropdown(); + + void initialize_evidence(); + void refresh_evidence(); + void set_evidence_page(); public slots: - void objection_done(); - void preanim_done(); - void do_screenshake(); - void do_flash(); - void do_effect(QString fx_path, QString fx_sound, QString p_char, QString p_folder); - void play_char_sfx(QString sfx_name); + void objection_done(); + void preanim_done(); + void do_screenshake(); + void do_flash(); + void do_effect(QString fx_path, QString fx_sound, QString p_char, + QString p_folder); + void play_char_sfx(QString sfx_name); - void mod_called(QString p_ip); + void mod_called(QString p_ip); - void case_called(QString msg, bool def, bool pro, bool jud, bool jur, bool steno); + void case_called(QString msg, bool def, bool pro, bool jud, bool jur, + bool steno); private slots: - void start_chat_ticking(); - void play_sfx(); + void start_chat_ticking(); + void play_sfx(); - void chat_tick(); + void chat_tick(); - void on_mute_list_clicked(QModelIndex p_index); - void on_pair_list_clicked(QModelIndex p_index); + void on_mute_list_clicked(QModelIndex p_index); + void on_pair_list_clicked(QModelIndex p_index); - void on_chat_return_pressed(); + void on_chat_return_pressed(); - void on_ooc_return_pressed(); + void on_ooc_return_pressed(); - void on_music_search_edited(QString p_text); - void on_music_list_double_clicked(QTreeWidgetItem *p_item, int column); - void on_music_list_context_menu_requested(const QPoint &pos); - void music_fade_out(bool toggle); - void music_fade_in(bool toggle); - void music_synchronize(bool toggle); - void music_list_expand_all(); - void music_list_collapse_all(); - void on_area_list_double_clicked(QTreeWidgetItem *p_item, int column); + void on_music_search_edited(QString p_text); + void on_music_list_double_clicked(QTreeWidgetItem *p_item, int column); + void on_music_list_context_menu_requested(const QPoint &pos); + void music_fade_out(bool toggle); + void music_fade_in(bool toggle); + void music_synchronize(bool toggle); + void music_list_expand_all(); + void music_list_collapse_all(); + void on_area_list_double_clicked(QTreeWidgetItem *p_item, int column); - void select_emote(int p_id); + void select_emote(int p_id); - void on_emote_clicked(int p_id); + void on_emote_clicked(int p_id); - void on_emote_left_clicked(); - void on_emote_right_clicked(); + void on_emote_left_clicked(); + void on_emote_right_clicked(); - void on_emote_dropdown_changed(int p_index); - void on_pos_dropdown_changed(int p_index); + void on_emote_dropdown_changed(int p_index); + void on_pos_dropdown_changed(int p_index); - void on_iniswap_dropdown_changed(int p_index); - void set_iniswap_dropdown(); - void on_iniswap_context_menu_requested(const QPoint &pos); - void on_iniswap_edit_requested(); - void on_iniswap_remove_clicked(); + void on_iniswap_dropdown_changed(int p_index); + void set_iniswap_dropdown(); + void on_iniswap_context_menu_requested(const QPoint &pos); + void on_iniswap_edit_requested(); + void on_iniswap_remove_clicked(); - void on_sfx_dropdown_changed(int p_index); - void set_sfx_dropdown(); - void on_sfx_context_menu_requested(const QPoint &pos); - void on_sfx_edit_requested(); - void on_sfx_remove_clicked(); + void on_sfx_dropdown_changed(int p_index); + void set_sfx_dropdown(); + void on_sfx_context_menu_requested(const QPoint &pos); + void on_sfx_edit_requested(); + void on_sfx_remove_clicked(); - void set_effects_dropdown(); - void on_effects_context_menu_requested(const QPoint &pos); - void on_effects_edit_requested(); - void on_character_effects_edit_requested(); - void on_effects_dropdown_changed(int p_index); - bool effects_dropdown_find_and_set(QString effect); + void set_effects_dropdown(); + void on_effects_context_menu_requested(const QPoint &pos); + void on_effects_edit_requested(); + void on_character_effects_edit_requested(); + void on_effects_dropdown_changed(int p_index); + bool effects_dropdown_find_and_set(QString effect); - QString get_char_sfx(); - int get_char_sfx_delay(); + QString get_char_sfx(); + int get_char_sfx_delay(); - void on_evidence_name_edited(); - void on_evidence_image_name_edited(); - void on_evidence_image_button_clicked(); - void on_evidence_clicked(int p_id); - void on_evidence_double_clicked(int p_id); + void on_evidence_name_edited(); + void on_evidence_image_name_edited(); + void on_evidence_image_button_clicked(); + void on_evidence_clicked(int p_id); + void on_evidence_double_clicked(int p_id); - void on_evidence_hover(int p_id, bool p_state); + void on_evidence_hover(int p_id, bool p_state); - void on_evidence_left_clicked(); - void on_evidence_right_clicked(); - void on_evidence_present_clicked(); + void on_evidence_left_clicked(); + void on_evidence_right_clicked(); + void on_evidence_present_clicked(); - void on_hold_it_clicked(); - void on_objection_clicked(); - void on_take_that_clicked(); - void on_custom_objection_clicked(); + void on_hold_it_clicked(); + void on_objection_clicked(); + void on_take_that_clicked(); + void on_custom_objection_clicked(); - void on_realization_clicked(); - void on_screenshake_clicked(); + void on_realization_clicked(); + void on_screenshake_clicked(); - void on_mute_clicked(); - void on_pair_clicked(); - void on_pair_order_dropdown_changed(int p_index); + void on_mute_clicked(); + void on_pair_clicked(); + void on_pair_order_dropdown_changed(int p_index); - void on_defense_minus_clicked(); - void on_defense_plus_clicked(); - void on_prosecution_minus_clicked(); - void on_prosecution_plus_clicked(); + void on_defense_minus_clicked(); + void on_defense_plus_clicked(); + void on_prosecution_minus_clicked(); + void on_prosecution_plus_clicked(); - void on_text_color_changed(int p_color); - void set_text_color_dropdown(); + void on_text_color_changed(int p_color); + void set_text_color_dropdown(); - void on_music_slider_moved(int p_value); - void on_sfx_slider_moved(int p_value); - void on_blip_slider_moved(int p_value); + void on_music_slider_moved(int p_value); + void on_sfx_slider_moved(int p_value); + void on_blip_slider_moved(int p_value); - void on_log_limit_changed(int value); - void on_pair_offset_changed(int value); + void on_log_limit_changed(int value); + void on_pair_offset_changed(int value); - void on_ooc_toggle_clicked(); + void on_ooc_toggle_clicked(); - void on_witness_testimony_clicked(); - void on_cross_examination_clicked(); - void on_not_guilty_clicked(); - void on_guilty_clicked(); + void on_witness_testimony_clicked(); + void on_cross_examination_clicked(); + void on_not_guilty_clicked(); + void on_guilty_clicked(); - void on_change_character_clicked(); - void on_reload_theme_clicked(); - void on_call_mod_clicked(); - void on_settings_clicked(); - void on_announce_casing_clicked(); + void on_change_character_clicked(); + void on_reload_theme_clicked(); + void on_call_mod_clicked(); + void on_settings_clicked(); + void on_announce_casing_clicked(); - void on_pre_clicked(); - void on_flip_clicked(); - void on_additive_clicked(); - void on_guard_clicked(); + void on_pre_clicked(); + void on_flip_clicked(); + void on_additive_clicked(); + void on_guard_clicked(); - void on_showname_enable_clicked(); + void on_showname_enable_clicked(); - void on_evidence_name_double_clicked(); - void on_evidence_image_name_double_clicked(); - void on_evidence_button_clicked(); + void on_evidence_name_double_clicked(); + void on_evidence_image_name_double_clicked(); + void on_evidence_button_clicked(); - void on_evidence_delete_clicked(); - void on_evidence_x_clicked(); - void on_evidence_ok_clicked(); - void on_evidence_switch_clicked(); - void on_evidence_transfer_clicked(); + void on_evidence_delete_clicked(); + void on_evidence_x_clicked(); + void on_evidence_ok_clicked(); + void on_evidence_switch_clicked(); + void on_evidence_transfer_clicked(); - void on_evidence_edited(); + void on_evidence_edited(); - void evidence_close(); - void evidence_switch(bool global); - void on_evidence_save_clicked(); - void on_evidence_load_clicked(); - bool compare_evidence_changed(evi_type evi_a, evi_type evi_b); + void evidence_close(); + void evidence_switch(bool global); + void on_evidence_save_clicked(); + void on_evidence_load_clicked(); + bool compare_evidence_changed(evi_type evi_a, evi_type evi_b); - void on_back_to_lobby_clicked(); + void on_back_to_lobby_clicked(); - void on_char_select_left_clicked(); - void on_char_select_right_clicked(); - void on_char_search_changed(); - void on_char_taken_clicked(); - void on_char_passworded_clicked(); + void on_char_select_left_clicked(); + void on_char_select_right_clicked(); + void on_char_search_changed(); + void on_char_taken_clicked(); + void on_char_passworded_clicked(); - void on_spectator_clicked(); + void on_spectator_clicked(); - void on_switch_area_music_clicked(); + void on_switch_area_music_clicked(); - void on_casing_clicked(); + void on_casing_clicked(); - void ping_server(); + void ping_server(); - void load_bass_opus_plugin(); + void load_bass_opus_plugin(); }; #endif // COURTROOM_H diff --git a/include/datatypes.h b/include/datatypes.h index 715bb3e0..21ade040 100644 --- a/include/datatypes.h +++ b/include/datatypes.h @@ -4,107 +4,103 @@ #include <QString> struct server_type { - QString name; - QString desc; - QString ip; - int port; + QString name; + QString desc; + QString ip; + int port; }; struct emote_type { - QString comment; - QString preanim; - QString anim; - int mod; - QString sfx_name; - int sfx_delay; - int sfx_duration; + QString comment; + QString preanim; + QString anim; + int mod; + QString sfx_name; + int sfx_delay; + int sfx_duration; }; struct char_type { - QString name; - QString description; - QString evidence_string; - bool taken; + QString name; + QString description; + QString evidence_string; + bool taken; }; struct evi_type { - QString name; - QString description; - QString image; + QString name; + QString description; + QString image; }; struct chatmessage_type { - QString message; - QString character; - QString side; - QString sfx_name; - QString pre_emote; - QString emote; - int emote_modifier; - int objection_modifier; - int realization; - int text_color; - int evidence; - int cid; - int sfx_delay; - int flip; + QString message; + QString character; + QString side; + QString sfx_name; + QString pre_emote; + QString emote; + int emote_modifier; + int objection_modifier; + int realization; + int text_color; + int evidence; + int cid; + int sfx_delay; + int flip; }; struct area_type { - QString name; - QString background; - bool passworded; + QString name; + QString background; + bool passworded; }; struct pos_type { - int x; - int y; + int x; + int y; }; struct pos_size_type { - int x = 0; - int y = 0; - int width = 0; - int height = 0; + int x = 0; + int y = 0; + int width = 0; + int height = 0; }; enum CHAT_MESSAGE { - DESK_MOD = 0, - PRE_EMOTE, - CHAR_NAME, - EMOTE, - MESSAGE, - SIDE, - SFX_NAME, - EMOTE_MOD, - CHAR_ID, - SFX_DELAY, - OBJECTION_MOD, - EVIDENCE_ID, - FLIP, - REALIZATION, - TEXT_COLOR, - SHOWNAME, - OTHER_CHARID, - OTHER_NAME, - OTHER_EMOTE, - SELF_OFFSET, - OTHER_OFFSET, - OTHER_FLIP, - NONINTERRUPTING_PRE, - LOOPING_SFX, - SCREENSHAKE, - FRAME_SCREENSHAKE, - FRAME_REALIZATION, - FRAME_SFX, - ADDITIVE, - EFFECTS + DESK_MOD = 0, + PRE_EMOTE, + CHAR_NAME, + EMOTE, + MESSAGE, + SIDE, + SFX_NAME, + EMOTE_MOD, + CHAR_ID, + SFX_DELAY, + OBJECTION_MOD, + EVIDENCE_ID, + FLIP, + REALIZATION, + TEXT_COLOR, + SHOWNAME, + OTHER_CHARID, + OTHER_NAME, + OTHER_EMOTE, + SELF_OFFSET, + OTHER_OFFSET, + OTHER_FLIP, + NONINTERRUPTING_PRE, + LOOPING_SFX, + SCREENSHAKE, + FRAME_SCREENSHAKE, + FRAME_REALIZATION, + FRAME_SFX, + ADDITIVE, + EFFECTS }; -enum MUSIC_EFFECT { - FADE_IN = 1, - FADE_OUT = 2, - SYNC_POS = 4 -}; +enum MUSIC_EFFECT { FADE_IN = 1, FADE_OUT = 2, SYNC_POS = 4 }; #endif // DATATYPES_H diff --git a/include/discord-rpc.h b/include/discord-rpc.h index 24885430..455f62aa 100644 --- a/include/discord-rpc.h +++ b/include/discord-rpc.h @@ -24,37 +24,37 @@ extern "C" { #endif typedef struct DiscordRichPresence { - const char *state; /* max 128 bytes */ - const char *details; /* max 128 bytes */ - int64_t startTimestamp; - int64_t endTimestamp; - const char *largeImageKey; /* max 32 bytes */ - const char *largeImageText; /* max 128 bytes */ - const char *smallImageKey; /* max 32 bytes */ - const char *smallImageText; /* max 128 bytes */ - const char *partyId; /* max 128 bytes */ - int partySize; - int partyMax; - const char *matchSecret; /* max 128 bytes */ - const char *joinSecret; /* max 128 bytes */ - const char *spectateSecret; /* max 128 bytes */ - int8_t instance; + const char *state; /* max 128 bytes */ + const char *details; /* max 128 bytes */ + int64_t startTimestamp; + int64_t endTimestamp; + const char *largeImageKey; /* max 32 bytes */ + const char *largeImageText; /* max 128 bytes */ + const char *smallImageKey; /* max 32 bytes */ + const char *smallImageText; /* max 128 bytes */ + const char *partyId; /* max 128 bytes */ + int partySize; + int partyMax; + const char *matchSecret; /* max 128 bytes */ + const char *joinSecret; /* max 128 bytes */ + const char *spectateSecret; /* max 128 bytes */ + int8_t instance; } DiscordRichPresence; typedef struct DiscordJoinRequest { - const char *userId; - const char *username; - const char *discriminator; - const char *avatar; + const char *userId; + const char *username; + const char *discriminator; + const char *avatar; } DiscordJoinRequest; typedef struct DiscordEventHandlers { - void (*ready)(void); - void (*disconnected)(int errorCode, const char *message); - void (*errored)(int errorCode, const char *message); - void (*joinGame)(const char *joinSecret); - void (*spectateGame)(const char *spectateSecret); - void (*joinRequest)(const DiscordJoinRequest *request); + void (*ready)(void); + void (*disconnected)(int errorCode, const char *message); + void (*errored)(int errorCode, const char *message); + void (*joinGame)(const char *joinSecret); + void (*spectateGame)(const char *spectateSecret); + void (*joinRequest)(const DiscordJoinRequest *request); } DiscordEventHandlers; #define DISCORD_REPLY_NO 0 @@ -70,7 +70,8 @@ DISCORD_EXPORT void Discord_Shutdown(void); /* checks for incoming messages, dispatches callbacks */ DISCORD_EXPORT void Discord_RunCallbacks(void); -/* If you disable the lib starting its own io thread, you'll need to call this from your own */ +/* If you disable the lib starting its own io thread, you'll need to call this + * from your own */ #ifdef DISCORD_DISABLE_IO_THREAD DISCORD_EXPORT void Discord_UpdateConnection(void); #endif @@ -78,7 +79,8 @@ DISCORD_EXPORT void Discord_UpdateConnection(void); DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence *presence); DISCORD_EXPORT void Discord_ClearPresence(void); -DISCORD_EXPORT void Discord_Respond(const char *userid, /* DISCORD_REPLY_ */ int reply); +DISCORD_EXPORT void Discord_Respond(const char *userid, + /* DISCORD_REPLY_ */ int reply); #ifdef __cplusplus } /* extern "C" */ diff --git a/include/discord_register.h b/include/discord_register.h index 71e856a5..655a3dfb 100644 --- a/include/discord_register.h +++ b/include/discord_register.h @@ -18,8 +18,10 @@ extern "C" { #endif -DISCORD_EXPORT void Discord_Register(const char *applicationId, const char *command); -DISCORD_EXPORT void Discord_RegisterSteamGame(const char *applicationId, const char *steamId); +DISCORD_EXPORT void Discord_Register(const char *applicationId, + const char *command); +DISCORD_EXPORT void Discord_RegisterSteamGame(const char *applicationId, + const char *steamId); #ifdef __cplusplus } diff --git a/include/discord_rich_presence.h b/include/discord_rich_presence.h index 1949d248..71c85e25 100644 --- a/include/discord_rich_presence.h +++ b/include/discord_rich_presence.h @@ -16,23 +16,23 @@ namespace AttorneyOnline { - class Discord { - Q_DECLARE_TR_FUNCTIONS(Discord) - - private: - const char *APPLICATION_ID = "399779271737868288"; - std::string server_name, server_id; - int64_t timestamp; - - public: - Discord(); - ~Discord(); - - void state_lobby(); - void state_server(std::string name, std::string server_id); - void state_character(std::string name); - void state_spectate(); - }; +class Discord { + Q_DECLARE_TR_FUNCTIONS(Discord) + +private: + const char *APPLICATION_ID = "399779271737868288"; + std::string server_name, server_id; + int64_t timestamp; + +public: + Discord(); + ~Discord(); + + void state_lobby(); + void state_server(std::string name, std::string server_id); + void state_character(std::string name); + void state_spectate(); +}; } // namespace AttorneyOnline #endif // DISCORD_RICH_PRESENCE_H diff --git a/include/discord_rpc.h b/include/discord_rpc.h index 737f2f66..6bd44041 100644 --- a/include/discord_rpc.h +++ b/include/discord_rpc.h @@ -24,37 +24,37 @@ extern "C" { #endif typedef struct DiscordRichPresence { - const char *state; /* max 128 bytes */ - const char *details; /* max 128 bytes */ - int64_t startTimestamp; - int64_t endTimestamp; - const char *largeImageKey; /* max 32 bytes */ - const char *largeImageText; /* max 128 bytes */ - const char *smallImageKey; /* max 32 bytes */ - const char *smallImageText; /* max 128 bytes */ - const char *partyId; /* max 128 bytes */ - int partySize; - int partyMax; - const char *matchSecret; /* max 128 bytes */ - const char *joinSecret; /* max 128 bytes */ - const char *spectateSecret; /* max 128 bytes */ - int8_t instance; + const char *state; /* max 128 bytes */ + const char *details; /* max 128 bytes */ + int64_t startTimestamp; + int64_t endTimestamp; + const char *largeImageKey; /* max 32 bytes */ + const char *largeImageText; /* max 128 bytes */ + const char *smallImageKey; /* max 32 bytes */ + const char *smallImageText; /* max 128 bytes */ + const char *partyId; /* max 128 bytes */ + int partySize; + int partyMax; + const char *matchSecret; /* max 128 bytes */ + const char *joinSecret; /* max 128 bytes */ + const char *spectateSecret; /* max 128 bytes */ + int8_t instance; } DiscordRichPresence; typedef struct DiscordUser { - const char *userId; - const char *username; - const char *discriminator; - const char *avatar; + const char *userId; + const char *username; + const char *discriminator; + const char *avatar; } DiscordUser; typedef struct DiscordEventHandlers { - void (*ready)(const DiscordUser *request); - void (*disconnected)(int errorCode, const char *message); - void (*errored)(int errorCode, const char *message); - void (*joinGame)(const char *joinSecret); - void (*spectateGame)(const char *spectateSecret); - void (*joinRequest)(const DiscordUser *request); + void (*ready)(const DiscordUser *request); + void (*disconnected)(int errorCode, const char *message); + void (*errored)(int errorCode, const char *message); + void (*joinGame)(const char *joinSecret); + void (*spectateGame)(const char *spectateSecret); + void (*joinRequest)(const DiscordUser *request); } DiscordEventHandlers; #define DISCORD_REPLY_NO 0 @@ -70,7 +70,8 @@ DISCORD_EXPORT void Discord_Shutdown(void); /* checks for incoming messages, dispatches callbacks */ DISCORD_EXPORT void Discord_RunCallbacks(void); -/* If you disable the lib starting its own io thread, you'll need to call this from your own */ +/* If you disable the lib starting its own io thread, you'll need to call this + * from your own */ #ifdef DISCORD_DISABLE_IO_THREAD DISCORD_EXPORT void Discord_UpdateConnection(void); #endif @@ -78,7 +79,8 @@ DISCORD_EXPORT void Discord_UpdateConnection(void); DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence *presence); DISCORD_EXPORT void Discord_ClearPresence(void); -DISCORD_EXPORT void Discord_Respond(const char *userid, /* DISCORD_REPLY_ */ int reply); +DISCORD_EXPORT void Discord_Respond(const char *userid, + /* DISCORD_REPLY_ */ int reply); DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers *handlers); diff --git a/include/hex_functions.h b/include/hex_functions.h index 429bdb14..d178ba1b 100644 --- a/include/hex_functions.h +++ b/include/hex_functions.h @@ -10,7 +10,7 @@ #include <string> namespace omni { - std::string int_to_hex(unsigned int input); +std::string int_to_hex(unsigned int input); } -#endif //HEX_OPERATIONS_H +#endif // HEX_OPERATIONS_H diff --git a/include/lobby.h b/include/lobby.h index 7b978d32..42f52977 100644 --- a/include/lobby.h +++ b/include/lobby.h @@ -21,87 +21,87 @@ class AOApplication; class Lobby : public QMainWindow { - Q_OBJECT + Q_OBJECT public: - Lobby(AOApplication *p_ao_app); - - void set_widgets(); - void list_servers(); - void list_favorites(); - void append_chatmessage(QString f_name, QString f_message); - void append_error(QString f_message); - void set_player_count(int players_online, int max_players); - void set_stylesheet(QWidget *widget, QString target_tag); - void set_stylesheets(); - void set_fonts(); - void set_font(QWidget *widget, QString p_identifier); - void set_loading_text(QString p_text); - void show_loading_overlay() { ui_loading_background->show(); } - void hide_loading_overlay() { ui_loading_background->hide(); } - QString get_chatlog(); - int get_selected_server(); - void enable_connect_button(); - - void set_loading_value(int p_value); - - bool public_servers_selected = true; - - ~Lobby(); + Lobby(AOApplication *p_ao_app); + + void set_widgets(); + void list_servers(); + void list_favorites(); + void append_chatmessage(QString f_name, QString f_message); + void append_error(QString f_message); + void set_player_count(int players_online, int max_players); + void set_stylesheet(QWidget *widget, QString target_tag); + void set_stylesheets(); + void set_fonts(); + void set_font(QWidget *widget, QString p_identifier); + void set_loading_text(QString p_text); + void show_loading_overlay() { ui_loading_background->show(); } + void hide_loading_overlay() { ui_loading_background->hide(); } + QString get_chatlog(); + int get_selected_server(); + void enable_connect_button(); + + void set_loading_value(int p_value); + + bool public_servers_selected = true; + + ~Lobby(); private: - AOApplication *ao_app; + AOApplication *ao_app; - AOImage *ui_background; + AOImage *ui_background; - AOButton *ui_public_servers; - AOButton *ui_favorites; + AOButton *ui_public_servers; + AOButton *ui_favorites; - AOButton *ui_refresh; - AOButton *ui_add_to_fav; - AOButton *ui_connect; + AOButton *ui_refresh; + AOButton *ui_add_to_fav; + AOButton *ui_connect; - QLabel *ui_version; - AOButton *ui_about; + QLabel *ui_version; + AOButton *ui_about; - AOButton *ui_settings; + AOButton *ui_settings; - QTreeWidget *ui_server_list; - QLineEdit *ui_server_search; + QTreeWidget *ui_server_list; + QLineEdit *ui_server_search; - QLabel *ui_player_count; - AOTextArea *ui_description; + QLabel *ui_player_count; + AOTextArea *ui_description; - AOTextArea *ui_chatbox; + AOTextArea *ui_chatbox; - QLineEdit *ui_chatname; - QLineEdit *ui_chatmessage; + QLineEdit *ui_chatname; + QLineEdit *ui_chatmessage; - AOImage *ui_loading_background; - QTextEdit *ui_loading_text; - QProgressBar *ui_progress_bar; - AOButton *ui_cancel; + AOImage *ui_loading_background; + QTextEdit *ui_loading_text; + QProgressBar *ui_progress_bar; + AOButton *ui_cancel; - int last_index; + int last_index; - void set_size_and_pos(QWidget *p_widget, QString p_identifier); + void set_size_and_pos(QWidget *p_widget, QString p_identifier); private slots: - void on_public_servers_clicked(); - void on_favorites_clicked(); - - void on_refresh_pressed(); - void on_refresh_released(); - void on_add_to_fav_pressed(); - void on_add_to_fav_released(); - void on_connect_pressed(); - void on_connect_released(); - void on_about_clicked(); - void on_settings_clicked(); - void on_server_list_clicked(QTreeWidgetItem *p_item, int column); - void on_server_list_doubleclicked(QTreeWidgetItem *p_item, int column); - void on_server_search_edited(QString p_text); - void on_chatfield_return_pressed(); + void on_public_servers_clicked(); + void on_favorites_clicked(); + + void on_refresh_pressed(); + void on_refresh_released(); + void on_add_to_fav_pressed(); + void on_add_to_fav_released(); + void on_connect_pressed(); + void on_connect_released(); + void on_about_clicked(); + void on_settings_clicked(); + void on_server_list_clicked(QTreeWidgetItem *p_item, int column); + void on_server_list_doubleclicked(QTreeWidgetItem *p_item, int column); + void on_server_search_edited(QString p_text); + void on_chatfield_return_pressed(); }; #endif // LOBBY_H diff --git a/include/networkmanager.h b/include/networkmanager.h index 4d9d401d..ed57a956 100644 --- a/include/networkmanager.h +++ b/include/networkmanager.h @@ -1,8 +1,8 @@ #ifndef NETWORKMANAGER_H #define NETWORKMANAGER_H -// Qt for Android has stubbed QDnsLookup. This is not documented in any part of their wiki. -// This prevents SRV lookup/failover behavior from functioning. +// Qt for Android has stubbed QDnsLookup. This is not documented in any part of +// their wiki. This prevents SRV lookup/failover behavior from functioning. // https://bugreports.qt.io/browse/QTBUG-56143 #ifndef ANDROID #define MS_FAILOVER_SUPPORTED @@ -24,60 +24,60 @@ #include <cstring> class NetworkManager : public QObject { - Q_OBJECT + Q_OBJECT public: - NetworkManager(AOApplication *parent); - ~NetworkManager(); + NetworkManager(AOApplication *parent); + ~NetworkManager(); - AOApplication *ao_app; - QTcpSocket *ms_socket; - QTcpSocket *server_socket; - QDnsLookup *ms_dns; - QTimer *ms_reconnect_timer; + AOApplication *ao_app; + QTcpSocket *ms_socket; + QTcpSocket *server_socket; + QDnsLookup *ms_dns; + QTimer *ms_reconnect_timer; - const QString ms_srv_hostname = "_aoms._tcp.aceattorneyonline.com"; + const QString ms_srv_hostname = "_aoms._tcp.aceattorneyonline.com"; #ifdef LOCAL_MS - QString ms_nosrv_hostname = "localhost"; + QString ms_nosrv_hostname = "localhost"; #else - QString ms_nosrv_hostname = "master.aceattorneyonline.com"; + QString ms_nosrv_hostname = "master.aceattorneyonline.com"; #endif - const quint16 ms_port = 27016; - const int timeout_milliseconds = 2000; + const quint16 ms_port = 27016; + const int timeout_milliseconds = 2000; - // in seconds - const int ms_reconnect_delay = 7; + // in seconds + const int ms_reconnect_delay = 7; - bool ms_partial_packet = false; - QString ms_temp_packet = ""; + bool ms_partial_packet = false; + QString ms_temp_packet = ""; - bool partial_packet = false; - QString temp_packet = ""; + bool partial_packet = false; + QString temp_packet = ""; - unsigned int s_decryptor = 5; + unsigned int s_decryptor = 5; - void connect_to_master(); - void connect_to_master_nosrv(); - void connect_to_server(server_type p_server); + void connect_to_master(); + void connect_to_master_nosrv(); + void connect_to_server(server_type p_server); public slots: - void ship_ms_packet(QString p_packet); - void ship_server_packet(QString p_packet); + void ship_ms_packet(QString p_packet); + void ship_server_packet(QString p_packet); signals: - void ms_connect_finished(bool success, bool will_retry); + void ms_connect_finished(bool success, bool will_retry); private: - void perform_srv_lookup(); + void perform_srv_lookup(); private slots: - void on_srv_lookup(); - void handle_ms_packet(); - void handle_server_packet(); - void on_ms_nosrv_connect_success(); - void on_ms_socket_error(QAbstractSocket::SocketError error); - void retry_ms_connect(); + void on_srv_lookup(); + void handle_ms_packet(); + void handle_server_packet(); + void on_ms_nosrv_connect_success(); + void on_ms_socket_error(QAbstractSocket::SocketError error); + void retry_ms_connect(); }; #endif // NETWORKMANAGER_H diff --git a/include/scrolltext.h b/include/scrolltext.h index 1455762f..9ed5ff77 100644 --- a/include/scrolltext.h +++ b/include/scrolltext.h @@ -8,40 +8,40 @@ #include <QWidget> class ScrollText : public QWidget { - Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText) - Q_PROPERTY(QString separator READ separator WRITE setSeparator) + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(QString separator READ separator WRITE setSeparator) public: - explicit ScrollText(QWidget *parent = nullptr); + explicit ScrollText(QWidget *parent = nullptr); public slots: - QString text() const; - void setText(QString text); + QString text() const; + void setText(QString text); - QString separator() const; - void setSeparator(QString separator); + QString separator() const; + void setSeparator(QString separator); protected: - virtual void paintEvent(QPaintEvent *); - virtual void resizeEvent(QResizeEvent *); + virtual void paintEvent(QPaintEvent *); + virtual void resizeEvent(QResizeEvent *); private: - void updateText(); - QString _text; - QString _separator; - QStaticText staticText; - int singleTextWidth; - QSize wholeTextSize; - int leftMargin; - bool scrollEnabled; - int scrollPos; - QImage alphaChannel; - QImage buffer; - QTimer timer; + void updateText(); + QString _text; + QString _separator; + QStaticText staticText; + int singleTextWidth; + QSize wholeTextSize; + int leftMargin; + bool scrollEnabled; + int scrollPos; + QImage alphaChannel; + QImage buffer; + QTimer timer; private slots: - virtual void timer_timeout(); + virtual void timer_timeout(); }; #endif // SCROLLTEXT_H diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp index 4d2bb31d..e1e9e7fe 100644 --- a/src/aoapplication.cpp +++ b/src/aoapplication.cpp @@ -10,167 +10,170 @@ AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv) { - // Create the QSettings class that points to the config.ini. - configini = new QSettings(get_base_path() + "config.ini", QSettings::IniFormat); + // Create the QSettings class that points to the config.ini. + configini = + new QSettings(get_base_path() + "config.ini", QSettings::IniFormat); - net_manager = new NetworkManager(this); - discord = new AttorneyOnline::Discord(); - QObject::connect(net_manager, SIGNAL(ms_connect_finished(bool, bool)), - SLOT(ms_connect_finished(bool, bool))); + net_manager = new NetworkManager(this); + discord = new AttorneyOnline::Discord(); + QObject::connect(net_manager, SIGNAL(ms_connect_finished(bool, bool)), + SLOT(ms_connect_finished(bool, bool))); } AOApplication::~AOApplication() { - destruct_lobby(); - destruct_courtroom(); - delete discord; + destruct_lobby(); + destruct_courtroom(); + delete discord; } void AOApplication::construct_lobby() { - if (lobby_constructed) { - qDebug() << "W: lobby was attempted constructed when it already exists"; - return; - } + if (lobby_constructed) { + qDebug() << "W: lobby was attempted constructed when it already exists"; + return; + } - w_lobby = new Lobby(this); - lobby_constructed = true; + w_lobby = new Lobby(this); + lobby_constructed = true; - QRect geometry = QGuiApplication::primaryScreen()->geometry(); - int x = (geometry.width() - w_lobby->width()) / 2; - int y = (geometry.height() - w_lobby->height()) / 2; - w_lobby->move(x, y); + QRect geometry = QGuiApplication::primaryScreen()->geometry(); + int x = (geometry.width() - w_lobby->width()) / 2; + int y = (geometry.height() - w_lobby->height()) / 2; + w_lobby->move(x, y); - if (is_discord_enabled()) - discord->state_lobby(); + if (is_discord_enabled()) + discord->state_lobby(); - w_lobby->show(); + w_lobby->show(); } void AOApplication::destruct_lobby() { - if (!lobby_constructed) { - qDebug() << "W: lobby was attempted destructed when it did not exist"; - return; - } + if (!lobby_constructed) { + qDebug() << "W: lobby was attempted destructed when it did not exist"; + return; + } - delete w_lobby; - w_lobby = nullptr; - lobby_constructed = false; + delete w_lobby; + w_lobby = nullptr; + lobby_constructed = false; } void AOApplication::construct_courtroom() { - if (courtroom_constructed) { - qDebug() << "W: courtroom was attempted constructed when it already exists"; - return; - } + if (courtroom_constructed) { + qDebug() << "W: courtroom was attempted constructed when it already exists"; + return; + } - w_courtroom = new Courtroom(this); - courtroom_constructed = true; + w_courtroom = new Courtroom(this); + courtroom_constructed = true; - QRect geometry = QGuiApplication::primaryScreen()->geometry(); - int x = (geometry.width() - w_courtroom->width()) / 2; - int y = (geometry.height() - w_courtroom->height()) / 2; - w_courtroom->move(x, y); + QRect geometry = QGuiApplication::primaryScreen()->geometry(); + int x = (geometry.width() - w_courtroom->width()) / 2; + int y = (geometry.height() - w_courtroom->height()) / 2; + w_courtroom->move(x, y); } void AOApplication::destruct_courtroom() { - if (!courtroom_constructed) { - qDebug() << "W: courtroom was attempted destructed when it did not exist"; - return; - } + if (!courtroom_constructed) { + qDebug() << "W: courtroom was attempted destructed when it did not exist"; + return; + } - delete w_courtroom; - w_courtroom = nullptr; - courtroom_constructed = false; + delete w_courtroom; + w_courtroom = nullptr; + courtroom_constructed = false; } QString AOApplication::get_version_string() { - return QString::number(RELEASE) + "." + - QString::number(MAJOR_VERSION) + "." + - QString::number(MINOR_VERSION); + return QString::number(RELEASE) + "." + QString::number(MAJOR_VERSION) + "." + + QString::number(MINOR_VERSION); } -void AOApplication::reload_theme() -{ - current_theme = read_theme(); -} +void AOApplication::reload_theme() { current_theme = read_theme(); } void AOApplication::set_favorite_list() { - favorite_list = read_serverlist_txt(); + favorite_list = read_serverlist_txt(); } QString AOApplication::get_current_char() { - if (courtroom_constructed) - return w_courtroom->get_current_char(); - else - return ""; + if (courtroom_constructed) + return w_courtroom->get_current_char(); + else + return ""; } void AOApplication::add_favorite_server(int p_server) { - if (p_server < 0 || p_server >= server_list.size()) - return; + if (p_server < 0 || p_server >= server_list.size()) + return; - server_type fav_server = server_list.at(p_server); + server_type fav_server = server_list.at(p_server); - QString str_port = QString::number(fav_server.port); + QString str_port = QString::number(fav_server.port); - QString server_line = fav_server.ip + ":" + str_port + ":" + fav_server.name; + QString server_line = fav_server.ip + ":" + str_port + ":" + fav_server.name; - write_to_serverlist_txt(server_line); + write_to_serverlist_txt(server_line); } void AOApplication::server_disconnected() { - if (courtroom_constructed) { - call_notice(tr("Disconnected from server.")); - construct_lobby(); - destruct_courtroom(); - } + if (courtroom_constructed) { + call_notice(tr("Disconnected from server.")); + construct_lobby(); + destruct_courtroom(); + } } void AOApplication::loading_cancelled() { - destruct_courtroom(); + destruct_courtroom(); - w_lobby->hide_loading_overlay(); + w_lobby->hide_loading_overlay(); } void AOApplication::ms_connect_finished(bool connected, bool will_retry) { - if (connected) { - AOPacket *f_packet = new AOPacket("ALL#%"); - send_ms_packet(f_packet); + if (connected) { + AOPacket *f_packet = new AOPacket("ALL#%"); + send_ms_packet(f_packet); + } + else { + if (will_retry) { + if (lobby_constructed) + w_lobby->append_error( + tr("Error connecting to master server. Will try again in %1 " + "seconds.") + .arg(QString::number(net_manager->ms_reconnect_delay))); } else { - if (will_retry) { - if (lobby_constructed) - w_lobby->append_error(tr("Error connecting to master server. Will try again in %1 seconds.").arg(QString::number(net_manager->ms_reconnect_delay))); - } - else { - call_error(tr("There was an error connecting to the master server.\n" - "We deploy multiple master servers to mitigate any possible downtime, " - "but the client appears to have exhausted all possible methods of finding " - "and connecting to one.\n" - "Please check your Internet connection and firewall, and please try again.")); - } + call_error(tr("There was an error connecting to the master server.\n" + "We deploy multiple master servers to mitigate any " + "possible downtime, " + "but the client appears to have exhausted all possible " + "methods of finding " + "and connecting to one.\n" + "Please check your Internet connection and firewall, and " + "please try again.")); } + } } void AOApplication::call_settings_menu() { - AOOptionsDialog settings(nullptr, this); - settings.exec(); + AOOptionsDialog settings(nullptr, this); + settings.exec(); } void AOApplication::call_announce_menu(Courtroom *court) { - AOCaseAnnouncerDialog announcer(nullptr, this, court); - announcer.exec(); + AOCaseAnnouncerDialog announcer(nullptr, this, court); + announcer.exec(); } diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 957fd559..6affc284 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -1,117 +1,111 @@ #include "aoblipplayer.h" -#if defined(BASSAUDIO) //Using bass.dll for the blips +#if defined(BASSAUDIO) // Using bass.dll for the blips AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) { - m_parent = parent; - ao_app = p_ao_app; + m_parent = parent; + ao_app = p_ao_app; } void AOBlipPlayer::set_blips(QString p_sfx) { - QString f_path = ao_app->get_sfx_suffix(ao_app->get_sounds_path(p_sfx)); + QString f_path = ao_app->get_sfx_suffix(ao_app->get_sounds_path(p_sfx)); - for (int n_stream = 0; n_stream < 5; ++n_stream) { - BASS_StreamFree(m_stream_list[n_stream]); + for (int n_stream = 0; n_stream < 5; ++n_stream) { + BASS_StreamFree(m_stream_list[n_stream]); - if (f_path.endsWith(".opus")) - m_stream_list[n_stream] = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE); - else - m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE); - } + if (f_path.endsWith(".opus")) + m_stream_list[n_stream] = BASS_OPUS_StreamCreateFile( + FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE); + else + m_stream_list[n_stream] = BASS_StreamCreateFile( + FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE); + } - set_volume_internal(m_volume); + set_volume_internal(m_volume); } void AOBlipPlayer::blip_tick() { - if (delay.isValid() && delay.elapsed() < max_blip_ms) - return; + if (delay.isValid() && delay.elapsed() < max_blip_ms) + return; - delay.start(); - int f_cycle = m_cycle++; + delay.start(); + int f_cycle = m_cycle++; - if (m_cycle == 5) - m_cycle = 0; + if (m_cycle == 5) + m_cycle = 0; - HSTREAM f_stream = m_stream_list[f_cycle]; - if (ao_app->get_audio_output_device() != "default") - BASS_ChannelSetDevice(f_stream, BASS_GetDevice()); - BASS_ChannelPlay(f_stream, false); + HSTREAM f_stream = m_stream_list[f_cycle]; + if (ao_app->get_audio_output_device() != "default") + BASS_ChannelSetDevice(f_stream, BASS_GetDevice()); + BASS_ChannelPlay(f_stream, false); } void AOBlipPlayer::set_volume(qreal p_value) { - m_volume = p_value / 100; - set_volume_internal(m_volume); + m_volume = p_value / 100; + set_volume_internal(m_volume); } void AOBlipPlayer::set_volume_internal(qreal p_value) { - float volume = static_cast<float>(p_value); + float volume = static_cast<float>(p_value); - for (int n_stream = 0; n_stream < 5; ++n_stream) { - BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); - } + for (int n_stream = 0; n_stream < 5; ++n_stream) { + BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); + } } -#elif defined(QTAUDIO) //Using Qt's QSoundEffect class +#elif defined(QTAUDIO) // Using Qt's QSoundEffect class AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) { - m_parent = parent; - ao_app = p_ao_app; + m_parent = parent; + ao_app = p_ao_app; } void AOBlipPlayer::set_blips(QString p_sfx) { - QString f_path = ao_app->get_sounds_path(p_sfx); + QString f_path = ao_app->get_sounds_path(p_sfx); - for (int n_stream = 0; n_stream < 5; ++n_stream) { - m_blips.setSource(QUrl::fromLocalFile(f_path)); - } + for (int n_stream = 0; n_stream < 5; ++n_stream) { + m_blips.setSource(QUrl::fromLocalFile(f_path)); + } - set_volume_internal(m_volume); + set_volume_internal(m_volume); } void AOBlipPlayer::blip_tick() { - int f_cycle = m_cycle++; + int f_cycle = m_cycle++; - if (m_cycle == 5) - m_cycle = 0; + if (m_cycle == 5) + m_cycle = 0; - m_blips.play(); + m_blips.play(); } void AOBlipPlayer::set_volume(qreal p_value) { - m_volume = p_value / 100; - set_volume_internal(m_volume); + m_volume = p_value / 100; + set_volume_internal(m_volume); } void AOBlipPlayer::set_volume_internal(qreal p_value) { - m_blips.setVolume(m_volume); + m_blips.setVolume(m_volume); } -#else //No audio +#else // No audio AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) { - m_parent = parent; - ao_app = p_ao_app; + m_parent = parent; + ao_app = p_ao_app; } -void AOBlipPlayer::set_blips(QString p_sfx) -{ -} +void AOBlipPlayer::set_blips(QString p_sfx) {} -void AOBlipPlayer::blip_tick() -{ -} +void AOBlipPlayer::blip_tick() {} -void AOBlipPlayer::set_volume(qreal p_value) -{ -} +void AOBlipPlayer::set_volume(qreal p_value) {} -void AOBlipPlayer::set_volume_internal(qreal p_value) -{ -} +void AOBlipPlayer::set_volume_internal(qreal p_value) {} #endif diff --git a/src/aobutton.cpp b/src/aobutton.cpp index 05dedc16..dc2d8817 100644 --- a/src/aobutton.cpp +++ b/src/aobutton.cpp @@ -3,30 +3,36 @@ #include "debug_functions.h" #include "file_functions.h" -AOButton::AOButton(QWidget *parent, AOApplication *p_ao_app) : QPushButton(parent) +AOButton::AOButton(QWidget *parent, AOApplication *p_ao_app) + : QPushButton(parent) { - ao_app = p_ao_app; + ao_app = p_ao_app; } -AOButton::~AOButton() -{ -} +AOButton::~AOButton() {} void AOButton::set_image(QString p_image) { - QString image_path = ao_app->get_static_image_suffix(ao_app->get_theme_path(p_image)); - QString default_image_path = ao_app->get_static_image_suffix(ao_app->get_default_theme_path(p_image)); + QString image_path = + ao_app->get_static_image_suffix(ao_app->get_theme_path(p_image)); + QString default_image_path = + ao_app->get_static_image_suffix(ao_app->get_default_theme_path(p_image)); - if (file_exists(image_path)) { - this->setText(""); - this->setStyleSheet("QPushButton { border-image: url(\"" + image_path + "\") 0 0 0 0 stretch stretch; }" - "QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }"); - } - else if (file_exists(default_image_path)) { - this->setText(""); - this->setStyleSheet("QPushButton { border-image: url(\"" + default_image_path + "\"); }" - "QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }"); - } - else - return; + if (file_exists(image_path)) { + this->setText(""); + this->setStyleSheet("QPushButton { border-image: url(\"" + image_path + + "\") 0 0 0 0 stretch stretch; }" + "QToolTip { background-image: url(); color: #000000; " + "background-color: #ffffff; border: 0px; }"); + } + else if (file_exists(default_image_path)) { + this->setText(""); + this->setStyleSheet("QPushButton { border-image: url(\"" + + default_image_path + + "\"); }" + "QToolTip { background-image: url(); color: #000000; " + "background-color: #ffffff; border: 0px; }"); + } + else + return; } diff --git a/src/aocaseannouncerdialog.cpp b/src/aocaseannouncerdialog.cpp index 3063aa8a..d91433a6 100644 --- a/src/aocaseannouncerdialog.cpp +++ b/src/aocaseannouncerdialog.cpp @@ -1,82 +1,85 @@ #include "aocaseannouncerdialog.h" -AOCaseAnnouncerDialog::AOCaseAnnouncerDialog(QWidget *parent, AOApplication *p_ao_app, Courtroom *p_court) +AOCaseAnnouncerDialog::AOCaseAnnouncerDialog(QWidget *parent, + AOApplication *p_ao_app, + Courtroom *p_court) : QDialog(parent) { - ao_app = p_ao_app; - court = p_court; - - setWindowTitle(tr("Case Announcer")); - resize(405, 235); - - ui_announcer_buttons = new QDialogButtonBox(this); - - QSizePolicy sizepolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - sizepolicy.setHorizontalStretch(0); - sizepolicy.setVerticalStretch(0); - sizepolicy.setHeightForWidth(ui_announcer_buttons->sizePolicy().hasHeightForWidth()); - ui_announcer_buttons->setSizePolicy(sizepolicy); - ui_announcer_buttons->setOrientation(Qt::Horizontal); - ui_announcer_buttons->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - - QObject::connect(ui_announcer_buttons, SIGNAL(accepted()), this, SLOT(ok_pressed())); - QObject::connect(ui_announcer_buttons, SIGNAL(rejected()), this, SLOT(cancel_pressed())); - - setUpdatesEnabled(false); - - ui_vbox_layout = new QVBoxLayout(this); - - ui_form_layout = new QFormLayout(this); - ui_form_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter); - ui_form_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop); - ui_form_layout->setContentsMargins(6, 6, 6, 6); - - ui_vbox_layout->addItem(ui_form_layout); - ui_vbox_layout->addWidget(ui_announcer_buttons); - - ui_case_title_label = new QLabel(this); - ui_case_title_label->setText(tr("Case title:")); - - ui_form_layout->setWidget(0, QFormLayout::LabelRole, ui_case_title_label); - - ui_case_title_textbox = new QLineEdit(this); - ui_case_title_textbox->setMaxLength(50); - - ui_form_layout->setWidget(0, QFormLayout::FieldRole, ui_case_title_textbox); - - ui_defense_needed = new QCheckBox(this); - ui_defense_needed->setText(tr("Defense needed")); - ui_prosecutor_needed = new QCheckBox(this); - ui_prosecutor_needed->setText(tr("Prosecution needed")); - ui_judge_needed = new QCheckBox(this); - ui_judge_needed->setText(tr("Judge needed")); - ui_juror_needed = new QCheckBox(this); - ui_juror_needed->setText(tr("Jurors needed")); - ui_steno_needed = new QCheckBox(this); - ui_steno_needed->setText(tr("Stenographer needed")); - - ui_form_layout->setWidget(1, QFormLayout::FieldRole, ui_defense_needed); - ui_form_layout->setWidget(2, QFormLayout::FieldRole, ui_prosecutor_needed); - ui_form_layout->setWidget(3, QFormLayout::FieldRole, ui_judge_needed); - ui_form_layout->setWidget(4, QFormLayout::FieldRole, ui_juror_needed); - ui_form_layout->setWidget(5, QFormLayout::FieldRole, ui_steno_needed); - - setUpdatesEnabled(true); + ao_app = p_ao_app; + court = p_court; + + setWindowTitle(tr("Case Announcer")); + resize(405, 235); + + ui_announcer_buttons = new QDialogButtonBox(this); + + QSizePolicy sizepolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + sizepolicy.setHorizontalStretch(0); + sizepolicy.setVerticalStretch(0); + sizepolicy.setHeightForWidth( + ui_announcer_buttons->sizePolicy().hasHeightForWidth()); + ui_announcer_buttons->setSizePolicy(sizepolicy); + ui_announcer_buttons->setOrientation(Qt::Horizontal); + ui_announcer_buttons->setStandardButtons(QDialogButtonBox::Ok | + QDialogButtonBox::Cancel); + + QObject::connect(ui_announcer_buttons, SIGNAL(accepted()), this, + SLOT(ok_pressed())); + QObject::connect(ui_announcer_buttons, SIGNAL(rejected()), this, + SLOT(cancel_pressed())); + + setUpdatesEnabled(false); + + ui_vbox_layout = new QVBoxLayout(this); + + ui_form_layout = new QFormLayout(this); + ui_form_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft | + Qt::AlignVCenter); + ui_form_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft | + Qt::AlignTop); + ui_form_layout->setContentsMargins(6, 6, 6, 6); + + ui_vbox_layout->addItem(ui_form_layout); + ui_vbox_layout->addWidget(ui_announcer_buttons); + + ui_case_title_label = new QLabel(this); + ui_case_title_label->setText(tr("Case title:")); + + ui_form_layout->setWidget(0, QFormLayout::LabelRole, ui_case_title_label); + + ui_case_title_textbox = new QLineEdit(this); + ui_case_title_textbox->setMaxLength(50); + + ui_form_layout->setWidget(0, QFormLayout::FieldRole, ui_case_title_textbox); + + ui_defense_needed = new QCheckBox(this); + ui_defense_needed->setText(tr("Defense needed")); + ui_prosecutor_needed = new QCheckBox(this); + ui_prosecutor_needed->setText(tr("Prosecution needed")); + ui_judge_needed = new QCheckBox(this); + ui_judge_needed->setText(tr("Judge needed")); + ui_juror_needed = new QCheckBox(this); + ui_juror_needed->setText(tr("Jurors needed")); + ui_steno_needed = new QCheckBox(this); + ui_steno_needed->setText(tr("Stenographer needed")); + + ui_form_layout->setWidget(1, QFormLayout::FieldRole, ui_defense_needed); + ui_form_layout->setWidget(2, QFormLayout::FieldRole, ui_prosecutor_needed); + ui_form_layout->setWidget(3, QFormLayout::FieldRole, ui_judge_needed); + ui_form_layout->setWidget(4, QFormLayout::FieldRole, ui_juror_needed); + ui_form_layout->setWidget(5, QFormLayout::FieldRole, ui_steno_needed); + + setUpdatesEnabled(true); } void AOCaseAnnouncerDialog::ok_pressed() { - court->announce_case(ui_case_title_textbox->text(), - ui_defense_needed->isChecked(), - ui_prosecutor_needed->isChecked(), - ui_judge_needed->isChecked(), - ui_juror_needed->isChecked(), - ui_steno_needed->isChecked()); - - done(0); -} + court->announce_case( + ui_case_title_textbox->text(), ui_defense_needed->isChecked(), + ui_prosecutor_needed->isChecked(), ui_judge_needed->isChecked(), + ui_juror_needed->isChecked(), ui_steno_needed->isChecked()); -void AOCaseAnnouncerDialog::cancel_pressed() -{ - done(0); + done(0); } + +void AOCaseAnnouncerDialog::cancel_pressed() { done(0); } diff --git a/src/aocharbutton.cpp b/src/aocharbutton.cpp index d8c337d9..844c9599 100644 --- a/src/aocharbutton.cpp +++ b/src/aocharbutton.cpp @@ -2,94 +2,94 @@ #include "file_functions.h" -AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos, bool is_taken) : QPushButton(parent) +AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, + int y_pos, bool is_taken) + : QPushButton(parent) { - m_parent = parent; + m_parent = parent; - ao_app = p_ao_app; + ao_app = p_ao_app; - taken = is_taken; + taken = is_taken; - this->resize(60, 60); - this->move(x_pos, y_pos); + this->resize(60, 60); + this->move(x_pos, y_pos); - ui_taken = new AOImage(this, ao_app); - ui_taken->resize(60, 60); - ui_taken->set_image("char_taken"); - ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_taken->hide(); + ui_taken = new AOImage(this, ao_app); + ui_taken->resize(60, 60); + ui_taken->set_image("char_taken"); + ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_taken->hide(); + + ui_passworded = new AOImage(this, ao_app); + ui_passworded->resize(60, 60); + ui_passworded->set_image("char_passworded"); + ui_passworded->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_passworded->hide(); - ui_passworded = new AOImage(this, ao_app); - ui_passworded->resize(60, 60); - ui_passworded->set_image("char_passworded"); - ui_passworded->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_passworded->hide(); - - ui_selector = new AOImage(parent, ao_app); - ui_selector->resize(62, 62); - ui_selector->move(x_pos - 1, y_pos - 1); - ui_selector->set_image("char_selector"); - ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_selector->hide(); + ui_selector = new AOImage(parent, ao_app); + ui_selector->resize(62, 62); + ui_selector->move(x_pos - 1, y_pos - 1); + ui_selector->set_image("char_selector"); + ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_selector->hide(); } void AOCharButton::reset() { - ui_taken->hide(); - ui_passworded->hide(); - ui_selector->hide(); + ui_taken->hide(); + ui_passworded->hide(); + ui_selector->hide(); } -void AOCharButton::set_taken(bool is_taken) -{ - taken = is_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(); - } + if (taken) { + ui_taken->move(0, 0); + ui_taken->show(); + } + else { + ui_taken->hide(); + } } -void AOCharButton::set_passworded() -{ - ui_passworded->show(); -} +void AOCharButton::set_passworded() { ui_passworded->show(); } void AOCharButton::set_image(QString p_character) { - QString image_path = ao_app->get_static_image_suffix(ao_app->get_character_path(p_character, "char_icon")); - - this->setText(""); - - if (file_exists(image_path)) { - this->setStyleSheet("QPushButton { border-image: url(\"" + image_path + "\") 0 0 0 0 stretch stretch; }" - "QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }"); - } - else { - this->setStyleSheet("QPushButton { border-image: url(); }" - "QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }"); - this->setText(p_character); - } + QString image_path = ao_app->get_static_image_suffix( + ao_app->get_character_path(p_character, "char_icon")); + + this->setText(""); + + if (file_exists(image_path)) { + this->setStyleSheet("QPushButton { border-image: url(\"" + image_path + + "\") 0 0 0 0 stretch stretch; }" + "QToolTip { background-image: url(); color: #000000; " + "background-color: #ffffff; border: 0px; }"); + } + else { + this->setStyleSheet("QPushButton { border-image: url(); }" + "QToolTip { background-image: url(); color: #000000; " + "background-color: #ffffff; border: 0px; }"); + this->setText(p_character); + } } void AOCharButton::enterEvent(QEvent *e) { - ui_selector->move(this->x() - 1, this->y() - 1); - ui_selector->raise(); - ui_selector->show(); + ui_selector->move(this->x() - 1, this->y() - 1); + ui_selector->raise(); + ui_selector->show(); - setFlat(false); - QPushButton::enterEvent(e); + setFlat(false); + QPushButton::enterEvent(e); } void AOCharButton::leaveEvent(QEvent *e) { - ui_selector->hide(); - QPushButton::leaveEvent(e); + ui_selector->hide(); + QPushButton::leaveEvent(e); } diff --git a/src/aocharmovie.cpp b/src/aocharmovie.cpp index 29632757..252aab5d 100644 --- a/src/aocharmovie.cpp +++ b/src/aocharmovie.cpp @@ -4,292 +4,320 @@ #include "file_functions.h" #include "misc_functions.h" -AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) +AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) + : QLabel(p_parent) { - ao_app = p_ao_app; - preanim_timer = new QTimer(this); - preanim_timer->setSingleShot(true); - - ticker = new QTimer(this); - ticker->setTimerType(Qt::PreciseTimer); - ticker->setSingleShot(false); - connect(ticker, SIGNAL(timeout()), this, SLOT(movie_ticker())); - - // connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int))); - connect(preanim_timer, SIGNAL(timeout()), this, SLOT(preanim_done())); + ao_app = p_ao_app; + preanim_timer = new QTimer(this); + preanim_timer->setSingleShot(true); + + ticker = new QTimer(this); + ticker->setTimerType(Qt::PreciseTimer); + ticker->setSingleShot(false); + connect(ticker, SIGNAL(timeout()), this, SLOT(movie_ticker())); + + // connect(m_movie, SIGNAL(frameChanged(int)), this, + // SLOT(frame_change(int))); + connect(preanim_timer, SIGNAL(timeout()), this, SLOT(preanim_done())); } -void AOCharMovie::load_image(QString p_char, QString p_emote, QString emote_prefix) +void AOCharMovie::load_image(QString p_char, QString p_emote, + QString emote_prefix) { #ifdef DEBUG_CHARMOVIE - actual_time.restart(); + actual_time.restart(); #endif - QString emote_path; - QList<QString> pathlist; - pathlist = { - ao_app->get_image_suffix(ao_app->get_character_path(p_char, emote_prefix + p_emote)), //Default path - ao_app->get_image_suffix(ao_app->get_character_path(p_char, emote_prefix + "/" + p_emote)), //Path check if it's categorized into a folder - ao_app->get_character_path(p_char, p_emote + ".png"), //Non-animated path if emote_prefix fails - ao_app->get_image_suffix(ao_app->get_theme_path("placeholder")), //Theme placeholder path - ao_app->get_image_suffix(ao_app->get_default_theme_path("placeholder")), //Default theme placeholder path - }; - - for (QString path : pathlist) { - if (file_exists(path)) { - emote_path = path; - break; - } + QString emote_path; + QList<QString> pathlist; + pathlist = { + ao_app->get_image_suffix(ao_app->get_character_path( + p_char, emote_prefix + p_emote)), // Default path + ao_app->get_image_suffix(ao_app->get_character_path( + p_char, emote_prefix + "/" + + p_emote)), // Path check if it's categorized into a folder + ao_app->get_character_path( + p_char, p_emote + ".png"), // Non-animated path if emote_prefix fails + ao_app->get_image_suffix( + ao_app->get_theme_path("placeholder")), // Theme placeholder path + ao_app->get_image_suffix(ao_app->get_default_theme_path( + "placeholder")), // Default theme placeholder path + }; + + for (QString path : pathlist) { + if (file_exists(path)) { + emote_path = path; + break; } - - this->clear(); - ticker->stop(); - preanim_timer->stop(); - movie_frames.clear(); - movie_delays.clear(); - movie_effects.clear(); - - if (!file_exists(emote_path)) - return; - - m_reader->setFileName(emote_path); - QPixmap f_pixmap = this->get_pixmap(m_reader->read()); - int f_delay = m_reader->nextImageDelay(); - - frame = 0; - max_frames = m_reader->imageCount(); - - this->set_frame(f_pixmap); - this->show(); - if (max_frames > 1) { - movie_frames.append(f_pixmap); - movie_delays.append(f_delay); - } - - m_char = p_char; - m_emote = emote_prefix + p_emote; - - if (network_strings.size() > 0) //our FX overwritten by networked ones - this->load_network_effects(); - else //Use default ini FX - this->load_effects(); + } + + this->clear(); + ticker->stop(); + preanim_timer->stop(); + movie_frames.clear(); + movie_delays.clear(); + movie_effects.clear(); + + if (!file_exists(emote_path)) + return; + + m_reader->setFileName(emote_path); + QPixmap f_pixmap = this->get_pixmap(m_reader->read()); + int f_delay = m_reader->nextImageDelay(); + + frame = 0; + max_frames = m_reader->imageCount(); + + this->set_frame(f_pixmap); + this->show(); + if (max_frames > 1) { + movie_frames.append(f_pixmap); + movie_delays.append(f_delay); + } + + m_char = p_char; + m_emote = emote_prefix + p_emote; + + if (network_strings.size() > 0) // our FX overwritten by networked ones + this->load_network_effects(); + else // Use default ini FX + this->load_effects(); #ifdef DEBUG_CHARMOVIE - qDebug() << max_frames << "Setting image to " << emote_path << "Time taken to process image:" << actual_time.elapsed(); + qDebug() << max_frames << "Setting image to " << emote_path + << "Time taken to process image:" << actual_time.elapsed(); - actual_time.restart(); + actual_time.restart(); #endif } void AOCharMovie::load_effects() { - movie_effects.clear(); - movie_effects.resize(max_frames); - for (int e_frame = 0; e_frame < max_frames; ++e_frame) { - QString effect = ao_app->get_screenshake_frame(m_char, m_emote, e_frame); - if (effect != "") { - movie_effects[e_frame].append("shake"); - } + movie_effects.clear(); + movie_effects.resize(max_frames); + for (int e_frame = 0; e_frame < max_frames; ++e_frame) { + QString effect = ao_app->get_screenshake_frame(m_char, m_emote, e_frame); + if (effect != "") { + movie_effects[e_frame].append("shake"); + } - effect = ao_app->get_flash_frame(m_char, m_emote, e_frame); - if (effect != "") { - movie_effects[e_frame].append("flash"); - } + effect = ao_app->get_flash_frame(m_char, m_emote, e_frame); + if (effect != "") { + movie_effects[e_frame].append("flash"); + } - effect = ao_app->get_sfx_frame(m_char, m_emote, e_frame); - if (effect != "") { - movie_effects[e_frame].append("sfx^" + effect); - } + effect = ao_app->get_sfx_frame(m_char, m_emote, e_frame); + if (effect != "") { + movie_effects[e_frame].append("sfx^" + effect); } + } } void AOCharMovie::load_network_effects() { - movie_effects.clear(); - movie_effects.resize(max_frames); - //Order is important!!! - QStringList effects_list = {"shake", "flash", "sfx^"}; - - //Determines which list is smaller - effects_list or network_strings - and uses it as basis for the loop. - //This way, incomplete network_strings would still be parsed, and excess/unaccounted for networked information is omitted. - int effects_size = qMin(effects_list.size(), network_strings.size()); - - for (int i = 0; i < effects_size; ++i) { - QString netstring = network_strings.at(i); - QStringList emote_splits = netstring.split("^"); - foreach (QString emote, emote_splits) { - QStringList parsed = emote.split("|"); - if (parsed.size() <= 0 || parsed.at(0) != m_emote) - continue; - foreach (QString frame_data, parsed) { - QStringList frame_split = frame_data.split("="); - if (frame_split.size() <= 1) //We might still be hanging at the emote itself (entry 0). - continue; - int f_frame = frame_split.at(0).toInt(); - if (f_frame >= max_frames) { - qDebug() << "Warning: out of bounds" << effects_list[i] << "frame" << f_frame << "out of" << max_frames << "for" << m_char << m_emote; - continue; - } - QString f_data = frame_split.at(1); - if (f_data != "") { - QString effect = effects_list[i]; - if (effect == "sfx^") //Currently the only frame result that feeds us data, let's yank it in. - effect += f_data; - qDebug() << effect << f_data << "frame" << f_frame << "for" << m_char << m_emote; - movie_effects[f_frame].append(effect); - } - } + movie_effects.clear(); + movie_effects.resize(max_frames); + // Order is important!!! + QStringList effects_list = {"shake", "flash", "sfx^"}; + + // Determines which list is smaller - effects_list or network_strings - and + // uses it as basis for the loop. This way, incomplete network_strings would + // still be parsed, and excess/unaccounted for networked information is + // omitted. + int effects_size = qMin(effects_list.size(), network_strings.size()); + + for (int i = 0; i < effects_size; ++i) { + QString netstring = network_strings.at(i); + QStringList emote_splits = netstring.split("^"); + foreach (QString emote, emote_splits) { + QStringList parsed = emote.split("|"); + if (parsed.size() <= 0 || parsed.at(0) != m_emote) + continue; + foreach (QString frame_data, parsed) { + QStringList frame_split = frame_data.split("="); + if (frame_split.size() <= + 1) // We might still be hanging at the emote itself (entry 0). + continue; + int f_frame = frame_split.at(0).toInt(); + if (f_frame >= max_frames) { + qDebug() << "Warning: out of bounds" << effects_list[i] << "frame" + << f_frame << "out of" << max_frames << "for" << m_char + << m_emote; + continue; + } + QString f_data = frame_split.at(1); + if (f_data != "") { + QString effect = effects_list[i]; + if (effect == "sfx^") // Currently the only frame result that feeds us + // data, let's yank it in. + effect += f_data; + qDebug() << effect << f_data << "frame" << f_frame << "for" << m_char + << m_emote; + movie_effects[f_frame].append(effect); } + } } + } } void AOCharMovie::play() { - play_frame_effect(frame); - if (max_frames <= 1) { - if (play_once) - ticker->start(60); - } - else - ticker->start(this->get_frame_delay(movie_delays[frame])); + play_frame_effect(frame); + if (max_frames <= 1) { + if (play_once) + ticker->start(60); + } + else + ticker->start(this->get_frame_delay(movie_delays[frame])); } void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration) { - load_image(p_char, p_emote, ""); - //As much as I'd like to screw around with [Time] durations modifying the animation speed, I don't think I can reliably do that, - //not without looping through all frames in the image at least - which causes lag. So for now it simply ends the preanimation early instead. - play_once = true; - if (duration > 0) //It's -1 if there's no definition in [Time] for it. In which case, it will let the animation run out in full. Duration 0 does the same. - preanim_timer->start(duration * time_mod); //This timer will not fire if the animation finishes earlier than that - play(); + load_image(p_char, p_emote, ""); + // As much as I'd like to screw around with [Time] durations modifying the + // animation speed, I don't think I can reliably do that, not without looping + // through all frames in the image at least - which causes lag. So for now it + // simply ends the preanimation early instead. + play_once = true; + if (duration > + 0) // It's -1 if there's no definition in [Time] for it. In which case, it + // will let the animation run out in full. Duration 0 does the same. + preanim_timer->start(duration * + time_mod); // This timer will not fire if the animation + // finishes earlier than that + play(); } void AOCharMovie::play_talking(QString p_char, QString p_emote) { - play_once = false; - load_image(p_char, p_emote, "(b)"); - play(); + play_once = false; + load_image(p_char, p_emote, "(b)"); + play(); } void AOCharMovie::play_idle(QString p_char, QString p_emote) { - play_once = false; - load_image(p_char, p_emote, "(a)"); - play(); + play_once = false; + load_image(p_char, p_emote, "(a)"); + play(); } void AOCharMovie::play_frame_effect(int frame) { - if (frame < max_frames) { - foreach (QString effect, movie_effects[frame]) { - if (effect == "shake") { - shake(); + if (frame < max_frames) { + foreach (QString effect, movie_effects[frame]) { + if (effect == "shake") { + shake(); #ifdef DEBUG_CHARMOVIE - qDebug() << "Attempting to play shake on frame" << frame; + qDebug() << "Attempting to play shake on frame" << frame; #endif - } + } - if (effect == "flash") { - flash(); + if (effect == "flash") { + flash(); #ifdef DEBUG_CHARMOVIE - qDebug() << "Attempting to play flash on frame" << frame; + qDebug() << "Attempting to play flash on frame" << frame; #endif - } + } - if (effect.startsWith("sfx^")) { - QString sfx = effect.section("^", 1); - play_sfx(sfx); + if (effect.startsWith("sfx^")) { + QString sfx = effect.section("^", 1); + play_sfx(sfx); #ifdef DEBUG_CHARMOVIE - qDebug() << "Attempting to play sfx" << sfx << "on frame" << frame; + qDebug() << "Attempting to play sfx" << sfx << "on frame" << frame; #endif - } - } + } } + } } void AOCharMovie::stop() { - //for all intents and purposes, stopping is the same as hiding. at no point do we want a frozen gif to display - ticker->stop(); - preanim_timer->stop(); - this->hide(); + // for all intents and purposes, stopping is the same as hiding. at no point + // do we want a frozen gif to display + ticker->stop(); + preanim_timer->stop(); + this->hide(); } QPixmap AOCharMovie::get_pixmap(QImage image) { - QPixmap f_pixmap; - if (m_flipped) - f_pixmap = QPixmap::fromImage(image.mirrored(true, false)); - else - f_pixmap = QPixmap::fromImage(image); - // auto aspect_ratio = Qt::KeepAspectRatio; - auto transform_mode = Qt::FastTransformation; - if (f_pixmap.height() > f_h) //We are downscaling, use anti-aliasing. - transform_mode = Qt::SmoothTransformation; - - f_pixmap = f_pixmap.scaledToHeight(f_h, transform_mode); - this->resize(f_pixmap.size()); - - return f_pixmap; + QPixmap f_pixmap; + if (m_flipped) + f_pixmap = QPixmap::fromImage(image.mirrored(true, false)); + else + f_pixmap = QPixmap::fromImage(image); + // auto aspect_ratio = Qt::KeepAspectRatio; + auto transform_mode = Qt::FastTransformation; + if (f_pixmap.height() > f_h) // We are downscaling, use anti-aliasing. + transform_mode = Qt::SmoothTransformation; + + f_pixmap = f_pixmap.scaledToHeight(f_h, transform_mode); + this->resize(f_pixmap.size()); + + return f_pixmap; } void AOCharMovie::set_frame(QPixmap f_pixmap) { - this->setPixmap(f_pixmap); - QLabel::move(x + (f_w - f_pixmap.width()) / 2, y + (f_h - f_pixmap.height())); //Always center horizontally, always put at the bottom vertically + this->setPixmap(f_pixmap); + QLabel::move( + x + (f_w - f_pixmap.width()) / 2, + y + (f_h - f_pixmap.height())); // Always center horizontally, always put + // at the bottom vertically } void AOCharMovie::combo_resize(int w, int h) { - QSize f_size(w, h); - f_w = w; - f_h = h; - this->resize(f_size); + QSize f_size(w, h); + f_w = w; + f_h = h; + this->resize(f_size); } int AOCharMovie::get_frame_delay(int delay) { - return static_cast<int>(double(delay) * double(speed / 100)); + return static_cast<int>(double(delay) * double(speed / 100)); } void AOCharMovie::move(int ax, int ay) { - x = ax; - y = ay; - QLabel::move(x, y); + x = ax; + y = ay; + QLabel::move(x, y); } void AOCharMovie::movie_ticker() { - ++frame; - if (frame >= max_frames) { - if (play_once) { - preanim_done(); - return; - } - else - frame = 0; - } - // qint64 difference = elapsed - movie_delays[frame]; - if (frame >= movie_frames.size()) { - m_reader->jumpToImage(frame); - movie_frames.resize(frame + 1); - movie_frames[frame] = this->get_pixmap(m_reader->read()); - movie_delays.resize(frame + 1); - movie_delays[frame] = m_reader->nextImageDelay(); + ++frame; + if (frame >= max_frames) { + if (play_once) { + preanim_done(); + return; } + else + frame = 0; + } + // qint64 difference = elapsed - movie_delays[frame]; + if (frame >= movie_frames.size()) { + m_reader->jumpToImage(frame); + movie_frames.resize(frame + 1); + movie_frames[frame] = this->get_pixmap(m_reader->read()); + movie_delays.resize(frame + 1); + movie_delays[frame] = m_reader->nextImageDelay(); + } #ifdef DEBUG_CHARMOVIE - qDebug() << frame << movie_delays[frame] << "actual time taken from last frame:" << actual_time.restart(); + qDebug() << frame << movie_delays[frame] + << "actual time taken from last frame:" << actual_time.restart(); #endif - this->set_frame(movie_frames[frame]); - play_frame_effect(frame); - ticker->setInterval(this->get_frame_delay(movie_delays[frame])); + this->set_frame(movie_frames[frame]); + play_frame_effect(frame); + ticker->setInterval(this->get_frame_delay(movie_delays[frame])); } void AOCharMovie::preanim_done() { - ticker->stop(); - preanim_timer->stop(); - done(); + ticker->stop(); + preanim_timer->stop(); + done(); } diff --git a/src/aoemotebutton.cpp b/src/aoemotebutton.cpp index 991451f8..abec526b 100644 --- a/src/aoemotebutton.cpp +++ b/src/aoemotebutton.cpp @@ -2,40 +2,44 @@ #include "file_functions.h" -AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h) : QPushButton(p_parent) +AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, + int p_x, int p_y, int p_w, int p_h) + : QPushButton(p_parent) { - parent = p_parent; - ao_app = p_ao_app; + parent = p_parent; + ao_app = p_ao_app; - this->move(p_x, p_y); - this->resize(p_w, p_h); + this->move(p_x, p_y); + this->resize(p_w, p_h); - connect(this, SIGNAL(clicked()), this, SLOT(on_clicked())); + connect(this, SIGNAL(clicked()), this, SLOT(on_clicked())); } void AOEmoteButton::set_image(QString p_image, QString p_emote_comment) { - if (file_exists(p_image)) { - this->setText(""); - this->setStyleSheet("QPushButton { border-image: url(\"" + p_image + "\") 0 0 0 0 stretch stretch; }" - "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }"); - } - else { - this->setText(p_emote_comment); - this->setStyleSheet("QPushButton { border-image: url(); }" - "QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }"); - } + if (file_exists(p_image)) { + this->setText(""); + this->setStyleSheet( + "QPushButton { border-image: url(\"" + p_image + + "\") 0 0 0 0 stretch stretch; }" + "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }"); + } + else { + this->setText(p_emote_comment); + this->setStyleSheet("QPushButton { border-image: url(); }" + "QToolTip { background-image: url(); color: #000000; " + "background-color: #ffffff; border: 0px; }"); + } } void AOEmoteButton::set_char_image(QString p_char, int p_emote, QString suffix) { - QString emotion_number = QString::number(p_emote + 1); - QString image_path = ao_app->get_static_image_suffix(ao_app->get_character_path(p_char, "emotions/button" + emotion_number + suffix)); + QString emotion_number = QString::number(p_emote + 1); + QString image_path = + ao_app->get_static_image_suffix(ao_app->get_character_path( + p_char, "emotions/button" + emotion_number + suffix)); - this->set_image(image_path, ao_app->get_emote_comment(p_char, p_emote)); + this->set_image(image_path, ao_app->get_emote_comment(p_char, p_emote)); } -void AOEmoteButton::on_clicked() -{ - emote_clicked(m_id); -} +void AOEmoteButton::on_clicked() { emote_clicked(m_id); } diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp index 596374b2..f85a223f 100644 --- a/src/aoevidencebutton.cpp +++ b/src/aoevidencebutton.cpp @@ -2,84 +2,88 @@ #include "file_functions.h" -AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h) : QPushButton(p_parent) +AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, + int p_x, int p_y, int p_w, int p_h) + : QPushButton(p_parent) { - ao_app = p_ao_app; - m_parent = p_parent; - - ui_selected = new AOImage(this, ao_app); - ui_selected->resize(p_w, p_h); - // ui_selected->move(p_x, p_y); - ui_selected->set_image("evidence_selected"); - ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_selected->hide(); - - ui_selector = new AOImage(this, ao_app); - ui_selector->resize(p_w, p_h); - // ui_selector->move(p_x - 1, p_y - 1); - ui_selector->set_image("evidence_selector"); - ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_selector->hide(); - - this->move(p_x, p_y); - this->resize(p_w, p_h); - // this->setAcceptDrops(true); - - connect(this, SIGNAL(clicked()), this, SLOT(on_clicked())); + ao_app = p_ao_app; + m_parent = p_parent; + + ui_selected = new AOImage(this, ao_app); + ui_selected->resize(p_w, p_h); + // ui_selected->move(p_x, p_y); + ui_selected->set_image("evidence_selected"); + ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_selected->hide(); + + ui_selector = new AOImage(this, ao_app); + ui_selector->resize(p_w, p_h); + // ui_selector->move(p_x - 1, p_y - 1); + ui_selector->set_image("evidence_selector"); + ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_selector->hide(); + + this->move(p_x, p_y); + this->resize(p_w, p_h); + // this->setAcceptDrops(true); + + connect(this, SIGNAL(clicked()), this, SLOT(on_clicked())); } void AOEvidenceButton::set_image(QString p_image) { - QString image_path = ao_app->get_evidence_path(p_image); - if (file_exists(p_image)) { - this->setText(""); - this->setStyleSheet("QPushButton { border-image: url(\"" + p_image + "\") 0 0 0 0 stretch stretch; }" - "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }"); - } - else if (file_exists(image_path)) { - this->setText(""); - this->setStyleSheet("QPushButton { border-image: url(\"" + image_path + "\") 0 0 0 0 stretch stretch; }" - "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }"); - } - else { - this->setText(p_image); - this->setStyleSheet("QPushButton { border-image: url(); }" - "QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }"); - } + QString image_path = ao_app->get_evidence_path(p_image); + if (file_exists(p_image)) { + this->setText(""); + this->setStyleSheet( + "QPushButton { border-image: url(\"" + p_image + + "\") 0 0 0 0 stretch stretch; }" + "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }"); + } + else if (file_exists(image_path)) { + this->setText(""); + this->setStyleSheet( + "QPushButton { border-image: url(\"" + image_path + + "\") 0 0 0 0 stretch stretch; }" + "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }"); + } + else { + this->setText(p_image); + this->setStyleSheet("QPushButton { border-image: url(); }" + "QToolTip { background-image: url(); color: #000000; " + "background-color: #ffffff; border: 0px; }"); + } } void AOEvidenceButton::set_theme_image(QString p_image) { - QString theme_image_path = ao_app->get_theme_path(p_image); - QString default_image_path = ao_app->get_default_theme_path(p_image); + QString theme_image_path = ao_app->get_theme_path(p_image); + QString default_image_path = ao_app->get_default_theme_path(p_image); - QString final_image_path; + QString final_image_path; - if (file_exists(theme_image_path)) - final_image_path = theme_image_path; - else - final_image_path = default_image_path; + if (file_exists(theme_image_path)) + final_image_path = theme_image_path; + else + final_image_path = default_image_path; - this->set_image(final_image_path); + this->set_image(final_image_path); } void AOEvidenceButton::set_selected(bool p_selected) { - if (p_selected) - ui_selected->show(); - else - ui_selected->hide(); + if (p_selected) + ui_selected->show(); + else + ui_selected->hide(); } -void AOEvidenceButton::on_clicked() -{ - evidence_clicked(m_id); -} +void AOEvidenceButton::on_clicked() { evidence_clicked(m_id); } void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e) { - QPushButton::mouseDoubleClickEvent(e); - evidence_double_clicked(m_id); + QPushButton::mouseDoubleClickEvent(e); + evidence_double_clicked(m_id); } /* @@ -100,18 +104,18 @@ void AOEvidenceButton::dragEnterEvent(QMouseEvent *e) void AOEvidenceButton::enterEvent(QEvent *e) { - ui_selector->show(); + ui_selector->show(); - on_hover(m_id, true); + on_hover(m_id, true); - setFlat(false); - QPushButton::enterEvent(e); + setFlat(false); + QPushButton::enterEvent(e); } void AOEvidenceButton::leaveEvent(QEvent *e) { - ui_selector->hide(); + ui_selector->hide(); - on_hover(m_id, false); - QPushButton::leaveEvent(e); + on_hover(m_id, false); + QPushButton::leaveEvent(e); } diff --git a/src/aoevidencedisplay.cpp b/src/aoevidencedisplay.cpp index 22f57205..2ffea2c9 100644 --- a/src/aoevidencedisplay.cpp +++ b/src/aoevidencedisplay.cpp @@ -4,71 +4,68 @@ #include "file_functions.h" #include "misc_functions.h" -AOEvidenceDisplay::AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) +AOEvidenceDisplay::AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app) + : QLabel(p_parent) { - ao_app = p_ao_app; - evidence_icon = new QLabel(this); - sfx_player = new AOSfxPlayer(this, ao_app); + ao_app = p_ao_app; + evidence_icon = new QLabel(this); + sfx_player = new AOSfxPlayer(this, ao_app); - evidence_movie = new AOMovie(this, ao_app); + evidence_movie = new AOMovie(this, ao_app); - connect(evidence_movie, SIGNAL(done()), this, SLOT(show_done())); + connect(evidence_movie, SIGNAL(done()), this, SLOT(show_done())); } -void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_side, int p_volume) +void AOEvidenceDisplay::show_evidence(QString p_evidence_image, + bool is_left_side, int p_volume) { - this->reset(); + this->reset(); - sfx_player->set_volume(p_volume); + sfx_player->set_volume(p_volume); - QString final_gif_path; - QString gif_name; - QString icon_identifier; + QString final_gif_path; + QString gif_name; + QString icon_identifier; - if (is_left_side) { - icon_identifier = "left_evidence_icon"; - gif_name = "evidence_appear_left"; - } - else { - icon_identifier = "right_evidence_icon"; - gif_name = "evidence_appear_right"; - } + if (is_left_side) { + icon_identifier = "left_evidence_icon"; + gif_name = "evidence_appear_left"; + } + else { + icon_identifier = "right_evidence_icon"; + gif_name = "evidence_appear_right"; + } - QString f_evidence_path = ao_app->get_evidence_path(p_evidence_image); - QPixmap f_pixmap(f_evidence_path); + QString f_evidence_path = ao_app->get_evidence_path(p_evidence_image); + QPixmap f_pixmap(f_evidence_path); - pos_size_type icon_dimensions = ao_app->get_element_dimensions(icon_identifier, "courtroom_design.ini"); + pos_size_type icon_dimensions = + ao_app->get_element_dimensions(icon_identifier, "courtroom_design.ini"); - f_pixmap = f_pixmap.scaled(icon_dimensions.width, icon_dimensions.height); - evidence_icon->setPixmap(f_pixmap); - evidence_icon->resize(f_pixmap.size()); - evidence_icon->move(icon_dimensions.x, icon_dimensions.y); + f_pixmap = f_pixmap.scaled(icon_dimensions.width, icon_dimensions.height); + evidence_icon->setPixmap(f_pixmap); + evidence_icon->resize(f_pixmap.size()); + evidence_icon->move(icon_dimensions.x, icon_dimensions.y); - evidence_movie->play(gif_name); - sfx_player->play(ao_app->get_sfx("evidence_present")); + evidence_movie->play(gif_name); + sfx_player->play(ao_app->get_sfx("evidence_present")); } void AOEvidenceDisplay::reset() { - sfx_player->stop(); - evidence_movie->stop(); - evidence_icon->hide(); - this->clear(); + sfx_player->stop(); + evidence_movie->stop(); + evidence_icon->hide(); + this->clear(); } -void AOEvidenceDisplay::show_done() -{ - evidence_icon->show(); -} +void AOEvidenceDisplay::show_done() { evidence_icon->show(); } -QLabel *AOEvidenceDisplay::get_evidence_icon() -{ - return evidence_icon; -} +QLabel *AOEvidenceDisplay::get_evidence_icon() { return evidence_icon; } void AOEvidenceDisplay::combo_resize(int w, int h) { - QSize f_size(w, h); - this->resize(f_size); - evidence_movie->combo_resize(w, h); + QSize f_size(w, h); + this->resize(f_size); + evidence_movie->combo_resize(w, h); } diff --git a/src/aoimage.cpp b/src/aoimage.cpp index e1c01e55..2663ba05 100644 --- a/src/aoimage.cpp +++ b/src/aoimage.cpp @@ -4,46 +4,48 @@ AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent) { - m_parent = parent; - ao_app = p_ao_app; + m_parent = parent; + ao_app = p_ao_app; } -AOImage::~AOImage() -{ -} +AOImage::~AOImage() {} bool AOImage::set_image(QString p_image) { - QString theme_image_path = ao_app->get_static_image_suffix(ao_app->get_theme_path(p_image)); - QString default_image_path = ao_app->get_static_image_suffix(ao_app->get_default_theme_path(p_image)); - - QString final_image_path; - - if (file_exists(theme_image_path)) - final_image_path = theme_image_path; - else if (file_exists(default_image_path)) - final_image_path = default_image_path; - else { - qDebug() << "Warning: Image" << p_image << "not found! Can't set!"; - return false; - } - - QPixmap f_pixmap(final_image_path); - - this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio)); - return true; + QString theme_image_path = + ao_app->get_static_image_suffix(ao_app->get_theme_path(p_image)); + QString default_image_path = + ao_app->get_static_image_suffix(ao_app->get_default_theme_path(p_image)); + + QString final_image_path; + + if (file_exists(theme_image_path)) + final_image_path = theme_image_path; + else if (file_exists(default_image_path)) + final_image_path = default_image_path; + else { + qDebug() << "Warning: Image" << p_image << "not found! Can't set!"; + return false; + } + + QPixmap f_pixmap(final_image_path); + + this->setPixmap( + f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio)); + return true; } bool AOImage::set_chatbox(QString p_path) { - p_path = ao_app->get_static_image_suffix(p_path); - if (!file_exists(p_path)) { - qDebug() << "Warning: Chatbox" << p_path << "not found! Can't set!"; - return false; - } + p_path = ao_app->get_static_image_suffix(p_path); + if (!file_exists(p_path)) { + qDebug() << "Warning: Chatbox" << p_path << "not found! Can't set!"; + return false; + } - QPixmap f_pixmap(p_path); + QPixmap f_pixmap(p_path); - this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio)); - return true; + this->setPixmap( + f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio)); + return true; } diff --git a/src/aolineedit.cpp b/src/aolineedit.cpp index ce851a0d..f98d95fe 100644 --- a/src/aolineedit.cpp +++ b/src/aolineedit.cpp @@ -1,20 +1,19 @@ #include "aolineedit.h" -AOLineEdit::AOLineEdit(QWidget *parent) : QLineEdit(parent) -{ -} +AOLineEdit::AOLineEdit(QWidget *parent) : QLineEdit(parent) {} void AOLineEdit::mouseDoubleClickEvent(QMouseEvent *e) { - QLineEdit::mouseDoubleClickEvent(e); + QLineEdit::mouseDoubleClickEvent(e); - double_clicked(); + double_clicked(); } void AOLineEdit::focusOutEvent(QFocusEvent *ev) { - int start = selectionStart(); - int len = selectionEnd() - start; //We're not using selectionLength because Linux build doesn't run qt5.10 - QLineEdit::focusOutEvent(ev); - if (p_selection && start != -1 && len != -1) - this->setSelection(start, len); + int start = selectionStart(); + int len = selectionEnd() - start; // We're not using selectionLength because + // Linux build doesn't run qt5.10 + QLineEdit::focusOutEvent(ev); + if (p_selection && start != -1 && len != -1) + this->setSelection(start, len); } diff --git a/src/aomovie.cpp b/src/aomovie.cpp index 7e3bbae0..ac949219 100644 --- a/src/aomovie.cpp +++ b/src/aomovie.cpp @@ -6,88 +6,94 @@ AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) { - ao_app = p_ao_app; + ao_app = p_ao_app; - m_movie = new QMovie(); + m_movie = new QMovie(); - this->setMovie(m_movie); + this->setMovie(m_movie); - timer = new QTimer(this); - timer->setTimerType(Qt::PreciseTimer); - timer->setSingleShot(true); + timer = new QTimer(this); + timer->setTimerType(Qt::PreciseTimer); + timer->setSingleShot(true); - connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int))); - connect(timer, SIGNAL(timeout()), this, SLOT(timer_done())); + connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int))); + connect(timer, SIGNAL(timeout()), this, SLOT(timer_done())); } -void AOMovie::set_play_once(bool p_play_once) -{ - play_once = p_play_once; -} +void AOMovie::set_play_once(bool p_play_once) { play_once = p_play_once; } -void AOMovie::play(QString p_image, QString p_char, QString p_custom_theme, int duration) +void AOMovie::play(QString p_image, QString p_char, QString p_custom_theme, + int duration) { - m_movie->stop(); - - QString shout_path = p_image; - if (!file_exists(p_image)) { - QList<QString> pathlist; - - pathlist = { - ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_image)), //Character folder - ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + p_image), //Misc path - ao_app->get_image_suffix(ao_app->get_custom_theme_path(p_custom_theme, p_image)), //Custom theme path - ao_app->get_image_suffix(ao_app->get_theme_path(p_image)), //Theme path - ao_app->get_image_suffix(ao_app->get_default_theme_path(p_image)), //Default theme path - ao_app->get_image_suffix(ao_app->get_theme_path("placeholder")), //Placeholder path - ao_app->get_image_suffix(ao_app->get_default_theme_path("placeholder")), //Default placeholder path - }; - - for (QString path : pathlist) { - if (file_exists(path)) { - shout_path = path; - break; - } - } + m_movie->stop(); + + QString shout_path = p_image; + if (!file_exists(p_image)) { + QList<QString> pathlist; + + pathlist = { + ao_app->get_image_suffix( + ao_app->get_character_path(p_char, p_image)), // Character folder + ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + + p_custom_theme + "/" + p_image), // Misc path + ao_app->get_image_suffix(ao_app->get_custom_theme_path( + p_custom_theme, p_image)), // Custom theme path + ao_app->get_image_suffix(ao_app->get_theme_path(p_image)), // Theme path + ao_app->get_image_suffix( + ao_app->get_default_theme_path(p_image)), // Default theme path + ao_app->get_image_suffix( + ao_app->get_theme_path("placeholder")), // Placeholder path + ao_app->get_image_suffix(ao_app->get_default_theme_path( + "placeholder")), // Default placeholder path + }; + + for (QString path : pathlist) { + if (file_exists(path)) { + shout_path = path; + break; + } } + } - m_movie->setFileName(shout_path); + m_movie->setFileName(shout_path); - if (m_movie->loopCount() == 0) - play_once = true; + if (m_movie->loopCount() == 0) + play_once = true; - this->show(); - m_movie->start(); - if (m_movie->frameCount() == 0 && duration > 0) - timer->start(duration); + this->show(); + m_movie->start(); + if (m_movie->frameCount() == 0 && duration > 0) + timer->start(duration); } void AOMovie::stop() { - m_movie->stop(); - this->hide(); + m_movie->stop(); + this->hide(); } void AOMovie::frame_change(int n_frame) { - //If it's a "static movie" (only one frame - png image), we can't change frames - ignore this function (use timer instead). - //If the frame didn't reach the last frame or the movie is continuous, don't stop the movie. - if (m_movie->frameCount() == 0 || n_frame < (m_movie->frameCount() - 1) || !play_once) - return; - //we need this or else the last frame wont show - timer->start(m_movie->nextFrameDelay()); + // If it's a "static movie" (only one frame - png image), we can't change + // frames - ignore this function (use timer instead). If the frame didn't reach + // the last frame or the movie is continuous, don't stop the movie. + if (m_movie->frameCount() == 0 || n_frame < (m_movie->frameCount() - 1) || + !play_once) + return; + // we need this or else the last frame wont show + timer->start(m_movie->nextFrameDelay()); } void AOMovie::timer_done() { - this->stop(); - //signal connected to courtroom object, let it figure out what to do - done(); + this->stop(); + // signal connected to courtroom object, let it figure out what to do + done(); } void AOMovie::combo_resize(int w, int h) { - QSize f_size(w, h); - this->resize(f_size); - m_movie->setScaledSize(f_size); + QSize f_size(w, h); + this->resize(f_size); + m_movie->setScaledSize(f_size); } diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index 77222e1d..bc1ab235 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -3,200 +3,209 @@ #ifdef BASSAUDIO AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) { - m_parent = parent; - ao_app = p_ao_app; + m_parent = parent; + ao_app = p_ao_app; } AOMusicPlayer::~AOMusicPlayer() { - for (int n_stream = 0; n_stream < m_channelmax; ++n_stream) { - BASS_ChannelStop(m_stream_list[n_stream]); - } + for (int n_stream = 0; n_stream < m_channelmax; ++n_stream) { + BASS_ChannelStop(m_stream_list[n_stream]); + } } -void AOMusicPlayer::play(QString p_song, int channel, bool loop, int effect_flags) +void AOMusicPlayer::play(QString p_song, int channel, bool loop, + int effect_flags) { - channel = channel % m_channelmax; - if (channel < 0) //wtf? - return; - QString f_path = ao_app->get_music_path(p_song); - - unsigned int flags = BASS_STREAM_PRESCAN | BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE; - if (loop) - flags |= BASS_SAMPLE_LOOP; - - DWORD newstream; - if (f_path.endsWith(".opus")) - newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); - else - newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); - - if (ao_app->get_audio_output_device() != "default") - BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice()); - - QString d_path = f_path + ".txt"; - - loop_start = 0; - loop_end = BASS_ChannelGetLength(newstream, BASS_POS_BYTE); - if (loop && file_exists(d_path)) //Contains loop/etc. information file - { - QStringList lines = ao_app->read_file(d_path).split("\n"); - foreach (QString line, lines) { - QStringList args = line.split("="); - if (args.size() < 2) - continue; - QString arg = args[0].trimmed(); - - float sample_rate; - BASS_ChannelGetAttribute(newstream, BASS_ATTRIB_FREQ, &sample_rate); - - //Grab number of bytes for sample size - int sample_size = 16 / 8; - - //number of channels (stereo/mono) - int num_channels = 2; - - //Calculate the bytes for loop_start/loop_end to use with the sync proc - QWORD bytes = static_cast<QWORD>(args[1].trimmed().toFloat() * sample_size * num_channels); - if (arg == "loop_start") - loop_start = bytes; - else if (arg == "loop_length") - loop_end = loop_start + bytes; - else if (arg == "loop_end") - loop_end = bytes; - } - qDebug() << "Found data file for song" << p_song << "length" << BASS_ChannelGetLength(newstream, BASS_POS_BYTE) << "loop start" << loop_start << "loop end" << loop_end; + channel = channel % m_channelmax; + if (channel < 0) // wtf? + return; + QString f_path = ao_app->get_music_path(p_song); + + unsigned int flags = BASS_STREAM_PRESCAN | BASS_STREAM_AUTOFREE | + BASS_UNICODE | BASS_ASYNCFILE; + if (loop) + flags |= BASS_SAMPLE_LOOP; + + DWORD newstream; + if (f_path.endsWith(".opus")) + newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); + else + newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); + + if (ao_app->get_audio_output_device() != "default") + BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice()); + + QString d_path = f_path + ".txt"; + + loop_start = 0; + loop_end = BASS_ChannelGetLength(newstream, BASS_POS_BYTE); + if (loop && file_exists(d_path)) // Contains loop/etc. information file + { + QStringList lines = ao_app->read_file(d_path).split("\n"); + foreach (QString line, lines) { + QStringList args = line.split("="); + if (args.size() < 2) + continue; + QString arg = args[0].trimmed(); + + float sample_rate; + BASS_ChannelGetAttribute(newstream, BASS_ATTRIB_FREQ, &sample_rate); + + // Grab number of bytes for sample size + int sample_size = 16 / 8; + + // number of channels (stereo/mono) + int num_channels = 2; + + // Calculate the bytes for loop_start/loop_end to use with the sync proc + QWORD bytes = static_cast<QWORD>(args[1].trimmed().toFloat() * + sample_size * num_channels); + if (arg == "loop_start") + loop_start = bytes; + else if (arg == "loop_length") + loop_end = loop_start + bytes; + else if (arg == "loop_end") + loop_end = bytes; } - - if (BASS_ChannelIsActive(m_stream_list[channel]) == BASS_ACTIVE_PLAYING) { - DWORD oldstream = m_stream_list[channel]; - - if (effect_flags & SYNC_POS) { - BASS_ChannelLock(oldstream, true); - //Sync it with the new sample - BASS_ChannelSetPosition(newstream, BASS_ChannelGetPosition(oldstream, BASS_POS_BYTE), BASS_POS_BYTE); - BASS_ChannelLock(oldstream, false); - } - - if (effect_flags & FADE_OUT) { - //Fade out the other sample and stop it (due to -1) - BASS_ChannelSlideAttribute(oldstream, BASS_ATTRIB_VOL | BASS_SLIDE_LOG, -1, 4000); - } - else - BASS_ChannelStop(oldstream); //Stop the sample since we don't need it anymore + qDebug() << "Found data file for song" << p_song << "length" + << BASS_ChannelGetLength(newstream, BASS_POS_BYTE) << "loop start" + << loop_start << "loop end" << loop_end; + } + + if (BASS_ChannelIsActive(m_stream_list[channel]) == BASS_ACTIVE_PLAYING) { + DWORD oldstream = m_stream_list[channel]; + + if (effect_flags & SYNC_POS) { + BASS_ChannelLock(oldstream, true); + // Sync it with the new sample + BASS_ChannelSetPosition(newstream, + BASS_ChannelGetPosition(oldstream, BASS_POS_BYTE), + BASS_POS_BYTE); + BASS_ChannelLock(oldstream, false); } - else - BASS_ChannelStop(m_stream_list[channel]); - - m_stream_list[channel] = newstream; - BASS_ChannelPlay(m_stream_list[channel], false); - if (effect_flags & FADE_IN) { - //Fade in our sample - BASS_ChannelSetAttribute(newstream, BASS_ATTRIB_VOL, 0); - BASS_ChannelSlideAttribute(newstream, BASS_ATTRIB_VOL, static_cast<float>(m_volume[channel] / 100.0f), 1000); + + if (effect_flags & FADE_OUT) { + // Fade out the other sample and stop it (due to -1) + BASS_ChannelSlideAttribute(oldstream, BASS_ATTRIB_VOL | BASS_SLIDE_LOG, + -1, 4000); } else - this->set_volume(m_volume[channel], channel); + BASS_ChannelStop( + oldstream); // Stop the sample since we don't need it anymore + } + else + BASS_ChannelStop(m_stream_list[channel]); - this->set_looping(loop); //Have to do this here due to any crossfading-related changes, etc. + m_stream_list[channel] = newstream; + BASS_ChannelPlay(m_stream_list[channel], false); + if (effect_flags & FADE_IN) { + // Fade in our sample + BASS_ChannelSetAttribute(newstream, BASS_ATTRIB_VOL, 0); + BASS_ChannelSlideAttribute(newstream, BASS_ATTRIB_VOL, + static_cast<float>(m_volume[channel] / 100.0f), + 1000); + } + else + this->set_volume(m_volume[channel], channel); + + this->set_looping(loop); // Have to do this here due to any + // crossfading-related changes, etc. } void AOMusicPlayer::stop(int channel) { - BASS_ChannelStop(m_stream_list[channel]); + BASS_ChannelStop(m_stream_list[channel]); } void AOMusicPlayer::set_volume(int p_value, int channel) { - m_volume[channel] = p_value; - float volume = m_volume[channel] / 100.0f; - if (channel < 0) { - for (int n_stream = 0; n_stream < m_channelmax; ++n_stream) { - BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); - } - } - else { - BASS_ChannelSetAttribute(m_stream_list[channel], BASS_ATTRIB_VOL, volume); + m_volume[channel] = p_value; + float volume = m_volume[channel] / 100.0f; + if (channel < 0) { + for (int n_stream = 0; n_stream < m_channelmax; ++n_stream) { + BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, + volume); } + } + else { + BASS_ChannelSetAttribute(m_stream_list[channel], BASS_ATTRIB_VOL, volume); + } } void CALLBACK loopProc(HSYNC handle, DWORD channel, DWORD data, void *user) { - QWORD loop_start = *(static_cast<unsigned *>(user)); - BASS_ChannelLock(channel, true); - BASS_ChannelSetPosition(channel, loop_start, BASS_POS_BYTE); - BASS_ChannelLock(channel, false); + QWORD loop_start = *(static_cast<unsigned *>(user)); + BASS_ChannelLock(channel, true); + BASS_ChannelSetPosition(channel, loop_start, BASS_POS_BYTE); + BASS_ChannelLock(channel, false); } void AOMusicPlayer::set_looping(bool toggle, int channel) { - m_looping = toggle; - if (!m_looping) { - if (BASS_ChannelFlags(m_stream_list[channel], 0, 0) & BASS_SAMPLE_LOOP) - BASS_ChannelFlags(m_stream_list[channel], 0, BASS_SAMPLE_LOOP); // remove the LOOP flag - BASS_ChannelRemoveSync(m_stream_list[channel], loop_sync[channel]); - loop_sync[channel] = 0; + m_looping = toggle; + if (!m_looping) { + if (BASS_ChannelFlags(m_stream_list[channel], 0, 0) & BASS_SAMPLE_LOOP) + BASS_ChannelFlags(m_stream_list[channel], 0, + BASS_SAMPLE_LOOP); // remove the LOOP flag + BASS_ChannelRemoveSync(m_stream_list[channel], loop_sync[channel]); + loop_sync[channel] = 0; + } + else { + BASS_ChannelFlags(m_stream_list[channel], BASS_SAMPLE_LOOP, + BASS_SAMPLE_LOOP); // set the LOOP flag + if (loop_sync[channel] != 0) { + BASS_ChannelRemoveSync(m_stream_list[channel], + loop_sync[channel]); // remove the sync + loop_sync[channel] = 0; } - else { - BASS_ChannelFlags(m_stream_list[channel], BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set the LOOP flag - if (loop_sync[channel] != 0) { - BASS_ChannelRemoveSync(m_stream_list[channel], loop_sync[channel]); //remove the sync - loop_sync[channel] = 0; - } - if (loop_start > 0) { - if (loop_end == 0) - loop_end = BASS_ChannelGetLength(m_stream_list[channel], BASS_POS_BYTE); - if (loop_end > 0) //Don't loop zero length songs even if we're asked to - loop_sync[channel] = BASS_ChannelSetSync(m_stream_list[channel], BASS_SYNC_POS | BASS_SYNC_MIXTIME, loop_end, loopProc, &loop_start); - } + if (loop_start > 0) { + if (loop_end == 0) + loop_end = BASS_ChannelGetLength(m_stream_list[channel], BASS_POS_BYTE); + if (loop_end > 0) // Don't loop zero length songs even if we're asked to + loop_sync[channel] = BASS_ChannelSetSync( + m_stream_list[channel], BASS_SYNC_POS | BASS_SYNC_MIXTIME, loop_end, + loopProc, &loop_start); } + } } #elif defined(QTAUDIO) AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) { - m_parent = parent; - ao_app = p_ao_app; + m_parent = parent; + ao_app = p_ao_app; } -AOMusicPlayer::~AOMusicPlayer() -{ - m_player.stop(); -} +AOMusicPlayer::~AOMusicPlayer() { m_player.stop(); } void AOMusicPlayer::play(QString p_song) { - m_player.stop(); + m_player.stop(); - QString f_path = ao_app->get_music_path(p_song); + QString f_path = ao_app->get_music_path(p_song); - m_player.setMedia(QUrl::fromLocalFile(f_path)); + m_player.setMedia(QUrl::fromLocalFile(f_path)); - this->set_volume(m_volume); + this->set_volume(m_volume); - m_player.play(); + m_player.play(); } void AOMusicPlayer::set_volume(int p_value) { - m_volume = p_value; - m_player.setVolume(m_volume); + m_volume = p_value; + m_player.setVolume(m_volume); } #else AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) { - m_parent = parent; - ao_app = p_ao_app; + m_parent = parent; + ao_app = p_ao_app; } -AOMusicPlayer::~AOMusicPlayer() -{ -} +AOMusicPlayer::~AOMusicPlayer() {} -void AOMusicPlayer::play(QString p_song) -{ -} +void AOMusicPlayer::play(QString p_song) {} -void AOMusicPlayer::set_volume(int p_value) -{ -} +void AOMusicPlayer::set_volume(int p_value) {} #endif diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 06df7a56..18556f3f 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -1,689 +1,755 @@ #include "aooptionsdialog.h" #include "aoapplication.h" -AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDialog(parent) +AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) + : QDialog(parent) { - ao_app = p_ao_app; - - // Setting up the basics. - // setAttribute(Qt::WA_DeleteOnClose); - setWindowTitle(tr("Settings")); - resize(398, 320); - - ui_settings_buttons = new QDialogButtonBox(this); - - QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); - sizePolicy1.setHorizontalStretch(0); - sizePolicy1.setVerticalStretch(0); - sizePolicy1.setHeightForWidth(ui_settings_buttons->sizePolicy().hasHeightForWidth()); - ui_settings_buttons->setSizePolicy(sizePolicy1); - ui_settings_buttons->setOrientation(Qt::Horizontal); - ui_settings_buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save); - - QObject::connect(ui_settings_buttons, SIGNAL(accepted()), this, SLOT(save_pressed())); - QObject::connect(ui_settings_buttons, SIGNAL(rejected()), this, SLOT(discard_pressed())); - - // We'll stop updates so that the window won't flicker while it's being made. - setUpdatesEnabled(false); - - // First of all, we want a tabbed dialog, so let's add some layout. - ui_vertical_layout = new QVBoxLayout(this); - ui_settings_tabs = new QTabWidget(this); - - ui_vertical_layout->addWidget(ui_settings_tabs); - ui_vertical_layout->addWidget(ui_settings_buttons); - - // Let's add the tabs one by one. - // First, we'll start with 'Gameplay'. - ui_gameplay_tab = new QWidget(); - ui_gameplay_tab->setSizePolicy(sizePolicy1); - ui_settings_tabs->addTab(ui_gameplay_tab, tr("Gameplay")); - ui_form_layout_widget = new QWidget(ui_gameplay_tab); - ui_form_layout_widget->setGeometry(QRect(10, 10, 361, 361)); - ui_form_layout_widget->setSizePolicy(sizePolicy1); + ao_app = p_ao_app; + + // Setting up the basics. + // setAttribute(Qt::WA_DeleteOnClose); + setWindowTitle(tr("Settings")); + resize(398, 320); + + ui_settings_buttons = new QDialogButtonBox(this); + + QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth( + ui_settings_buttons->sizePolicy().hasHeightForWidth()); + ui_settings_buttons->setSizePolicy(sizePolicy1); + ui_settings_buttons->setOrientation(Qt::Horizontal); + ui_settings_buttons->setStandardButtons(QDialogButtonBox::Cancel | + QDialogButtonBox::Save); + + QObject::connect(ui_settings_buttons, SIGNAL(accepted()), this, + SLOT(save_pressed())); + QObject::connect(ui_settings_buttons, SIGNAL(rejected()), this, + SLOT(discard_pressed())); + + // We'll stop updates so that the window won't flicker while it's being made. + setUpdatesEnabled(false); + + // First of all, we want a tabbed dialog, so let's add some layout. + ui_vertical_layout = new QVBoxLayout(this); + ui_settings_tabs = new QTabWidget(this); + + ui_vertical_layout->addWidget(ui_settings_tabs); + ui_vertical_layout->addWidget(ui_settings_buttons); + + // Let's add the tabs one by one. + // First, we'll start with 'Gameplay'. + ui_gameplay_tab = new QWidget(); + ui_gameplay_tab->setSizePolicy(sizePolicy1); + ui_settings_tabs->addTab(ui_gameplay_tab, tr("Gameplay")); + ui_form_layout_widget = new QWidget(ui_gameplay_tab); + ui_form_layout_widget->setGeometry(QRect(10, 10, 361, 361)); + ui_form_layout_widget->setSizePolicy(sizePolicy1); + + ui_gameplay_form = new QFormLayout(ui_form_layout_widget); + ui_gameplay_form->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft | + Qt::AlignVCenter); + ui_gameplay_form->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft | + Qt::AlignTop); + ui_gameplay_form->setContentsMargins(0, 0, 0, 0); + ui_gameplay_form->setSpacing(2); + + int row = 0; + + ui_theme_label = new QLabel(ui_form_layout_widget); + ui_theme_label->setText(tr("Theme:")); + ui_theme_label->setToolTip( + tr("Sets the theme used in-game. If the new theme changes " + "the lobby's look as well, you'll need to reload the " + "lobby for the changes to take effect, such as by joining " + "a server and leaving it.")); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_theme_label); + ui_theme_combobox = new QComboBox(ui_form_layout_widget); + + // Fill the combobox with the names of the themes. + QDirIterator it(p_ao_app->get_base_path() + "themes", QDir::Dirs, + QDirIterator::NoIteratorFlags); + while (it.hasNext()) { + QString actualname = QDir(it.next()).dirName(); + if (actualname != "." && actualname != "..") + ui_theme_combobox->addItem(actualname); + if (actualname == p_ao_app->read_theme()) + ui_theme_combobox->setCurrentIndex(ui_theme_combobox->count() - 1); + } + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_theme_combobox); + + row += 1; + ui_theme_log_divider = new QFrame(ui_form_layout_widget); + ui_theme_log_divider->setMidLineWidth(0); + ui_theme_log_divider->setFrameShape(QFrame::HLine); + ui_theme_log_divider->setFrameShadow(QFrame::Sunken); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, + ui_theme_log_divider); + + row += 1; + ui_downwards_lbl = new QLabel(ui_form_layout_widget); + ui_downwards_lbl->setText(tr("Log goes downwards:")); + ui_downwards_lbl->setToolTip( + tr("If ticked, new messages will appear at " + "the bottom (like the OOC chatlog). The traditional " + "(AO1) behaviour is equivalent to this being unticked.")); + + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_downwards_lbl); + + ui_downwards_cb = new QCheckBox(ui_form_layout_widget); + ui_downwards_cb->setChecked(p_ao_app->get_log_goes_downwards()); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_downwards_cb); + + row += 1; + ui_length_lbl = new QLabel(ui_form_layout_widget); + ui_length_lbl->setText(tr("Log length:")); + ui_length_lbl->setToolTip(tr( + "The amount of messages the IC chatlog will keep before " + "deleting older messages. A value of 0 or below counts as 'infinite'.")); + + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_length_lbl); + + ui_length_spinbox = new QSpinBox(ui_form_layout_widget); + ui_length_spinbox->setMaximum(10000); + ui_length_spinbox->setValue(p_ao_app->get_max_log_size()); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_length_spinbox); + + row += 1; + ui_log_names_divider = new QFrame(ui_form_layout_widget); + ui_log_names_divider->setFrameShape(QFrame::HLine); + ui_log_names_divider->setFrameShadow(QFrame::Sunken); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, + ui_log_names_divider); + + row += 1; + ui_username_lbl = new QLabel(ui_form_layout_widget); + ui_username_lbl->setText(tr("Default username:")); + ui_username_lbl->setToolTip( + tr("Your OOC name will be automatically set to this value " + "when you join a server.")); + + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_username_lbl); + + ui_username_textbox = new QLineEdit(ui_form_layout_widget); + ui_username_textbox->setMaxLength(30); + ui_username_textbox->setText(p_ao_app->get_default_username()); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_username_textbox); + + row += 1; + ui_showname_lbl = new QLabel(ui_form_layout_widget); + ui_showname_lbl->setText(tr("Custom shownames:")); + ui_showname_lbl->setToolTip( + tr("Gives the default value for the in-game 'Custom shownames' " + "tickbox, which in turn determines whether the client should " + "display custom in-character names.")); + + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_showname_lbl); + + ui_showname_cb = new QCheckBox(ui_form_layout_widget); + ui_showname_cb->setChecked(p_ao_app->get_showname_enabled_by_default()); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_showname_cb); + + row += 1; + ui_net_divider = new QFrame(ui_form_layout_widget); + ui_net_divider->setFrameShape(QFrame::HLine); + ui_net_divider->setFrameShadow(QFrame::Sunken); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_net_divider); + + row += 1; + ui_ms_lbl = new QLabel(ui_form_layout_widget); + ui_ms_lbl->setText(tr("Backup MS:")); + ui_ms_lbl->setToolTip( + tr("If the built-in server lookups fail, the game will try the " + "address given here and use it as a backup master server address.")); - ui_gameplay_form = new QFormLayout(ui_form_layout_widget); - ui_gameplay_form->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter); - ui_gameplay_form->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop); - ui_gameplay_form->setContentsMargins(0, 0, 0, 0); - ui_gameplay_form->setSpacing(2); - - int row = 0; + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_ms_lbl); - ui_theme_label = new QLabel(ui_form_layout_widget); - ui_theme_label->setText(tr("Theme:")); - ui_theme_label->setToolTip(tr("Sets the theme used in-game. If the new theme changes " - "the lobby's look as well, you'll need to reload the " - "lobby for the changes to take effect, such as by joining " - "a server and leaving it.")); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_theme_label); - ui_theme_combobox = new QComboBox(ui_form_layout_widget); - - // Fill the combobox with the names of the themes. - QDirIterator it(p_ao_app->get_base_path() + "themes", QDir::Dirs, QDirIterator::NoIteratorFlags); - while (it.hasNext()) { - QString actualname = QDir(it.next()).dirName(); - if (actualname != "." && actualname != "..") - ui_theme_combobox->addItem(actualname); - if (actualname == p_ao_app->read_theme()) - ui_theme_combobox->setCurrentIndex(ui_theme_combobox->count() - 1); - } - - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_theme_combobox); - - row += 1; - ui_theme_log_divider = new QFrame(ui_form_layout_widget); - ui_theme_log_divider->setMidLineWidth(0); - ui_theme_log_divider->setFrameShape(QFrame::HLine); - ui_theme_log_divider->setFrameShadow(QFrame::Sunken); + QSettings *configini = ao_app->configini; + ui_ms_textbox = new QLineEdit(ui_form_layout_widget); + ui_ms_textbox->setText(configini->value("master", "").value<QString>()); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_theme_log_divider); + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_ms_textbox); - row += 1; - ui_downwards_lbl = new QLabel(ui_form_layout_widget); - ui_downwards_lbl->setText(tr("Log goes downwards:")); - ui_downwards_lbl->setToolTip(tr("If ticked, new messages will appear at " - "the bottom (like the OOC chatlog). The traditional " - "(AO1) behaviour is equivalent to this being unticked.")); + row += 1; + ui_discord_lbl = new QLabel(ui_form_layout_widget); + ui_discord_lbl->setText(tr("Discord:")); + ui_discord_lbl->setToolTip( + tr("Allows others on Discord to see what server you are in, " + "what character are you playing, and how long you have " + "been playing for.")); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_downwards_lbl); - - ui_downwards_cb = new QCheckBox(ui_form_layout_widget); - ui_downwards_cb->setChecked(p_ao_app->get_log_goes_downwards()); - - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_downwards_cb); - - row += 1; - ui_length_lbl = new QLabel(ui_form_layout_widget); - ui_length_lbl->setText(tr("Log length:")); - ui_length_lbl->setToolTip(tr("The amount of messages the IC chatlog will keep before " - "deleting older messages. A value of 0 or below counts as 'infinite'.")); - - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_length_lbl); - - ui_length_spinbox = new QSpinBox(ui_form_layout_widget); - ui_length_spinbox->setMaximum(10000); - ui_length_spinbox->setValue(p_ao_app->get_max_log_size()); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_discord_lbl); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_length_spinbox); - - row += 1; - ui_log_names_divider = new QFrame(ui_form_layout_widget); - ui_log_names_divider->setFrameShape(QFrame::HLine); - ui_log_names_divider->setFrameShadow(QFrame::Sunken); + ui_discord_cb = new QCheckBox(ui_form_layout_widget); + ui_discord_cb->setChecked(ao_app->is_discord_enabled()); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_names_divider); - - row += 1; - ui_username_lbl = new QLabel(ui_form_layout_widget); - ui_username_lbl->setText(tr("Default username:")); - ui_username_lbl->setToolTip(tr("Your OOC name will be automatically set to this value " - "when you join a server.")); + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_discord_cb); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_username_lbl); + row += 1; + ui_language_label = new QLabel(ui_form_layout_widget); + ui_language_label->setText(tr("Language:")); + ui_language_label->setToolTip( + tr("Sets the language if you don't want to use your system language.")); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_language_label); - ui_username_textbox = new QLineEdit(ui_form_layout_widget); - ui_username_textbox->setMaxLength(30); - ui_username_textbox->setText(p_ao_app->get_default_username()); + ui_language_combobox = new QComboBox(ui_form_layout_widget); + ui_language_combobox->addItem( + configini->value("language", " ").value<QString>() + + " - Keep current setting"); + ui_language_combobox->addItem(" - Default"); + ui_language_combobox->addItem("en - English"); + ui_language_combobox->addItem("de - Deutsch"); + ui_language_combobox->addItem("es - Español"); + ui_language_combobox->addItem("jp - 日本語"); + ui_language_combobox->addItem("ru - Русский"); + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, + ui_language_combobox); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_username_textbox); + row += 1; + ui_shake_lbl = new QLabel(ui_form_layout_widget); + ui_shake_lbl->setText(tr("Allow Screenshake:")); + ui_shake_lbl->setToolTip( + tr("Allows screenshaking. Disable this if you have concerns or issues " + "with photosensitivity and/or seizures.")); - row += 1; - ui_showname_lbl = new QLabel(ui_form_layout_widget); - ui_showname_lbl->setText(tr("Custom shownames:")); - ui_showname_lbl->setToolTip(tr("Gives the default value for the in-game 'Custom shownames' " - "tickbox, which in turn determines whether the client should " - "display custom in-character names.")); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_shake_lbl); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_showname_lbl); + ui_shake_cb = new QCheckBox(ui_form_layout_widget); + ui_shake_cb->setChecked(ao_app->is_shake_enabled()); - ui_showname_cb = new QCheckBox(ui_form_layout_widget); - ui_showname_cb->setChecked(p_ao_app->get_showname_enabled_by_default()); + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_shake_cb); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_showname_cb); + row += 1; + ui_effects_lbl = new QLabel(ui_form_layout_widget); + ui_effects_lbl->setText(tr("Allow Effects:")); + ui_effects_lbl->setToolTip( + tr("Allows screen effects. Disable this if you have concerns or issues " + "with photosensitivity and/or seizures.")); - row += 1; - ui_net_divider = new QFrame(ui_form_layout_widget); - ui_net_divider->setFrameShape(QFrame::HLine); - ui_net_divider->setFrameShadow(QFrame::Sunken); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_effects_lbl); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_net_divider); + ui_effects_cb = new QCheckBox(ui_form_layout_widget); + ui_effects_cb->setChecked(ao_app->is_effects_enabled()); - row += 1; - ui_ms_lbl = new QLabel(ui_form_layout_widget); - ui_ms_lbl->setText(tr("Backup MS:")); - ui_ms_lbl->setToolTip(tr("If the built-in server lookups fail, the game will try the " - "address given here and use it as a backup master server address.")); + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_effects_cb); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_ms_lbl); + row += 1; + ui_framenetwork_lbl = new QLabel(ui_form_layout_widget); + ui_framenetwork_lbl->setText(tr("Network Frame Effects:")); + ui_framenetwork_lbl->setToolTip(tr( + "Send screen-shaking, flashes and sounds as defined in the char.ini over " + "the network. Only works for servers that support this functionality.")); - QSettings *configini = ao_app->configini; - ui_ms_textbox = new QLineEdit(ui_form_layout_widget); - ui_ms_textbox->setText(configini->value("master", "").value<QString>()); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_framenetwork_lbl); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_ms_textbox); + ui_framenetwork_cb = new QCheckBox(ui_form_layout_widget); + ui_framenetwork_cb->setChecked(ao_app->is_frame_network_enabled()); - row += 1; - ui_discord_lbl = new QLabel(ui_form_layout_widget); - ui_discord_lbl->setText(tr("Discord:")); - ui_discord_lbl->setToolTip(tr("Allows others on Discord to see what server you are in, " - "what character are you playing, and how long you have " - "been playing for.")); + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_framenetwork_cb); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_discord_lbl); + row += 1; + ui_colorlog_lbl = new QLabel(ui_form_layout_widget); + ui_colorlog_lbl->setText(tr("Colors in IC Log:")); + ui_colorlog_lbl->setToolTip( + tr("Use the markup colors in the server IC chatlog.")); - ui_discord_cb = new QCheckBox(ui_form_layout_widget); - ui_discord_cb->setChecked(ao_app->is_discord_enabled()); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_colorlog_lbl); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_discord_cb); + ui_colorlog_cb = new QCheckBox(ui_form_layout_widget); + ui_colorlog_cb->setChecked(ao_app->is_colorlog_enabled()); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_colorlog_cb); + + row += 1; + ui_stickysounds_lbl = new QLabel(ui_form_layout_widget); + ui_stickysounds_lbl->setText(tr("Sticky Sounds:")); + ui_stickysounds_lbl->setToolTip( + tr("Turn this on to prevent the sound dropdown from clearing the sound " + "after playing it.")); - row += 1; - ui_language_label = new QLabel(ui_form_layout_widget); - ui_language_label->setText(tr("Language:")); - ui_language_label->setToolTip(tr("Sets the language if you don't want to use your system language.")); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_language_label); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_stickysounds_lbl); - ui_language_combobox = new QComboBox(ui_form_layout_widget); - ui_language_combobox->addItem(configini->value("language", " ").value<QString>() + " - Keep current setting"); - ui_language_combobox->addItem(" - Default"); - ui_language_combobox->addItem("en - English"); - ui_language_combobox->addItem("de - Deutsch"); - ui_language_combobox->addItem("es - Español"); - ui_language_combobox->addItem("jp - 日本語"); - ui_language_combobox->addItem("ru - Русский"); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_language_combobox); + ui_stickysounds_cb = new QCheckBox(ui_form_layout_widget); + ui_stickysounds_cb->setChecked(ao_app->is_stickysounds_enabled()); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_stickysounds_cb); - row += 1; - ui_shake_lbl = new QLabel(ui_form_layout_widget); - ui_shake_lbl->setText(tr("Allow Screenshake:")); - ui_shake_lbl->setToolTip(tr("Allows screenshaking. Disable this if you have concerns or issues with photosensitivity and/or seizures.")); + row += 1; + ui_stickyeffects_lbl = new QLabel(ui_form_layout_widget); + ui_stickyeffects_lbl->setText(tr("Sticky Effects:")); + ui_stickyeffects_lbl->setToolTip( + tr("Turn this on to prevent the effects dropdown from clearing the " + "effect after playing it.")); + + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, + ui_stickyeffects_lbl); + + ui_stickyeffects_cb = new QCheckBox(ui_form_layout_widget); + ui_stickyeffects_cb->setChecked(ao_app->is_stickyeffects_enabled()); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_stickyeffects_cb); + + row += 1; + ui_stickypres_lbl = new QLabel(ui_form_layout_widget); + ui_stickypres_lbl->setText(tr("Sticky Preanims:")); + ui_stickypres_lbl->setToolTip( + tr("Turn this on to prevent preanimation checkbox from clearing after " + "playing the emote.")); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_shake_lbl); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_stickypres_lbl); - ui_shake_cb = new QCheckBox(ui_form_layout_widget); - ui_shake_cb->setChecked(ao_app->is_shake_enabled()); + ui_stickypres_cb = new QCheckBox(ui_form_layout_widget); + ui_stickypres_cb->setChecked(ao_app->is_stickypres_enabled()); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_shake_cb); + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_stickypres_cb); - row += 1; - ui_effects_lbl = new QLabel(ui_form_layout_widget); - ui_effects_lbl->setText(tr("Allow Effects:")); - ui_effects_lbl->setToolTip(tr("Allows screen effects. Disable this if you have concerns or issues with photosensitivity and/or seizures.")); + QScrollArea *scroll = new QScrollArea; + scroll->setWidget(ui_form_layout_widget); + ui_gameplay_tab->setLayout(new QVBoxLayout); + ui_gameplay_tab->layout()->addWidget(scroll); + ui_gameplay_tab->show(); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_effects_lbl); + // Here we start the callwords tab. + ui_callwords_tab = new QWidget(); + ui_settings_tabs->addTab(ui_callwords_tab, tr("Callwords")); - ui_effects_cb = new QCheckBox(ui_form_layout_widget); - ui_effects_cb->setChecked(ao_app->is_effects_enabled()); + ui_callwords_widget = new QWidget(ui_callwords_tab); + ui_callwords_widget->setGeometry(QRect(10, 10, 361, 211)); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_effects_cb); + ui_callwords_layout = new QVBoxLayout(ui_callwords_widget); + ui_callwords_layout->setContentsMargins(0, 0, 0, 0); - row += 1; - ui_framenetwork_lbl = new QLabel(ui_form_layout_widget); - ui_framenetwork_lbl->setText(tr("Network Frame Effects:")); - ui_framenetwork_lbl->setToolTip(tr("Send screen-shaking, flashes and sounds as defined in the char.ini over the network. Only works for servers that support this functionality.")); + ui_callwords_textbox = new QPlainTextEdit(ui_callwords_widget); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth( + ui_callwords_textbox->sizePolicy().hasHeightForWidth()); + ui_callwords_textbox->setSizePolicy(sizePolicy); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_framenetwork_lbl); + // Let's fill the callwords text edit with the already present callwords. + ui_callwords_textbox->document()->clear(); + foreach (QString callword, p_ao_app->get_call_words()) { + ui_callwords_textbox->appendPlainText(callword); + } - ui_framenetwork_cb = new QCheckBox(ui_form_layout_widget); - ui_framenetwork_cb->setChecked(ao_app->is_frame_network_enabled()); + ui_callwords_layout->addWidget(ui_callwords_textbox); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_framenetwork_cb); + ui_callwords_explain_lbl = new QLabel(ui_callwords_widget); + ui_callwords_explain_lbl->setWordWrap(true); + ui_callwords_explain_lbl->setText( + tr("<html><head/><body>Enter as many callwords as you would like. These " + "are case insensitive. Make sure to leave every callword in its own " + "line!<br>Do not leave a line with a space at the end -- you will be " + "alerted everytime someone uses a space in their " + "messages.</body></html>")); - row += 1; - ui_colorlog_lbl = new QLabel(ui_form_layout_widget); - ui_colorlog_lbl->setText(tr("Colors in IC Log:")); - ui_colorlog_lbl->setToolTip(tr("Use the markup colors in the server IC chatlog.")); + ui_callwords_layout->addWidget(ui_callwords_explain_lbl); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_colorlog_lbl); + // The audio tab. + ui_audio_tab = new QWidget(); + ui_settings_tabs->addTab(ui_audio_tab, tr("Audio")); - ui_colorlog_cb = new QCheckBox(ui_form_layout_widget); - ui_colorlog_cb->setChecked(ao_app->is_colorlog_enabled()); + ui_audio_widget = new QWidget(ui_audio_tab); + ui_audio_widget->setGeometry(QRect(10, 10, 361, 211)); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_colorlog_cb); + ui_audio_layout = new QFormLayout(ui_audio_widget); + ui_audio_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft | + Qt::AlignVCenter); + ui_audio_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft | + Qt::AlignTop); + ui_audio_layout->setContentsMargins(0, 0, 0, 0); + row = 0; + + ui_audio_device_lbl = new QLabel(ui_audio_widget); + ui_audio_device_lbl->setText(tr("Audio device:")); + ui_audio_device_lbl->setToolTip(tr("Sets the audio device for all sounds.")); - row += 1; - ui_stickysounds_lbl = new QLabel(ui_form_layout_widget); - ui_stickysounds_lbl->setText(tr("Sticky Sounds:")); - ui_stickysounds_lbl->setToolTip(tr("Turn this on to prevent the sound dropdown from clearing the sound after playing it.")); + ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_audio_device_lbl); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_stickysounds_lbl); + ui_audio_device_combobox = new QComboBox(ui_audio_widget); - ui_stickysounds_cb = new QCheckBox(ui_form_layout_widget); - ui_stickysounds_cb->setChecked(ao_app->is_stickysounds_enabled()); + // Let's fill out the combobox with the available audio devices. Or don't if + // there is no audio + int a = 0; + if (needs_default_audiodev()) { - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_stickysounds_cb); - - row += 1; - ui_stickyeffects_lbl = new QLabel(ui_form_layout_widget); - ui_stickyeffects_lbl->setText(tr("Sticky Effects:")); - ui_stickyeffects_lbl->setToolTip(tr("Turn this on to prevent the effects dropdown from clearing the effect after playing it.")); - - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_stickyeffects_lbl); - - ui_stickyeffects_cb = new QCheckBox(ui_form_layout_widget); - ui_stickyeffects_cb->setChecked(ao_app->is_stickyeffects_enabled()); - - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_stickyeffects_cb); - - row += 1; - ui_stickypres_lbl = new QLabel(ui_form_layout_widget); - ui_stickypres_lbl->setText(tr("Sticky Preanims:")); - ui_stickypres_lbl->setToolTip(tr("Turn this on to prevent preanimation checkbox from clearing after playing the emote.")); - - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_stickypres_lbl); - - ui_stickypres_cb = new QCheckBox(ui_form_layout_widget); - ui_stickypres_cb->setChecked(ao_app->is_stickypres_enabled()); - - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_stickypres_cb); - - QScrollArea *scroll = new QScrollArea; - scroll->setWidget(ui_form_layout_widget); - ui_gameplay_tab->setLayout(new QVBoxLayout); - ui_gameplay_tab->layout()->addWidget(scroll); - ui_gameplay_tab->show(); - - // Here we start the callwords tab. - ui_callwords_tab = new QWidget(); - ui_settings_tabs->addTab(ui_callwords_tab, tr("Callwords")); - - ui_callwords_widget = new QWidget(ui_callwords_tab); - ui_callwords_widget->setGeometry(QRect(10, 10, 361, 211)); - - ui_callwords_layout = new QVBoxLayout(ui_callwords_widget); - ui_callwords_layout->setContentsMargins(0, 0, 0, 0); - - ui_callwords_textbox = new QPlainTextEdit(ui_callwords_widget); - QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(ui_callwords_textbox->sizePolicy().hasHeightForWidth()); - ui_callwords_textbox->setSizePolicy(sizePolicy); - - // Let's fill the callwords text edit with the already present callwords. - ui_callwords_textbox->document()->clear(); - foreach (QString callword, p_ao_app->get_call_words()) { - ui_callwords_textbox->appendPlainText(callword); - } - - ui_callwords_layout->addWidget(ui_callwords_textbox); - - ui_callwords_explain_lbl = new QLabel(ui_callwords_widget); - ui_callwords_explain_lbl->setWordWrap(true); - ui_callwords_explain_lbl->setText(tr("<html><head/><body>Enter as many callwords as you would like. These are case insensitive. Make sure to leave every callword in its own line!<br>Do not leave a line with a space at the end -- you will be alerted everytime someone uses a space in their messages.</body></html>")); - - ui_callwords_layout->addWidget(ui_callwords_explain_lbl); - - // The audio tab. - ui_audio_tab = new QWidget(); - ui_settings_tabs->addTab(ui_audio_tab, tr("Audio")); - - ui_audio_widget = new QWidget(ui_audio_tab); - ui_audio_widget->setGeometry(QRect(10, 10, 361, 211)); - - ui_audio_layout = new QFormLayout(ui_audio_widget); - ui_audio_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter); - ui_audio_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop); - ui_audio_layout->setContentsMargins(0, 0, 0, 0); - row = 0; - - ui_audio_device_lbl = new QLabel(ui_audio_widget); - ui_audio_device_lbl->setText(tr("Audio device:")); - ui_audio_device_lbl->setToolTip(tr("Sets the audio device for all sounds.")); - - ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_audio_device_lbl); - - ui_audio_device_combobox = new QComboBox(ui_audio_widget); - - // Let's fill out the combobox with the available audio devices. Or don't if there is no audio - int a = 0; - if (needs_default_audiodev()) { - - ui_audio_device_combobox->addItem("default"); - } + ui_audio_device_combobox->addItem("default"); + } #ifdef BASSAUDIO - BASS_DEVICEINFO info; - for (a = 0; BASS_GetDeviceInfo(a, &info); a++) { - ui_audio_device_combobox->addItem(info.name); - if (p_ao_app->get_audio_output_device() == info.name) - ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count() - 1); - } + BASS_DEVICEINFO info; + for (a = 0; BASS_GetDeviceInfo(a, &info); a++) { + ui_audio_device_combobox->addItem(info.name); + if (p_ao_app->get_audio_output_device() == info.name) + ui_audio_device_combobox->setCurrentIndex( + ui_audio_device_combobox->count() - 1); + } #elif defined QTAUDIO - foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) { - ui_audio_device_combobox->addItem(deviceInfo.deviceName()); - if (p_ao_app->get_audio_output_device() == deviceInfo.deviceName()) - ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count() - 1); - } + foreach (const QAudioDeviceInfo &deviceInfo, + QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) { + ui_audio_device_combobox->addItem(deviceInfo.deviceName()); + if (p_ao_app->get_audio_output_device() == deviceInfo.deviceName()) + ui_audio_device_combobox->setCurrentIndex( + ui_audio_device_combobox->count() - 1); + } #endif - ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_audio_device_combobox); - - row += 1; - ui_audio_volume_divider = new QFrame(ui_audio_widget); - ui_audio_volume_divider->setFrameShape(QFrame::HLine); - ui_audio_volume_divider->setFrameShadow(QFrame::Sunken); - - ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_audio_volume_divider); + ui_audio_layout->setWidget(row, QFormLayout::FieldRole, + ui_audio_device_combobox); - row += 1; - ui_music_volume_lbl = new QLabel(ui_audio_widget); - ui_music_volume_lbl->setText(tr("Music:")); - ui_music_volume_lbl->setToolTip(tr("Sets the music's default volume.")); + row += 1; + ui_audio_volume_divider = new QFrame(ui_audio_widget); + ui_audio_volume_divider->setFrameShape(QFrame::HLine); + ui_audio_volume_divider->setFrameShadow(QFrame::Sunken); - ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_music_volume_lbl); + ui_audio_layout->setWidget(row, QFormLayout::FieldRole, + ui_audio_volume_divider); - ui_music_volume_spinbox = new QSpinBox(ui_audio_widget); - ui_music_volume_spinbox->setValue(p_ao_app->get_default_music()); - ui_music_volume_spinbox->setMaximum(100); - ui_music_volume_spinbox->setSuffix("%"); + row += 1; + ui_music_volume_lbl = new QLabel(ui_audio_widget); + ui_music_volume_lbl->setText(tr("Music:")); + ui_music_volume_lbl->setToolTip(tr("Sets the music's default volume.")); + + ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_music_volume_lbl); - ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_music_volume_spinbox); + ui_music_volume_spinbox = new QSpinBox(ui_audio_widget); + ui_music_volume_spinbox->setValue(p_ao_app->get_default_music()); + ui_music_volume_spinbox->setMaximum(100); + ui_music_volume_spinbox->setSuffix("%"); - row += 1; - ui_sfx_volume_lbl = new QLabel(ui_audio_widget); - ui_sfx_volume_lbl->setText(tr("SFX:")); - ui_sfx_volume_lbl->setToolTip(tr("Sets the SFX's default volume. " - "Interjections and actual sound effects count as 'SFX'.")); - ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_sfx_volume_lbl); + ui_audio_layout->setWidget(row, QFormLayout::FieldRole, + ui_music_volume_spinbox); - ui_sfx_volume_spinbox = new QSpinBox(ui_audio_widget); - ui_sfx_volume_spinbox->setValue(p_ao_app->get_default_sfx()); - ui_sfx_volume_spinbox->setMaximum(100); - ui_sfx_volume_spinbox->setSuffix("%"); + row += 1; + ui_sfx_volume_lbl = new QLabel(ui_audio_widget); + ui_sfx_volume_lbl->setText(tr("SFX:")); + ui_sfx_volume_lbl->setToolTip( + tr("Sets the SFX's default volume. " + "Interjections and actual sound effects count as 'SFX'.")); + ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_sfx_volume_lbl); - ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_sfx_volume_spinbox); + ui_sfx_volume_spinbox = new QSpinBox(ui_audio_widget); + ui_sfx_volume_spinbox->setValue(p_ao_app->get_default_sfx()); + ui_sfx_volume_spinbox->setMaximum(100); + ui_sfx_volume_spinbox->setSuffix("%"); - row += 1; - ui_blips_volume_lbl = new QLabel(ui_audio_widget); - ui_blips_volume_lbl->setText(tr("Blips:")); - ui_blips_volume_lbl->setToolTip(tr("Sets the volume of the blips, the talking sound effects.")); + ui_audio_layout->setWidget(row, QFormLayout::FieldRole, + ui_sfx_volume_spinbox); - ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_blips_volume_lbl); + row += 1; + ui_blips_volume_lbl = new QLabel(ui_audio_widget); + ui_blips_volume_lbl->setText(tr("Blips:")); + ui_blips_volume_lbl->setToolTip( + tr("Sets the volume of the blips, the talking sound effects.")); + + ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_blips_volume_lbl); - ui_blips_volume_spinbox = new QSpinBox(ui_audio_widget); - ui_blips_volume_spinbox->setValue(p_ao_app->get_default_blip()); - ui_blips_volume_spinbox->setMaximum(100); - ui_blips_volume_spinbox->setSuffix("%"); + ui_blips_volume_spinbox = new QSpinBox(ui_audio_widget); + ui_blips_volume_spinbox->setValue(p_ao_app->get_default_blip()); + ui_blips_volume_spinbox->setMaximum(100); + ui_blips_volume_spinbox->setSuffix("%"); - ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_blips_volume_spinbox); + ui_audio_layout->setWidget(row, QFormLayout::FieldRole, + ui_blips_volume_spinbox); - row += 1; - ui_volume_blip_divider = new QFrame(ui_audio_widget); - ui_volume_blip_divider->setFrameShape(QFrame::HLine); - ui_volume_blip_divider->setFrameShadow(QFrame::Sunken); + row += 1; + ui_volume_blip_divider = new QFrame(ui_audio_widget); + ui_volume_blip_divider->setFrameShape(QFrame::HLine); + ui_volume_blip_divider->setFrameShadow(QFrame::Sunken); - ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_volume_blip_divider); + ui_audio_layout->setWidget(row, QFormLayout::FieldRole, + ui_volume_blip_divider); - row += 1; - ui_bliprate_lbl = new QLabel(ui_audio_widget); - ui_bliprate_lbl->setText(tr("Blip rate:")); - ui_bliprate_lbl->setToolTip(tr("Sets the delay between playing the blip sounds.")); + row += 1; + ui_bliprate_lbl = new QLabel(ui_audio_widget); + ui_bliprate_lbl->setText(tr("Blip rate:")); + ui_bliprate_lbl->setToolTip( + tr("Sets the delay between playing the blip sounds.")); - ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_bliprate_lbl); + ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_bliprate_lbl); - ui_bliprate_spinbox = new QSpinBox(ui_audio_widget); - ui_bliprate_spinbox->setValue(p_ao_app->read_blip_rate()); - ui_bliprate_spinbox->setMinimum(1); - ui_bliprate_spinbox->setToolTip(tr("Play a blip sound \"once per every X symbols\", where " - "X is the blip rate.")); + ui_bliprate_spinbox = new QSpinBox(ui_audio_widget); + ui_bliprate_spinbox->setValue(p_ao_app->read_blip_rate()); + ui_bliprate_spinbox->setMinimum(1); + ui_bliprate_spinbox->setToolTip( + tr("Play a blip sound \"once per every X symbols\", where " + "X is the blip rate.")); - ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_bliprate_spinbox); + ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_bliprate_spinbox); - row += 1; - ui_blank_blips_lbl = new QLabel(ui_audio_widget); - ui_blank_blips_lbl->setText(tr("Blank blips:")); - ui_blank_blips_lbl->setToolTip(tr("If true, the game will play a blip sound even " - "when a space is 'being said'.")); + row += 1; + ui_blank_blips_lbl = new QLabel(ui_audio_widget); + ui_blank_blips_lbl->setText(tr("Blank blips:")); + ui_blank_blips_lbl->setToolTip( + tr("If true, the game will play a blip sound even " + "when a space is 'being said'.")); - ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_blank_blips_lbl); + ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_blank_blips_lbl); - ui_blank_blips_cb = new QCheckBox(ui_audio_widget); - ui_blank_blips_cb->setChecked(p_ao_app->get_blank_blip()); + ui_blank_blips_cb = new QCheckBox(ui_audio_widget); + ui_blank_blips_cb->setChecked(p_ao_app->get_blank_blip()); - ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_blank_blips_cb); + ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_blank_blips_cb); - row += 1; - ui_loopsfx_lbl = new QLabel(ui_audio_widget); - ui_loopsfx_lbl->setText(tr("Enable Looping SFX:")); - ui_loopsfx_lbl->setToolTip(tr("If true, the game will allow looping sound effects to play on preanimations.")); + row += 1; + ui_loopsfx_lbl = new QLabel(ui_audio_widget); + ui_loopsfx_lbl->setText(tr("Enable Looping SFX:")); + ui_loopsfx_lbl->setToolTip(tr("If true, the game will allow looping sound " + "effects to play on preanimations.")); - ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_loopsfx_lbl); + ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_loopsfx_lbl); - ui_loopsfx_cb = new QCheckBox(ui_audio_widget); - ui_loopsfx_cb->setChecked(p_ao_app->get_looping_sfx()); + ui_loopsfx_cb = new QCheckBox(ui_audio_widget); + ui_loopsfx_cb->setChecked(p_ao_app->get_looping_sfx()); - ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_loopsfx_cb); + ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_loopsfx_cb); - row += 1; - ui_objectmusic_lbl = new QLabel(ui_audio_widget); - ui_objectmusic_lbl->setText(tr("Kill Music On Objection:")); - ui_objectmusic_lbl->setToolTip(tr("If true, AO2 will stop the music for you when you or someone else does 'Objection!'.")); + row += 1; + ui_objectmusic_lbl = new QLabel(ui_audio_widget); + ui_objectmusic_lbl->setText(tr("Kill Music On Objection:")); + ui_objectmusic_lbl->setToolTip( + tr("If true, AO2 will stop the music for you when you or someone else " + "does 'Objection!'.")); - ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_objectmusic_lbl); + ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_objectmusic_lbl); - ui_objectmusic_cb = new QCheckBox(ui_audio_widget); - ui_objectmusic_cb->setChecked(p_ao_app->objection_stop_music()); + ui_objectmusic_cb = new QCheckBox(ui_audio_widget); + ui_objectmusic_cb->setChecked(p_ao_app->objection_stop_music()); - ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_objectmusic_cb); + ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_objectmusic_cb); - // The casing tab! - ui_casing_tab = new QWidget(); - ui_settings_tabs->addTab(ui_casing_tab, tr("Casing")); + // The casing tab! + ui_casing_tab = new QWidget(); + ui_settings_tabs->addTab(ui_casing_tab, tr("Casing")); - ui_casing_widget = new QWidget(ui_casing_tab); - ui_casing_widget->setGeometry(QRect(10, 10, 361, 211)); + ui_casing_widget = new QWidget(ui_casing_tab); + ui_casing_widget->setGeometry(QRect(10, 10, 361, 211)); - ui_casing_layout = new QFormLayout(ui_casing_widget); - ui_casing_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter); - ui_casing_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop); - ui_casing_layout->setContentsMargins(0, 0, 0, 0); - row = 0; + ui_casing_layout = new QFormLayout(ui_casing_widget); + ui_casing_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft | + Qt::AlignVCenter); + ui_casing_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft | + Qt::AlignTop); + ui_casing_layout->setContentsMargins(0, 0, 0, 0); + row = 0; - // -- SERVER SUPPORTS CASING + // -- SERVER SUPPORTS CASING - ui_casing_supported_lbl = new QLabel(ui_casing_widget); - if (ao_app->casing_alerts_enabled) - ui_casing_supported_lbl->setText(tr("This server supports case alerts.")); - else - ui_casing_supported_lbl->setText(tr("This server does not support case alerts.")); - ui_casing_supported_lbl->setToolTip(tr("Pretty self-explanatory.")); + ui_casing_supported_lbl = new QLabel(ui_casing_widget); + if (ao_app->casing_alerts_enabled) + ui_casing_supported_lbl->setText(tr("This server supports case alerts.")); + else + ui_casing_supported_lbl->setText( + tr("This server does not support case alerts.")); + ui_casing_supported_lbl->setToolTip(tr("Pretty self-explanatory.")); - ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_supported_lbl); + ui_casing_layout->setWidget(row, QFormLayout::FieldRole, + ui_casing_supported_lbl); - // -- CASE ANNOUNCEMENTS + // -- CASE ANNOUNCEMENTS - row += 1; - ui_casing_enabled_lbl = new QLabel(ui_casing_widget); - ui_casing_enabled_lbl->setText(tr("Casing:")); - ui_casing_enabled_lbl->setToolTip(tr("If checked, you will get alerts about case " - "announcements.")); + row += 1; + ui_casing_enabled_lbl = new QLabel(ui_casing_widget); + ui_casing_enabled_lbl->setText(tr("Casing:")); + ui_casing_enabled_lbl->setToolTip( + tr("If checked, you will get alerts about case " + "announcements.")); - ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_enabled_lbl); + ui_casing_layout->setWidget(row, QFormLayout::LabelRole, + ui_casing_enabled_lbl); - ui_casing_enabled_cb = new QCheckBox(ui_casing_widget); - ui_casing_enabled_cb->setChecked(ao_app->get_casing_enabled()); + ui_casing_enabled_cb = new QCheckBox(ui_casing_widget); + ui_casing_enabled_cb->setChecked(ao_app->get_casing_enabled()); - ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_enabled_cb); + ui_casing_layout->setWidget(row, QFormLayout::FieldRole, + ui_casing_enabled_cb); - // -- DEFENSE ANNOUNCEMENTS + // -- DEFENSE ANNOUNCEMENTS - row += 1; - ui_casing_def_lbl = new QLabel(ui_casing_widget); - ui_casing_def_lbl->setText(tr("Defense:")); - ui_casing_def_lbl->setToolTip(tr("If checked, you will get alerts about case " - "announcements if a defense spot is open.")); + row += 1; + ui_casing_def_lbl = new QLabel(ui_casing_widget); + ui_casing_def_lbl->setText(tr("Defense:")); + ui_casing_def_lbl->setToolTip(tr("If checked, you will get alerts about case " + "announcements if a defense spot is open.")); - ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_def_lbl); + ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_def_lbl); - ui_casing_def_cb = new QCheckBox(ui_casing_widget); - ui_casing_def_cb->setChecked(ao_app->get_casing_defence_enabled()); + ui_casing_def_cb = new QCheckBox(ui_casing_widget); + ui_casing_def_cb->setChecked(ao_app->get_casing_defence_enabled()); - ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_def_cb); + ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_def_cb); - // -- PROSECUTOR ANNOUNCEMENTS + // -- PROSECUTOR ANNOUNCEMENTS - row += 1; - ui_casing_pro_lbl = new QLabel(ui_casing_widget); - ui_casing_pro_lbl->setText(tr("Prosecution:")); - ui_casing_pro_lbl->setToolTip(tr("If checked, you will get alerts about case " - "announcements if a prosecutor spot is open.")); + row += 1; + ui_casing_pro_lbl = new QLabel(ui_casing_widget); + ui_casing_pro_lbl->setText(tr("Prosecution:")); + ui_casing_pro_lbl->setToolTip( + tr("If checked, you will get alerts about case " + "announcements if a prosecutor spot is open.")); - ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_pro_lbl); + ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_pro_lbl); - ui_casing_pro_cb = new QCheckBox(ui_casing_widget); - ui_casing_pro_cb->setChecked(ao_app->get_casing_prosecution_enabled()); + ui_casing_pro_cb = new QCheckBox(ui_casing_widget); + ui_casing_pro_cb->setChecked(ao_app->get_casing_prosecution_enabled()); - ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_pro_cb); + ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_pro_cb); - // -- JUDGE ANNOUNCEMENTS + // -- JUDGE ANNOUNCEMENTS - row += 1; - ui_casing_jud_lbl = new QLabel(ui_casing_widget); - ui_casing_jud_lbl->setText(tr("Judge:")); - ui_casing_jud_lbl->setToolTip(tr("If checked, you will get alerts about case " - "announcements if the judge spot is open.")); + row += 1; + ui_casing_jud_lbl = new QLabel(ui_casing_widget); + ui_casing_jud_lbl->setText(tr("Judge:")); + ui_casing_jud_lbl->setToolTip(tr("If checked, you will get alerts about case " + "announcements if the judge spot is open.")); - ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_jud_lbl); + ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_jud_lbl); - ui_casing_jud_cb = new QCheckBox(ui_casing_widget); - ui_casing_jud_cb->setChecked(ao_app->get_casing_judge_enabled()); + ui_casing_jud_cb = new QCheckBox(ui_casing_widget); + ui_casing_jud_cb->setChecked(ao_app->get_casing_judge_enabled()); - ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_jud_cb); + ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_jud_cb); - // -- JUROR ANNOUNCEMENTS + // -- JUROR ANNOUNCEMENTS - row += 1; - ui_casing_jur_lbl = new QLabel(ui_casing_widget); - ui_casing_jur_lbl->setText(tr("Juror:")); - ui_casing_jur_lbl->setToolTip(tr("If checked, you will get alerts about case " - "announcements if a juror spot is open.")); + row += 1; + ui_casing_jur_lbl = new QLabel(ui_casing_widget); + ui_casing_jur_lbl->setText(tr("Juror:")); + ui_casing_jur_lbl->setToolTip(tr("If checked, you will get alerts about case " + "announcements if a juror spot is open.")); - ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_jur_lbl); + ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_jur_lbl); - ui_casing_jur_cb = new QCheckBox(ui_casing_widget); - ui_casing_jur_cb->setChecked(ao_app->get_casing_juror_enabled()); + ui_casing_jur_cb = new QCheckBox(ui_casing_widget); + ui_casing_jur_cb->setChecked(ao_app->get_casing_juror_enabled()); - ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_jur_cb); + ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_jur_cb); - // -- STENO ANNOUNCEMENTS + // -- STENO ANNOUNCEMENTS - row += 1; - ui_casing_steno_lbl = new QLabel(ui_casing_widget); - ui_casing_steno_lbl->setText(tr("Stenographer:")); - ui_casing_steno_lbl->setToolTip(tr("If checked, you will get alerts about case " - "announcements if a stenographer spot is open.")); + row += 1; + ui_casing_steno_lbl = new QLabel(ui_casing_widget); + ui_casing_steno_lbl->setText(tr("Stenographer:")); + ui_casing_steno_lbl->setToolTip( + tr("If checked, you will get alerts about case " + "announcements if a stenographer spot is open.")); - ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_steno_lbl); + ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_steno_lbl); - ui_casing_steno_cb = new QCheckBox(ui_casing_widget); - ui_casing_steno_cb->setChecked(ao_app->get_casing_steno_enabled()); + ui_casing_steno_cb = new QCheckBox(ui_casing_widget); + ui_casing_steno_cb->setChecked(ao_app->get_casing_steno_enabled()); - ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_steno_cb); + ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_steno_cb); - // -- CM ANNOUNCEMENTS + // -- CM ANNOUNCEMENTS - row += 1; - ui_casing_cm_lbl = new QLabel(ui_casing_widget); - ui_casing_cm_lbl->setText(tr("CM:")); - ui_casing_cm_lbl->setToolTip(tr("If checked, you will appear amongst the potential " - "CMs on the server.")); + row += 1; + ui_casing_cm_lbl = new QLabel(ui_casing_widget); + ui_casing_cm_lbl->setText(tr("CM:")); + ui_casing_cm_lbl->setToolTip( + tr("If checked, you will appear amongst the potential " + "CMs on the server.")); - ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_cm_lbl); + ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_cm_lbl); - ui_casing_cm_cb = new QCheckBox(ui_casing_widget); - ui_casing_cm_cb->setChecked(ao_app->get_casing_cm_enabled()); + ui_casing_cm_cb = new QCheckBox(ui_casing_widget); + ui_casing_cm_cb->setChecked(ao_app->get_casing_cm_enabled()); - ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_cm_cb); + ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_cm_cb); - // -- CM CASES ANNOUNCEMENTS + // -- CM CASES ANNOUNCEMENTS - row += 1; - ui_casing_cm_cases_lbl = new QLabel(ui_casing_widget); - ui_casing_cm_cases_lbl->setText(tr("Hosting cases:")); - ui_casing_cm_cases_lbl->setToolTip(tr("If you're a CM, enter what cases you are " - "willing to host.")); + row += 1; + ui_casing_cm_cases_lbl = new QLabel(ui_casing_widget); + ui_casing_cm_cases_lbl->setText(tr("Hosting cases:")); + ui_casing_cm_cases_lbl->setToolTip( + tr("If you're a CM, enter what cases you are " + "willing to host.")); - ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_casing_cm_cases_lbl); + ui_casing_layout->setWidget(row, QFormLayout::LabelRole, + ui_casing_cm_cases_lbl); - ui_casing_cm_cases_textbox = new QLineEdit(ui_casing_widget); - ui_casing_cm_cases_textbox->setText(ao_app->get_casing_can_host_cases()); + ui_casing_cm_cases_textbox = new QLineEdit(ui_casing_widget); + ui_casing_cm_cases_textbox->setText(ao_app->get_casing_can_host_cases()); - ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_casing_cm_cases_textbox); + ui_casing_layout->setWidget(row, QFormLayout::FieldRole, + ui_casing_cm_cases_textbox); - // When we're done, we should continue the updates! - setUpdatesEnabled(true); + // When we're done, we should continue the updates! + setUpdatesEnabled(true); } void AOOptionsDialog::save_pressed() { - // Save everything into the config.ini. - QSettings *configini = ao_app->configini; - - configini->setValue("theme", ui_theme_combobox->currentText()); - configini->setValue("log_goes_downwards", ui_downwards_cb->isChecked()); - configini->setValue("log_maximum", ui_length_spinbox->value()); - configini->setValue("default_username", ui_username_textbox->text()); - configini->setValue("show_custom_shownames", ui_showname_cb->isChecked()); - configini->setValue("master", ui_ms_textbox->text()); - configini->setValue("discord", ui_discord_cb->isChecked()); - configini->setValue("language", ui_language_combobox->currentText().left(2)); - configini->setValue("shake", ui_shake_cb->isChecked()); - configini->setValue("effects", ui_effects_cb->isChecked()); - configini->setValue("framenetwork", ui_framenetwork_cb->isChecked()); - configini->setValue("colorlog", ui_colorlog_cb->isChecked()); - configini->setValue("stickysounds", ui_stickysounds_cb->isChecked()); - configini->setValue("stickyeffects", ui_stickyeffects_cb->isChecked()); - configini->setValue("stickypres", ui_stickypres_cb->isChecked()); - - QFile *callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini"); - - if (callwordsini->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { - QTextStream out(callwordsini); - out << ui_callwords_textbox->toPlainText(); - callwordsini->close(); - } - - configini->setValue("default_audio_device", ui_audio_device_combobox->currentText()); - configini->setValue("default_music", ui_music_volume_spinbox->value()); - configini->setValue("default_sfx", ui_sfx_volume_spinbox->value()); - configini->setValue("default_blip", ui_blips_volume_spinbox->value()); - configini->setValue("blip_rate", ui_bliprate_spinbox->value()); - configini->setValue("blank_blip", ui_blank_blips_cb->isChecked()); - configini->setValue("looping_sfx", ui_loopsfx_cb->isChecked()); - configini->setValue("objection_stop_music", ui_objectmusic_cb->isChecked()); - - configini->setValue("casing_enabled", ui_casing_enabled_cb->isChecked()); - configini->setValue("casing_defence_enabled", ui_casing_def_cb->isChecked()); - configini->setValue("casing_prosecution_enabled", ui_casing_pro_cb->isChecked()); - configini->setValue("casing_judge_enabled", ui_casing_jud_cb->isChecked()); - configini->setValue("casing_juror_enabled", ui_casing_jur_cb->isChecked()); - configini->setValue("casing_steno_enabled", ui_casing_steno_cb->isChecked()); - configini->setValue("casing_cm_enabled", ui_casing_cm_cb->isChecked()); - configini->setValue("casing_can_host_cases", ui_casing_cm_cases_textbox->text()); - + // Save everything into the config.ini. + QSettings *configini = ao_app->configini; + + configini->setValue("theme", ui_theme_combobox->currentText()); + configini->setValue("log_goes_downwards", ui_downwards_cb->isChecked()); + configini->setValue("log_maximum", ui_length_spinbox->value()); + configini->setValue("default_username", ui_username_textbox->text()); + configini->setValue("show_custom_shownames", ui_showname_cb->isChecked()); + configini->setValue("master", ui_ms_textbox->text()); + configini->setValue("discord", ui_discord_cb->isChecked()); + configini->setValue("language", ui_language_combobox->currentText().left(2)); + configini->setValue("shake", ui_shake_cb->isChecked()); + configini->setValue("effects", ui_effects_cb->isChecked()); + configini->setValue("framenetwork", ui_framenetwork_cb->isChecked()); + configini->setValue("colorlog", ui_colorlog_cb->isChecked()); + configini->setValue("stickysounds", ui_stickysounds_cb->isChecked()); + configini->setValue("stickyeffects", ui_stickyeffects_cb->isChecked()); + configini->setValue("stickypres", ui_stickypres_cb->isChecked()); + + QFile *callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini"); + + if (callwordsini->open(QIODevice::WriteOnly | QIODevice::Truncate | + QIODevice::Text)) { + QTextStream out(callwordsini); + out << ui_callwords_textbox->toPlainText(); callwordsini->close(); - done(0); + } + + configini->setValue("default_audio_device", + ui_audio_device_combobox->currentText()); + configini->setValue("default_music", ui_music_volume_spinbox->value()); + configini->setValue("default_sfx", ui_sfx_volume_spinbox->value()); + configini->setValue("default_blip", ui_blips_volume_spinbox->value()); + configini->setValue("blip_rate", ui_bliprate_spinbox->value()); + configini->setValue("blank_blip", ui_blank_blips_cb->isChecked()); + configini->setValue("looping_sfx", ui_loopsfx_cb->isChecked()); + configini->setValue("objection_stop_music", ui_objectmusic_cb->isChecked()); + + configini->setValue("casing_enabled", ui_casing_enabled_cb->isChecked()); + configini->setValue("casing_defence_enabled", ui_casing_def_cb->isChecked()); + configini->setValue("casing_prosecution_enabled", + ui_casing_pro_cb->isChecked()); + configini->setValue("casing_judge_enabled", ui_casing_jud_cb->isChecked()); + configini->setValue("casing_juror_enabled", ui_casing_jur_cb->isChecked()); + configini->setValue("casing_steno_enabled", ui_casing_steno_cb->isChecked()); + configini->setValue("casing_cm_enabled", ui_casing_cm_cb->isChecked()); + configini->setValue("casing_can_host_cases", + ui_casing_cm_cases_textbox->text()); + + callwordsini->close(); + done(0); } -void AOOptionsDialog::discard_pressed() -{ - done(0); -} +void AOOptionsDialog::discard_pressed() { done(0); } #if (defined(_WIN32) || defined(_WIN64)) -bool AOOptionsDialog::needs_default_audiodev() -{ - return true; -} +bool AOOptionsDialog::needs_default_audiodev() { return true; } #elif (defined(LINUX) || defined(__linux__)) -bool AOOptionsDialog::needs_default_audiodev() -{ - return false; -} +bool AOOptionsDialog::needs_default_audiodev() { return false; } #elif defined __APPLE__ -bool AOOptionsDialog::needs_default_audiodev() -{ - return true; -} +bool AOOptionsDialog::needs_default_audiodev() { return true; } #else #error This operating system is not supported. #endif diff --git a/src/aopacket.cpp b/src/aopacket.cpp index 457cc65c..6afd39e7 100644 --- a/src/aopacket.cpp +++ b/src/aopacket.cpp @@ -4,73 +4,77 @@ AOPacket::AOPacket(QString p_packet_string) { - QStringList packet_contents = p_packet_string.split("#"); + QStringList packet_contents = p_packet_string.split("#"); - m_header = packet_contents.at(0); + m_header = packet_contents.at(0); - for (int n_string = 1; n_string < packet_contents.size() - 1; ++n_string) { - m_contents.append(packet_contents.at(n_string)); - } + for (int n_string = 1; n_string < packet_contents.size() - 1; ++n_string) { + m_contents.append(packet_contents.at(n_string)); + } } AOPacket::AOPacket(QString p_header, QStringList &p_contents) { - m_header = p_header; - m_contents = p_contents; + m_header = p_header; + m_contents = p_contents; } -AOPacket::~AOPacket() -{ -} +AOPacket::~AOPacket() {} QString AOPacket::to_string() { - QString f_string = m_header; + QString f_string = m_header; - for (QString i_string : m_contents) { - f_string += ("#" + i_string); - } + for (QString i_string : m_contents) { + f_string += ("#" + i_string); + } - f_string += "#%"; + f_string += "#%"; - if (encrypted) - return "#" + f_string; - else - return f_string; + if (encrypted) + return "#" + f_string; + else + return f_string; } void AOPacket::encrypt_header(unsigned int p_key) { - m_header = fanta_encrypt(m_header, p_key); + m_header = fanta_encrypt(m_header, p_key); - encrypted = true; + encrypted = true; } void AOPacket::decrypt_header(unsigned int p_key) { - m_header = fanta_decrypt(m_header, p_key); + m_header = fanta_decrypt(m_header, p_key); - encrypted = false; + encrypted = false; } void AOPacket::net_encode() { - for (int n_element = 0; n_element < m_contents.size(); ++n_element) { - QString f_element = m_contents.at(n_element); - f_element.replace("#", "<num>").replace("%", "<percent>").replace("$", "<dollar>").replace("&", "<and>"); - - m_contents.removeAt(n_element); - m_contents.insert(n_element, f_element); - } + for (int n_element = 0; n_element < m_contents.size(); ++n_element) { + QString f_element = m_contents.at(n_element); + f_element.replace("#", "<num>") + .replace("%", "<percent>") + .replace("$", "<dollar>") + .replace("&", "<and>"); + + m_contents.removeAt(n_element); + m_contents.insert(n_element, f_element); + } } void AOPacket::net_decode() { - for (int n_element = 0; n_element < m_contents.size(); ++n_element) { - QString f_element = m_contents.at(n_element); - f_element.replace("<num>", "#").replace("<percent>", "%").replace("<dollar>", "$").replace("<and>", "&"); - - m_contents.removeAt(n_element); - m_contents.insert(n_element, f_element); - } + for (int n_element = 0; n_element < m_contents.size(); ++n_element) { + QString f_element = m_contents.at(n_element); + f_element.replace("<num>", "#") + .replace("<percent>", "%") + .replace("<dollar>", "$") + .replace("<and>", "&"); + + m_contents.removeAt(n_element); + m_contents.insert(n_element, f_element); + } } diff --git a/src/aoscene.cpp b/src/aoscene.cpp index 64f741a4..094d7a54 100644 --- a/src/aoscene.cpp +++ b/src/aoscene.cpp @@ -4,119 +4,125 @@ AOScene::AOScene(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent) { - m_parent = parent; - ao_app = p_ao_app; - m_movie = new QMovie(this); - last_image = ""; + m_parent = parent; + ao_app = p_ao_app; + m_movie = new QMovie(this); + last_image = ""; } void AOScene::set_image(QString p_image) { - QString background_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image)); - if (!file_exists(background_path)) //If image is missing, clear current image - { - this->clear(); - this->setMovie(nullptr); - - m_movie->stop(); - last_image = ""; - return; - } - - if (file_exists(background_path) && background_path == last_image) - return; - + QString background_path = + ao_app->get_image_suffix(ao_app->get_background_path(p_image)); + if (!file_exists(background_path)) // If image is missing, clear current image + { this->clear(); this->setMovie(nullptr); m_movie->stop(); - m_movie->setFileName(background_path); - - if (m_movie->isValid() && m_movie->frameCount() > 1) { - m_movie->jumpToNextFrame(); - float scale_factor = static_cast<float>(f_h) / static_cast<float>(m_movie->frameRect().height()); - //preserve aspect ratio - int n_w = static_cast<int>(m_movie->frameRect().width() * scale_factor); - int n_h = static_cast<int>(m_movie->frameRect().height() * scale_factor); - - m_movie->setScaledSize(QSize(n_w, n_h)); - this->resize(m_movie->scaledSize()); - this->setMovie(m_movie); - QLabel::move(x + (f_w - n_w) / 2, y + (f_h - n_h) / 2); //Center - m_movie->start(); - } - else { - QPixmap background(background_path); - auto transform_mode = Qt::FastTransformation; - if (background.height() > f_h) //We are downscaling, use anti-aliasing. - transform_mode = Qt::SmoothTransformation; - - background = background.scaledToHeight(f_h, transform_mode); - this->resize(background.size()); - this->setPixmap(background); - QLabel::move(x + (f_w - background.width()) / 2, y + (f_h - background.height()) / 2); //Always center horizontally, always center vertically - } - last_image = background_path; + last_image = ""; + return; + } + + if (file_exists(background_path) && background_path == last_image) + return; + + this->clear(); + this->setMovie(nullptr); + + m_movie->stop(); + m_movie->setFileName(background_path); + + if (m_movie->isValid() && m_movie->frameCount() > 1) { + m_movie->jumpToNextFrame(); + float scale_factor = static_cast<float>(f_h) / + static_cast<float>(m_movie->frameRect().height()); + // preserve aspect ratio + int n_w = static_cast<int>(m_movie->frameRect().width() * scale_factor); + int n_h = static_cast<int>(m_movie->frameRect().height() * scale_factor); + + m_movie->setScaledSize(QSize(n_w, n_h)); + this->resize(m_movie->scaledSize()); + this->setMovie(m_movie); + QLabel::move(x + (f_w - n_w) / 2, y + (f_h - n_h) / 2); // Center + m_movie->start(); + } + else { + QPixmap background(background_path); + auto transform_mode = Qt::FastTransformation; + if (background.height() > f_h) // We are downscaling, use anti-aliasing. + transform_mode = Qt::SmoothTransformation; + + background = background.scaledToHeight(f_h, transform_mode); + this->resize(background.size()); + this->setPixmap(background); + QLabel::move( + x + (f_w - background.width()) / 2, + y + (f_h - background.height()) / + 2); // Always center horizontally, always center vertically + } + last_image = background_path; } void AOScene::set_legacy_desk(QString p_image) { - QString desk_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image)); - if (!file_exists(desk_path)) //If image is missing, clear current image - { - this->clear(); - this->setMovie(nullptr); + QString desk_path = + ao_app->get_image_suffix(ao_app->get_background_path(p_image)); + if (!file_exists(desk_path)) // If image is missing, clear current image + { + this->clear(); + this->setMovie(nullptr); + + m_movie->stop(); + last_image = ""; + return; + } - m_movie->stop(); - last_image = ""; - return; - } + if (file_exists(desk_path) && desk_path == last_image) + return; - if (file_exists(desk_path) && desk_path == last_image) - return; + QPixmap f_desk(desk_path); - QPixmap f_desk(desk_path); + // vanilla desks vary in both width and height. in order to make that work + // with viewport rescaling, some INTENSE math is needed. + int vp_width = m_parent->width(); + int vp_height = m_parent->height(); - //vanilla desks vary in both width and height. in order to make that work with viewport rescaling, - //some INTENSE math is needed. - int vp_width = m_parent->width(); - int vp_height = m_parent->height(); + double h_modifier = vp_height / 192; - double h_modifier = vp_height / 192; + int final_h = static_cast<int>(h_modifier * f_desk.height()); - int final_h = static_cast<int>(h_modifier * f_desk.height()); + this->clear(); + this->setMovie(nullptr); - this->clear(); - this->setMovie(nullptr); + m_movie->stop(); + m_movie->setFileName(desk_path); - m_movie->stop(); - m_movie->setFileName(desk_path); - - m_movie->setScaledSize(QSize(vp_width, final_h)); - - if (m_movie->isValid() && m_movie->frameCount() > 1) { - this->setMovie(m_movie); - m_movie->start(); - } - else { - this->resize(vp_width, final_h); - this->setPixmap(f_desk.scaled(vp_width, final_h)); - } - last_image = desk_path; + m_movie->setScaledSize(QSize(vp_width, final_h)); + + if (m_movie->isValid() && m_movie->frameCount() > 1) { + this->setMovie(m_movie); + m_movie->start(); + } + else { + this->resize(vp_width, final_h); + this->setPixmap(f_desk.scaled(vp_width, final_h)); + } + last_image = desk_path; } void AOScene::combo_resize(int w, int h) { - QSize f_size(w, h); - f_w = w; - f_h = h; - this->resize(f_size); + QSize f_size(w, h); + f_w = w; + f_h = h; + this->resize(f_size); } void AOScene::move(int ax, int ay) { - x = ax; - y = ay; - QLabel::move(x, y); + x = ax; + y = ay; + QLabel::move(x, y); } diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 4b375a46..3afd704f 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -1,181 +1,179 @@ #include "aosfxplayer.h" #include "file_functions.h" -#if defined(BASSAUDIO) //Using bass.dll for sfx +#if defined(BASSAUDIO) // Using bass.dll for sfx AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) { - m_parent = parent; - ao_app = p_ao_app; + m_parent = parent; + ao_app = p_ao_app; } void AOSfxPlayer::clear() { - for (int n_stream = 0; n_stream < m_channelmax; ++n_stream) { - BASS_ChannelStop(m_stream_list[n_stream]); - } - set_volume_internal(m_volume); + for (int n_stream = 0; n_stream < m_channelmax; ++n_stream) { + BASS_ChannelStop(m_stream_list[n_stream]); + } + set_volume_internal(m_volume); } void AOSfxPlayer::loop_clear() { - for (int n_stream = 0; n_stream < m_channelmax; ++n_stream) { - if ((BASS_ChannelFlags(m_stream_list[n_stream], 0, 0) & BASS_SAMPLE_LOOP)) - BASS_ChannelStop(m_stream_list[n_stream]); - } - set_volume_internal(m_volume); + for (int n_stream = 0; n_stream < m_channelmax; ++n_stream) { + if ((BASS_ChannelFlags(m_stream_list[n_stream], 0, 0) & BASS_SAMPLE_LOOP)) + BASS_ChannelStop(m_stream_list[n_stream]); + } + set_volume_internal(m_volume); } -void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout, int channel) +void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout, + int channel) { - if (channel == -1) { - if (BASS_ChannelIsActive(m_stream_list[channel]) == BASS_ACTIVE_PLAYING) - m_channel = (m_channel + 1) % m_channelmax; - channel = m_channel; - } + if (channel == -1) { + if (BASS_ChannelIsActive(m_stream_list[channel]) == BASS_ACTIVE_PLAYING) + m_channel = (m_channel + 1) % m_channelmax; + channel = m_channel; + } - BASS_ChannelStop(m_stream_list[channel]); + BASS_ChannelStop(m_stream_list[channel]); - QString misc_path = ""; - QString char_path = ""; - QString sound_path = ao_app->get_sfx_suffix(ao_app->get_sounds_path(p_sfx)); + QString misc_path = ""; + QString char_path = ""; + QString sound_path = ao_app->get_sfx_suffix(ao_app->get_sounds_path(p_sfx)); - if (shout != "") - misc_path = ao_app->get_sfx_suffix(ao_app->get_base_path() + "misc/" + shout + "/" + p_sfx); - if (p_char != "") - char_path = ao_app->get_sfx_suffix(ao_app->get_character_path(p_char, p_sfx)); + if (shout != "") + misc_path = ao_app->get_sfx_suffix(ao_app->get_base_path() + "misc/" + + shout + "/" + p_sfx); + if (p_char != "") + char_path = + ao_app->get_sfx_suffix(ao_app->get_character_path(p_char, p_sfx)); - QString f_path; + QString f_path; - if (file_exists(char_path)) - f_path = char_path; - else if (file_exists(misc_path)) - f_path = misc_path; - else - f_path = sound_path; + if (file_exists(char_path)) + f_path = char_path; + else if (file_exists(misc_path)) + f_path = misc_path; + else + f_path = sound_path; - if (f_path.endsWith(".opus")) - m_stream_list[channel] = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); - else - m_stream_list[channel] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); + if (f_path.endsWith(".opus")) + m_stream_list[channel] = BASS_OPUS_StreamCreateFile( + FALSE, f_path.utf16(), 0, 0, + BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); + else + m_stream_list[channel] = BASS_StreamCreateFile( + FALSE, f_path.utf16(), 0, 0, + BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); - set_volume_internal(m_volume); + set_volume_internal(m_volume); - if (ao_app->get_audio_output_device() != "default") - BASS_ChannelSetDevice(m_stream_list[m_channel], BASS_GetDevice()); - BASS_ChannelPlay(m_stream_list[m_channel], false); + if (ao_app->get_audio_output_device() != "default") + BASS_ChannelSetDevice(m_stream_list[m_channel], BASS_GetDevice()); + BASS_ChannelPlay(m_stream_list[m_channel], false); } void AOSfxPlayer::stop(int channel) { - if (channel == -1) { - channel = m_channel; - } - BASS_ChannelStop(m_stream_list[channel]); + if (channel == -1) { + channel = m_channel; + } + BASS_ChannelStop(m_stream_list[channel]); } void AOSfxPlayer::set_volume(qreal p_value) { - m_volume = p_value / 100; - set_volume_internal(m_volume); + m_volume = p_value / 100; + set_volume_internal(m_volume); } void AOSfxPlayer::set_volume_internal(qreal p_value) { - float volume = static_cast<float>(p_value); - for (int n_stream = 0; n_stream < m_channelmax; ++n_stream) { - BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); - } + float volume = static_cast<float>(p_value); + for (int n_stream = 0; n_stream < m_channelmax; ++n_stream) { + BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); + } } void AOSfxPlayer::set_looping(bool toggle, int channel) { - if (channel == -1) { - channel = m_channel; - } - m_looping = toggle; - if (BASS_ChannelFlags(m_stream_list[channel], 0, 0) & BASS_SAMPLE_LOOP) { - if (m_looping == false) - BASS_ChannelFlags(m_stream_list[channel], 0, BASS_SAMPLE_LOOP); // remove the LOOP flag - } - else { - if (m_looping == true) - BASS_ChannelFlags(m_stream_list[channel], BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set the LOOP flag - } -} -#elif defined(QTAUDIO) //Using Qt's QSoundEffect class + if (channel == -1) { + channel = m_channel; + } + m_looping = toggle; + if (BASS_ChannelFlags(m_stream_list[channel], 0, 0) & BASS_SAMPLE_LOOP) { + if (m_looping == false) + BASS_ChannelFlags(m_stream_list[channel], 0, + BASS_SAMPLE_LOOP); // remove the LOOP flag + } + else { + if (m_looping == true) + BASS_ChannelFlags(m_stream_list[channel], BASS_SAMPLE_LOOP, + BASS_SAMPLE_LOOP); // set the LOOP flag + } +} +#elif defined(QTAUDIO) // Using Qt's QSoundEffect class AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) { - m_parent = parent; - ao_app = p_ao_app; + m_parent = parent; + ao_app = p_ao_app; } void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) { - m_sfx.stop(); + m_sfx.stop(); - QString misc_path = ""; - QString char_path = ""; - QString sound_path = ao_app->get_sounds_path(p_sfx); + QString misc_path = ""; + QString char_path = ""; + QString sound_path = ao_app->get_sounds_path(p_sfx); - if (shout != "") - misc_path = ao_app->get_base_path() + "misc/" + shout + "/" + p_sfx; - if (p_char != "") - char_path = ao_app->get_character_path(p_char, p_sfx); + if (shout != "") + misc_path = ao_app->get_base_path() + "misc/" + shout + "/" + p_sfx; + if (p_char != "") + char_path = ao_app->get_character_path(p_char, p_sfx); - QString f_path; + QString f_path; - if (file_exists(char_path)) - f_path = char_path; - else if (file_exists(misc_path)) - f_path = misc_path; - else - f_path = sound_path; + if (file_exists(char_path)) + f_path = char_path; + else if (file_exists(misc_path)) + f_path = misc_path; + else + f_path = sound_path; - if (file_exists(f_path)) //if its missing, it will glitch out - { - m_sfx.setSource(QUrl::fromLocalFile(f_path)); + if (file_exists(f_path)) // if its missing, it will glitch out + { + m_sfx.setSource(QUrl::fromLocalFile(f_path)); - set_volume_internal(m_volume); + set_volume_internal(m_volume); - m_sfx.play(); - } + m_sfx.play(); + } } -void AOSfxPlayer::stop() -{ - m_sfx.stop(); -} +void AOSfxPlayer::stop() { m_sfx.stop(); } void AOSfxPlayer::set_volume(qreal p_value) { - m_volume = p_value / 100; - set_volume_internal(m_volume); + m_volume = p_value / 100; + set_volume_internal(m_volume); } void AOSfxPlayer::set_volume_internal(qreal p_value) { - m_sfx.setVolume(m_volume); + m_sfx.setVolume(m_volume); } #else AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) { - m_parent = parent; - ao_app = p_ao_app; + m_parent = parent; + ao_app = p_ao_app; } -void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) -{ -} +void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) {} -void AOSfxPlayer::stop() -{ -} +void AOSfxPlayer::stop() {} -void AOSfxPlayer::set_volume(qreal p_value) -{ -} +void AOSfxPlayer::set_volume(qreal p_value) {} -void AOSfxPlayer::set_volume_internal(qreal p_value) -{ -} +void AOSfxPlayer::set_volume_internal(qreal p_value) {} #endif diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp index 524f3283..52e32f55 100644 --- a/src/aotextarea.cpp +++ b/src/aotextarea.cpp @@ -1,63 +1,73 @@ #include "aotextarea.h" -AOTextArea::AOTextArea(QWidget *p_parent) : QTextBrowser(p_parent) -{ -} +AOTextArea::AOTextArea(QWidget *p_parent) : QTextBrowser(p_parent) {} void AOTextArea::append_linked(QString p_message) { - QString result = p_message.toHtmlEscaped().replace("\n", "<br>").replace(url_parser_regex, "<a href='\\1'>\\1</a>"); - this->insertHtml(result); + QString result = p_message.toHtmlEscaped() + .replace("\n", "<br>") + .replace(url_parser_regex, "<a href='\\1'>\\1</a>"); + this->insertHtml(result); } -void AOTextArea::append_chatmessage(QString p_name, QString p_message, QString p_colour) +void AOTextArea::append_chatmessage(QString p_name, QString p_message, + QString p_colour) { - const QTextCursor old_cursor = this->textCursor(); - const int old_scrollbar_value = this->verticalScrollBar()->value(); - const bool is_scrolled_down = old_scrollbar_value == this->verticalScrollBar()->maximum(); + const QTextCursor old_cursor = this->textCursor(); + const int old_scrollbar_value = this->verticalScrollBar()->value(); + const bool is_scrolled_down = + old_scrollbar_value == this->verticalScrollBar()->maximum(); - this->moveCursor(QTextCursor::End); + this->moveCursor(QTextCursor::End); - this->append(""); - this->insertHtml("<b><font color=" + p_colour + ">" + p_name.toHtmlEscaped() + "</font></b>: "); + this->append(""); + this->insertHtml("<b><font color=" + p_colour + ">" + p_name.toHtmlEscaped() + + "</font></b>: "); - //cheap workarounds ahoy - p_message += " "; - QString result = p_message.toHtmlEscaped().replace("\n", "<br>").replace(url_parser_regex, "<a href='\\1'>\\1</a>"); + // cheap workarounds ahoy + p_message += " "; + QString result = p_message.toHtmlEscaped() + .replace("\n", "<br>") + .replace(url_parser_regex, "<a href='\\1'>\\1</a>"); - this->insertHtml(result); + this->insertHtml(result); - this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); + this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); } void AOTextArea::append_error(QString p_message) { - const QTextCursor old_cursor = this->textCursor(); - const int old_scrollbar_value = this->verticalScrollBar()->value(); - const bool is_scrolled_down = old_scrollbar_value == this->verticalScrollBar()->maximum(); + const QTextCursor old_cursor = this->textCursor(); + const int old_scrollbar_value = this->verticalScrollBar()->value(); + const bool is_scrolled_down = + old_scrollbar_value == this->verticalScrollBar()->maximum(); - this->moveCursor(QTextCursor::End); + this->moveCursor(QTextCursor::End); - this->append(""); + this->append(""); - p_message += " "; - QString result = p_message.replace("\n", "<br>").replace(url_parser_regex, "<a href='\\1'>\\1</a>"); + p_message += " "; + QString result = p_message.replace("\n", "<br>") + .replace(url_parser_regex, "<a href='\\1'>\\1</a>"); - this->insertHtml("<font color='red'>" + result + "</font>"); + this->insertHtml("<font color='red'>" + result + "</font>"); - this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); + this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); } -void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value, bool is_scrolled_down) +void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value, + bool is_scrolled_down) { - if (old_cursor.hasSelection() || !is_scrolled_down) { - // The user has selected text or scrolled away from the bottom: maintain position. - this->setTextCursor(old_cursor); - this->verticalScrollBar()->setValue(old_scrollbar_value); - } - else { - // The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom. - this->moveCursor(QTextCursor::End); - this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum()); - } + if (old_cursor.hasSelection() || !is_scrolled_down) { + // The user has selected text or scrolled away from the bottom: maintain + // position. + this->setTextCursor(old_cursor); + this->verticalScrollBar()->setValue(old_scrollbar_value); + } + else { + // The user hasn't selected any text and the scrollbar is at the bottom: + // scroll to the bottom. + this->moveCursor(QTextCursor::End); + this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum()); + } } diff --git a/src/aotextedit.cpp b/src/aotextedit.cpp index 0dc5cb4f..22d9a62e 100644 --- a/src/aotextedit.cpp +++ b/src/aotextedit.cpp @@ -2,19 +2,16 @@ AOTextEdit::AOTextEdit(QWidget *parent) : QPlainTextEdit(parent) { - this->setReadOnly(true); + this->setReadOnly(true); - //connect(this, SIGNAL(returnPressed()), this, SLOT(on_enter_pressed())); + // connect(this, SIGNAL(returnPressed()), this, SLOT(on_enter_pressed())); } void AOTextEdit::mouseDoubleClickEvent(QMouseEvent *e) { - QPlainTextEdit::mouseDoubleClickEvent(e); + QPlainTextEdit::mouseDoubleClickEvent(e); - this->setReadOnly(false); + this->setReadOnly(false); } -void AOTextEdit::on_enter_pressed() -{ - this->setReadOnly(true); -} +void AOTextEdit::on_enter_pressed() { this->setReadOnly(true); } diff --git a/src/charselect.cpp b/src/charselect.cpp index 65758690..de9748b0 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -7,251 +7,269 @@ void Courtroom::construct_char_select() { - ui_char_select_background = new AOImage(this, ao_app); + ui_char_select_background = new AOImage(this, ao_app); - ui_char_buttons = new QWidget(ui_char_select_background); + ui_char_buttons = new QWidget(ui_char_select_background); - ui_selector = new AOImage(ui_char_select_background, ao_app); - ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_selector->resize(62, 62); + ui_selector = new AOImage(ui_char_select_background, ao_app); + ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_selector->resize(62, 62); - ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app); + ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app); - ui_char_password = new QLineEdit(ui_char_select_background); - ui_char_password->setPlaceholderText(tr("Password")); + ui_char_password = new QLineEdit(ui_char_select_background); + ui_char_password->setPlaceholderText(tr("Password")); - ui_char_select_left = new AOButton(ui_char_select_background, ao_app); - ui_char_select_right = new AOButton(ui_char_select_background, ao_app); + ui_char_select_left = new AOButton(ui_char_select_background, ao_app); + ui_char_select_right = new AOButton(ui_char_select_background, ao_app); - ui_spectator = new AOButton(ui_char_select_background, ao_app); - ui_spectator->setText(tr("Spectator")); + ui_spectator = new AOButton(ui_char_select_background, ao_app); + ui_spectator->setText(tr("Spectator")); - ui_char_search = new QLineEdit(ui_char_select_background); - ui_char_search->setPlaceholderText(tr("Search")); - ui_char_search->setFocus(); - set_size_and_pos(ui_char_search, "char_search"); + ui_char_search = new QLineEdit(ui_char_select_background); + ui_char_search->setPlaceholderText(tr("Search")); + ui_char_search->setFocus(); + set_size_and_pos(ui_char_search, "char_search"); - ui_char_passworded = new QCheckBox(ui_char_select_background); - ui_char_passworded->setText(tr("Passworded")); - set_size_and_pos(ui_char_passworded, "char_passworded"); + ui_char_passworded = new QCheckBox(ui_char_select_background); + ui_char_passworded->setText(tr("Passworded")); + set_size_and_pos(ui_char_passworded, "char_passworded"); - ui_char_taken = new QCheckBox(ui_char_select_background); - ui_char_taken->setText(tr("Taken")); - set_size_and_pos(ui_char_taken, "char_taken"); + ui_char_taken = new QCheckBox(ui_char_select_background); + ui_char_taken->setText(tr("Taken")); + set_size_and_pos(ui_char_taken, "char_taken"); - ui_char_taken->setChecked(true); - ui_char_passworded->setChecked(true); + ui_char_taken->setChecked(true); + ui_char_passworded->setChecked(true); - set_size_and_pos(ui_char_buttons, "char_buttons"); + set_size_and_pos(ui_char_buttons, "char_buttons"); - connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked())); + connect(ui_back_to_lobby, SIGNAL(clicked()), this, + SLOT(on_back_to_lobby_clicked())); - connect(ui_char_select_left, SIGNAL(clicked()), this, SLOT(on_char_select_left_clicked())); - connect(ui_char_select_right, SIGNAL(clicked()), this, SLOT(on_char_select_right_clicked())); + connect(ui_char_select_left, SIGNAL(clicked()), this, + SLOT(on_char_select_left_clicked())); + connect(ui_char_select_right, SIGNAL(clicked()), this, + SLOT(on_char_select_right_clicked())); - connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); + connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); - connect(ui_char_search, SIGNAL(textEdited(const QString &)), this, SLOT(on_char_search_changed())); - connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, SLOT(on_char_passworded_clicked())); - connect(ui_char_taken, SIGNAL(stateChanged(int)), this, SLOT(on_char_taken_clicked())); + connect(ui_char_search, SIGNAL(textEdited(const QString &)), this, + SLOT(on_char_search_changed())); + connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, + SLOT(on_char_passworded_clicked())); + connect(ui_char_taken, SIGNAL(stateChanged(int)), this, + SLOT(on_char_taken_clicked())); } void Courtroom::set_char_select() { - QString filename = "courtroom_design.ini"; + QString filename = "courtroom_design.ini"; - pos_size_type f_charselect = ao_app->get_element_dimensions("char_select", filename); + pos_size_type f_charselect = + ao_app->get_element_dimensions("char_select", filename); - if (f_charselect.width < 0 || f_charselect.height < 0) { - qDebug() << "W: did not find char_select width or height in courtroom_design.ini!"; - this->resize(714, 668); - } - else - this->resize(f_charselect.width, f_charselect.height); + if (f_charselect.width < 0 || f_charselect.height < 0) { + qDebug() << "W: did not find char_select width or height in " + "courtroom_design.ini!"; + this->resize(714, 668); + } + else + this->resize(f_charselect.width, f_charselect.height); - ui_char_select_background->resize(f_charselect.width, f_charselect.height); - ui_char_select_background->set_image("charselect_background"); + ui_char_select_background->resize(f_charselect.width, f_charselect.height); + ui_char_select_background->set_image("charselect_background"); - filter_character_list(); + filter_character_list(); - ui_char_search->setFocus(); + ui_char_search->setFocus(); } void Courtroom::set_char_select_page() { - ui_char_select_background->show(); + ui_char_select_background->show(); - ui_char_select_left->hide(); - ui_char_select_right->hide(); + ui_char_select_left->hide(); + ui_char_select_right->hide(); - for (AOCharButton *i_button : ui_char_button_list) { - i_button->reset(); - i_button->hide(); - i_button->move(0, 0); - } + for (AOCharButton *i_button : ui_char_button_list) { + i_button->reset(); + i_button->hide(); + i_button->move(0, 0); + } - int total_pages = ui_char_button_list_filtered.size() / max_chars_on_page; - int chars_on_page = 0; + int total_pages = ui_char_button_list_filtered.size() / max_chars_on_page; + int chars_on_page = 0; - if (ui_char_button_list_filtered.size() % max_chars_on_page != 0) { - ++total_pages; - //i. e. not on the last page - if (total_pages > current_char_page + 1) - chars_on_page = max_chars_on_page; - else - chars_on_page = ui_char_button_list_filtered.size() % max_chars_on_page; - } + if (ui_char_button_list_filtered.size() % max_chars_on_page != 0) { + ++total_pages; + // i. e. not on the last page + if (total_pages > current_char_page + 1) + chars_on_page = max_chars_on_page; else - chars_on_page = max_chars_on_page; + chars_on_page = ui_char_button_list_filtered.size() % max_chars_on_page; + } + else + chars_on_page = max_chars_on_page; - if (total_pages > current_char_page + 1) - ui_char_select_right->show(); + if (total_pages > current_char_page + 1) + ui_char_select_right->show(); - if (current_char_page > 0) - ui_char_select_left->show(); + if (current_char_page > 0) + ui_char_select_left->show(); - put_button_in_place(current_char_page * max_chars_on_page, chars_on_page); + put_button_in_place(current_char_page * max_chars_on_page, chars_on_page); } void Courtroom::char_clicked(int n_char) { - QString char_ini_path = ao_app->get_character_path(char_list.at(n_char).name, "char.ini"); + QString char_ini_path = + ao_app->get_character_path(char_list.at(n_char).name, "char.ini"); - qDebug() << "char_ini_path" << char_ini_path; + qDebug() << "char_ini_path" << char_ini_path; - if (!file_exists(char_ini_path)) { - call_notice("Could not find " + char_ini_path); - return; - } + if (!file_exists(char_ini_path)) { + call_notice("Could not find " + char_ini_path); + return; + } - if (n_char != m_cid) { - ao_app->send_server_packet(new AOPacket("PW#" + ui_char_password->text() + "#%")); - ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%")); - } - else - update_character(n_char); + if (n_char != m_cid) { + ao_app->send_server_packet( + new AOPacket("PW#" + ui_char_password->text() + "#%")); + ao_app->send_server_packet( + new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + + QString::number(n_char) + "#" + get_hdid() + "#%")); + } + else + update_character(n_char); - enter_courtroom(); + enter_courtroom(); - ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); + ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); } void Courtroom::put_button_in_place(int starting, int chars_on_this_page) { - if (ui_char_button_list_filtered.size() == 0) - return; + if (ui_char_button_list_filtered.size() == 0) + return; - QPoint f_spacing = ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini"); + QPoint f_spacing = + ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini"); - int x_spacing = f_spacing.x(); - int x_mod_count = 0; + int x_spacing = f_spacing.x(); + int x_mod_count = 0; - int y_spacing = f_spacing.y(); - int y_mod_count = 0; + int y_spacing = f_spacing.y(); + int y_mod_count = 0; - char_columns = ((ui_char_buttons->width() - button_width) / (x_spacing + button_width)) + 1; - char_rows = ((ui_char_buttons->height() - button_height) / (y_spacing + button_height)) + 1; + char_columns = + ((ui_char_buttons->width() - button_width) / (x_spacing + button_width)) + + 1; + char_rows = ((ui_char_buttons->height() - button_height) / + (y_spacing + button_height)) + + 1; - max_chars_on_page = char_columns * char_rows; + max_chars_on_page = char_columns * char_rows; - int startout = starting; - for (int n = starting; n < startout + chars_on_this_page; ++n) { - int x_pos = (button_width + x_spacing) * x_mod_count; - int y_pos = (button_height + y_spacing) * y_mod_count; + int startout = starting; + for (int n = starting; n < startout + chars_on_this_page; ++n) { + int x_pos = (button_width + x_spacing) * x_mod_count; + int y_pos = (button_height + y_spacing) * y_mod_count; - 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)->apply_taken_image(); + 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)->apply_taken_image(); - ++x_mod_count; + ++x_mod_count; - if (x_mod_count == char_columns) { - ++y_mod_count; - x_mod_count = 0; - } + if (x_mod_count == char_columns) { + ++y_mod_count; + x_mod_count = 0; } + } } void Courtroom::character_loading_finished() { - // Zeroeth, we'll clear any leftover characters from previous server visits. - ao_app->generated_chars = 0; - if (ui_char_button_list.size() > 0) { - foreach (AOCharButton *item, ui_char_button_list) { - delete item; - } - ui_char_button_list.clear(); + // Zeroeth, we'll clear any leftover characters from previous server visits. + ao_app->generated_chars = 0; + if (ui_char_button_list.size() > 0) { + foreach (AOCharButton *item, ui_char_button_list) { + delete item; } - - // First, we'll make all the character buttons in the very beginning. - // We also hide them all, so they can't be accidentally clicked. - // Later on, we'll be revealing buttons as we need them. - for (int n = 0; n < char_list.size(); n++) { - AOCharButton *char_button = new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); - char_button->reset(); - char_button->hide(); - char_button->set_image(char_list.at(n).name); - ui_char_button_list.append(char_button); - - connect(char_button, &AOCharButton::clicked, [this, n]() { - this->char_clicked(n); - }); - - // This part here serves as a way of showing to the player that the game is still running, it is - // just loading the pictures of the characters. - if (ao_app->lobby_constructed) { - ao_app->generated_chars++; - int total_loading_size = ao_app->char_list_size * 2 + ao_app->evidence_list_size + ao_app->music_list_size; - int loading_value = int(((ao_app->loaded_chars + ao_app->generated_chars + ao_app->loaded_music + ao_app->loaded_evidence) / static_cast<double>(total_loading_size)) * 100); - ao_app->w_lobby->set_loading_value(loading_value); - ao_app->w_lobby->set_loading_text(tr("Generating chars:\n%1/%2").arg(QString::number(ao_app->generated_chars)).arg(QString::number(ao_app->char_list_size))); - } + ui_char_button_list.clear(); + } + + // First, we'll make all the character buttons in the very beginning. + // We also hide them all, so they can't be accidentally clicked. + // Later on, we'll be revealing buttons as we need them. + for (int n = 0; n < char_list.size(); n++) { + AOCharButton *char_button = + new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); + char_button->reset(); + char_button->hide(); + char_button->set_image(char_list.at(n).name); + ui_char_button_list.append(char_button); + + connect(char_button, &AOCharButton::clicked, + [this, n]() { this->char_clicked(n); }); + + // This part here serves as a way of showing to the player that the game is + // still running, it is just loading the pictures of the characters. + if (ao_app->lobby_constructed) { + ao_app->generated_chars++; + int total_loading_size = ao_app->char_list_size * 2 + + ao_app->evidence_list_size + + ao_app->music_list_size; + int loading_value = + int(((ao_app->loaded_chars + ao_app->generated_chars + + ao_app->loaded_music + ao_app->loaded_evidence) / + static_cast<double>(total_loading_size)) * + 100); + ao_app->w_lobby->set_loading_value(loading_value); + ao_app->w_lobby->set_loading_text( + tr("Generating chars:\n%1/%2") + .arg(QString::number(ao_app->generated_chars)) + .arg(QString::number(ao_app->char_list_size))); } + } - filter_character_list(); + filter_character_list(); } void Courtroom::filter_character_list() { - ui_char_button_list_filtered.clear(); - for (int i = 0; i < char_list.size(); i++) { - AOCharButton *current_char = ui_char_button_list.at(i); + ui_char_button_list_filtered.clear(); + for (int i = 0; i < char_list.size(); i++) { + AOCharButton *current_char = ui_char_button_list.at(i); - // It seems passwording characters is unimplemented yet? - // Until then, this will stay here, I suppose. - //if (ui_char_passworded->isChecked() && character_is_passworded??) - // continue; + // It seems passwording characters is unimplemented yet? + // Until then, this will stay here, I suppose. + // if (ui_char_passworded->isChecked() && character_is_passworded??) + // continue; - if (!ui_char_taken->isChecked() && char_list.at(i).taken) - continue; + if (!ui_char_taken->isChecked() && char_list.at(i).taken) + continue; - if (!char_list.at(i).name.contains(ui_char_search->text(), Qt::CaseInsensitive)) - continue; + 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); + // 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); - } + ui_char_button_list_filtered.append(current_char); + } - current_char_page = 0; - set_char_select_page(); + current_char_page = 0; + set_char_select_page(); } -void Courtroom::on_char_search_changed() -{ - filter_character_list(); -} +void Courtroom::on_char_search_changed() { filter_character_list(); } -void Courtroom::on_char_passworded_clicked() -{ - filter_character_list(); -} +void Courtroom::on_char_passworded_clicked() { filter_character_list(); } -void Courtroom::on_char_taken_clicked() -{ - filter_character_list(); -} +void Courtroom::on_char_taken_clicked() { filter_character_list(); } diff --git a/src/chatlogpiece.cpp b/src/chatlogpiece.cpp index b0113de2..34a2fea4 100644 --- a/src/chatlogpiece.cpp +++ b/src/chatlogpiece.cpp @@ -2,76 +2,60 @@ chatlogpiece::chatlogpiece() { - name = "UNKNOWN"; - showname = "UNKNOWN"; - message = "UNKNOWN"; - p_is_song = false; - datetime = QDateTime::currentDateTime().toUTC(); + name = "UNKNOWN"; + showname = "UNKNOWN"; + message = "UNKNOWN"; + p_is_song = false; + datetime = QDateTime::currentDateTime().toUTC(); } -chatlogpiece::chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song) +chatlogpiece::chatlogpiece(QString p_name, QString p_showname, + QString p_message, bool p_song) { - name = p_name; - showname = p_showname; - message = p_message; - p_is_song = p_song; - datetime = QDateTime::currentDateTime().toUTC(); + name = p_name; + showname = p_showname; + message = p_message; + p_is_song = p_song; + datetime = QDateTime::currentDateTime().toUTC(); } -chatlogpiece::chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song, QDateTime p_datetime) +chatlogpiece::chatlogpiece(QString p_name, QString p_showname, + QString p_message, bool p_song, QDateTime p_datetime) { - name = p_name; - showname = p_showname; - message = p_message; - p_is_song = p_song; - datetime = p_datetime.toUTC(); + name = p_name; + showname = p_showname; + message = p_message; + p_is_song = p_song; + datetime = p_datetime.toUTC(); } -QString chatlogpiece::get_name() -{ - return name; -} +QString chatlogpiece::get_name() { return name; } -QString chatlogpiece::get_showname() -{ - return showname; -} +QString chatlogpiece::get_showname() { return showname; } -QString chatlogpiece::get_message() -{ - return message; -} +QString chatlogpiece::get_message() { return message; } -QDateTime chatlogpiece::get_datetime() -{ - return datetime; -} +QDateTime chatlogpiece::get_datetime() { return datetime; } -bool chatlogpiece::is_song() -{ - return p_is_song; -} +bool chatlogpiece::is_song() { return p_is_song; } -QString chatlogpiece::get_datetime_as_string() -{ - return datetime.toString(); -} +QString chatlogpiece::get_datetime_as_string() { return datetime.toString(); } QString chatlogpiece::get_full() { - QString full = "["; - - full.append(get_datetime_as_string()); - full.append("] "); - full.append(get_showname()); - full.append(" ("); - full.append(get_name()); - full.append(")"); - if (p_is_song) - full.append(" has played a song: "); - else - full.append(": "); - full.append(get_message()); - - return full; + QString full = "["; + + full.append(get_datetime_as_string()); + full.append("] "); + full.append(get_showname()); + full.append(" ("); + full.append(get_name()); + full.append(")"); + if (p_is_song) + full.append(" has played a song: "); + else + full.append(": "); + full.append(get_message()); + + return full; } diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 4c240fed..9261de33 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2,4225 +2,4598 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() { - ao_app = p_ao_app; + ao_app = p_ao_app; #ifdef BASSAUDIO - // Change the default audio output device to be the one the user has given - // in his config.ini file for now. - unsigned int a = 0; - BASS_DEVICEINFO info; - - if (ao_app->get_audio_output_device() == "default") { - BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); + // Change the default audio output device to be the one the user has given + // in his config.ini file for now. + unsigned int a = 0; + BASS_DEVICEINFO info; + + if (ao_app->get_audio_output_device() == "default") { + BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); + load_bass_opus_plugin(); + } + else { + for (a = 0; BASS_GetDeviceInfo(a, &info); a++) { + if (ao_app->get_audio_output_device() == info.name) { + BASS_SetDevice(a); + BASS_Init(static_cast<int>(a), 48000, BASS_DEVICE_LATENCY, nullptr, + nullptr); load_bass_opus_plugin(); + qDebug() << info.name << "was set as the default audio output device."; + break; + } } - else { - for (a = 0; BASS_GetDeviceInfo(a, &info); a++) { - if (ao_app->get_audio_output_device() == info.name) { - BASS_SetDevice(a); - BASS_Init(static_cast<int>(a), 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); - load_bass_opus_plugin(); - qDebug() << info.name << "was set as the default audio output device."; - break; - } - } - } + } #elif defined QTAUDIO - if (ao_app->get_audio_output_device() != "default") { - foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) { - if (ao_app->get_audio_output_device() == deviceInfo.deviceName()) { - ao_app->QtAudioDevice = deviceInfo; - qDebug() << deviceInfo.deviceName() << "was set as the default audio output device."; - break; - } - } + if (ao_app->get_audio_output_device() != "default") { + foreach (const QAudioDeviceInfo &deviceInfo, + QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) { + if (ao_app->get_audio_output_device() == deviceInfo.deviceName()) { + ao_app->QtAudioDevice = deviceInfo; + qDebug() << deviceInfo.deviceName() + << "was set as the default audio output device."; + break; + } } + } #endif - qsrand(static_cast<uint>(QDateTime::currentMSecsSinceEpoch() / 1000)); - - keepalive_timer = new QTimer(this); - keepalive_timer->start(60000); - - chat_tick_timer = new QTimer(this); - - text_delay_timer = new QTimer(this); - text_delay_timer->setSingleShot(true); - - sfx_delay_timer = new QTimer(this); - sfx_delay_timer->setSingleShot(true); - - music_player = new AOMusicPlayer(this, ao_app); - music_player->set_volume(0); - - sfx_player = new AOSfxPlayer(this, ao_app); - sfx_player->set_volume(0); - - objection_player = new AOSfxPlayer(this, ao_app); - objection_player->set_volume(0); - - blip_player = new AOBlipPlayer(this, ao_app); - blip_player->set_volume(0); - - modcall_player = new AOSfxPlayer(this, ao_app); - modcall_player->set_volume(50); - - ui_background = new AOImage(this, ao_app); - - ui_viewport = new QWidget(this); - ui_vp_background = new AOScene(ui_viewport, ao_app); - ui_vp_speedlines = new AOMovie(ui_viewport, ao_app); - ui_vp_speedlines->set_play_once(false); - ui_vp_player_char = new AOCharMovie(ui_viewport, ao_app); - ui_vp_sideplayer_char = new AOCharMovie(ui_viewport, ao_app); - ui_vp_sideplayer_char->hide(); - ui_vp_desk = new AOScene(ui_viewport, ao_app); - ui_vp_legacy_desk = new AOScene(ui_viewport, ao_app); - - ui_vp_evidence_display = new AOEvidenceDisplay(ui_viewport, ao_app); - - ui_vp_chatbox = new AOImage(this, ao_app); - ui_vp_showname = new QLabel(ui_vp_chatbox); - ui_vp_showname->setAlignment(Qt::AlignHCenter); - ui_vp_chat_arrow = new AOMovie(ui_vp_chatbox, ao_app); - ui_vp_chat_arrow->set_play_once(false); - - ui_vp_message = new QTextEdit(this); - ui_vp_message->setFrameStyle(QFrame::NoFrame); - ui_vp_message->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - ui_vp_message->setReadOnly(true); - - ui_vp_testimony = new AOMovie(this, ao_app); - ui_vp_testimony->set_play_once(false); - ui_vp_testimony->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_vp_effect = new AOMovie(this, ao_app); - ui_vp_effect->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_vp_wtce = new AOMovie(this, ao_app); - ui_vp_wtce->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_vp_objection = new AOMovie(this, ao_app); - ui_vp_objection->setAttribute(Qt::WA_TransparentForMouseEvents); - - ui_ic_chatlog = new QTextEdit(this); - ui_ic_chatlog->setReadOnly(true); - - log_maximum_blocks = ao_app->get_max_log_size(); - log_goes_downwards = ao_app->get_log_goes_downwards(); - - ui_ms_chatlog = new AOTextArea(this); - ui_ms_chatlog->setReadOnly(true); - ui_ms_chatlog->setOpenExternalLinks(true); - ui_ms_chatlog->hide(); - - ui_server_chatlog = new AOTextArea(this); - ui_server_chatlog->setReadOnly(true); - ui_server_chatlog->setOpenExternalLinks(true); - - ui_area_list = new QTreeWidget(this); - ui_area_list->setColumnCount(2); - ui_area_list->hideColumn(0); - ui_area_list->setHeaderHidden(true); - ui_area_list->header()->setStretchLastSection(false); - ui_area_list->header()->setSectionResizeMode(QHeaderView::ResizeToContents); - ui_area_list->hide(); - - ui_music_list = new QTreeWidget(this); - ui_music_list->setColumnCount(2); - ui_music_list->hideColumn(1); - ui_music_list->setHeaderHidden(true); - ui_music_list->header()->setStretchLastSection(false); - ui_music_list->header()->setSectionResizeMode(QHeaderView::ResizeToContents); - ui_music_list->setContextMenuPolicy(Qt::CustomContextMenu); - - ui_music_display = new AOMovie(this, ao_app); - ui_music_display->set_play_once(false); - ui_music_display->setAttribute(Qt::WA_TransparentForMouseEvents); - - ui_music_name = new ScrollText(ui_music_display); - ui_music_name->setText(tr("None")); - ui_music_name->setAttribute(Qt::WA_TransparentForMouseEvents); - - ui_ic_chat_name = new QLineEdit(this); - ui_ic_chat_name->setFrame(false); - ui_ic_chat_name->setPlaceholderText(tr("Showname")); - - ui_ic_chat_message = new AOLineEdit(this); - ui_ic_chat_message->setFrame(false); - ui_ic_chat_message->setPlaceholderText(tr("Message")); - ui_ic_chat_message->preserve_selection(true); - // ui_ic_chat_message->setValidator(new QRegExpValidator(QRegExp("^\\S+(?: \\S+)*$"), ui_ic_chat_message)); - //todo: filter out \n from showing up as that commonly breaks the chatlog and can be spammed to hell - - ui_muted = new AOImage(ui_ic_chat_message, ao_app); - ui_muted->hide(); - - ui_ooc_chat_message = new QLineEdit(this); - ui_ooc_chat_message->setFrame(false); - - ui_ooc_chat_name = new QLineEdit(this); - ui_ooc_chat_name->setFrame(false); - ui_ooc_chat_name->setPlaceholderText(tr("Name")); - ui_ooc_chat_name->setMaxLength(30); - ui_ooc_chat_name->setText(p_ao_app->get_default_username()); - - //ui_area_password = new QLineEdit(this); - //ui_area_password->setFrame(false); - ui_music_search = new QLineEdit(this); - ui_music_search->setFrame(false); - ui_music_search->setPlaceholderText(tr("Search")); - - initialize_emotes(); - - ui_pos_dropdown = new QComboBox(this); - - ui_iniswap_dropdown = new QComboBox(this); - ui_iniswap_dropdown->setContextMenuPolicy(Qt::CustomContextMenu); - ui_iniswap_remove = new AOButton(this, ao_app); - - ui_sfx_dropdown = new QComboBox(this); - ui_sfx_dropdown->setContextMenuPolicy(Qt::CustomContextMenu); - ui_sfx_remove = new AOButton(this, ao_app); - - ui_effects_dropdown = new QComboBox(this); - ui_effects_dropdown->setContextMenuPolicy(Qt::CustomContextMenu); - - ui_defense_bar = new AOImage(this, ao_app); - ui_prosecution_bar = new AOImage(this, ao_app); - - ui_music_label = new QLabel(this); - ui_sfx_label = new QLabel(this); - ui_blip_label = new QLabel(this); - - ui_hold_it = new AOButton(this, ao_app); - ui_objection = new AOButton(this, ao_app); - ui_take_that = new AOButton(this, ao_app); - - ui_ooc_toggle = new AOButton(this, ao_app); - ui_witness_testimony = new AOButton(this, ao_app); - ui_cross_examination = new AOButton(this, ao_app); - ui_guilty = new AOButton(this, ao_app); - ui_not_guilty = new AOButton(this, ao_app); - - ui_change_character = new AOButton(this, ao_app); - ui_reload_theme = new AOButton(this, ao_app); - ui_call_mod = new AOButton(this, ao_app); - ui_settings = new AOButton(this, ao_app); - ui_announce_casing = new AOButton(this, ao_app); - ui_switch_area_music = new AOButton(this, ao_app); - - ui_pre = new QCheckBox(this); - ui_pre->setText(tr("Pre")); - - ui_flip = new QCheckBox(this); - ui_flip->setText(tr("Flip")); - ui_flip->hide(); - - ui_guard = new QCheckBox(this); - ui_guard->setText(tr("Guard")); - ui_guard->hide(); - - ui_additive = new QCheckBox(this); - ui_additive->setText(tr("Additive")); - ui_additive->hide(); - - ui_casing = new QCheckBox(this); - ui_casing->setChecked(ao_app->get_casing_enabled()); - ui_casing->setText(tr("Casing")); - ui_casing->hide(); - - ui_showname_enable = new QCheckBox(this); - ui_showname_enable->setChecked(ao_app->get_showname_enabled_by_default()); - ui_showname_enable->setText(tr("Shownames")); - - ui_pre_non_interrupt = new QCheckBox(this); - ui_pre_non_interrupt->setText(tr("No Interrupt")); - ui_pre_non_interrupt->hide(); - - ui_custom_objection = new AOButton(this, ao_app); - ui_realization = new AOButton(this, ao_app); - ui_screenshake = new AOButton(this, ao_app); - ui_mute = new AOButton(this, ao_app); - - ui_defense_plus = new AOButton(this, ao_app); - ui_defense_minus = new AOButton(this, ao_app); - - ui_prosecution_plus = new AOButton(this, ao_app); - ui_prosecution_minus = new AOButton(this, ao_app); - - ui_text_color = new QComboBox(this); - - ui_music_slider = new QSlider(Qt::Horizontal, this); - ui_music_slider->setRange(0, 100); - ui_music_slider->setValue(ao_app->get_default_music()); - - ui_sfx_slider = new QSlider(Qt::Horizontal, this); - ui_sfx_slider->setRange(0, 100); - ui_sfx_slider->setValue(ao_app->get_default_sfx()); - - ui_blip_slider = new QSlider(Qt::Horizontal, this); - ui_blip_slider->setRange(0, 100); - ui_blip_slider->setValue(ao_app->get_default_blip()); - - ui_mute_list = new QListWidget(this); - - ui_pair_list = new QListWidget(this); - ui_pair_offset_spinbox = new QSpinBox(this); - ui_pair_offset_spinbox->setRange(-100, 100); - ui_pair_offset_spinbox->setSuffix(tr("% offset")); - - ui_pair_order_dropdown = new QComboBox(this); - ui_pair_order_dropdown->addItem("To front"); - ui_pair_order_dropdown->addItem("To behind"); - - ui_pair_button = new AOButton(this, ao_app); + qsrand(static_cast<uint>(QDateTime::currentMSecsSinceEpoch() / 1000)); + + keepalive_timer = new QTimer(this); + keepalive_timer->start(60000); + + chat_tick_timer = new QTimer(this); + + text_delay_timer = new QTimer(this); + text_delay_timer->setSingleShot(true); + + sfx_delay_timer = new QTimer(this); + sfx_delay_timer->setSingleShot(true); + + music_player = new AOMusicPlayer(this, ao_app); + music_player->set_volume(0); + + sfx_player = new AOSfxPlayer(this, ao_app); + sfx_player->set_volume(0); + + objection_player = new AOSfxPlayer(this, ao_app); + objection_player->set_volume(0); + + blip_player = new AOBlipPlayer(this, ao_app); + blip_player->set_volume(0); + + modcall_player = new AOSfxPlayer(this, ao_app); + modcall_player->set_volume(50); + + ui_background = new AOImage(this, ao_app); + + ui_viewport = new QWidget(this); + ui_vp_background = new AOScene(ui_viewport, ao_app); + ui_vp_speedlines = new AOMovie(ui_viewport, ao_app); + ui_vp_speedlines->set_play_once(false); + ui_vp_player_char = new AOCharMovie(ui_viewport, ao_app); + ui_vp_sideplayer_char = new AOCharMovie(ui_viewport, ao_app); + ui_vp_sideplayer_char->hide(); + ui_vp_desk = new AOScene(ui_viewport, ao_app); + ui_vp_legacy_desk = new AOScene(ui_viewport, ao_app); + + ui_vp_evidence_display = new AOEvidenceDisplay(ui_viewport, ao_app); + + ui_vp_chatbox = new AOImage(this, ao_app); + ui_vp_showname = new QLabel(ui_vp_chatbox); + ui_vp_showname->setAlignment(Qt::AlignHCenter); + ui_vp_chat_arrow = new AOMovie(ui_vp_chatbox, ao_app); + ui_vp_chat_arrow->set_play_once(false); + + ui_vp_message = new QTextEdit(this); + ui_vp_message->setFrameStyle(QFrame::NoFrame); + ui_vp_message->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + ui_vp_message->setReadOnly(true); + + ui_vp_testimony = new AOMovie(this, ao_app); + ui_vp_testimony->set_play_once(false); + ui_vp_testimony->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_vp_effect = new AOMovie(this, ao_app); + ui_vp_effect->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_vp_wtce = new AOMovie(this, ao_app); + ui_vp_wtce->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_vp_objection = new AOMovie(this, ao_app); + ui_vp_objection->setAttribute(Qt::WA_TransparentForMouseEvents); + + ui_ic_chatlog = new QTextEdit(this); + ui_ic_chatlog->setReadOnly(true); + + log_maximum_blocks = ao_app->get_max_log_size(); + log_goes_downwards = ao_app->get_log_goes_downwards(); + + ui_ms_chatlog = new AOTextArea(this); + ui_ms_chatlog->setReadOnly(true); + ui_ms_chatlog->setOpenExternalLinks(true); + ui_ms_chatlog->hide(); + + ui_server_chatlog = new AOTextArea(this); + ui_server_chatlog->setReadOnly(true); + ui_server_chatlog->setOpenExternalLinks(true); + + ui_area_list = new QTreeWidget(this); + ui_area_list->setColumnCount(2); + ui_area_list->hideColumn(0); + ui_area_list->setHeaderHidden(true); + ui_area_list->header()->setStretchLastSection(false); + ui_area_list->header()->setSectionResizeMode(QHeaderView::ResizeToContents); + ui_area_list->hide(); + + ui_music_list = new QTreeWidget(this); + ui_music_list->setColumnCount(2); + ui_music_list->hideColumn(1); + ui_music_list->setHeaderHidden(true); + ui_music_list->header()->setStretchLastSection(false); + ui_music_list->header()->setSectionResizeMode(QHeaderView::ResizeToContents); + ui_music_list->setContextMenuPolicy(Qt::CustomContextMenu); + + ui_music_display = new AOMovie(this, ao_app); + ui_music_display->set_play_once(false); + ui_music_display->setAttribute(Qt::WA_TransparentForMouseEvents); + + ui_music_name = new ScrollText(ui_music_display); + ui_music_name->setText(tr("None")); + ui_music_name->setAttribute(Qt::WA_TransparentForMouseEvents); + + ui_ic_chat_name = new QLineEdit(this); + ui_ic_chat_name->setFrame(false); + ui_ic_chat_name->setPlaceholderText(tr("Showname")); + + ui_ic_chat_message = new AOLineEdit(this); + ui_ic_chat_message->setFrame(false); + ui_ic_chat_message->setPlaceholderText(tr("Message")); + ui_ic_chat_message->preserve_selection(true); + // ui_ic_chat_message->setValidator(new QRegExpValidator(QRegExp("^\\S+(?: + // \\S+)*$"), ui_ic_chat_message)); + // todo: filter out \n from showing up as that commonly breaks the chatlog and + // can be spammed to hell + + ui_muted = new AOImage(ui_ic_chat_message, ao_app); + ui_muted->hide(); + + ui_ooc_chat_message = new QLineEdit(this); + ui_ooc_chat_message->setFrame(false); + + ui_ooc_chat_name = new QLineEdit(this); + ui_ooc_chat_name->setFrame(false); + ui_ooc_chat_name->setPlaceholderText(tr("Name")); + ui_ooc_chat_name->setMaxLength(30); + ui_ooc_chat_name->setText(p_ao_app->get_default_username()); + + // ui_area_password = new QLineEdit(this); + // ui_area_password->setFrame(false); + ui_music_search = new QLineEdit(this); + ui_music_search->setFrame(false); + ui_music_search->setPlaceholderText(tr("Search")); + + initialize_emotes(); + + ui_pos_dropdown = new QComboBox(this); + + ui_iniswap_dropdown = new QComboBox(this); + ui_iniswap_dropdown->setContextMenuPolicy(Qt::CustomContextMenu); + ui_iniswap_remove = new AOButton(this, ao_app); + + ui_sfx_dropdown = new QComboBox(this); + ui_sfx_dropdown->setContextMenuPolicy(Qt::CustomContextMenu); + ui_sfx_remove = new AOButton(this, ao_app); + + ui_effects_dropdown = new QComboBox(this); + ui_effects_dropdown->setContextMenuPolicy(Qt::CustomContextMenu); + + ui_defense_bar = new AOImage(this, ao_app); + ui_prosecution_bar = new AOImage(this, ao_app); + + ui_music_label = new QLabel(this); + ui_sfx_label = new QLabel(this); + ui_blip_label = new QLabel(this); + + ui_hold_it = new AOButton(this, ao_app); + ui_objection = new AOButton(this, ao_app); + ui_take_that = new AOButton(this, ao_app); - ui_evidence_button = new AOButton(this, ao_app); + ui_ooc_toggle = new AOButton(this, ao_app); + ui_witness_testimony = new AOButton(this, ao_app); + ui_cross_examination = new AOButton(this, ao_app); + ui_guilty = new AOButton(this, ao_app); + ui_not_guilty = new AOButton(this, ao_app); - initialize_evidence(); + ui_change_character = new AOButton(this, ao_app); + ui_reload_theme = new AOButton(this, ao_app); + ui_call_mod = new AOButton(this, ao_app); + ui_settings = new AOButton(this, ao_app); + ui_announce_casing = new AOButton(this, ao_app); + ui_switch_area_music = new AOButton(this, ao_app); + + ui_pre = new QCheckBox(this); + ui_pre->setText(tr("Pre")); + + ui_flip = new QCheckBox(this); + ui_flip->setText(tr("Flip")); + ui_flip->hide(); + + ui_guard = new QCheckBox(this); + ui_guard->setText(tr("Guard")); + ui_guard->hide(); + + ui_additive = new QCheckBox(this); + ui_additive->setText(tr("Additive")); + ui_additive->hide(); - construct_char_select(); + ui_casing = new QCheckBox(this); + ui_casing->setChecked(ao_app->get_casing_enabled()); + ui_casing->setText(tr("Casing")); + ui_casing->hide(); - connect(keepalive_timer, SIGNAL(timeout()), this, SLOT(ping_server())); + ui_showname_enable = new QCheckBox(this); + ui_showname_enable->setChecked(ao_app->get_showname_enabled_by_default()); + ui_showname_enable->setText(tr("Shownames")); - connect(ui_vp_objection, SIGNAL(done()), this, SLOT(objection_done())); - connect(ui_vp_player_char, SIGNAL(done()), this, SLOT(preanim_done())); - connect(ui_vp_player_char, SIGNAL(shake()), this, SLOT(do_screenshake())); - connect(ui_vp_player_char, SIGNAL(flash()), this, SLOT(do_flash())); - connect(ui_vp_player_char, SIGNAL(play_sfx(QString)), this, SLOT(play_char_sfx(QString))); + ui_pre_non_interrupt = new QCheckBox(this); + ui_pre_non_interrupt->setText(tr("No Interrupt")); + ui_pre_non_interrupt->hide(); - connect(text_delay_timer, SIGNAL(timeout()), this, SLOT(start_chat_ticking())); - connect(sfx_delay_timer, SIGNAL(timeout()), this, SLOT(play_sfx())); + ui_custom_objection = new AOButton(this, ao_app); + ui_realization = new AOButton(this, ao_app); + ui_screenshake = new AOButton(this, ao_app); + ui_mute = new AOButton(this, ao_app); - connect(chat_tick_timer, SIGNAL(timeout()), this, SLOT(chat_tick())); + ui_defense_plus = new AOButton(this, ao_app); + ui_defense_minus = new AOButton(this, ao_app); - connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_pos_dropdown_changed(int))); + ui_prosecution_plus = new AOButton(this, ao_app); + ui_prosecution_minus = new AOButton(this, ao_app); - connect(ui_iniswap_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_iniswap_dropdown_changed(int))); - connect(ui_iniswap_dropdown, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_iniswap_context_menu_requested(QPoint))); - connect(ui_iniswap_remove, SIGNAL(clicked()), this, SLOT(on_iniswap_remove_clicked())); + ui_text_color = new QComboBox(this); - connect(ui_sfx_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_sfx_dropdown_changed(int))); - connect(ui_sfx_dropdown, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_sfx_context_menu_requested(QPoint))); - connect(ui_sfx_remove, SIGNAL(clicked()), this, SLOT(on_sfx_remove_clicked())); + ui_music_slider = new QSlider(Qt::Horizontal, this); + ui_music_slider->setRange(0, 100); + ui_music_slider->setValue(ao_app->get_default_music()); - connect(ui_effects_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_effects_dropdown_changed(int))); - connect(ui_effects_dropdown, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_effects_context_menu_requested(QPoint))); + ui_sfx_slider = new QSlider(Qt::Horizontal, this); + ui_sfx_slider->setRange(0, 100); + ui_sfx_slider->setValue(ao_app->get_default_sfx()); - connect(ui_mute_list, SIGNAL(clicked(QModelIndex)), this, SLOT(on_mute_list_clicked(QModelIndex))); + ui_blip_slider = new QSlider(Qt::Horizontal, this); + ui_blip_slider->setRange(0, 100); + ui_blip_slider->setValue(ao_app->get_default_blip()); - connect(ui_ic_chat_message, SIGNAL(returnPressed()), this, SLOT(on_chat_return_pressed())); + ui_mute_list = new QListWidget(this); - connect(ui_ooc_chat_message, SIGNAL(returnPressed()), this, SLOT(on_ooc_return_pressed())); + ui_pair_list = new QListWidget(this); + ui_pair_offset_spinbox = new QSpinBox(this); + ui_pair_offset_spinbox->setRange(-100, 100); + ui_pair_offset_spinbox->setSuffix(tr("% offset")); - connect(ui_music_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(on_music_list_double_clicked(QTreeWidgetItem *, int))); - connect(ui_music_list, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_music_list_context_menu_requested(QPoint))); + ui_pair_order_dropdown = new QComboBox(this); + ui_pair_order_dropdown->addItem("To front"); + ui_pair_order_dropdown->addItem("To behind"); - connect(ui_area_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(on_area_list_double_clicked(QTreeWidgetItem *, int))); + ui_pair_button = new AOButton(this, ao_app); - connect(ui_hold_it, SIGNAL(clicked()), this, SLOT(on_hold_it_clicked())); - connect(ui_objection, SIGNAL(clicked()), this, SLOT(on_objection_clicked())); - connect(ui_take_that, SIGNAL(clicked()), this, SLOT(on_take_that_clicked())); - connect(ui_custom_objection, SIGNAL(clicked()), this, SLOT(on_custom_objection_clicked())); + ui_evidence_button = new AOButton(this, ao_app); - connect(ui_realization, SIGNAL(clicked()), this, SLOT(on_realization_clicked())); - connect(ui_screenshake, SIGNAL(clicked()), this, SLOT(on_screenshake_clicked())); + initialize_evidence(); + + construct_char_select(); - connect(ui_mute, SIGNAL(clicked()), this, SLOT(on_mute_clicked())); + connect(keepalive_timer, SIGNAL(timeout()), this, SLOT(ping_server())); + + connect(ui_vp_objection, SIGNAL(done()), this, SLOT(objection_done())); + connect(ui_vp_player_char, SIGNAL(done()), this, SLOT(preanim_done())); + connect(ui_vp_player_char, SIGNAL(shake()), this, SLOT(do_screenshake())); + connect(ui_vp_player_char, SIGNAL(flash()), this, SLOT(do_flash())); + connect(ui_vp_player_char, SIGNAL(play_sfx(QString)), this, + SLOT(play_char_sfx(QString))); + + connect(text_delay_timer, SIGNAL(timeout()), this, + SLOT(start_chat_ticking())); + connect(sfx_delay_timer, SIGNAL(timeout()), this, SLOT(play_sfx())); + + connect(chat_tick_timer, SIGNAL(timeout()), this, SLOT(chat_tick())); + + connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this, + SLOT(on_pos_dropdown_changed(int))); + + connect(ui_iniswap_dropdown, SIGNAL(currentIndexChanged(int)), this, + SLOT(on_iniswap_dropdown_changed(int))); + connect(ui_iniswap_dropdown, SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(on_iniswap_context_menu_requested(QPoint))); + connect(ui_iniswap_remove, SIGNAL(clicked()), this, + SLOT(on_iniswap_remove_clicked())); + + connect(ui_sfx_dropdown, SIGNAL(currentIndexChanged(int)), this, + SLOT(on_sfx_dropdown_changed(int))); + connect(ui_sfx_dropdown, SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(on_sfx_context_menu_requested(QPoint))); + connect(ui_sfx_remove, SIGNAL(clicked()), this, + SLOT(on_sfx_remove_clicked())); + + connect(ui_effects_dropdown, SIGNAL(currentIndexChanged(int)), this, + SLOT(on_effects_dropdown_changed(int))); + connect(ui_effects_dropdown, SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(on_effects_context_menu_requested(QPoint))); + + connect(ui_mute_list, SIGNAL(clicked(QModelIndex)), this, + SLOT(on_mute_list_clicked(QModelIndex))); + + connect(ui_ic_chat_message, SIGNAL(returnPressed()), this, + SLOT(on_chat_return_pressed())); - connect(ui_defense_minus, SIGNAL(clicked()), this, SLOT(on_defense_minus_clicked())); - connect(ui_defense_plus, SIGNAL(clicked()), this, SLOT(on_defense_plus_clicked())); - connect(ui_prosecution_minus, SIGNAL(clicked()), this, SLOT(on_prosecution_minus_clicked())); - connect(ui_prosecution_plus, SIGNAL(clicked()), this, SLOT(on_prosecution_plus_clicked())); + connect(ui_ooc_chat_message, SIGNAL(returnPressed()), this, + SLOT(on_ooc_return_pressed())); - connect(ui_text_color, SIGNAL(currentIndexChanged(int)), this, SLOT(on_text_color_changed(int))); + connect(ui_music_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), + this, SLOT(on_music_list_double_clicked(QTreeWidgetItem *, int))); + connect(ui_music_list, SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(on_music_list_context_menu_requested(QPoint))); - connect(ui_music_slider, SIGNAL(valueChanged(int)), this, SLOT(on_music_slider_moved(int))); - connect(ui_sfx_slider, SIGNAL(valueChanged(int)), this, SLOT(on_sfx_slider_moved(int))); - connect(ui_blip_slider, SIGNAL(valueChanged(int)), this, SLOT(on_blip_slider_moved(int))); + connect(ui_area_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, + SLOT(on_area_list_double_clicked(QTreeWidgetItem *, int))); - connect(ui_ooc_toggle, SIGNAL(clicked()), this, SLOT(on_ooc_toggle_clicked())); + connect(ui_hold_it, SIGNAL(clicked()), this, SLOT(on_hold_it_clicked())); + connect(ui_objection, SIGNAL(clicked()), this, SLOT(on_objection_clicked())); + connect(ui_take_that, SIGNAL(clicked()), this, SLOT(on_take_that_clicked())); + connect(ui_custom_objection, SIGNAL(clicked()), this, + SLOT(on_custom_objection_clicked())); - connect(ui_music_search, SIGNAL(textChanged(QString)), this, SLOT(on_music_search_edited(QString))); + connect(ui_realization, SIGNAL(clicked()), this, + SLOT(on_realization_clicked())); + connect(ui_screenshake, SIGNAL(clicked()), this, + SLOT(on_screenshake_clicked())); + + connect(ui_mute, SIGNAL(clicked()), this, SLOT(on_mute_clicked())); - connect(ui_witness_testimony, SIGNAL(clicked()), this, SLOT(on_witness_testimony_clicked())); - connect(ui_cross_examination, SIGNAL(clicked()), this, SLOT(on_cross_examination_clicked())); - connect(ui_guilty, SIGNAL(clicked()), this, SLOT(on_guilty_clicked())); - connect(ui_not_guilty, SIGNAL(clicked()), this, SLOT(on_not_guilty_clicked())); - - connect(ui_change_character, SIGNAL(clicked()), this, SLOT(on_change_character_clicked())); - connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked())); - connect(ui_call_mod, SIGNAL(clicked()), this, SLOT(on_call_mod_clicked())); - connect(ui_settings, SIGNAL(clicked()), this, SLOT(on_settings_clicked())); - connect(ui_announce_casing, SIGNAL(clicked()), this, SLOT(on_announce_casing_clicked())); - connect(ui_switch_area_music, SIGNAL(clicked()), this, SLOT(on_switch_area_music_clicked())); - - connect(ui_pre, SIGNAL(clicked()), this, SLOT(on_pre_clicked())); - connect(ui_flip, SIGNAL(clicked()), this, SLOT(on_flip_clicked())); - connect(ui_additive, SIGNAL(clicked()), this, SLOT(on_additive_clicked())); - connect(ui_guard, SIGNAL(clicked()), this, SLOT(on_guard_clicked())); - connect(ui_casing, SIGNAL(clicked()), this, SLOT(on_casing_clicked())); - - connect(ui_showname_enable, SIGNAL(clicked()), this, SLOT(on_showname_enable_clicked())); - - connect(ui_pair_button, SIGNAL(clicked()), this, SLOT(on_pair_clicked())); - connect(ui_pair_list, SIGNAL(clicked(QModelIndex)), this, SLOT(on_pair_list_clicked(QModelIndex))); - connect(ui_pair_offset_spinbox, SIGNAL(valueChanged(int)), this, SLOT(on_pair_offset_changed(int))); - connect(ui_pair_order_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_pair_order_dropdown_changed(int))); - - connect(ui_evidence_button, SIGNAL(clicked()), this, SLOT(on_evidence_button_clicked())); - - set_widgets(); - - set_char_select(); + connect(ui_defense_minus, SIGNAL(clicked()), this, + SLOT(on_defense_minus_clicked())); + connect(ui_defense_plus, SIGNAL(clicked()), this, + SLOT(on_defense_plus_clicked())); + connect(ui_prosecution_minus, SIGNAL(clicked()), this, + SLOT(on_prosecution_minus_clicked())); + connect(ui_prosecution_plus, SIGNAL(clicked()), this, + SLOT(on_prosecution_plus_clicked())); + + connect(ui_text_color, SIGNAL(currentIndexChanged(int)), this, + SLOT(on_text_color_changed(int))); + + connect(ui_music_slider, SIGNAL(valueChanged(int)), this, + SLOT(on_music_slider_moved(int))); + connect(ui_sfx_slider, SIGNAL(valueChanged(int)), this, + SLOT(on_sfx_slider_moved(int))); + connect(ui_blip_slider, SIGNAL(valueChanged(int)), this, + SLOT(on_blip_slider_moved(int))); + + connect(ui_ooc_toggle, SIGNAL(clicked()), this, + SLOT(on_ooc_toggle_clicked())); + + connect(ui_music_search, SIGNAL(textChanged(QString)), this, + SLOT(on_music_search_edited(QString))); + + connect(ui_witness_testimony, SIGNAL(clicked()), this, + SLOT(on_witness_testimony_clicked())); + connect(ui_cross_examination, SIGNAL(clicked()), this, + SLOT(on_cross_examination_clicked())); + connect(ui_guilty, SIGNAL(clicked()), this, SLOT(on_guilty_clicked())); + connect(ui_not_guilty, SIGNAL(clicked()), this, + SLOT(on_not_guilty_clicked())); + + connect(ui_change_character, SIGNAL(clicked()), this, + SLOT(on_change_character_clicked())); + connect(ui_reload_theme, SIGNAL(clicked()), this, + SLOT(on_reload_theme_clicked())); + connect(ui_call_mod, SIGNAL(clicked()), this, SLOT(on_call_mod_clicked())); + connect(ui_settings, SIGNAL(clicked()), this, SLOT(on_settings_clicked())); + connect(ui_announce_casing, SIGNAL(clicked()), this, + SLOT(on_announce_casing_clicked())); + connect(ui_switch_area_music, SIGNAL(clicked()), this, + SLOT(on_switch_area_music_clicked())); + + connect(ui_pre, SIGNAL(clicked()), this, SLOT(on_pre_clicked())); + connect(ui_flip, SIGNAL(clicked()), this, SLOT(on_flip_clicked())); + connect(ui_additive, SIGNAL(clicked()), this, SLOT(on_additive_clicked())); + connect(ui_guard, SIGNAL(clicked()), this, SLOT(on_guard_clicked())); + connect(ui_casing, SIGNAL(clicked()), this, SLOT(on_casing_clicked())); + + connect(ui_showname_enable, SIGNAL(clicked()), this, + SLOT(on_showname_enable_clicked())); + + connect(ui_pair_button, SIGNAL(clicked()), this, SLOT(on_pair_clicked())); + connect(ui_pair_list, SIGNAL(clicked(QModelIndex)), this, + SLOT(on_pair_list_clicked(QModelIndex))); + connect(ui_pair_offset_spinbox, SIGNAL(valueChanged(int)), this, + SLOT(on_pair_offset_changed(int))); + connect(ui_pair_order_dropdown, SIGNAL(currentIndexChanged(int)), this, + SLOT(on_pair_order_dropdown_changed(int))); + + connect(ui_evidence_button, SIGNAL(clicked()), this, + SLOT(on_evidence_button_clicked())); + + set_widgets(); + + set_char_select(); } void Courtroom::set_mute_list() { - mute_map.clear(); + mute_map.clear(); - //maps which characters are muted based on cid, none are muted by default - for (int n_cid = 0; n_cid < char_list.size(); n_cid++) { - mute_map.insert(n_cid, false); - } + // maps which characters are muted based on cid, none are muted by default + for (int n_cid = 0; n_cid < char_list.size(); n_cid++) { + mute_map.insert(n_cid, false); + } - QStringList sorted_mute_list; + QStringList sorted_mute_list; - for (char_type i_char : char_list) - sorted_mute_list.append(i_char.name); + for (char_type i_char : char_list) + sorted_mute_list.append(i_char.name); - sorted_mute_list.sort(); + sorted_mute_list.sort(); - for (QString i_name : sorted_mute_list) { - //mute_map.insert(i_name, false); - ui_mute_list->addItem(i_name); - } + for (QString i_name : sorted_mute_list) { + // mute_map.insert(i_name, false); + ui_mute_list->addItem(i_name); + } } void Courtroom::set_pair_list() { - QStringList sorted_pair_list; + QStringList sorted_pair_list; - for (char_type i_char : char_list) - sorted_pair_list.append(i_char.name); + for (char_type i_char : char_list) + sorted_pair_list.append(i_char.name); - sorted_pair_list.sort(); + sorted_pair_list.sort(); - for (QString i_name : sorted_pair_list) { - ui_pair_list->addItem(i_name); - } + for (QString i_name : sorted_pair_list) { + ui_pair_list->addItem(i_name); + } } void Courtroom::set_widgets() { - blip_rate = ao_app->read_blip_rate(); - blank_blip = ao_app->get_blank_blip(); - - QString filename = "courtroom_design.ini"; - - pos_size_type f_courtroom = ao_app->get_element_dimensions("courtroom", filename); - - if (f_courtroom.width < 0 || f_courtroom.height < 0) { - qDebug() << "W: did not find courtroom width or height in " << filename; - - this->resize(714, 668); - } - else { - m_courtroom_width = f_courtroom.width; - m_courtroom_height = f_courtroom.height; - - this->resize(f_courtroom.width, f_courtroom.height); - } - - set_fonts(); - - ui_background->move(0, 0); - ui_background->resize(m_courtroom_width, m_courtroom_height); - ui_background->set_image("courtroombackground"); - - set_size_and_pos(ui_viewport, "viewport"); - - // If there is a point to it, show all CCCC features. - // We also do this this soon so that set_size_and_pos can hide them all later, if needed. - if (ao_app->cccc_ic_support_enabled) { - ui_pair_button->show(); - ui_pre_non_interrupt->show(); - ui_showname_enable->show(); - ui_ic_chat_name->show(); - ui_ic_chat_name->setEnabled(true); - } - else { - ui_pair_button->hide(); - ui_pre_non_interrupt->hide(); - ui_showname_enable->hide(); - ui_ic_chat_name->hide(); - ui_ic_chat_name->setEnabled(false); - } - - if (ao_app->casing_alerts_enabled) { - ui_announce_casing->show(); - ui_casing->show(); - } - else { - ui_announce_casing->hide(); - ui_casing->hide(); - } - - // We also show the non-server-dependent client additions. - // Once again, if the theme can't display it, set_move_and_pos will catch them. - ui_settings->show(); - - ui_vp_background->move(0, 0); - ui_vp_background->combo_resize(ui_viewport->width(), ui_viewport->height()); - - ui_vp_speedlines->move(0, 0); - ui_vp_speedlines->combo_resize(ui_viewport->width(), ui_viewport->height()); - - ui_vp_player_char->move(0, 0); - ui_vp_player_char->combo_resize(ui_viewport->width(), ui_viewport->height()); - - ui_vp_sideplayer_char->move(0, 0); - ui_vp_sideplayer_char->combo_resize(ui_viewport->width(), ui_viewport->height()); - - //the AO2 desk element - ui_vp_desk->move(0, 0); - ui_vp_desk->combo_resize(ui_viewport->width(), ui_viewport->height()); - - //the size of the ui_vp_legacy_desk element relies on various factors and is set in set_scene() - - double y_modifier = 147.0 / 192.0; - int final_y = static_cast<int>(y_modifier * ui_viewport->height()); - ui_vp_legacy_desk->move(0, final_y); - ui_vp_legacy_desk->hide(); - - ui_vp_evidence_display->move(0, 0); - ui_vp_evidence_display->combo_resize(ui_viewport->width(), ui_viewport->height()); - - ui_vp_chat_arrow->move(0, 0); - pos_size_type design_ini_result = ao_app->get_element_dimensions("chat_arrow", "courtroom_design.ini"); - - if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; - ui_vp_chat_arrow->hide(); - } - else { - ui_vp_chat_arrow->move(design_ini_result.x, design_ini_result.y); - ui_vp_chat_arrow->combo_resize(design_ini_result.width, design_ini_result.height); - } - - ui_vp_testimony->move(ui_viewport->x(), ui_viewport->y()); - ui_vp_testimony->combo_resize(ui_viewport->width(), ui_viewport->height()); - - ui_vp_effect->move(ui_viewport->x(), ui_viewport->y()); - ui_vp_effect->combo_resize(ui_viewport->width(), ui_viewport->height()); - - ui_vp_wtce->move(ui_viewport->x(), ui_viewport->y()); - ui_vp_wtce->combo_resize(ui_viewport->width(), ui_viewport->height()); - - ui_vp_objection->move(ui_viewport->x(), ui_viewport->y()); - ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height()); - - set_size_and_pos(ui_ic_chatlog, "ic_chatlog"); - ui_ic_chatlog->setFrameShape(QFrame::NoFrame); - - set_size_and_pos(ui_ms_chatlog, "ms_chatlog"); - ui_ms_chatlog->setFrameShape(QFrame::NoFrame); - - set_size_and_pos(ui_server_chatlog, "server_chatlog"); - ui_server_chatlog->setFrameShape(QFrame::NoFrame); - - set_size_and_pos(ui_mute_list, "mute_list"); - ui_mute_list->hide(); - - set_size_and_pos(ui_pair_list, "pair_list"); - ui_pair_list->hide(); - ui_pair_list->setToolTip(tr("Select a character you wish to pair with.")); - - set_size_and_pos(ui_pair_offset_spinbox, "pair_offset_spinbox"); - ui_pair_offset_spinbox->hide(); - ui_pair_offset_spinbox->setToolTip(tr("Change the percentage offset of your character's position from the center of the screen.")); - - ui_pair_order_dropdown->hide(); - set_size_and_pos(ui_pair_order_dropdown, "pair_order_dropdown"); - ui_pair_offset_spinbox->setToolTip(tr("Change the order of appearance for your character.")); - - set_size_and_pos(ui_pair_button, "pair_button"); - ui_pair_button->set_image("pair_button"); - ui_pair_button->setToolTip(tr("Display the list of characters to pair with.")); - - set_size_and_pos(ui_area_list, "music_list"); - ui_area_list->header()->setMinimumSectionSize(ui_area_list->width()); - - set_size_and_pos(ui_music_list, "music_list"); - ui_music_list->header()->setMinimumSectionSize(ui_music_list->width()); - - set_size_and_pos(ui_music_name, "music_name"); - - ui_music_display->move(0, 0); - design_ini_result = ao_app->get_element_dimensions("music_display", "courtroom_design.ini"); - - if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"music_name\" in courtroom_design.ini"; - ui_music_display->hide(); - } - else { - ui_music_display->move(design_ini_result.x, design_ini_result.y); - ui_music_display->combo_resize(design_ini_result.width, design_ini_result.height); - } - - ui_music_display->play("music_display"); - - if (is_ao2_bg) { - set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); - set_size_and_pos(ui_vp_chatbox, "ao2_chatbox"); - set_size_and_pos(ui_ic_chat_name, "ao2_ic_chat_name"); - } - else { - set_size_and_pos(ui_ic_chat_message, "ic_chat_message"); - set_size_and_pos(ui_vp_chatbox, "chatbox"); - set_size_and_pos(ui_ic_chat_name, "ic_chat_name"); - } - - ui_ic_chat_message->setStyleSheet("QLineEdit{background-color: rgba(100, 100, 100, 255);}"); - ui_ic_chat_name->setStyleSheet("QLineEdit{background-color: rgba(180, 180, 180, 255);}"); - - ui_vp_chatbox->set_image("chatblank"); - ui_vp_chatbox->hide(); - - set_size_and_pos(ui_vp_showname, "showname"); - - set_size_and_pos(ui_vp_message, "message"); - ui_vp_message->hide(); - - //We detached the text as parent from the chatbox so it doesn't get affected by the screenshake. - ui_vp_message->move(ui_vp_message->x() + ui_vp_chatbox->x(), ui_vp_message->y() + ui_vp_chatbox->y()); - ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction); - - ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height()); - ui_muted->set_image("muted"); - ui_muted->setToolTip(tr("Oops, you're muted!")); - - set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message"); - ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); - - set_size_and_pos(ui_ooc_chat_name, "ooc_chat_name"); - ui_ooc_chat_name->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); - - //set_size_and_pos(ui_area_password, "area_password"); - set_size_and_pos(ui_music_search, "music_search"); - ui_music_search->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); - - set_size_and_pos(ui_emote_dropdown, "emote_dropdown"); - ui_emote_dropdown->setToolTip(tr("Set your character's emote to play on your next message.")); + blip_rate = ao_app->read_blip_rate(); + blank_blip = ao_app->get_blank_blip(); - set_size_and_pos(ui_pos_dropdown, "pos_dropdown"); - ui_pos_dropdown->setToolTip(tr("Set your character's supplementary background.")); + QString filename = "courtroom_design.ini"; - set_size_and_pos(ui_iniswap_dropdown, "iniswap_dropdown"); - ui_iniswap_dropdown->setEditable(true); - ui_iniswap_dropdown->setInsertPolicy(QComboBox::InsertAtBottom); - ui_iniswap_dropdown->setToolTip(tr("Set an 'iniswap', or an alternative character folder to refer to from your current character.\n" - "Edit by typing and pressing Enter, [X] to remove. This saves to your base/characters/<charname>/iniswaps.ini")); + pos_size_type f_courtroom = + ao_app->get_element_dimensions("courtroom", filename); - set_size_and_pos(ui_iniswap_remove, "iniswap_remove"); - ui_iniswap_remove->setText("X"); - ui_iniswap_remove->set_image("evidencex"); - ui_iniswap_remove->setToolTip(tr("Remove the currently selected iniswap from the list and return to the original character folder.")); - ui_iniswap_remove->hide(); - - set_size_and_pos(ui_sfx_dropdown, "sfx_dropdown"); - ui_sfx_dropdown->setEditable(true); - ui_sfx_dropdown->setInsertPolicy(QComboBox::InsertAtBottom); - ui_sfx_dropdown->setToolTip(tr("Set a sound effect to play on your next 'Preanim'. Leaving it on Default will use the emote-defined sound (if any).\n" - "Edit by typing and pressing Enter, [X] to remove. This saves to your base/characters/<charname>/soundlist.ini")); - - set_size_and_pos(ui_sfx_remove, "sfx_remove"); - ui_sfx_remove->setText("X"); - ui_sfx_remove->set_image("evidencex"); - ui_sfx_remove->setToolTip(tr("Remove the currently selected iniswap from the list and return to the original character folder.")); - ui_sfx_remove->hide(); - - set_size_and_pos(ui_effects_dropdown, "effects_dropdown"); - ui_effects_dropdown->setInsertPolicy(QComboBox::InsertAtBottom); - ui_effects_dropdown->setToolTip(tr("Choose an effect to play on your next spoken message.\n" - "The effects are defined in your theme/effects/effects.ini. Your character can define custom effects by\n" - "char.ini [Options] category, effects = 'miscname' where it referes to misc/<miscname>/effects.ini to read the effects.")); - //Todo: recode this entire fucking system with these dumbass goddamn ini's why is everything so specifically coded for all these purposes - //is ABSTRACT CODING not a thing now huh what the FUCK why do I gotta do this pleASE FOR THE LOVE OF GOD SPARE ME FROM THIS FRESH HELL - //btw i still love coding. - QPoint p_point = ao_app->get_button_spacing("effects_icon_size", filename); - ui_effects_dropdown->setIconSize(QSize(p_point.x(), p_point.y())); - - set_size_and_pos(ui_defense_bar, "defense_bar"); - ui_defense_bar->set_image("defensebar" + QString::number(defense_bar_state)); - - set_size_and_pos(ui_prosecution_bar, "prosecution_bar"); - ui_prosecution_bar->set_image("prosecutionbar" + QString::number(prosecution_bar_state)); - - set_size_and_pos(ui_music_label, "music_label"); - ui_music_label->setText(tr("Music")); - set_size_and_pos(ui_sfx_label, "sfx_label"); - ui_sfx_label->setText(tr("Sfx")); - set_size_and_pos(ui_blip_label, "blip_label"); - ui_blip_label->setText(tr("Blips")); - - set_size_and_pos(ui_hold_it, "hold_it"); - ui_hold_it->setText(tr("Hold It!")); - ui_hold_it->setToolTip(tr("When this is turned on, your next in-character message will be a shout!")); - ui_hold_it->set_image("holdit"); - - set_size_and_pos(ui_objection, "objection"); - ui_objection->setText(tr("Objection!")); - ui_objection->setToolTip(tr("When this is turned on, your next in-character message will be a shout!")); - ui_objection->set_image("objection"); + if (f_courtroom.width < 0 || f_courtroom.height < 0) { + qDebug() << "W: did not find courtroom width or height in " << filename; - set_size_and_pos(ui_take_that, "take_that"); - ui_take_that->setText(tr("Take That!")); - ui_take_that->setToolTip(tr("When this is turned on, your next in-character message will be a shout!")); - ui_take_that->set_image("takethat"); + this->resize(714, 668); + } + else { + m_courtroom_width = f_courtroom.width; + m_courtroom_height = f_courtroom.height; - set_size_and_pos(ui_ooc_toggle, "ooc_toggle"); - ui_ooc_toggle->setText(tr("Server")); - ui_ooc_toggle->setToolTip(tr("Toggle between server chat and global AO2 chat.")); - - set_size_and_pos(ui_witness_testimony, "witness_testimony"); - ui_witness_testimony->set_image("witnesstestimony"); - ui_witness_testimony->setToolTip(tr("This will display the animation in the viewport as soon as it is pressed.")); - set_size_and_pos(ui_cross_examination, "cross_examination"); - ui_cross_examination->set_image("crossexamination"); - ui_cross_examination->setToolTip(tr("This will display the animation in the viewport as soon as it is pressed.")); - - set_size_and_pos(ui_guilty, "guilty"); - ui_guilty->setText(tr("Guilty!")); - ui_guilty->set_image("guilty"); - ui_guilty->setToolTip(tr("This will display the animation in the viewport as soon as it is pressed.")); - set_size_and_pos(ui_not_guilty, "not_guilty"); - ui_not_guilty->set_image("notguilty"); - ui_not_guilty->setToolTip(tr("This will display the animation in the viewport as soon as it is pressed.")); - - set_size_and_pos(ui_change_character, "change_character"); - ui_change_character->setText(tr("Change character")); - ui_change_character->set_image("change_character"); - ui_change_character->setToolTip(tr("Bring up the Character Select Screen and change your character.")); - - set_size_and_pos(ui_reload_theme, "reload_theme"); - ui_reload_theme->setText(tr("Reload theme")); - ui_reload_theme->set_image("reload_theme"); - ui_reload_theme->setToolTip(tr("Refresh the theme and update all of the ui elements to match.")); - - set_size_and_pos(ui_call_mod, "call_mod"); - ui_call_mod->setText(tr("Call mod")); - ui_call_mod->set_image("call_mod"); - ui_call_mod->setToolTip(tr("Request the attention of the current server's moderator.")); - - set_size_and_pos(ui_settings, "settings"); - ui_settings->setText(tr("Settings")); - ui_settings->set_image("settings"); - ui_settings->setToolTip(tr("Allows you to change various aspects of the client.")); - - set_size_and_pos(ui_announce_casing, "casing_button"); - ui_announce_casing->setText(tr("Casing")); - ui_announce_casing->set_image("casing_button"); - ui_announce_casing->setToolTip(tr("An interface to help you announce a case (you have to be a CM first to be able to announce cases)")); - - set_size_and_pos(ui_switch_area_music, "switch_area_music"); - ui_switch_area_music->setText(tr("A/M")); - ui_switch_area_music->set_image("switch_area_music"); - ui_switch_area_music->setToolTip(tr("Switch between Areas and Music lists")); - - set_size_and_pos(ui_pre, "pre"); - ui_pre->setText(tr("Preanim")); - ui_pre->setToolTip(tr("Play a single-shot animation as defined by the emote when checked.")); - - set_size_and_pos(ui_pre_non_interrupt, "pre_no_interrupt"); - ui_pre_non_interrupt->setToolTip(tr("If preanim is checked, display the input text immediately as the animation plays concurrently.")); - - set_size_and_pos(ui_flip, "flip"); - ui_flip->setToolTip(tr("Mirror your character's emotes when checked.")); - - set_size_and_pos(ui_additive, "additive"); - ui_additive->setToolTip(tr("Add text to your last spoken message when checked.")); - - set_size_and_pos(ui_guard, "guard"); - ui_guard->setToolTip(tr("Do not listen to mod calls when checked, preventing them from playing sounds or focusing attention on the window.")); - - set_size_and_pos(ui_casing, "casing"); - ui_casing->setToolTip(tr("Lets you receive case alerts when enabled.\n" - "(You can set your preferences in the Settings!)")); - - set_size_and_pos(ui_showname_enable, "showname_enable"); - ui_showname_enable->setToolTip(tr("Display customized shownames for all users when checked.")); - - set_size_and_pos(ui_custom_objection, "custom_objection"); - ui_custom_objection->setText(tr("Custom Shout!")); - ui_custom_objection->set_image("custom"); - ui_custom_objection->setToolTip(tr("This will display the custom character-defined animation in the viewport as soon as it is pressed.\n" - "To make one, your character's folder must contain custom.[webp/apng/gif/png] and custom.[wav/ogg/opus] sound effect")); + this->resize(f_courtroom.width, f_courtroom.height); + } - set_size_and_pos(ui_realization, "realization"); - ui_realization->set_image("realization"); - ui_realization->setToolTip(tr("Play realization sound and animation in the viewport on the next spoken message when checked.")); + set_fonts(); - set_size_and_pos(ui_screenshake, "screenshake"); - ui_screenshake->set_image("screenshake"); - ui_screenshake->setToolTip(tr("Shake the screen on next spoken message when checked.")); + ui_background->move(0, 0); + ui_background->resize(m_courtroom_width, m_courtroom_height); + ui_background->set_image("courtroombackground"); - set_size_and_pos(ui_mute, "mute_button"); - ui_mute->setText("Mute"); - ui_mute->set_image("mute"); - ui_mute->setToolTip(tr("Display the list of character folders you wish to mute.")); + set_size_and_pos(ui_viewport, "viewport"); - set_size_and_pos(ui_defense_plus, "defense_plus"); - ui_defense_plus->set_image("defplus"); - ui_defense_plus->setToolTip(tr("Increase the health bar.")); + // If there is a point to it, show all CCCC features. + // We also do this this soon so that set_size_and_pos can hide them all later, + // if needed. + if (ao_app->cccc_ic_support_enabled) { + ui_pair_button->show(); + ui_pre_non_interrupt->show(); + ui_showname_enable->show(); + ui_ic_chat_name->show(); + ui_ic_chat_name->setEnabled(true); + } + else { + ui_pair_button->hide(); + ui_pre_non_interrupt->hide(); + ui_showname_enable->hide(); + ui_ic_chat_name->hide(); + ui_ic_chat_name->setEnabled(false); + } + + if (ao_app->casing_alerts_enabled) { + ui_announce_casing->show(); + ui_casing->show(); + } + else { + ui_announce_casing->hide(); + ui_casing->hide(); + } - set_size_and_pos(ui_defense_minus, "defense_minus"); - ui_defense_minus->set_image("defminus"); - ui_defense_minus->setToolTip(tr("Decrease the health bar.")); + // We also show the non-server-dependent client additions. + // Once again, if the theme can't display it, set_move_and_pos will catch + // them. + ui_settings->show(); - set_size_and_pos(ui_prosecution_plus, "prosecution_plus"); - ui_prosecution_plus->set_image("proplus"); - ui_prosecution_plus->setToolTip(tr("Increase the health bar.")); + ui_vp_background->move(0, 0); + ui_vp_background->combo_resize(ui_viewport->width(), ui_viewport->height()); - set_size_and_pos(ui_prosecution_minus, "prosecution_minus"); - ui_prosecution_minus->set_image("prominus"); - ui_prosecution_minus->setToolTip(tr("Decrease the health bar.")); + ui_vp_speedlines->move(0, 0); + ui_vp_speedlines->combo_resize(ui_viewport->width(), ui_viewport->height()); - set_size_and_pos(ui_text_color, "text_color"); - ui_text_color->setToolTip(tr("Change the text color of the spoken message.\n" - "You can also select a part of your currently typed message and use the dropdown to change its color!")); - set_text_color_dropdown(); + ui_vp_player_char->move(0, 0); + ui_vp_player_char->combo_resize(ui_viewport->width(), ui_viewport->height()); - set_size_and_pos(ui_music_slider, "music_slider"); - set_size_and_pos(ui_sfx_slider, "sfx_slider"); - set_size_and_pos(ui_blip_slider, "blip_slider"); + ui_vp_sideplayer_char->move(0, 0); + ui_vp_sideplayer_char->combo_resize(ui_viewport->width(), + ui_viewport->height()); - ui_selector->set_image("char_selector"); - ui_selector->hide(); + // the AO2 desk element + ui_vp_desk->move(0, 0); + ui_vp_desk->combo_resize(ui_viewport->width(), ui_viewport->height()); + + // the size of the ui_vp_legacy_desk element relies on various factors and is + // set in set_scene() + + double y_modifier = 147.0 / 192.0; + int final_y = static_cast<int>(y_modifier * ui_viewport->height()); + ui_vp_legacy_desk->move(0, final_y); + ui_vp_legacy_desk->hide(); + + ui_vp_evidence_display->move(0, 0); + ui_vp_evidence_display->combo_resize(ui_viewport->width(), + ui_viewport->height()); + + ui_vp_chat_arrow->move(0, 0); + pos_size_type design_ini_result = + ao_app->get_element_dimensions("chat_arrow", "courtroom_design.ini"); + + if (design_ini_result.width < 0 || design_ini_result.height < 0) { + qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; + ui_vp_chat_arrow->hide(); + } + else { + ui_vp_chat_arrow->move(design_ini_result.x, design_ini_result.y); + ui_vp_chat_arrow->combo_resize(design_ini_result.width, + design_ini_result.height); + } + + ui_vp_testimony->move(ui_viewport->x(), ui_viewport->y()); + ui_vp_testimony->combo_resize(ui_viewport->width(), ui_viewport->height()); + + ui_vp_effect->move(ui_viewport->x(), ui_viewport->y()); + ui_vp_effect->combo_resize(ui_viewport->width(), ui_viewport->height()); + + ui_vp_wtce->move(ui_viewport->x(), ui_viewport->y()); + ui_vp_wtce->combo_resize(ui_viewport->width(), ui_viewport->height()); - set_size_and_pos(ui_back_to_lobby, "back_to_lobby"); - ui_back_to_lobby->setText(tr("Back to Lobby")); - ui_back_to_lobby->setToolTip(tr("Return back to the server list.")); + ui_vp_objection->move(ui_viewport->x(), ui_viewport->y()); + ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height()); - set_size_and_pos(ui_char_password, "char_password"); + set_size_and_pos(ui_ic_chatlog, "ic_chatlog"); + ui_ic_chatlog->setFrameShape(QFrame::NoFrame); + + set_size_and_pos(ui_ms_chatlog, "ms_chatlog"); + ui_ms_chatlog->setFrameShape(QFrame::NoFrame); + + set_size_and_pos(ui_server_chatlog, "server_chatlog"); + ui_server_chatlog->setFrameShape(QFrame::NoFrame); - set_size_and_pos(ui_char_buttons, "char_buttons"); + set_size_and_pos(ui_mute_list, "mute_list"); + ui_mute_list->hide(); + + set_size_and_pos(ui_pair_list, "pair_list"); + ui_pair_list->hide(); + ui_pair_list->setToolTip(tr("Select a character you wish to pair with.")); + + set_size_and_pos(ui_pair_offset_spinbox, "pair_offset_spinbox"); + ui_pair_offset_spinbox->hide(); + ui_pair_offset_spinbox->setToolTip( + tr("Change the percentage offset of your character's position from the " + "center of the screen.")); + + ui_pair_order_dropdown->hide(); + set_size_and_pos(ui_pair_order_dropdown, "pair_order_dropdown"); + ui_pair_offset_spinbox->setToolTip( + tr("Change the order of appearance for your character.")); + + set_size_and_pos(ui_pair_button, "pair_button"); + ui_pair_button->set_image("pair_button"); + ui_pair_button->setToolTip( + tr("Display the list of characters to pair with.")); + + set_size_and_pos(ui_area_list, "music_list"); + ui_area_list->header()->setMinimumSectionSize(ui_area_list->width()); + + set_size_and_pos(ui_music_list, "music_list"); + ui_music_list->header()->setMinimumSectionSize(ui_music_list->width()); + + set_size_and_pos(ui_music_name, "music_name"); + + ui_music_display->move(0, 0); + design_ini_result = + ao_app->get_element_dimensions("music_display", "courtroom_design.ini"); + + if (design_ini_result.width < 0 || design_ini_result.height < 0) { + qDebug() << "W: could not find \"music_name\" in courtroom_design.ini"; + ui_music_display->hide(); + } + else { + ui_music_display->move(design_ini_result.x, design_ini_result.y); + ui_music_display->combo_resize(design_ini_result.width, + design_ini_result.height); + } + + ui_music_display->play("music_display"); + + if (is_ao2_bg) { + set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); + set_size_and_pos(ui_vp_chatbox, "ao2_chatbox"); + set_size_and_pos(ui_ic_chat_name, "ao2_ic_chat_name"); + } + else { + set_size_and_pos(ui_ic_chat_message, "ic_chat_message"); + set_size_and_pos(ui_vp_chatbox, "chatbox"); + set_size_and_pos(ui_ic_chat_name, "ic_chat_name"); + } + + ui_ic_chat_message->setStyleSheet( + "QLineEdit{background-color: rgba(100, 100, 100, 255);}"); + ui_ic_chat_name->setStyleSheet( + "QLineEdit{background-color: rgba(180, 180, 180, 255);}"); + + ui_vp_chatbox->set_image("chatblank"); + ui_vp_chatbox->hide(); + + set_size_and_pos(ui_vp_showname, "showname"); + + set_size_and_pos(ui_vp_message, "message"); + ui_vp_message->hide(); + + // We detached the text as parent from the chatbox so it doesn't get affected + // by the screenshake. + ui_vp_message->move(ui_vp_message->x() + ui_vp_chatbox->x(), + ui_vp_message->y() + ui_vp_chatbox->y()); + ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction); + + ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height()); + ui_muted->set_image("muted"); + ui_muted->setToolTip(tr("Oops, you're muted!")); + + set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message"); + ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); + + set_size_and_pos(ui_ooc_chat_name, "ooc_chat_name"); + ui_ooc_chat_name->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); + + // set_size_and_pos(ui_area_password, "area_password"); + set_size_and_pos(ui_music_search, "music_search"); + ui_music_search->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); + + set_size_and_pos(ui_emote_dropdown, "emote_dropdown"); + ui_emote_dropdown->setToolTip( + tr("Set your character's emote to play on your next message.")); + + set_size_and_pos(ui_pos_dropdown, "pos_dropdown"); + ui_pos_dropdown->setToolTip( + tr("Set your character's supplementary background.")); + + set_size_and_pos(ui_iniswap_dropdown, "iniswap_dropdown"); + ui_iniswap_dropdown->setEditable(true); + ui_iniswap_dropdown->setInsertPolicy(QComboBox::InsertAtBottom); + ui_iniswap_dropdown->setToolTip( + tr("Set an 'iniswap', or an alternative character folder to refer to " + "from your current character.\n" + "Edit by typing and pressing Enter, [X] to remove. This saves to your " + "base/characters/<charname>/iniswaps.ini")); + + set_size_and_pos(ui_iniswap_remove, "iniswap_remove"); + ui_iniswap_remove->setText("X"); + ui_iniswap_remove->set_image("evidencex"); + ui_iniswap_remove->setToolTip( + tr("Remove the currently selected iniswap from the list and return to " + "the original character folder.")); + ui_iniswap_remove->hide(); + + set_size_and_pos(ui_sfx_dropdown, "sfx_dropdown"); + ui_sfx_dropdown->setEditable(true); + ui_sfx_dropdown->setInsertPolicy(QComboBox::InsertAtBottom); + ui_sfx_dropdown->setToolTip( + tr("Set a sound effect to play on your next 'Preanim'. Leaving it on " + "Default will use the emote-defined sound (if any).\n" + "Edit by typing and pressing Enter, [X] to remove. This saves to your " + "base/characters/<charname>/soundlist.ini")); + + set_size_and_pos(ui_sfx_remove, "sfx_remove"); + ui_sfx_remove->setText("X"); + ui_sfx_remove->set_image("evidencex"); + ui_sfx_remove->setToolTip( + tr("Remove the currently selected iniswap from the list and return to " + "the original character folder.")); + ui_sfx_remove->hide(); + + set_size_and_pos(ui_effects_dropdown, "effects_dropdown"); + ui_effects_dropdown->setInsertPolicy(QComboBox::InsertAtBottom); + ui_effects_dropdown->setToolTip( + tr("Choose an effect to play on your next spoken message.\n" + "The effects are defined in your theme/effects/effects.ini. Your " + "character can define custom effects by\n" + "char.ini [Options] category, effects = 'miscname' where it referes " + "to misc/<miscname>/effects.ini to read the effects.")); + // Todo: recode this entire fucking system with these dumbass goddamn ini's + // why is everything so specifically coded for all these purposes is ABSTRACT + // CODING not a thing now huh what the FUCK why do I gotta do this pleASE FOR + // THE LOVE OF GOD SPARE ME FROM THIS FRESH HELL btw i still love coding. + QPoint p_point = ao_app->get_button_spacing("effects_icon_size", filename); + ui_effects_dropdown->setIconSize(QSize(p_point.x(), p_point.y())); + + set_size_and_pos(ui_defense_bar, "defense_bar"); + ui_defense_bar->set_image("defensebar" + QString::number(defense_bar_state)); + + set_size_and_pos(ui_prosecution_bar, "prosecution_bar"); + ui_prosecution_bar->set_image("prosecutionbar" + + QString::number(prosecution_bar_state)); + + set_size_and_pos(ui_music_label, "music_label"); + ui_music_label->setText(tr("Music")); + set_size_and_pos(ui_sfx_label, "sfx_label"); + ui_sfx_label->setText(tr("Sfx")); + set_size_and_pos(ui_blip_label, "blip_label"); + ui_blip_label->setText(tr("Blips")); + + set_size_and_pos(ui_hold_it, "hold_it"); + ui_hold_it->setText(tr("Hold It!")); + ui_hold_it->setToolTip(tr("When this is turned on, your next in-character " + "message will be a shout!")); + ui_hold_it->set_image("holdit"); + + set_size_and_pos(ui_objection, "objection"); + ui_objection->setText(tr("Objection!")); + ui_objection->setToolTip(tr("When this is turned on, your next in-character " + "message will be a shout!")); + ui_objection->set_image("objection"); + + set_size_and_pos(ui_take_that, "take_that"); + ui_take_that->setText(tr("Take That!")); + ui_take_that->setToolTip(tr("When this is turned on, your next in-character " + "message will be a shout!")); + ui_take_that->set_image("takethat"); + + set_size_and_pos(ui_ooc_toggle, "ooc_toggle"); + ui_ooc_toggle->setText(tr("Server")); + ui_ooc_toggle->setToolTip( + tr("Toggle between server chat and global AO2 chat.")); + + set_size_and_pos(ui_witness_testimony, "witness_testimony"); + ui_witness_testimony->set_image("witnesstestimony"); + ui_witness_testimony->setToolTip(tr("This will display the animation in the " + "viewport as soon as it is pressed.")); + set_size_and_pos(ui_cross_examination, "cross_examination"); + ui_cross_examination->set_image("crossexamination"); + ui_cross_examination->setToolTip(tr("This will display the animation in the " + "viewport as soon as it is pressed.")); + + set_size_and_pos(ui_guilty, "guilty"); + ui_guilty->setText(tr("Guilty!")); + ui_guilty->set_image("guilty"); + ui_guilty->setToolTip(tr("This will display the animation in the viewport as " + "soon as it is pressed.")); + set_size_and_pos(ui_not_guilty, "not_guilty"); + ui_not_guilty->set_image("notguilty"); + ui_not_guilty->setToolTip(tr("This will display the animation in the " + "viewport as soon as it is pressed.")); + + set_size_and_pos(ui_change_character, "change_character"); + ui_change_character->setText(tr("Change character")); + ui_change_character->set_image("change_character"); + ui_change_character->setToolTip( + tr("Bring up the Character Select Screen and change your character.")); + + set_size_and_pos(ui_reload_theme, "reload_theme"); + ui_reload_theme->setText(tr("Reload theme")); + ui_reload_theme->set_image("reload_theme"); + ui_reload_theme->setToolTip( + tr("Refresh the theme and update all of the ui elements to match.")); + + set_size_and_pos(ui_call_mod, "call_mod"); + ui_call_mod->setText(tr("Call mod")); + ui_call_mod->set_image("call_mod"); + ui_call_mod->setToolTip( + tr("Request the attention of the current server's moderator.")); + + set_size_and_pos(ui_settings, "settings"); + ui_settings->setText(tr("Settings")); + ui_settings->set_image("settings"); + ui_settings->setToolTip( + tr("Allows you to change various aspects of the client.")); + + set_size_and_pos(ui_announce_casing, "casing_button"); + ui_announce_casing->setText(tr("Casing")); + ui_announce_casing->set_image("casing_button"); + ui_announce_casing->setToolTip( + tr("An interface to help you announce a case (you have to be a CM first " + "to be able to announce cases)")); + + set_size_and_pos(ui_switch_area_music, "switch_area_music"); + ui_switch_area_music->setText(tr("A/M")); + ui_switch_area_music->set_image("switch_area_music"); + ui_switch_area_music->setToolTip(tr("Switch between Areas and Music lists")); + + set_size_and_pos(ui_pre, "pre"); + ui_pre->setText(tr("Preanim")); + ui_pre->setToolTip( + tr("Play a single-shot animation as defined by the emote when checked.")); + + set_size_and_pos(ui_pre_non_interrupt, "pre_no_interrupt"); + ui_pre_non_interrupt->setToolTip( + tr("If preanim is checked, display the input text immediately as the " + "animation plays concurrently.")); + + set_size_and_pos(ui_flip, "flip"); + ui_flip->setToolTip(tr("Mirror your character's emotes when checked.")); + + set_size_and_pos(ui_additive, "additive"); + ui_additive->setToolTip( + tr("Add text to your last spoken message when checked.")); + + set_size_and_pos(ui_guard, "guard"); + ui_guard->setToolTip( + tr("Do not listen to mod calls when checked, preventing them from " + "playing sounds or focusing attention on the window.")); + + set_size_and_pos(ui_casing, "casing"); + ui_casing->setToolTip(tr("Lets you receive case alerts when enabled.\n" + "(You can set your preferences in the Settings!)")); + + set_size_and_pos(ui_showname_enable, "showname_enable"); + ui_showname_enable->setToolTip( + tr("Display customized shownames for all users when checked.")); + + set_size_and_pos(ui_custom_objection, "custom_objection"); + ui_custom_objection->setText(tr("Custom Shout!")); + ui_custom_objection->set_image("custom"); + ui_custom_objection->setToolTip( + tr("This will display the custom character-defined animation in the " + "viewport as soon as it is pressed.\n" + "To make one, your character's folder must contain " + "custom.[webp/apng/gif/png] and custom.[wav/ogg/opus] sound effect")); + + set_size_and_pos(ui_realization, "realization"); + ui_realization->set_image("realization"); + ui_realization->setToolTip( + tr("Play realization sound and animation in the viewport on the next " + "spoken message when checked.")); + + set_size_and_pos(ui_screenshake, "screenshake"); + ui_screenshake->set_image("screenshake"); + ui_screenshake->setToolTip( + tr("Shake the screen on next spoken message when checked.")); + + set_size_and_pos(ui_mute, "mute_button"); + ui_mute->setText("Mute"); + ui_mute->set_image("mute"); + ui_mute->setToolTip( + tr("Display the list of character folders you wish to mute.")); + + set_size_and_pos(ui_defense_plus, "defense_plus"); + ui_defense_plus->set_image("defplus"); + ui_defense_plus->setToolTip(tr("Increase the health bar.")); + + set_size_and_pos(ui_defense_minus, "defense_minus"); + ui_defense_minus->set_image("defminus"); + ui_defense_minus->setToolTip(tr("Decrease the health bar.")); + + set_size_and_pos(ui_prosecution_plus, "prosecution_plus"); + ui_prosecution_plus->set_image("proplus"); + ui_prosecution_plus->setToolTip(tr("Increase the health bar.")); + + set_size_and_pos(ui_prosecution_minus, "prosecution_minus"); + ui_prosecution_minus->set_image("prominus"); + ui_prosecution_minus->setToolTip(tr("Decrease the health bar.")); + + set_size_and_pos(ui_text_color, "text_color"); + ui_text_color->setToolTip( + tr("Change the text color of the spoken message.\n" + "You can also select a part of your currently typed message and use " + "the dropdown to change its color!")); + set_text_color_dropdown(); + + set_size_and_pos(ui_music_slider, "music_slider"); + set_size_and_pos(ui_sfx_slider, "sfx_slider"); + set_size_and_pos(ui_blip_slider, "blip_slider"); + + ui_selector->set_image("char_selector"); + ui_selector->hide(); + + set_size_and_pos(ui_back_to_lobby, "back_to_lobby"); + ui_back_to_lobby->setText(tr("Back to Lobby")); + ui_back_to_lobby->setToolTip(tr("Return back to the server list.")); + + set_size_and_pos(ui_char_password, "char_password"); + + set_size_and_pos(ui_char_buttons, "char_buttons"); - set_size_and_pos(ui_char_select_left, "char_select_left"); - ui_char_select_left->set_image("arrow_left"); + set_size_and_pos(ui_char_select_left, "char_select_left"); + ui_char_select_left->set_image("arrow_left"); - set_size_and_pos(ui_char_select_right, "char_select_right"); - ui_char_select_right->set_image("arrow_right"); + set_size_and_pos(ui_char_select_right, "char_select_right"); + ui_char_select_right->set_image("arrow_right"); - set_size_and_pos(ui_spectator, "spectator"); - ui_spectator->setToolTip(tr("Become a spectator. You won't be able to interact with the in-character screen.")); + set_size_and_pos(ui_spectator, "spectator"); + ui_spectator->setToolTip(tr("Become a spectator. You won't be able to " + "interact with the in-character screen.")); - refresh_evidence(); + refresh_evidence(); } void Courtroom::set_fonts() { - set_font(ui_vp_showname, "", "showname"); - set_font(ui_vp_message, "", "message"); - set_font(ui_ic_chatlog, "", "ic_chatlog"); - set_font(ui_ms_chatlog, "", "ms_chatlog"); - set_font(ui_server_chatlog, "", "server_chatlog"); - set_font(ui_music_list, "", "music_list"); - set_font(ui_area_list, "", "area_list"); - set_font(ui_music_name, "", "music_name"); - - set_dropdowns(); + set_font(ui_vp_showname, "", "showname"); + set_font(ui_vp_message, "", "message"); + set_font(ui_ic_chatlog, "", "ic_chatlog"); + set_font(ui_ms_chatlog, "", "ms_chatlog"); + set_font(ui_server_chatlog, "", "server_chatlog"); + set_font(ui_music_list, "", "music_list"); + set_font(ui_area_list, "", "area_list"); + set_font(ui_music_name, "", "music_name"); + + set_dropdowns(); } -void Courtroom::set_font(QWidget *widget, QString class_name, QString p_identifier) +void Courtroom::set_font(QWidget *widget, QString class_name, + QString p_identifier) { - QString design_file = "courtroom_fonts.ini"; - int f_pointsize = ao_app->get_font_size(p_identifier, design_file); - QString font_name = ao_app->get_font_name(p_identifier + "_font", design_file); - QColor f_color = ao_app->get_color(p_identifier + "_color", design_file); - bool bold = ao_app->get_font_size(p_identifier + "_bold", design_file) == 1; // is the font bold or not? - bool antialias = ao_app->get_font_size(p_identifier + "_sharp", design_file) != 1; // is the font anti-aliased or not? - - this->set_qfont(widget, class_name, get_qfont(font_name, f_pointsize, antialias), f_color, bold); + QString design_file = "courtroom_fonts.ini"; + int f_pointsize = ao_app->get_font_size(p_identifier, design_file); + QString font_name = + ao_app->get_font_name(p_identifier + "_font", design_file); + QColor f_color = ao_app->get_color(p_identifier + "_color", design_file); + bool bold = ao_app->get_font_size(p_identifier + "_bold", design_file) == + 1; // is the font bold or not? + bool antialias = + ao_app->get_font_size(p_identifier + "_sharp", design_file) != + 1; // is the font anti-aliased or not? + + this->set_qfont(widget, class_name, + get_qfont(font_name, f_pointsize, antialias), f_color, bold); } QFont Courtroom::get_qfont(QString font_name, int f_pointsize, bool antialias) { - QFont font; - if (font_name.isEmpty()) - font_name = "Arial"; + QFont font; + if (font_name.isEmpty()) + font_name = "Arial"; - QFont::StyleStrategy style_strategy = QFont::PreferDefault; - if (!antialias) - style_strategy = QFont::NoAntialias; + QFont::StyleStrategy style_strategy = QFont::PreferDefault; + if (!antialias) + style_strategy = QFont::NoAntialias; - font = QFont(font_name, f_pointsize); - font.setStyleHint(QFont::SansSerif, style_strategy); - return font; + font = QFont(font_name, f_pointsize); + font.setStyleHint(QFont::SansSerif, style_strategy); + return font; } -void Courtroom::set_qfont(QWidget *widget, QString class_name, QFont font, QColor f_color, bool bold) +void Courtroom::set_qfont(QWidget *widget, QString class_name, QFont font, + QColor f_color, bool bold) { - if (class_name.isEmpty()) - class_name = widget->metaObject()->className(); + if (class_name.isEmpty()) + class_name = widget->metaObject()->className(); - font.setBold(bold); - widget->setFont(font); + font.setBold(bold); + widget->setFont(font); - QString style_sheet_string = class_name + " { background-color: rgba(0, 0, 0, 0);\n" + - "color: rgba(" + - QString::number(f_color.red()) + ", " + - QString::number(f_color.green()) + ", " + - QString::number(f_color.blue()) + ", 255);}"; - widget->setStyleSheet(style_sheet_string); + QString style_sheet_string = + class_name + " { background-color: rgba(0, 0, 0, 0);\n" + "color: rgba(" + + QString::number(f_color.red()) + ", " + QString::number(f_color.green()) + + ", " + QString::number(f_color.blue()) + ", 255);}"; + widget->setStyleSheet(style_sheet_string); } void Courtroom::set_dropdown(QWidget *widget) { - QString f_file = "courtroom_stylesheets.css"; - QString style_sheet_string = ao_app->get_stylesheet(f_file); - if (style_sheet_string != "") - widget->setStyleSheet(style_sheet_string); + QString f_file = "courtroom_stylesheets.css"; + QString style_sheet_string = ao_app->get_stylesheet(f_file); + if (style_sheet_string != "") + widget->setStyleSheet(style_sheet_string); } void Courtroom::set_dropdowns() { - set_dropdown(this); //EXPERIMENTAL - Read the style-sheet as-is for maximum memeage - // set_dropdown(ui_text_color, "[TEXT COLOR]"); - // set_dropdown(ui_pos_dropdown, "[POS DROPDOWN]"); - // set_dropdown(ui_emote_dropdown, "[EMOTE DROPDOWN]"); - // set_dropdown(ui_mute_list, "[MUTE LIST]"); + set_dropdown( + this); // EXPERIMENTAL - Read the style-sheet as-is for maximum memeage + // set_dropdown(ui_text_color, "[TEXT COLOR]"); + // set_dropdown(ui_pos_dropdown, "[POS DROPDOWN]"); + // set_dropdown(ui_emote_dropdown, "[EMOTE DROPDOWN]"); + // set_dropdown(ui_mute_list, "[MUTE LIST]"); } void Courtroom::set_window_title(QString p_title) { - this->setWindowTitle(p_title); + this->setWindowTitle(p_title); } void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier) { - QString filename = "courtroom_design.ini"; + QString filename = "courtroom_design.ini"; - pos_size_type design_ini_result = ao_app->get_element_dimensions(p_identifier, filename); + pos_size_type design_ini_result = + ao_app->get_element_dimensions(p_identifier, filename); - if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; - p_widget->hide(); - } - else { - p_widget->move(design_ini_result.x, design_ini_result.y); - p_widget->resize(design_ini_result.width, design_ini_result.height); - } + if (design_ini_result.width < 0 || design_ini_result.height < 0) { + qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; + p_widget->hide(); + } + else { + p_widget->move(design_ini_result.x, design_ini_result.y); + p_widget->resize(design_ini_result.width, design_ini_result.height); + } } void Courtroom::set_taken(int n_char, bool p_taken) { - if (n_char >= char_list.size()) { - qDebug() << "W: set_taken attempted to set an index bigger than char_list size"; - return; - } + if (n_char >= char_list.size()) { + qDebug() + << "W: set_taken attempted to set an index bigger than char_list size"; + return; + } - char_type f_char; - f_char.name = char_list.at(n_char).name; - f_char.description = char_list.at(n_char).description; - f_char.taken = p_taken; - f_char.evidence_string = char_list.at(n_char).evidence_string; + char_type f_char; + f_char.name = char_list.at(n_char).name; + f_char.description = char_list.at(n_char).description; + f_char.taken = p_taken; + f_char.evidence_string = char_list.at(n_char).evidence_string; - char_list.replace(n_char, f_char); + char_list.replace(n_char, f_char); } QPoint Courtroom::get_theme_pos(QString p_identifier) { - QString filename = "courtroom_design.ini"; + QString filename = "courtroom_design.ini"; - pos_size_type design_ini_result = ao_app->get_element_dimensions(p_identifier, filename); + pos_size_type design_ini_result = + ao_app->get_element_dimensions(p_identifier, filename); - if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; - return QPoint(0, 0); - } - else { - return QPoint(design_ini_result.x, design_ini_result.y); - } + if (design_ini_result.width < 0 || design_ini_result.height < 0) { + qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; + return QPoint(0, 0); + } + else { + return QPoint(design_ini_result.x, design_ini_result.y); + } } void Courtroom::done_received() { - m_cid = -1; + m_cid = -1; - music_player->set_volume(0); - sfx_player->set_volume(0); - objection_player->set_volume(0); - blip_player->set_volume(0); + music_player->set_volume(0); + sfx_player->set_volume(0); + objection_player->set_volume(0); + blip_player->set_volume(0); - set_char_select_page(); + set_char_select_page(); - set_mute_list(); - set_pair_list(); + set_mute_list(); + set_pair_list(); - set_char_select(); + set_char_select(); - show(); + show(); - ui_spectator->show(); + ui_spectator->show(); } void Courtroom::set_background(QString p_background, bool display) { - ui_vp_testimony->stop(); - current_background = p_background; - - //welcome to hardcode central may I take your order of regularly scheduled CBT - QMap<QString, QString> default_pos; - default_pos["defenseempty"] = "def"; - default_pos["helperstand"] = "hld"; - default_pos["prosecutorempty"] = "pro"; - default_pos["prohelperstand"] = "hlp"; - default_pos["witnessempty"] = "wit"; - default_pos["judgestand"] = "jud"; - default_pos["jurystand"] = "jur"; - default_pos["seancestand"] = "sea"; - - //Populate the dropdown list with all pos that exist on this bg - QStringList pos_list = {}; - for (QString key : default_pos.keys()) { - if (file_exists(ao_app->get_static_image_suffix(ao_app->get_background_path(key)))) { - pos_list.append(default_pos[key]); - } - } - - //TODO: search through extra/custom pos and add them to the pos dropdown as well - - set_pos_dropdown(pos_list); - - is_ao2_bg = true; - - if (is_ao2_bg) { - set_size_and_pos(ui_vp_chatbox, "ao2_chatbox"); - set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); - } - else { - set_size_and_pos(ui_vp_chatbox, "chatbox"); - set_size_and_pos(ui_ic_chat_message, "ic_chat_message"); - } - - if (display) { - ui_vp_speedlines->stop(); - ui_vp_player_char->stop(); + ui_vp_testimony->stop(); + current_background = p_background; + + // welcome to hardcode central may I take your order of regularly scheduled + // CBT + QMap<QString, QString> default_pos; + default_pos["defenseempty"] = "def"; + default_pos["helperstand"] = "hld"; + default_pos["prosecutorempty"] = "pro"; + default_pos["prohelperstand"] = "hlp"; + default_pos["witnessempty"] = "wit"; + default_pos["judgestand"] = "jud"; + default_pos["jurystand"] = "jur"; + default_pos["seancestand"] = "sea"; + + // Populate the dropdown list with all pos that exist on this bg + QStringList pos_list = {}; + for (QString key : default_pos.keys()) { + if (file_exists(ao_app->get_static_image_suffix( + ao_app->get_background_path(key)))) { + pos_list.append(default_pos[key]); + } + } + + // TODO: search through extra/custom pos and add them to the pos dropdown as + // well + + set_pos_dropdown(pos_list); + + is_ao2_bg = true; + + if (is_ao2_bg) { + set_size_and_pos(ui_vp_chatbox, "ao2_chatbox"); + set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); + } + else { + set_size_and_pos(ui_vp_chatbox, "chatbox"); + set_size_and_pos(ui_ic_chat_message, "ic_chat_message"); + } + + if (display) { + ui_vp_speedlines->stop(); + ui_vp_player_char->stop(); - ui_vp_sideplayer_char->stop(); - ui_vp_effect->stop(); - ui_vp_message->hide(); - ui_vp_chatbox->hide(); + ui_vp_sideplayer_char->stop(); + ui_vp_effect->stop(); + ui_vp_message->hide(); + ui_vp_chatbox->hide(); - //Stop the chat arrow from animating - ui_vp_chat_arrow->stop(); + // Stop the chat arrow from animating + ui_vp_chat_arrow->stop(); - text_state = 2; - anim_state = 3; - ui_vp_objection->stop(); - chat_tick_timer->stop(); - ui_vp_evidence_display->reset(); - set_scene(QString::number(ao_app->get_desk_mod(current_char, current_emote)), current_side); - } + text_state = 2; + anim_state = 3; + ui_vp_objection->stop(); + chat_tick_timer->stop(); + ui_vp_evidence_display->reset(); + set_scene( + QString::number(ao_app->get_desk_mod(current_char, current_emote)), + current_side); + } } void Courtroom::set_side(QString p_side) { - if (p_side == "") - current_side = ao_app->get_char_side(current_char); - else - current_side = p_side; + if (p_side == "") + current_side = ao_app->get_char_side(current_char); + else + current_side = p_side; - for (int i = 0; i < ui_pos_dropdown->count(); ++i) { - QString pos = ui_pos_dropdown->itemText(i); - if (pos == current_side) { - //Block the signals to prevent setCurrentIndex from triggering a pos change - ui_pos_dropdown->blockSignals(true); + for (int i = 0; i < ui_pos_dropdown->count(); ++i) { + QString pos = ui_pos_dropdown->itemText(i); + if (pos == current_side) { + // Block the signals to prevent setCurrentIndex from triggering a pos + // change + ui_pos_dropdown->blockSignals(true); - //Set the index on dropdown ui element to let you know what pos you're on right now - ui_pos_dropdown->setCurrentIndex(i); + // Set the index on dropdown ui element to let you know what pos you're on + // right now + ui_pos_dropdown->setCurrentIndex(i); - //Unblock the signals so the element can be used for setting pos again - ui_pos_dropdown->blockSignals(false); + // Unblock the signals so the element can be used for setting pos again + ui_pos_dropdown->blockSignals(false); - //alright we dun, jobs done here boyos - break; - } + // alright we dun, jobs done here boyos + break; } + } } void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) { - //Block the signals to prevent setCurrentIndex from triggering a pos change - ui_pos_dropdown->blockSignals(true); - pos_dropdown_list = pos_dropdowns; - ui_pos_dropdown->clear(); - ui_pos_dropdown->addItems(pos_dropdown_list); - //Unblock the signals so the element can be used for setting pos again - ui_pos_dropdown->blockSignals(false); - - qDebug() << pos_dropdown_list; + // Block the signals to prevent setCurrentIndex from triggering a pos change + ui_pos_dropdown->blockSignals(true); + pos_dropdown_list = pos_dropdowns; + ui_pos_dropdown->clear(); + ui_pos_dropdown->addItems(pos_dropdown_list); + // Unblock the signals so the element can be used for setting pos again + ui_pos_dropdown->blockSignals(false); + + qDebug() << pos_dropdown_list; } void Courtroom::update_character(int p_cid) { - bool newchar = m_cid != p_cid; - - m_cid = p_cid; - - QString f_char; - - if (m_cid == -1) { - if (ao_app->is_discord_enabled()) - ao_app->discord->state_spectate(); - f_char = ""; - } - else { - f_char = ao_app->get_char_name(char_list.at(m_cid).name); - - if (ao_app->is_discord_enabled()) - ao_app->discord->state_character(f_char.toStdString()); - } - - current_char = f_char; - current_side = ao_app->get_char_side(current_char); - - current_emote_page = 0; - current_emote = 0; - - if (m_cid == -1) - ui_emotes->hide(); - else - ui_emotes->show(); - - refresh_emotes(); - set_emote_page(); - set_emote_dropdown(); - - set_sfx_dropdown(); - set_effects_dropdown(); - - qDebug() << "update_character called"; - if (newchar) //Avoid infinite loop of death and suffering - set_iniswap_dropdown(); - - if (current_side == "jud") { - ui_witness_testimony->show(); - ui_cross_examination->show(); - ui_not_guilty->show(); - ui_guilty->show(); - ui_defense_minus->show(); - ui_defense_plus->show(); - ui_prosecution_minus->show(); - ui_prosecution_plus->show(); - } - else { - ui_witness_testimony->hide(); - ui_cross_examination->hide(); - ui_guilty->hide(); - ui_not_guilty->hide(); - ui_defense_minus->hide(); - ui_defense_plus->hide(); - ui_prosecution_minus->hide(); - ui_prosecution_plus->hide(); - } - - if (ao_app->custom_objection_enabled && file_exists(ao_app->get_image_suffix(ao_app->get_character_path(current_char, "custom")))) - ui_custom_objection->show(); - else - ui_custom_objection->hide(); - - ui_char_select_background->hide(); - ui_ic_chat_message->setEnabled(m_cid != -1); - ui_ic_chat_message->setFocus(); + bool newchar = m_cid != p_cid; + + m_cid = p_cid; + + QString f_char; + + if (m_cid == -1) { + if (ao_app->is_discord_enabled()) + ao_app->discord->state_spectate(); + f_char = ""; + } + else { + f_char = ao_app->get_char_name(char_list.at(m_cid).name); + + if (ao_app->is_discord_enabled()) + ao_app->discord->state_character(f_char.toStdString()); + } + + current_char = f_char; + current_side = ao_app->get_char_side(current_char); + + current_emote_page = 0; + current_emote = 0; + + if (m_cid == -1) + ui_emotes->hide(); + else + ui_emotes->show(); + + refresh_emotes(); + set_emote_page(); + set_emote_dropdown(); + + set_sfx_dropdown(); + set_effects_dropdown(); + + qDebug() << "update_character called"; + if (newchar) // Avoid infinite loop of death and suffering + set_iniswap_dropdown(); + + if (current_side == "jud") { + ui_witness_testimony->show(); + ui_cross_examination->show(); + ui_not_guilty->show(); + ui_guilty->show(); + ui_defense_minus->show(); + ui_defense_plus->show(); + ui_prosecution_minus->show(); + ui_prosecution_plus->show(); + } + else { + ui_witness_testimony->hide(); + ui_cross_examination->hide(); + ui_guilty->hide(); + ui_not_guilty->hide(); + ui_defense_minus->hide(); + ui_defense_plus->hide(); + ui_prosecution_minus->hide(); + ui_prosecution_plus->hide(); + } + + if (ao_app->custom_objection_enabled && + file_exists(ao_app->get_image_suffix( + ao_app->get_character_path(current_char, "custom")))) + ui_custom_objection->show(); + else + ui_custom_objection->hide(); + + ui_char_select_background->hide(); + ui_ic_chat_message->setEnabled(m_cid != -1); + ui_ic_chat_message->setFocus(); } void Courtroom::enter_courtroom() { - set_widgets(); + set_widgets(); - current_evidence_page = 0; - current_evidence = 0; + current_evidence_page = 0; + current_evidence = 0; - set_evidence_page(); + set_evidence_page(); - if (ao_app->flipping_enabled) - ui_flip->show(); - else - ui_flip->hide(); + if (ao_app->flipping_enabled) + ui_flip->show(); + else + ui_flip->hide(); - if (ao_app->additive_enabled) - ui_additive->show(); - else - ui_additive->hide(); + if (ao_app->additive_enabled) + ui_additive->show(); + else + ui_additive->hide(); - if (ao_app->casing_alerts_enabled) - ui_casing->show(); - else - ui_casing->hide(); + if (ao_app->casing_alerts_enabled) + ui_casing->show(); + else + ui_casing->hide(); - list_music(); - list_areas(); + list_music(); + list_areas(); - music_player->set_volume(ui_music_slider->value(), 0); //set music - //Set the ambience and other misc. music layers - for (int i = 1; i < music_player->m_channelmax; ++i) { - music_player->set_volume(ui_sfx_slider->value(), i); - } - sfx_player->set_volume(ui_sfx_slider->value()); - objection_player->set_volume(ui_sfx_slider->value()); - blip_player->set_volume(ui_blip_slider->value()); + music_player->set_volume(ui_music_slider->value(), 0); // set music + // Set the ambience and other misc. music layers + for (int i = 1; i < music_player->m_channelmax; ++i) { + music_player->set_volume(ui_sfx_slider->value(), i); + } + sfx_player->set_volume(ui_sfx_slider->value()); + objection_player->set_volume(ui_sfx_slider->value()); + blip_player->set_volume(ui_blip_slider->value()); - ui_vp_testimony->stop(); - //ui_server_chatlog->setHtml(ui_server_chatlog->toHtml()); + ui_vp_testimony->stop(); + // ui_server_chatlog->setHtml(ui_server_chatlog->toHtml()); } -//Todo: multithread this due to some servers having large as hell music list +// Todo: multithread this due to some servers having large as hell music list void Courtroom::list_music() { - ui_music_list->clear(); - // ui_music_search->setText(""); + ui_music_list->clear(); + // ui_music_search->setText(""); - QString f_file = "courtroom_design.ini"; + QString f_file = "courtroom_design.ini"; - QBrush found_brush(ao_app->get_color("found_song_color", f_file)); - QBrush missing_brush(ao_app->get_color("missing_song_color", f_file)); + QBrush found_brush(ao_app->get_color("found_song_color", f_file)); + QBrush missing_brush(ao_app->get_color("missing_song_color", f_file)); - int n_listed_songs = 0; + int n_listed_songs = 0; - QTreeWidgetItem *parent = nullptr; - for (int n_song = 0; n_song < music_list.size(); ++n_song) { - QString i_song = music_list.at(n_song); - QString i_song_listname = i_song.left(i_song.lastIndexOf(".")); - i_song_listname = i_song_listname.right(i_song_listname.length() - (i_song_listname.lastIndexOf("/") + 1)); + QTreeWidgetItem *parent = nullptr; + for (int n_song = 0; n_song < music_list.size(); ++n_song) { + QString i_song = music_list.at(n_song); + QString i_song_listname = i_song.left(i_song.lastIndexOf(".")); + i_song_listname = i_song_listname.right( + i_song_listname.length() - (i_song_listname.lastIndexOf("/") + 1)); - QTreeWidgetItem *treeItem; - if (i_song_listname != i_song && parent != nullptr) //not a category, parent exists - treeItem = new QTreeWidgetItem(parent); - else - treeItem = new QTreeWidgetItem(ui_music_list); - treeItem->setText(0, i_song_listname); - treeItem->setText(1, i_song); - - QString song_path = ao_app->get_music_path(i_song); - - if (file_exists(song_path)) - treeItem->setBackground(0, found_brush); - else - treeItem->setBackground(0, missing_brush); + QTreeWidgetItem *treeItem; + if (i_song_listname != i_song && + parent != nullptr) // not a category, parent exists + treeItem = new QTreeWidgetItem(parent); + else + treeItem = new QTreeWidgetItem(ui_music_list); + treeItem->setText(0, i_song_listname); + treeItem->setText(1, i_song); - if (i_song_listname == i_song) //Not supposed to be a song to begin with - a category? - parent = treeItem; - ++n_listed_songs; - } + QString song_path = ao_app->get_music_path(i_song); - ui_music_list->expandAll(); //Needs to somehow remember which categories were expanded/collapsed if the music list didn't change since last time - if (ui_music_search->text() != "") { - on_music_search_edited(ui_music_search->text()); - } + if (file_exists(song_path)) + treeItem->setBackground(0, found_brush); + else + treeItem->setBackground(0, missing_brush); + + if (i_song_listname == + i_song) // Not supposed to be a song to begin with - a category? + parent = treeItem; + ++n_listed_songs; + } + + ui_music_list->expandAll(); // Needs to somehow remember which categories were + // expanded/collapsed if the music list didn't + // change since last time + if (ui_music_search->text() != "") { + on_music_search_edited(ui_music_search->text()); + } } -//Todo: multithread this due to some servers having large as hell area list +// Todo: multithread this due to some servers having large as hell area list void Courtroom::list_areas() { - ui_area_list->clear(); - // ui_music_search->setText(""); - - QString f_file = "courtroom_design.ini"; + ui_area_list->clear(); + // ui_music_search->setText(""); - QBrush free_brush(ao_app->get_color("area_free_color", f_file)); - QBrush lfp_brush(ao_app->get_color("area_lfp_color", f_file)); - QBrush casing_brush(ao_app->get_color("area_casing_color", f_file)); - QBrush recess_brush(ao_app->get_color("area_recess_color", f_file)); - QBrush rp_brush(ao_app->get_color("area_rp_color", f_file)); - QBrush gaming_brush(ao_app->get_color("area_gaming_color", f_file)); - QBrush locked_brush(ao_app->get_color("area_locked_color", f_file)); + QString f_file = "courtroom_design.ini"; - int n_listed_areas = 0; + QBrush free_brush(ao_app->get_color("area_free_color", f_file)); + QBrush lfp_brush(ao_app->get_color("area_lfp_color", f_file)); + QBrush casing_brush(ao_app->get_color("area_casing_color", f_file)); + QBrush recess_brush(ao_app->get_color("area_recess_color", f_file)); + QBrush rp_brush(ao_app->get_color("area_rp_color", f_file)); + QBrush gaming_brush(ao_app->get_color("area_gaming_color", f_file)); + QBrush locked_brush(ao_app->get_color("area_locked_color", f_file)); - for (int n_area = 0; n_area < area_list.size(); ++n_area) { - QString i_area = ""; - i_area.append(area_list.at(n_area)); + int n_listed_areas = 0; - if (ao_app->arup_enabled) { - i_area.prepend("[" + QString::number(n_area) + "] "); //Give it the index + for (int n_area = 0; n_area < area_list.size(); ++n_area) { + QString i_area = ""; + i_area.append(area_list.at(n_area)); - i_area.append("\n "); + if (ao_app->arup_enabled) { + i_area.prepend("[" + QString::number(n_area) + "] "); // Give it the index - i_area.append(arup_statuses.at(n_area)); - i_area.append(" | CM: "); - i_area.append(arup_cms.at(n_area)); + i_area.append("\n "); - i_area.append("\n "); + i_area.append(arup_statuses.at(n_area)); + i_area.append(" | CM: "); + i_area.append(arup_cms.at(n_area)); - i_area.append(QString::number(arup_players.at(n_area))); - i_area.append(" users | "); + i_area.append("\n "); - i_area.append(arup_locks.at(n_area)); - } + i_area.append(QString::number(arup_players.at(n_area))); + i_area.append(" users | "); - QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_area_list); - treeItem->setText(0, area_list.at(n_area)); - treeItem->setText(1, i_area); + i_area.append(arup_locks.at(n_area)); + } - if (ao_app->arup_enabled) { - // Coloring logic here. - treeItem->setBackground(1, free_brush); - if (arup_locks.at(n_area) == "LOCKED") { - treeItem->setBackground(1, locked_brush); - } - else { - if (arup_statuses.at(n_area) == "LOOKING-FOR-PLAYERS") - treeItem->setBackground(1, lfp_brush); - else if (arup_statuses.at(n_area) == "CASING") - treeItem->setBackground(1, casing_brush); - else if (arup_statuses.at(n_area) == "RECESS") - treeItem->setBackground(1, recess_brush); - else if (arup_statuses.at(n_area) == "RP") - treeItem->setBackground(1, rp_brush); - else if (arup_statuses.at(n_area) == "GAMING") - treeItem->setBackground(1, gaming_brush); - } - } - else { - treeItem->setBackground(1, free_brush); - } + QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_area_list); + treeItem->setText(0, area_list.at(n_area)); + treeItem->setText(1, i_area); - ++n_listed_areas; + if (ao_app->arup_enabled) { + // Coloring logic here. + treeItem->setBackground(1, free_brush); + if (arup_locks.at(n_area) == "LOCKED") { + treeItem->setBackground(1, locked_brush); + } + else { + if (arup_statuses.at(n_area) == "LOOKING-FOR-PLAYERS") + treeItem->setBackground(1, lfp_brush); + else if (arup_statuses.at(n_area) == "CASING") + treeItem->setBackground(1, casing_brush); + else if (arup_statuses.at(n_area) == "RECESS") + treeItem->setBackground(1, recess_brush); + else if (arup_statuses.at(n_area) == "RP") + treeItem->setBackground(1, rp_brush); + else if (arup_statuses.at(n_area) == "GAMING") + treeItem->setBackground(1, gaming_brush); + } } - - if (ui_music_search->text() != "") { - on_music_search_edited(ui_music_search->text()); + else { + treeItem->setBackground(1, free_brush); } + + ++n_listed_areas; + } + + if (ui_music_search->text() != "") { + on_music_search_edited(ui_music_search->text()); + } } void Courtroom::append_ms_chatmessage(QString f_name, QString f_message) { - ui_ms_chatlog->append_chatmessage(f_name, f_message, ao_app->get_color("ms_chatlog_sender_color", "courtroom_fonts.ini").name()); + ui_ms_chatlog->append_chatmessage( + f_name, f_message, + ao_app->get_color("ms_chatlog_sender_color", "courtroom_fonts.ini") + .name()); } -void Courtroom::append_server_chatmessage(QString p_name, QString p_message, QString p_color) +void Courtroom::append_server_chatmessage(QString p_name, QString p_message, + QString p_color) { - QString color = "#000000"; - - if (p_color == "0") - color = ao_app->get_color("ms_chatlog_sender_color", "courtroom_fonts.ini").name(); - if (p_color == "1") - color = ao_app->get_color("server_chatlog_sender_color", "courtroom_fonts.ini").name(); - if (p_message == "Logged in as a moderator.") { - ui_guard->show(); - append_server_chatmessage("CLIENT", "You were granted the Disable Modcalls button.", "1"); - } + QString color = "#000000"; + + if (p_color == "0") + color = ao_app->get_color("ms_chatlog_sender_color", "courtroom_fonts.ini") + .name(); + if (p_color == "1") + color = + ao_app->get_color("server_chatlog_sender_color", "courtroom_fonts.ini") + .name(); + if (p_message == "Logged in as a moderator.") { + ui_guard->show(); + append_server_chatmessage( + "CLIENT", "You were granted the Disable Modcalls button.", "1"); + } - ui_server_chatlog->append_chatmessage(p_name, p_message, color); + ui_server_chatlog->append_chatmessage(p_name, p_message, color); } void Courtroom::on_chat_return_pressed() { - if (ui_ic_chat_message->text() == "" || is_muted) - return; - - if ((anim_state < 3 || text_state < 2) && - objection_state == 0) - return; - - //MS# - //deskmod# - //pre-emote# - //character# - //emote# - //message# - //side# - //sfx-name# - //emote_modifier# - //char_id# - //sfx_delay# - //objection_modifier# - //evidence# - //placeholder# - //realization# - //text_color#% - - // Additionally, in our case: - - //showname# - //other_charid# - //self_offset# - //noninterrupting_preanim#% - - QStringList packet_contents; - - if (current_side == "") - current_side = ao_app->get_char_side(current_char); - - QString f_desk_mod = "chat"; - - if (ao_app->desk_mod_enabled) { - f_desk_mod = QString::number(ao_app->get_desk_mod(current_char, current_emote)); - if (f_desk_mod == "-1") - f_desk_mod = "chat"; - } - - packet_contents.append(f_desk_mod); - - packet_contents.append(ao_app->get_pre_emote(current_char, current_emote)); - - packet_contents.append(current_char); - - packet_contents.append(ao_app->get_emote(current_char, current_emote)); - - packet_contents.append(ui_ic_chat_message->text()); - - packet_contents.append(current_side); - - packet_contents.append(get_char_sfx()); - if (ui_pre->isChecked() && !ao_app->is_stickysounds_enabled()) { - ui_sfx_dropdown->blockSignals(true); - ui_sfx_dropdown->setCurrentIndex(0); - ui_sfx_dropdown->blockSignals(false); - ui_sfx_remove->hide(); - } - - int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote); + if (ui_ic_chat_message->text() == "" || is_muted) + return; + + if ((anim_state < 3 || text_state < 2) && objection_state == 0) + return; + + // MS# + // deskmod# + // pre-emote# + // character# + // emote# + // message# + // side# + // sfx-name# + // emote_modifier# + // char_id# + // sfx_delay# + // objection_modifier# + // evidence# + // placeholder# + // realization# + // text_color#% + + // Additionally, in our case: + + // showname# + // other_charid# + // self_offset# + // noninterrupting_preanim#% + + QStringList packet_contents; + + if (current_side == "") + current_side = ao_app->get_char_side(current_char); - //needed or else legacy won't understand what we're saying - if (objection_state > 0) { - if (ui_pre->isChecked()) { - if (f_emote_mod == 4 || f_emote_mod == 5) - f_emote_mod = 6; - else - f_emote_mod = 2; - } - } - else if (ui_pre->isChecked() and !ui_pre_non_interrupt->isChecked()) { - if (f_emote_mod == 0) - f_emote_mod = 1; - else if (f_emote_mod == 5 && ao_app->prezoom_enabled) - f_emote_mod = 4; - } - else { - if (f_emote_mod == 1) - f_emote_mod = 0; - else if (f_emote_mod == 4) - f_emote_mod = 5; - } + QString f_desk_mod = "chat"; - packet_contents.append(QString::number(f_emote_mod)); - packet_contents.append(QString::number(m_cid)); + if (ao_app->desk_mod_enabled) { + f_desk_mod = + QString::number(ao_app->get_desk_mod(current_char, current_emote)); + if (f_desk_mod == "-1") + f_desk_mod = "chat"; + } - packet_contents.append(QString::number(get_char_sfx_delay())); + packet_contents.append(f_desk_mod); - QString f_obj_state; + packet_contents.append(ao_app->get_pre_emote(current_char, current_emote)); - if ((objection_state == 4 && !ao_app->custom_objection_enabled) || - (objection_state < 0)) - f_obj_state = "0"; - else - f_obj_state = QString::number(objection_state); + packet_contents.append(current_char); - packet_contents.append(f_obj_state); + packet_contents.append(ao_app->get_emote(current_char, current_emote)); - if (is_presenting_evidence) - //the evidence index is shifted by 1 because 0 is no evidence per legacy standards - //besides, older clients crash if we pass -1 - packet_contents.append(QString::number(current_evidence + 1)); - else - packet_contents.append("0"); + packet_contents.append(ui_ic_chat_message->text()); - QString f_flip; + packet_contents.append(current_side); - if (ao_app->flipping_enabled) { - if (ui_flip->isChecked()) - f_flip = "1"; - else - f_flip = "0"; - } + packet_contents.append(get_char_sfx()); + if (ui_pre->isChecked() && !ao_app->is_stickysounds_enabled()) { + ui_sfx_dropdown->blockSignals(true); + ui_sfx_dropdown->setCurrentIndex(0); + ui_sfx_dropdown->blockSignals(false); + ui_sfx_remove->hide(); + } + + int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote); + + // needed or else legacy won't understand what we're saying + if (objection_state > 0) { + if (ui_pre->isChecked()) { + if (f_emote_mod == 4 || f_emote_mod == 5) + f_emote_mod = 6; + else + f_emote_mod = 2; + } + } + else if (ui_pre->isChecked() and !ui_pre_non_interrupt->isChecked()) { + if (f_emote_mod == 0) + f_emote_mod = 1; + else if (f_emote_mod == 5 && ao_app->prezoom_enabled) + f_emote_mod = 4; + } + else { + if (f_emote_mod == 1) + f_emote_mod = 0; + else if (f_emote_mod == 4) + f_emote_mod = 5; + } + + packet_contents.append(QString::number(f_emote_mod)); + packet_contents.append(QString::number(m_cid)); + + packet_contents.append(QString::number(get_char_sfx_delay())); + + QString f_obj_state; + + if ((objection_state == 4 && !ao_app->custom_objection_enabled) || + (objection_state < 0)) + f_obj_state = "0"; + else + f_obj_state = QString::number(objection_state); + + packet_contents.append(f_obj_state); + + if (is_presenting_evidence) + // the evidence index is shifted by 1 because 0 is no evidence per legacy + // standards besides, older clients crash if we pass -1 + packet_contents.append(QString::number(current_evidence + 1)); + else + packet_contents.append("0"); + + QString f_flip; + + if (ao_app->flipping_enabled) { + if (ui_flip->isChecked()) + f_flip = "1"; else - f_flip = QString::number(m_cid); - - packet_contents.append(f_flip); + f_flip = "0"; + } + else + f_flip = QString::number(m_cid); - packet_contents.append(QString::number(realization_state)); + packet_contents.append(f_flip); - QString f_text_color; - - if (text_color < 0) - f_text_color = "0"; - else if (text_color > max_colors) - f_text_color = "0"; - else - f_text_color = QString::number(text_color); + packet_contents.append(QString::number(realization_state)); - packet_contents.append(f_text_color); + QString f_text_color; - // If the server we're on supports CCCC stuff, we should use it! - if (ao_app->cccc_ic_support_enabled) { - // If there is a showname entered, use that -- else, just send an empty packet-part. - if (!ui_ic_chat_name->text().isEmpty()) { - packet_contents.append(ui_ic_chat_name->text()); - } - else { - packet_contents.append(""); - } + if (text_color < 0) + f_text_color = "0"; + else if (text_color > max_colors) + f_text_color = "0"; + else + f_text_color = QString::number(text_color); - // Similarly, we send over whom we're paired with, unless we have chosen ourselves. - // Or a charid of -1 or lower, through some means. - if (other_charid > -1 && other_charid != m_cid) { - QString packet = QString::number(other_charid); - if (ao_app->effects_enabled) //Only servers with effects enabled will support pair reordering - packet += "^" + QString::number(pair_order); - packet_contents.append(packet); - } - else { - packet_contents.append("-1"); - } - //Send the offset as it's gonna be used regardless - packet_contents.append(QString::number(char_offset)); + packet_contents.append(f_text_color); - // Finally, we send over if we want our pres to not interrupt. - if (ui_pre_non_interrupt->isChecked() && ui_pre->isChecked()) { - packet_contents.append("1"); - } - else { - packet_contents.append("0"); - } + // If the server we're on supports CCCC stuff, we should use it! + if (ao_app->cccc_ic_support_enabled) { + // If there is a showname entered, use that -- else, just send an empty + // packet-part. + if (!ui_ic_chat_name->text().isEmpty()) { + packet_contents.append(ui_ic_chat_name->text()); + } + else { + packet_contents.append(""); } - // If the server we're on supports Looping SFX and Screenshake, use it if the emote uses it. - if (ao_app->looping_sfx_support_enabled) { - packet_contents.append("0"); //ao_app->get_sfx_looping(current_char, current_emote)); - packet_contents.append(QString::number(screenshake_state)); - - QString pre_emote = ao_app->get_pre_emote(current_char, current_emote); - QString emote = ao_app->get_emote(current_char, current_emote); - QStringList emotes_to_check = {pre_emote, "(b)" + emote, "(a)" + emote}; - QStringList effects_to_check = {"_FrameScreenshake", "_FrameRealization", "_FrameSFX"}; - - foreach (QString f_effect, effects_to_check) { - QString packet; - foreach (QString f_emote, emotes_to_check) { - packet += f_emote; - if (ao_app->is_frame_network_enabled()) { - QString sfx_frames = ao_app->read_ini_tags(ao_app->get_character_path(current_char, "char.ini"), f_emote.append(f_effect)).join("|"); - if (sfx_frames != "") - packet += "|" + sfx_frames; - } - packet += "^"; - } - packet_contents.append(packet); - } + // Similarly, we send over whom we're paired with, unless we have chosen + // ourselves. Or a charid of -1 or lower, through some means. + if (other_charid > -1 && other_charid != m_cid) { + QString packet = QString::number(other_charid); + if (ao_app->effects_enabled) // Only servers with effects enabled will + // support pair reordering + packet += "^" + QString::number(pair_order); + packet_contents.append(packet); } + else { + packet_contents.append("-1"); + } + // Send the offset as it's gonna be used regardless + packet_contents.append(QString::number(char_offset)); - if (ao_app->additive_enabled) { - packet_contents.append(ui_additive->isChecked() ? "1" : "0"); + // Finally, we send over if we want our pres to not interrupt. + if (ui_pre_non_interrupt->isChecked() && ui_pre->isChecked()) { + packet_contents.append("1"); } - if (ao_app->effects_enabled) { - QString fx_sound = ao_app->get_effect_sound(effect, current_char); - QString p_effect = ao_app->read_char_ini(current_char, "effects", "Options"); - packet_contents.append(effect + "|" + p_effect + "|" + fx_sound); - if (!ao_app->is_stickyeffects_enabled()) { - ui_effects_dropdown->blockSignals(true); - ui_effects_dropdown->setCurrentIndex(0); - ui_effects_dropdown->blockSignals(false); - effect = ""; + else { + packet_contents.append("0"); + } + } + + // If the server we're on supports Looping SFX and Screenshake, use it if the + // emote uses it. + if (ao_app->looping_sfx_support_enabled) { + packet_contents.append( + "0"); // ao_app->get_sfx_looping(current_char, current_emote)); + packet_contents.append(QString::number(screenshake_state)); + + QString pre_emote = ao_app->get_pre_emote(current_char, current_emote); + QString emote = ao_app->get_emote(current_char, current_emote); + QStringList emotes_to_check = {pre_emote, "(b)" + emote, "(a)" + emote}; + QStringList effects_to_check = {"_FrameScreenshake", "_FrameRealization", + "_FrameSFX"}; + + foreach (QString f_effect, effects_to_check) { + QString packet; + foreach (QString f_emote, emotes_to_check) { + packet += f_emote; + if (ao_app->is_frame_network_enabled()) { + QString sfx_frames = + ao_app + ->read_ini_tags( + ao_app->get_character_path(current_char, "char.ini"), + f_emote.append(f_effect)) + .join("|"); + if (sfx_frames != "") + packet += "|" + sfx_frames; } + packet += "^"; + } + packet_contents.append(packet); + } + } + + if (ao_app->additive_enabled) { + packet_contents.append(ui_additive->isChecked() ? "1" : "0"); + } + if (ao_app->effects_enabled) { + QString fx_sound = ao_app->get_effect_sound(effect, current_char); + QString p_effect = + ao_app->read_char_ini(current_char, "effects", "Options"); + packet_contents.append(effect + "|" + p_effect + "|" + fx_sound); + if (!ao_app->is_stickyeffects_enabled()) { + ui_effects_dropdown->blockSignals(true); + ui_effects_dropdown->setCurrentIndex(0); + ui_effects_dropdown->blockSignals(false); + effect = ""; } + } - ao_app->send_server_packet(new AOPacket("MS", packet_contents)); + ao_app->send_server_packet(new AOPacket("MS", packet_contents)); } void Courtroom::handle_chatmessage(QStringList *p_contents) { - // Instead of checking for whether a message has at least chatmessage_size - // amount of packages, we'll check if it has at least 15. - // That was the original chatmessage_size. - if (p_contents->size() < 15) - return; + // Instead of checking for whether a message has at least chatmessage_size + // amount of packages, we'll check if it has at least 15. + // That was the original chatmessage_size. + if (p_contents->size() < 15) + return; - for (int n_string = 0; n_string < chatmessage_size; ++n_string) { - //m_chatmessage[n_string] = p_contents->at(n_string); + for (int n_string = 0; n_string < chatmessage_size; ++n_string) { + // m_chatmessage[n_string] = p_contents->at(n_string); - // Note that we have added stuff that vanilla clients and servers simply won't send. - // So now, we have to check if the thing we want even exists amongst the packet's content. - // We also have to check if the server even supports CCCC's IC features, or if it's just japing us. - // Also, don't forget! A size 15 message will have indices from 0 to 14. - if (n_string < p_contents->size() && - (n_string < 15 || ao_app->cccc_ic_support_enabled)) { - m_chatmessage[n_string] = p_contents->at(n_string); - } - else { - m_chatmessage[n_string] = ""; - } - } - - int f_char_id = m_chatmessage[CHAR_ID].toInt(); - - if (f_char_id >= 0 && f_char_id >= char_list.size()) - return; - - if (mute_map.value(m_chatmessage[CHAR_ID].toInt())) - return; - - QString f_showname; - if (f_char_id > 0 && (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { - f_showname = ao_app->get_showname(char_list.at(f_char_id).name); + // Note that we have added stuff that vanilla clients and servers simply + // won't send. So now, we have to check if the thing we want even exists + // amongst the packet's content. We also have to check if the server even + // supports CCCC's IC features, or if it's just japing us. Also, don't + // forget! A size 15 message will have indices from 0 to 14. + if (n_string < p_contents->size() && + (n_string < 15 || ao_app->cccc_ic_support_enabled)) { + m_chatmessage[n_string] = p_contents->at(n_string); } else { - f_showname = m_chatmessage[SHOWNAME]; - } - - if (f_showname.trimmed().isEmpty()) //Pure whitespace showname, get outta here. - f_showname = m_chatmessage[CHAR_NAME]; - - QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n'; - //Remove undesired newline chars - m_chatmessage[MESSAGE].remove("\n"); - chatmessage_is_empty = m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == ""; - - if (f_char_id >= 0 && !chatmessage_is_empty && f_message == previous_ic_message) //Not a system message - return; - - if (f_char_id <= -1) - previous_ic_message = ""; //System messages don't care about repeating themselves - else - previous_ic_message = f_message; - - //Stop the chat arrow from animating - ui_vp_chat_arrow->stop(); - - text_state = 0; - anim_state = 0; - ui_vp_objection->stop(); - chat_tick_timer->stop(); - ui_vp_evidence_display->reset(); + m_chatmessage[n_string] = ""; + } + } + + int f_char_id = m_chatmessage[CHAR_ID].toInt(); + + if (f_char_id >= 0 && f_char_id >= char_list.size()) + return; + + if (mute_map.value(m_chatmessage[CHAR_ID].toInt())) + return; + + QString f_showname; + if (f_char_id > 0 && + (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { + f_showname = ao_app->get_showname(char_list.at(f_char_id).name); + } + else { + f_showname = m_chatmessage[SHOWNAME]; + } + + if (f_showname.trimmed() + .isEmpty()) // Pure whitespace showname, get outta here. + f_showname = m_chatmessage[CHAR_NAME]; + + QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n'; + // Remove undesired newline chars + m_chatmessage[MESSAGE].remove("\n"); + chatmessage_is_empty = + m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == ""; + + if (f_char_id >= 0 && !chatmessage_is_empty && + f_message == previous_ic_message) // Not a system message + return; + + if (f_char_id <= -1) + previous_ic_message = + ""; // System messages don't care about repeating themselves + else + previous_ic_message = f_message; + + // Stop the chat arrow from animating + ui_vp_chat_arrow->stop(); + + text_state = 0; + anim_state = 0; + ui_vp_objection->stop(); + chat_tick_timer->stop(); + ui_vp_evidence_display->reset(); + + // Hey, our message showed up! Cool! + if (m_chatmessage[MESSAGE] == ui_ic_chat_message->text().remove("\n") && + m_chatmessage[CHAR_ID].toInt() == m_cid) { + ui_ic_chat_message->clear(); + if (ui_additive->isChecked()) + ui_ic_chat_message->insert(" "); + objection_state = 0; + realization_state = 0; + screenshake_state = 0; + is_presenting_evidence = false; + if (!ao_app->is_stickypres_enabled()) + ui_pre->setChecked(false); + ui_hold_it->set_image("holdit"); + ui_objection->set_image("objection"); + ui_take_that->set_image("takethat"); + ui_custom_objection->set_image("custom"); + ui_realization->set_image("realization"); + ui_screenshake->set_image("screenshake"); + ui_evidence_present->set_image("present"); + } - //Hey, our message showed up! Cool! - if (m_chatmessage[MESSAGE] == ui_ic_chat_message->text().remove("\n") && m_chatmessage[CHAR_ID].toInt() == m_cid) { - ui_ic_chat_message->clear(); - if (ui_additive->isChecked()) - ui_ic_chat_message->insert(" "); - objection_state = 0; - realization_state = 0; - screenshake_state = 0; - is_presenting_evidence = false; - if (!ao_app->is_stickypres_enabled()) - ui_pre->setChecked(false); - ui_hold_it->set_image("holdit"); - ui_objection->set_image("objection"); - ui_take_that->set_image("takethat"); - ui_custom_objection->set_image("custom"); - ui_realization->set_image("realization"); - ui_screenshake->set_image("screenshake"); - ui_evidence_present->set_image("present"); - } + // Let the server handle actually checking if they're allowed to do this. + is_additive = m_chatmessage[ADDITIVE].toInt() == 1; - //Let the server handle actually checking if they're allowed to do this. - is_additive = m_chatmessage[ADDITIVE].toInt() == 1; + QString f_charname = ""; + if (f_char_id >= 0) + f_charname = ao_app->get_showname(char_list.at(f_char_id).name); - QString f_charname = ""; - if (f_char_id >= 0) - f_charname = ao_app->get_showname(char_list.at(f_char_id).name); + chatlogpiece *temp = + new chatlogpiece(f_charname, f_showname, m_chatmessage[MESSAGE], false); + ic_chatlog_history.append(*temp); + ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); - chatlogpiece *temp = new chatlogpiece(f_charname, f_showname, m_chatmessage[MESSAGE], false); - ic_chatlog_history.append(*temp); - ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); + while (ic_chatlog_history.size() > log_maximum_blocks && + log_maximum_blocks > 0) { + ic_chatlog_history.removeFirst(); + } - while (ic_chatlog_history.size() > log_maximum_blocks && log_maximum_blocks > 0) { - ic_chatlog_history.removeFirst(); - } + append_ic_text(m_chatmessage[MESSAGE], f_showname); - append_ic_text(m_chatmessage[MESSAGE], f_showname); + int objection_mod = m_chatmessage[OBJECTION_MOD].toInt(); + QString f_char = m_chatmessage[CHAR_NAME]; + QString f_custom_theme = ao_app->get_char_shouts(f_char); - int objection_mod = m_chatmessage[OBJECTION_MOD].toInt(); - QString f_char = m_chatmessage[CHAR_NAME]; - QString f_custom_theme = ao_app->get_char_shouts(f_char); - - //if an objection is used - if (objection_mod <= 4 && objection_mod >= 1) { - switch (objection_mod) { - case 1: - ui_vp_objection->play("holdit_bubble", f_char, f_custom_theme, 724); - objection_player->play("holdit", f_char, f_custom_theme); - break; - case 2: - ui_vp_objection->play("objection_bubble", f_char, f_custom_theme, 724); - objection_player->play("objection", f_char, f_custom_theme); - if (ao_app->objection_stop_music()) - music_player->stop(); - break; - case 3: - ui_vp_objection->play("takethat_bubble", f_char, f_custom_theme, 724); - objection_player->play("takethat", f_char, f_custom_theme); - break; - //case 4 is AO2 only - case 4: - ui_vp_objection->play("custom", f_char, f_custom_theme, 724); - objection_player->play("custom", f_char, f_custom_theme); - break; - default: - qDebug() << "W: Logic error in objection switch statement!"; - } - sfx_player->clear(); //Objection played! Cut all sfx. - int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); - - if (emote_mod == 0) - m_chatmessage[EMOTE_MOD] = 1; + // if an objection is used + if (objection_mod <= 4 && objection_mod >= 1) { + switch (objection_mod) { + case 1: + ui_vp_objection->play("holdit_bubble", f_char, f_custom_theme, 724); + objection_player->play("holdit", f_char, f_custom_theme); + break; + case 2: + ui_vp_objection->play("objection_bubble", f_char, f_custom_theme, 724); + objection_player->play("objection", f_char, f_custom_theme); + if (ao_app->objection_stop_music()) + music_player->stop(); + break; + case 3: + ui_vp_objection->play("takethat_bubble", f_char, f_custom_theme, 724); + objection_player->play("takethat", f_char, f_custom_theme); + break; + // case 4 is AO2 only + case 4: + ui_vp_objection->play("custom", f_char, f_custom_theme, 724); + objection_player->play("custom", f_char, f_custom_theme); + break; + default: + qDebug() << "W: Logic error in objection switch statement!"; } - else - handle_chatmessage_2(); -} + sfx_player->clear(); // Objection played! Cut all sfx. + int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); -void Courtroom::objection_done() -{ + if (emote_mod == 0) + m_chatmessage[EMOTE_MOD] = 1; + } + else handle_chatmessage_2(); } +void Courtroom::objection_done() { handle_chatmessage_2(); } + void Courtroom::handle_chatmessage_2() { - ui_vp_speedlines->stop(); - ui_vp_player_char->stop(); - ui_vp_effect->stop(); - //Clear all looping sfx to prevent obnoxiousness - sfx_player->loop_clear(); - - if (!m_chatmessage[FRAME_SFX].isEmpty() && ao_app->is_frame_network_enabled()) { - //ORDER IS IMPORTANT!! - QStringList netstrings = {m_chatmessage[FRAME_SCREENSHAKE], m_chatmessage[FRAME_REALIZATION], m_chatmessage[FRAME_SFX]}; - ui_vp_player_char->network_strings = netstrings; - } - else - ui_vp_player_char->network_strings.clear(); - - int f_charid = m_chatmessage[CHAR_ID].toInt(); - if (f_charid >= 0 && (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { - QString real_name = char_list.at(f_charid).name; - - QString f_showname = ao_app->get_showname(real_name); - - ui_vp_showname->setText(f_showname); - } - else { - ui_vp_showname->setText(m_chatmessage[SHOWNAME]); - } - - if (ui_vp_showname->text().trimmed().isEmpty()) //Whitespace showname - { - ui_vp_chatbox->set_image("chatblank"); - } - else //Aw yeah dude do some showname resizing magic - { - if (!ui_vp_chatbox->set_image("chat")) - ui_vp_chatbox->set_image("chatbox"); - - QFontMetrics fm(ui_vp_showname->font()); - int fm_width = fm.horizontalAdvance(ui_vp_showname->text()); - - QString chatbox_path = ao_app->get_theme_path("chat"); - QString chatbox = ao_app->get_chat(m_chatmessage[CHAR_NAME]); - if (chatbox != "") { - chatbox_path = ao_app->get_base_path() + "misc/" + chatbox + "/chat"; - if (!ui_vp_chatbox->set_chatbox(chatbox_path)) - ui_vp_chatbox->set_chatbox(chatbox_path + "box"); - - pos_size_type design_ini_result = ao_app->get_element_dimensions("chat_arrow", "courtroom_design.ini", m_chatmessage[CHAR_NAME]); - if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; - ui_vp_chat_arrow->hide(); - } - else { - ui_vp_chat_arrow->move(design_ini_result.x, design_ini_result.y); - ui_vp_chat_arrow->combo_resize(design_ini_result.width, design_ini_result.height); - } + ui_vp_speedlines->stop(); + ui_vp_player_char->stop(); + ui_vp_effect->stop(); + // Clear all looping sfx to prevent obnoxiousness + sfx_player->loop_clear(); + + if (!m_chatmessage[FRAME_SFX].isEmpty() && + ao_app->is_frame_network_enabled()) { + // ORDER IS IMPORTANT!! + QStringList netstrings = {m_chatmessage[FRAME_SCREENSHAKE], + m_chatmessage[FRAME_REALIZATION], + m_chatmessage[FRAME_SFX]}; + ui_vp_player_char->network_strings = netstrings; + } + else + ui_vp_player_char->network_strings.clear(); + + int f_charid = m_chatmessage[CHAR_ID].toInt(); + if (f_charid >= 0 && + (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { + QString real_name = char_list.at(f_charid).name; + + QString f_showname = ao_app->get_showname(real_name); + + ui_vp_showname->setText(f_showname); + } + else { + ui_vp_showname->setText(m_chatmessage[SHOWNAME]); + } + + if (ui_vp_showname->text().trimmed().isEmpty()) // Whitespace showname + { + ui_vp_chatbox->set_image("chatblank"); + } + else // Aw yeah dude do some showname resizing magic + { + if (!ui_vp_chatbox->set_image("chat")) + ui_vp_chatbox->set_image("chatbox"); + + QFontMetrics fm(ui_vp_showname->font()); + int fm_width = fm.horizontalAdvance(ui_vp_showname->text()); + + QString chatbox_path = ao_app->get_theme_path("chat"); + QString chatbox = ao_app->get_chat(m_chatmessage[CHAR_NAME]); + if (chatbox != "") { + chatbox_path = ao_app->get_base_path() + "misc/" + chatbox + "/chat"; + if (!ui_vp_chatbox->set_chatbox(chatbox_path)) + ui_vp_chatbox->set_chatbox(chatbox_path + "box"); + + pos_size_type design_ini_result = ao_app->get_element_dimensions( + "chat_arrow", "courtroom_design.ini", m_chatmessage[CHAR_NAME]); + if (design_ini_result.width < 0 || design_ini_result.height < 0) { + qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; + ui_vp_chat_arrow->hide(); + } + else { + ui_vp_chat_arrow->move(design_ini_result.x, design_ini_result.y); + ui_vp_chat_arrow->combo_resize(design_ini_result.width, + design_ini_result.height); + } + } + + pos_size_type default_width = ao_app->get_element_dimensions( + "showname", "courtroom_design.ini", m_chatmessage[CHAR_NAME]); + int extra_width = + ao_app + ->get_design_element("showname_extra_width", "courtroom_design.ini", + m_chatmessage[CHAR_NAME]) + .toInt(); + + if (extra_width > 0) { + if (fm_width > default_width.width && + ui_vp_chatbox->set_chatbox( + chatbox_path + + "med")) // This text be big. Let's do some shenanigans. + { + ui_vp_showname->resize(default_width.width + extra_width, + ui_vp_showname->height()); + if (fm_width > ui_vp_showname->width() && + ui_vp_chatbox->set_chatbox(chatbox_path + + "big")) // Biggest possible size for us. + { + ui_vp_showname->resize( + static_cast<int>(default_width.width + (extra_width * 2)), + ui_vp_showname->height()); } - - pos_size_type default_width = ao_app->get_element_dimensions("showname", "courtroom_design.ini", m_chatmessage[CHAR_NAME]); - int extra_width = ao_app->get_design_element("showname_extra_width", "courtroom_design.ini", m_chatmessage[CHAR_NAME]).toInt(); - - if (extra_width > 0) { - if (fm_width > default_width.width && ui_vp_chatbox->set_chatbox(chatbox_path + "med")) //This text be big. Let's do some shenanigans. - { - ui_vp_showname->resize(default_width.width + extra_width, ui_vp_showname->height()); - if (fm_width > ui_vp_showname->width() && ui_vp_chatbox->set_chatbox(chatbox_path + "big")) //Biggest possible size for us. - { - ui_vp_showname->resize(static_cast<int>(default_width.width + (extra_width * 2)), ui_vp_showname->height()); - } - } - else - ui_vp_showname->resize(default_width.width, ui_vp_showname->height()); + } + else + ui_vp_showname->resize(default_width.width, ui_vp_showname->height()); + } + } + + ui_vp_message->hide(); + ui_vp_chatbox->hide(); + + // todo: put this in its own function or update + QString design_file = "courtroom_fonts.ini"; + int f_pointsize = ao_app->get_font_size("message", design_file); + QString font_name = ao_app->get_font_name("message_font", design_file); + QColor f_color = ao_app->get_color("message_color", design_file); + bool bold = ao_app->get_font_size("message_bold", design_file) == + 1; // is the font bold or not? + bool antialias = ao_app->get_font_size("message_sharp", design_file) != + 1; // is the font anti-aliased or not? + + QString chatfont = ao_app->get_chat_font(m_chatmessage[CHAR_NAME]); + if (chatfont != "") + font_name = chatfont; + + int chatsize = ao_app->get_chat_size(m_chatmessage[CHAR_NAME]); + if (chatsize != -1) + f_pointsize = chatsize; + this->set_qfont(ui_vp_message, "", + get_qfont(font_name, f_pointsize, antialias), f_color, bold); + + set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]); + + int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); + + if (ao_app->flipping_enabled && m_chatmessage[FLIP].toInt() == 1) + ui_vp_player_char->set_flipped(true); + else + ui_vp_player_char->set_flipped(false); + + QString side = m_chatmessage[SIDE]; + + // Making the second character appear. + if (m_chatmessage[OTHER_CHARID].isEmpty()) { + // If there is no second character, hide 'em + ui_vp_sideplayer_char->stop(); + ui_vp_sideplayer_char->move(0, 0); + } + else { + bool ok; + int got_other_charid = m_chatmessage[OTHER_CHARID].split("^")[0].toInt(&ok); + if (ok) { + if (got_other_charid > -1) { + // If there is, show them! + ui_vp_sideplayer_char->show(); + + int other_offset = m_chatmessage[OTHER_OFFSET].toInt(); + ui_vp_sideplayer_char->move(ui_viewport->width() * other_offset / 100, + 0); + + QStringList args = m_chatmessage[OTHER_CHARID].split("^"); + if (args.size() > + 1) // This ugly workaround is so we don't make an extra packet just + // for this purpose. Rewrite pairing when? + { + // Change the order of appearance based on the pair order variable + int order = args.at(1).toInt(); + switch (order) { + case 0: + ui_vp_sideplayer_char->stackUnder(ui_vp_player_char); + break; + case 1: + ui_vp_player_char->stackUnder(ui_vp_sideplayer_char); + break; + default: + break; + } } - } - - ui_vp_message->hide(); - ui_vp_chatbox->hide(); - - //todo: put this in its own function or update - QString design_file = "courtroom_fonts.ini"; - int f_pointsize = ao_app->get_font_size("message", design_file); - QString font_name = ao_app->get_font_name("message_font", design_file); - QColor f_color = ao_app->get_color("message_color", design_file); - bool bold = ao_app->get_font_size("message_bold", design_file) == 1; // is the font bold or not? - bool antialias = ao_app->get_font_size("message_sharp", design_file) != 1; // is the font anti-aliased or not? - - QString chatfont = ao_app->get_chat_font(m_chatmessage[CHAR_NAME]); - if (chatfont != "") - font_name = chatfont; - - int chatsize = ao_app->get_chat_size(m_chatmessage[CHAR_NAME]); - if (chatsize != -1) - f_pointsize = chatsize; - this->set_qfont(ui_vp_message, "", get_qfont(font_name, f_pointsize, antialias), f_color, bold); - - set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]); - - int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); - - if (ao_app->flipping_enabled && m_chatmessage[FLIP].toInt() == 1) - ui_vp_player_char->set_flipped(true); - else - ui_vp_player_char->set_flipped(false); - - QString side = m_chatmessage[SIDE]; - // Making the second character appear. - if (m_chatmessage[OTHER_CHARID].isEmpty()) { - // If there is no second character, hide 'em - ui_vp_sideplayer_char->stop(); + // We should probably also play the other character's idle emote. + if (ao_app->flipping_enabled && m_chatmessage[OTHER_FLIP].toInt() == 1) + ui_vp_sideplayer_char->set_flipped(true); + else + ui_vp_sideplayer_char->set_flipped(false); + ui_vp_sideplayer_char->play_idle(m_chatmessage[OTHER_NAME], + m_chatmessage[OTHER_EMOTE]); + } + else { + // If the server understands other characters, but there + // really is no second character, hide 'em, and center the first. + ui_vp_sideplayer_char->hide(); ui_vp_sideplayer_char->move(0, 0); + } } - else { - bool ok; - int got_other_charid = m_chatmessage[OTHER_CHARID].split("^")[0].toInt(&ok); - if (ok) { - if (got_other_charid > -1) { - // If there is, show them! - ui_vp_sideplayer_char->show(); - - int other_offset = m_chatmessage[OTHER_OFFSET].toInt(); - ui_vp_sideplayer_char->move(ui_viewport->width() * other_offset / 100, 0); - - QStringList args = m_chatmessage[OTHER_CHARID].split("^"); - if (args.size() > 1) //This ugly workaround is so we don't make an extra packet just for this purpose. Rewrite pairing when? - { - //Change the order of appearance based on the pair order variable - int order = args.at(1).toInt(); - switch (order) { - case 0: - ui_vp_sideplayer_char->stackUnder(ui_vp_player_char); - break; - case 1: - ui_vp_player_char->stackUnder(ui_vp_sideplayer_char); - break; - default: - break; - } - } + } + // Set ourselves according to SELF_OFFSET - // We should probably also play the other character's idle emote. - if (ao_app->flipping_enabled && m_chatmessage[OTHER_FLIP].toInt() == 1) - ui_vp_sideplayer_char->set_flipped(true); - else - ui_vp_sideplayer_char->set_flipped(false); - ui_vp_sideplayer_char->play_idle(m_chatmessage[OTHER_NAME], m_chatmessage[OTHER_EMOTE]); - } - else { - // If the server understands other characters, but there - // really is no second character, hide 'em, and center the first. - ui_vp_sideplayer_char->hide(); - ui_vp_sideplayer_char->move(0, 0); - } - } - } - //Set ourselves according to SELF_OFFSET + bool ok; + int self_offset = m_chatmessage[SELF_OFFSET].toInt(&ok); + if (ok) + ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, 0); + else + ui_vp_player_char->move(0, 0); - bool ok; - int self_offset = m_chatmessage[SELF_OFFSET].toInt(&ok); - if (ok) - ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, 0); + switch (emote_mod) { + case 1: + case 2: + case 6: + play_preanim(false); + break; + case 0: + case 5: + if (m_chatmessage[NONINTERRUPTING_PRE].toInt() == 0) + handle_chatmessage_3(); else - ui_vp_player_char->move(0, 0); - - switch (emote_mod) { - case 1: - case 2: - case 6: - play_preanim(false); - break; - case 0: - case 5: - if (m_chatmessage[NONINTERRUPTING_PRE].toInt() == 0) - handle_chatmessage_3(); - else - play_preanim(true); - break; - default: - qDebug() << "W: invalid emote mod: " << QString::number(emote_mod); - } + play_preanim(true); + break; + default: + qDebug() << "W: invalid emote mod: " << QString::number(emote_mod); + } } void Courtroom::do_screenshake() { - if (!ao_app->is_shake_enabled()) - return; - - //This way, the animation is reset in such a way that last played screenshake would return to its "final frame" properly. - //This properly resets all UI elements without having to bother keeping track of "origin" positions. - //Works great wit the chat text being detached from the chat box! - screenshake_animation_group->setCurrentTime(screenshake_animation_group->duration()); - screenshake_animation_group->clear(); - - QList<QWidget *> affected_list = { - ui_vp_background, - ui_vp_player_char, - ui_vp_sideplayer_char, - ui_vp_chatbox}; - - //I would prefer if this was its own "shake" function to be honest. - foreach (QWidget *ui_element, affected_list) { - QPropertyAnimation *screenshake_animation = new QPropertyAnimation(ui_element, "pos", this); - QPoint pos_default = QPoint(ui_element->x(), ui_element->y()); - - int duration = 300; //How long does the screenshake last - int frequency = 20; //How often in ms is there a "jolt" frame - int maxframes = duration / frequency; - int max_x = 7; //Max deviation from origin on x axis - int max_y = 7; //Max deviation from origin on y axis - screenshake_animation->setDuration(duration); - for (int frame = 0; frame < maxframes; frame++) { - double fraction = double(frame * frequency) / duration; - int rng = qrand(); //QRandomGenerator::global()->generate(); - int rand_x = max_x - (int(rng) % (max_x * 2)); - int rand_y = max_y - (int(rng + 100) % (max_y * 2)); - screenshake_animation->setKeyValueAt(fraction, QPoint(pos_default.x() + rand_x, pos_default.y() + rand_y)); - } - screenshake_animation->setEndValue(pos_default); - screenshake_animation->setEasingCurve(QEasingCurve::Linear); - screenshake_animation_group->addAnimation(screenshake_animation); - } - - screenshake_animation_group->start(); + if (!ao_app->is_shake_enabled()) + return; + + // This way, the animation is reset in such a way that last played screenshake + // would return to its "final frame" properly. This properly resets all UI + // elements without having to bother keeping track of "origin" positions. + // Works great wit the chat text being detached from the chat box! + screenshake_animation_group->setCurrentTime( + screenshake_animation_group->duration()); + screenshake_animation_group->clear(); + + QList<QWidget *> affected_list = {ui_vp_background, ui_vp_player_char, + ui_vp_sideplayer_char, ui_vp_chatbox}; + + // I would prefer if this was its own "shake" function to be honest. + foreach (QWidget *ui_element, affected_list) { + QPropertyAnimation *screenshake_animation = + new QPropertyAnimation(ui_element, "pos", this); + QPoint pos_default = QPoint(ui_element->x(), ui_element->y()); + + int duration = 300; // How long does the screenshake last + int frequency = 20; // How often in ms is there a "jolt" frame + int maxframes = duration / frequency; + int max_x = 7; // Max deviation from origin on x axis + int max_y = 7; // Max deviation from origin on y axis + screenshake_animation->setDuration(duration); + for (int frame = 0; frame < maxframes; frame++) { + double fraction = double(frame * frequency) / duration; + int rng = qrand(); // QRandomGenerator::global()->generate(); + int rand_x = max_x - (int(rng) % (max_x * 2)); + int rand_y = max_y - (int(rng + 100) % (max_y * 2)); + screenshake_animation->setKeyValueAt( + fraction, QPoint(pos_default.x() + rand_x, pos_default.y() + rand_y)); + } + screenshake_animation->setEndValue(pos_default); + screenshake_animation->setEasingCurve(QEasingCurve::Linear); + screenshake_animation_group->addAnimation(screenshake_animation); + } + + screenshake_animation_group->start(); } void Courtroom::do_flash() { - if (!ao_app->is_effects_enabled()) - return; + if (!ao_app->is_effects_enabled()) + return; - QString f_char = m_chatmessage[CHAR_NAME]; - QString f_custom_theme = ao_app->get_char_shouts(f_char); - ui_vp_effect->play("realizationflash", f_char, f_custom_theme, 60); + QString f_char = m_chatmessage[CHAR_NAME]; + QString f_custom_theme = ao_app->get_char_shouts(f_char); + ui_vp_effect->play("realizationflash", f_char, f_custom_theme, 60); } -void Courtroom::do_effect(QString fx_name, QString fx_sound, QString p_char, QString p_folder) +void Courtroom::do_effect(QString fx_name, QString fx_sound, QString p_char, + QString p_folder) { - QString effect = ao_app->get_effect(fx_name, p_char, p_folder); - if (effect == "") - return; + QString effect = ao_app->get_effect(fx_name, p_char, p_folder); + if (effect == "") + return; - if (fx_sound != "") - sfx_player->play(fx_sound); + if (fx_sound != "") + sfx_player->play(fx_sound); - //Only check if effects are disabled after playing the sound if it exists - if (!ao_app->is_effects_enabled()) - return; + // Only check if effects are disabled after playing the sound if it exists + if (!ao_app->is_effects_enabled()) + return; - ui_vp_effect->set_play_once(false); // The effects themselves dictate whether or not they're looping. Static effects will linger. - ui_vp_effect->play(effect); // It will set_play_once to true if the filepath provided is not designed to loop more than once + ui_vp_effect->set_play_once( + false); // The effects themselves dictate whether or not they're looping. + // Static effects will linger. + ui_vp_effect->play(effect); // It will set_play_once to true if the filepath + // provided is not designed to loop more than once } void Courtroom::play_char_sfx(QString sfx_name) { - sfx_player->play(sfx_name); - if (ao_app->get_looping_sfx()) - sfx_player->set_looping(ao_app->get_sfx_looping(current_char, QString::number(current_emote)) != "0"); + sfx_player->play(sfx_name); + if (ao_app->get_looping_sfx()) + sfx_player->set_looping( + ao_app->get_sfx_looping(current_char, QString::number(current_emote)) != + "0"); } void Courtroom::handle_chatmessage_3() { - start_chat_ticking(); - - int f_evi_id = m_chatmessage[EVIDENCE_ID].toInt(); - QString f_side = m_chatmessage[SIDE]; - - QString f_showname; - int f_char_id = m_chatmessage[CHAR_ID].toInt(); - if (f_char_id > 0 && (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { - f_showname = ao_app->get_showname(char_list.at(f_char_id).name); - } - else { - f_showname = m_chatmessage[SHOWNAME]; - } - if (f_showname.trimmed().isEmpty()) //Pure whitespace showname, get outta here. - f_showname = m_chatmessage[CHAR_NAME]; - - if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size()) { - //shifted by 1 because 0 is no evidence per legacy standards - QString f_image = local_evidence_list.at(f_evi_id - 1).image; - QString f_name = local_evidence_list.at(f_evi_id - 1).name; - //def jud and hlp should display the evidence icon on the RIGHT side - bool is_left_side = !(f_side == "def" || f_side == "hlp" || f_side == "jud" || f_side == "jur"); - ui_vp_evidence_display->show_evidence(f_image, is_left_side, ui_sfx_slider->value()); - append_ic_text(f_name, f_showname, "has presented evidence"); - } - - int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); - - QString side = m_chatmessage[SIDE]; - - if (emote_mod == 5 || - emote_mod == 6) { - ui_vp_desk->hide(); - ui_vp_legacy_desk->hide(); - - // Since we're zooming, hide the second character, and centre the first. - ui_vp_sideplayer_char->hide(); - ui_vp_player_char->move(0, 0); - - QString f_char = m_chatmessage[CHAR_NAME]; - QString f_custom_theme = ao_app->get_char_shouts(f_char); - if (side == "pro" || - side == "hlp" || - side == "wit") - ui_vp_speedlines->play("prosecution_speedlines", f_char, f_custom_theme); - else - ui_vp_speedlines->play("defense_speedlines", f_char, f_custom_theme); - } - - //If this color is talking - color_is_talking = color_markdown_talking_list.at(m_chatmessage[TEXT_COLOR].toInt()); - - if (color_is_talking && text_state == 1 && anim_state < 2) //Set it to talking as we're not on that already - { - ui_vp_player_char->stop(); - ui_vp_player_char->play_talking(m_chatmessage[CHAR_NAME], m_chatmessage[EMOTE]); - anim_state = 2; - } - else if (anim_state < 3) //Set it to idle as we're not on that already - { - ui_vp_player_char->stop(); - ui_vp_player_char->play_idle(m_chatmessage[CHAR_NAME], m_chatmessage[EMOTE]); - anim_state = 3; - } - - QString f_message = m_chatmessage[MESSAGE]; - QStringList call_words = ao_app->get_call_words(); - - for (QString word : call_words) { - if (f_message.contains(word, Qt::CaseInsensitive)) { - modcall_player->play(ao_app->get_sfx("word_call")); - ao_app->alert(this); + start_chat_ticking(); + + int f_evi_id = m_chatmessage[EVIDENCE_ID].toInt(); + QString f_side = m_chatmessage[SIDE]; + + QString f_showname; + int f_char_id = m_chatmessage[CHAR_ID].toInt(); + if (f_char_id > 0 && + (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { + f_showname = ao_app->get_showname(char_list.at(f_char_id).name); + } + else { + f_showname = m_chatmessage[SHOWNAME]; + } + if (f_showname.trimmed() + .isEmpty()) // Pure whitespace showname, get outta here. + f_showname = m_chatmessage[CHAR_NAME]; + + if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size()) { + // shifted by 1 because 0 is no evidence per legacy standards + QString f_image = local_evidence_list.at(f_evi_id - 1).image; + QString f_name = local_evidence_list.at(f_evi_id - 1).name; + // def jud and hlp should display the evidence icon on the RIGHT side + bool is_left_side = !(f_side == "def" || f_side == "hlp" || + f_side == "jud" || f_side == "jur"); + ui_vp_evidence_display->show_evidence(f_image, is_left_side, + ui_sfx_slider->value()); + append_ic_text(f_name, f_showname, "has presented evidence"); + } + + int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); + + QString side = m_chatmessage[SIDE]; + + if (emote_mod == 5 || emote_mod == 6) { + ui_vp_desk->hide(); + ui_vp_legacy_desk->hide(); - break; - } - } -} + // Since we're zooming, hide the second character, and centre the first. + ui_vp_sideplayer_char->hide(); + ui_vp_player_char->move(0, 0); -QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int default_color) -{ - QString p_text_escaped; - - int check_pos = 0; - int check_pos_escaped = 0; - bool ic_next_is_not_special = false; - std::stack<int> ic_color_stack; - - //Text alignment shenanigans. Could make a dropdown for this later, too! - QString align; - if (p_text.trimmed().startsWith("~~")) { - p_text.remove(p_text.indexOf("~~"), 2); - if (target_pos != -1) { - target_pos = qMax(0, target_pos - 2); - } - align = "center"; - } - else if (p_text.trimmed().startsWith("~>")) { - p_text.remove(p_text.indexOf("~>"), 2); - if (target_pos != -1) { - target_pos = qMax(0, target_pos - 2); - } - align = "right"; - } - else if (p_text.trimmed().startsWith("<>")) { - p_text.remove(p_text.indexOf("<>"), 2); - if (target_pos != -1) { - target_pos = qMax(0, target_pos - 2); - } - align = "justify"; - } + QString f_char = m_chatmessage[CHAR_NAME]; + QString f_custom_theme = ao_app->get_char_shouts(f_char); + if (side == "pro" || side == "hlp" || side == "wit") + ui_vp_speedlines->play("prosecution_speedlines", f_char, f_custom_theme); + else + ui_vp_speedlines->play("defense_speedlines", f_char, f_custom_theme); + } - //If html is enabled, prepare this text to be all ready for it. - if (html) { - ic_color_stack.push(default_color); - QString appendage = "<font color=\"" + color_rgb_list.at(default_color).name(QColor::HexRgb) + "\">"; + // If this color is talking + color_is_talking = + color_markdown_talking_list.at(m_chatmessage[TEXT_COLOR].toInt()); - if (!align.isEmpty()) - appendage.prepend("<div align=" + align + ">"); + if (color_is_talking && text_state == 1 && + anim_state < 2) // Set it to talking as we're not on that already + { + ui_vp_player_char->stop(); + ui_vp_player_char->play_talking(m_chatmessage[CHAR_NAME], + m_chatmessage[EMOTE]); + anim_state = 2; + } + else if (anim_state < 3) // Set it to idle as we're not on that already + { + ui_vp_player_char->stop(); + ui_vp_player_char->play_idle(m_chatmessage[CHAR_NAME], + m_chatmessage[EMOTE]); + anim_state = 3; + } + + QString f_message = m_chatmessage[MESSAGE]; + QStringList call_words = ao_app->get_call_words(); + + for (QString word : call_words) { + if (f_message.contains(word, Qt::CaseInsensitive)) { + modcall_player->play(ao_app->get_sfx("word_call")); + ao_app->alert(this); + + break; + } + } +} + +QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, + int default_color) +{ + QString p_text_escaped; + + int check_pos = 0; + int check_pos_escaped = 0; + bool ic_next_is_not_special = false; + std::stack<int> ic_color_stack; + + // Text alignment shenanigans. Could make a dropdown for this later, too! + QString align; + if (p_text.trimmed().startsWith("~~")) { + p_text.remove(p_text.indexOf("~~"), 2); + if (target_pos != -1) { + target_pos = qMax(0, target_pos - 2); + } + align = "center"; + } + else if (p_text.trimmed().startsWith("~>")) { + p_text.remove(p_text.indexOf("~>"), 2); + if (target_pos != -1) { + target_pos = qMax(0, target_pos - 2); + } + align = "right"; + } + else if (p_text.trimmed().startsWith("<>")) { + p_text.remove(p_text.indexOf("<>"), 2); + if (target_pos != -1) { + target_pos = qMax(0, target_pos - 2); + } + align = "justify"; + } + + // If html is enabled, prepare this text to be all ready for it. + if (html) { + ic_color_stack.push(default_color); + QString appendage = "<font color=\"" + + color_rgb_list.at(default_color).name(QColor::HexRgb) + + "\">"; + + if (!align.isEmpty()) + appendage.prepend("<div align=" + align + ">"); + + p_text_escaped.insert(check_pos_escaped, appendage); + check_pos_escaped += appendage.size(); + } + + // Current issue: does not properly escape html stuff. + // Solution: probably parse p_text and export into a different string + // separately, perform some mumbo jumbo to properly adjust string indexes. + while (check_pos < p_text.size()) { + QString f_rest = p_text.right(p_text.size() - check_pos); + QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_rest); + QString f_character; + int f_char_length; - p_text_escaped.insert(check_pos_escaped, appendage); - check_pos_escaped += appendage.size(); - } + tbf.toNextBoundary(); - //Current issue: does not properly escape html stuff. - //Solution: probably parse p_text and export into a different string separately, perform some mumbo jumbo to properly adjust string indexes. - while (check_pos < p_text.size()) { - QString f_rest = p_text.right(p_text.size() - check_pos); - QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_rest); - QString f_character; - int f_char_length; + if (tbf.position() == -1) + f_character = f_rest; + else + f_character = f_rest.left(tbf.position()); + + // if (f_character == "&") //oh shit it's probably an escaped html + // { + // //Skip escaped chars like you would graphemes + // QRegularExpression re("&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});", + // QRegularExpression::CaseInsensitiveOption); QRegularExpressionMatch + // match = re.match(f_rest); if (match.hasMatch()) //OH SHIT IT IS, + // PANIC, PANIC + // { + // f_character = match.captured(0); //Phew, we solved the big problem + // here. + // } + // } + + if (html) + f_character = f_character.toHtmlEscaped(); - tbf.toNextBoundary(); + f_char_length = f_character.length(); - if (tbf.position() == -1) - f_character = f_rest; - else - f_character = f_rest.left(tbf.position()); - - // if (f_character == "&") //oh shit it's probably an escaped html - // { - // //Skip escaped chars like you would graphemes - // QRegularExpression re("&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});", QRegularExpression::CaseInsensitiveOption); - // QRegularExpressionMatch match = re.match(f_rest); - // if (match.hasMatch()) //OH SHIT IT IS, PANIC, PANIC - // { - // f_character = match.captured(0); //Phew, we solved the big problem here. - // } - // } - - if (html) - f_character = f_character.toHtmlEscaped(); - - f_char_length = f_character.length(); - - bool color_update = false; - bool is_end = false; - bool skip = false; - - if (!ic_next_is_not_special) { - if (f_character == "\\") { - ic_next_is_not_special = true; - skip = true; - } - //Nothing related to colors here - else if (f_character == "{" || f_character == "}") //|| f_character == "@" || f_character == "$") - { - skip = true; - } - //Parse markdown colors - else { - for (int c = 0; c < max_colors; ++c) { - //Clear the stored optimization information - QString markdown_start = color_markdown_start_list.at(c); - QString markdown_end = color_markdown_end_list.at(c); - if (html) { - markdown_start = markdown_start.toHtmlEscaped(); - markdown_end = markdown_end.toHtmlEscaped(); - } - bool markdown_remove = color_markdown_remove_list.at(c); - if (markdown_start.isEmpty()) //Not defined - continue; - - if (markdown_end.isEmpty() || markdown_end == markdown_start) //"toggle switch" type - { - if (f_character == markdown_start) { - if (html) { - if (!ic_color_stack.empty() && ic_color_stack.top() == c && default_color != c) { - ic_color_stack.pop(); //Cease our coloring - is_end = true; - } - else { - ic_color_stack.push(c); //Begin our coloring - } - color_update = true; - } - skip = markdown_remove; - break; //Prevent it from looping forward for whatever reason - } - } - else if (f_character == markdown_start || (f_character == markdown_end && !ic_color_stack.empty() && ic_color_stack.top() == c)) { - if (html) { - if (f_character == markdown_end) { - ic_color_stack.pop(); //Cease our coloring - is_end = true; - } - else if (f_character == markdown_start) { - ic_color_stack.push(c); //Begin our coloring - } - color_update = true; - } - skip = markdown_remove; - break; //Prevent it from looping forward for whatever reason - } + bool color_update = false; + bool is_end = false; + bool skip = false; + + if (!ic_next_is_not_special) { + if (f_character == "\\") { + ic_next_is_not_special = true; + skip = true; + } + // Nothing related to colors here + else if (f_character == "{" || + f_character == + "}") //|| f_character == "@" || f_character == "$") + { + skip = true; + } + // Parse markdown colors + else { + for (int c = 0; c < max_colors; ++c) { + // Clear the stored optimization information + QString markdown_start = color_markdown_start_list.at(c); + QString markdown_end = color_markdown_end_list.at(c); + if (html) { + markdown_start = markdown_start.toHtmlEscaped(); + markdown_end = markdown_end.toHtmlEscaped(); + } + bool markdown_remove = color_markdown_remove_list.at(c); + if (markdown_start.isEmpty()) // Not defined + continue; + + if (markdown_end.isEmpty() || + markdown_end == markdown_start) //"toggle switch" type + { + if (f_character == markdown_start) { + if (html) { + if (!ic_color_stack.empty() && ic_color_stack.top() == c && + default_color != c) { + ic_color_stack.pop(); // Cease our coloring + is_end = true; } - //Parse the newest color stack - if (color_update && (target_pos <= -1 || check_pos < target_pos)) { - if (!ic_next_is_not_special) { - QString appendage = "</font>"; - - if (!ic_color_stack.empty()) - appendage += "<font color=\"" + color_rgb_list.at(ic_color_stack.top()).name(QColor::HexRgb) + "\">"; - - if (is_end && !skip) { - p_text_escaped.insert(check_pos_escaped, f_character); //Add that char right now - check_pos_escaped += f_char_length; //So the closing char is captured too - skip = true; - } - p_text_escaped.insert(check_pos_escaped, appendage); - check_pos_escaped += appendage.size(); - } + else { + ic_color_stack.push(c); // Begin our coloring } + color_update = true; + } + skip = markdown_remove; + break; // Prevent it from looping forward for whatever reason } - } - else { - if (f_character == "n") // \n, that's a line break son - { - QString appendage = "<br/>"; - if (!html) { - //actual newline commented out - // appendage = "\n"; - // size = 1; //yeah guess what \n is a "single character" apparently - appendage = "\\n "; //visual representation of a newline - } - p_text_escaped.insert(check_pos_escaped, appendage); - check_pos_escaped += appendage.size(); - skip = true; + } + else if (f_character == markdown_start || + (f_character == markdown_end && !ic_color_stack.empty() && + ic_color_stack.top() == c)) { + if (html) { + if (f_character == markdown_end) { + ic_color_stack.pop(); // Cease our coloring + is_end = true; + } + else if (f_character == markdown_start) { + ic_color_stack.push(c); // Begin our coloring + } + color_update = true; } - if (f_character == "s" || f_character == "f") // screenshake/flash - skip = true; - - ic_next_is_not_special = false; + skip = markdown_remove; + break; // Prevent it from looping forward for whatever reason + } } - - //Make all chars we're not supposed to see invisible - if (target_pos > -1 && check_pos == target_pos) { - QString appendage = ""; - if (!ic_color_stack.empty()) { - if (!is_end) //Was our last coloring char ending the color stack or nah - { - //God forgive me for my transgressions but I have refactored this whole thing about 25 times and having to refactor it - //again to more elegantly support this will finally make me go insane. - color_is_talking = color_markdown_talking_list.at(ic_color_stack.top()); - } - - //Clean it up, we're done here - while (!ic_color_stack.empty()) - ic_color_stack.pop(); - - appendage += "</font>"; + // Parse the newest color stack + if (color_update && (target_pos <= -1 || check_pos < target_pos)) { + if (!ic_next_is_not_special) { + QString appendage = "</font>"; + + if (!ic_color_stack.empty()) + appendage += + "<font color=\"" + + color_rgb_list.at(ic_color_stack.top()).name(QColor::HexRgb) + + "\">"; + + if (is_end && !skip) { + p_text_escaped.insert(check_pos_escaped, + f_character); // Add that char right now + check_pos_escaped += + f_char_length; // So the closing char is captured too + skip = true; } - ic_color_stack.push(-1); //Dummy colorstack push for maximum </font> appendage - appendage += "<font color=\"#00000000\">"; p_text_escaped.insert(check_pos_escaped, appendage); check_pos_escaped += appendage.size(); + } } - if (!skip) { - p_text_escaped.insert(check_pos_escaped, f_character); - check_pos_escaped += f_char_length; - } - check_pos += 1; + } } + else { + if (f_character == "n") // \n, that's a line break son + { + QString appendage = "<br/>"; + if (!html) { + // actual newline commented out + // appendage = "\n"; + // size = 1; //yeah guess what \n is a "single character" + // apparently + appendage = "\\n "; // visual representation of a newline + } + p_text_escaped.insert(check_pos_escaped, appendage); + check_pos_escaped += appendage.size(); + skip = true; + } + if (f_character == "s" || f_character == "f") // screenshake/flash + skip = true; - if (!ic_color_stack.empty() && html) { - p_text_escaped.append("</font>"); + ic_next_is_not_special = false; } - if (html) { - //Example: https://regex101.com/r/oL4nM9/37 - this replaces excessive/trailing/etc. whitespace with non-breaking space. - //I WOULD use white-space: pre; stylesheet tag, but for whataver reason it doesn't work no matter where I try it. - //If somoene else can get that piece of HTML memery to work, please do. - p_text_escaped.replace(QRegularExpression("^\\s|(?<=\\s)\\s"), " "); - if (!align.isEmpty()) - p_text_escaped.append("</div>"); + // Make all chars we're not supposed to see invisible + if (target_pos > -1 && check_pos == target_pos) { + QString appendage = ""; + if (!ic_color_stack.empty()) { + if (!is_end) // Was our last coloring char ending the color stack or nah + { + // God forgive me for my transgressions but I have refactored this + // whole thing about 25 times and having to refactor it again to more + // elegantly support this will finally make me go insane. + color_is_talking = + color_markdown_talking_list.at(ic_color_stack.top()); + } + + // Clean it up, we're done here + while (!ic_color_stack.empty()) + ic_color_stack.pop(); + + appendage += "</font>"; + } + ic_color_stack.push( + -1); // Dummy colorstack push for maximum </font> appendage + appendage += "<font color=\"#00000000\">"; + p_text_escaped.insert(check_pos_escaped, appendage); + check_pos_escaped += appendage.size(); } + if (!skip) { + p_text_escaped.insert(check_pos_escaped, f_character); + check_pos_escaped += f_char_length; + } + check_pos += 1; + } + + if (!ic_color_stack.empty() && html) { + p_text_escaped.append("</font>"); + } - return p_text_escaped; + if (html) { + // Example: https://regex101.com/r/oL4nM9/37 - this replaces + // excessive/trailing/etc. whitespace with non-breaking space. I WOULD use + // white-space: pre; stylesheet tag, but for whataver reason it doesn't work + // no matter where I try it. If somoene else can get that piece of HTML + // memery to work, please do. + p_text_escaped.replace(QRegularExpression("^\\s|(?<=\\s)\\s"), " "); + if (!align.isEmpty()) + p_text_escaped.append("</div>"); + } + + return p_text_escaped; } void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action) { - QTextCharFormat bold; - QTextCharFormat normal; - QTextCharFormat italics; - bold.setFontWeight(QFont::Bold); - normal.setFontWeight(QFont::Normal); - italics.setFontItalic(true); - const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); - const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); - - if (p_action == "") - p_text = filter_ic_text(p_text, ao_app->is_colorlog_enabled(), -1, m_chatmessage[TEXT_COLOR].toInt()); - - 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); - } + QTextCharFormat bold; + QTextCharFormat normal; + QTextCharFormat italics; + bold.setFontWeight(QFont::Bold); + normal.setFontWeight(QFont::Normal); + italics.setFontItalic(true); + const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); + const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); - if (p_action != "") { - ui_ic_chatlog->textCursor().insertText(" " + p_action + ": ", normal); - ui_ic_chatlog->textCursor().insertText(p_text + ".", italics); - } - else { - ui_ic_chatlog->textCursor().insertText(": ", normal); - ui_ic_chatlog->textCursor().insertHtml(p_text); - } + if (p_action == "") + p_text = filter_ic_text(p_text, ao_app->is_colorlog_enabled(), -1, + m_chatmessage[TEXT_COLOR].toInt()); - // 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(); - } + if (log_goes_downwards) { + const bool is_scrolled_down = + old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->maximum(); - 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()); - } + ui_ic_chatlog->moveCursor(QTextCursor::End); + + if (!first_message_sent) { + ui_ic_chatlog->textCursor().insertText(p_name, bold); + first_message_sent = true; } else { - const bool is_scrolled_up = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->minimum(); + ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold); + } - ui_ic_chatlog->moveCursor(QTextCursor::Start); + if (p_action != "") { + ui_ic_chatlog->textCursor().insertText(" " + p_action + ": ", normal); + ui_ic_chatlog->textCursor().insertText(p_text + ".", italics); + } + else { + ui_ic_chatlog->textCursor().insertText(": ", normal); + ui_ic_chatlog->textCursor().insertHtml(p_text); + } - ui_ic_chatlog->textCursor().insertText(p_name, bold); + // 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(); + } - if (p_action != "") { - ui_ic_chatlog->textCursor().insertText(" " + p_action + ": ", normal); - ui_ic_chatlog->textCursor().insertText(p_text + "." + '\n', italics); - } - else { - ui_ic_chatlog->textCursor().insertText(": ", normal); - ui_ic_chatlog->textCursor().insertText(p_text + '\n', normal); - } + 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(); - // 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(); - } + ui_ic_chatlog->moveCursor(QTextCursor::Start); - 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()); - } + ui_ic_chatlog->textCursor().insertText(p_name, bold); + + if (p_action != "") { + ui_ic_chatlog->textCursor().insertText(" " + p_action + ": ", normal); + ui_ic_chatlog->textCursor().insertText(p_text + "." + '\n', italics); } + else { + ui_ic_chatlog->textCursor().insertText(": ", normal); + 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(); + } + + 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()); + } + } } void Courtroom::play_preanim(bool noninterrupting) { - 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() * time_mod; + QString f_char = m_chatmessage[CHAR_NAME]; + QString f_preanim = m_chatmessage[PRE_EMOTE]; - int preanim_duration; - - if (ao2_duration < 0) - preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim); - else - preanim_duration = ao2_duration; + // 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() * time_mod; - 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)) { - if (noninterrupting) - anim_state = 4; - else - anim_state = 1; - preanim_done(); - qDebug() << "could not find " + anim_to_find; - return; - } + int preanim_duration; - ui_vp_player_char->play_pre(f_char, f_preanim, 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)) { if (noninterrupting) - anim_state = 4; + anim_state = 4; else - anim_state = 1; + anim_state = 1; + preanim_done(); + qDebug() << "could not find " + anim_to_find; + return; + } - if (text_delay >= 0) - text_delay_timer->start(text_delay); + ui_vp_player_char->play_pre(f_char, f_preanim, preanim_duration); - if (noninterrupting) - handle_chatmessage_3(); + if (noninterrupting) + anim_state = 4; + else + anim_state = 1; + + if (text_delay >= 0) + text_delay_timer->start(text_delay); + + if (noninterrupting) + handle_chatmessage_3(); } void Courtroom::preanim_done() { - anim_state = 1; - handle_chatmessage_3(); + anim_state = 1; + handle_chatmessage_3(); } void Courtroom::start_chat_ticking() { - //we need to ensure that the text isn't already ticking because this function can be called by two logic paths - if (text_state != 0) - return; + // we need to ensure that the text isn't already ticking because this function + // can be called by two logic paths + if (text_state != 0) + return; - if (m_chatmessage[EFFECTS] != "") { - QStringList fx_list = m_chatmessage[EFFECTS].split("|"); - QString fx = fx_list[0]; - QString fx_sound; - QString fx_folder; + if (m_chatmessage[EFFECTS] != "") { + QStringList fx_list = m_chatmessage[EFFECTS].split("|"); + QString fx = fx_list[0]; + QString fx_sound; + QString fx_folder; - if (fx_list.length() > 1) - fx_sound = fx_list[1]; + if (fx_list.length() > 1) + fx_sound = fx_list[1]; - if (fx_list.length() > 2) { - fx_folder = fx_list[1]; - fx_sound = fx_list[2]; - } - - this->do_effect(fx, fx_sound, m_chatmessage[CHAR_NAME], fx_folder); - } - else if (m_chatmessage[REALIZATION] == "1") { - this->do_flash(); - sfx_player->play(ao_app->get_custom_realization(m_chatmessage[CHAR_NAME])); - } - if (chatmessage_is_empty) { - //since the message is empty, it's technically done ticking - text_state = 2; - return; + if (fx_list.length() > 2) { + fx_folder = fx_list[1]; + fx_sound = fx_list[2]; } - ui_vp_chatbox->show(); - ui_vp_message->show(); + this->do_effect(fx, fx_sound, m_chatmessage[CHAR_NAME], fx_folder); + } + else if (m_chatmessage[REALIZATION] == "1") { + this->do_flash(); + sfx_player->play(ao_app->get_custom_realization(m_chatmessage[CHAR_NAME])); + } + if (chatmessage_is_empty) { + // since the message is empty, it's technically done ticking + text_state = 2; + return; + } - if (!is_additive) { - ui_vp_message->clear(); - real_tick_pos = 0; - additive_previous = ""; - } + ui_vp_chatbox->show(); + ui_vp_message->show(); - tick_pos = 0; - blip_ticker = 0; + if (!is_additive) { + ui_vp_message->clear(); + real_tick_pos = 0; + additive_previous = ""; + } - // At the start of every new message, we set the text speed to the default. - current_display_speed = 3; - chat_tick_timer->start(0); //Display the first char right away + tick_pos = 0; + blip_ticker = 0; - QString f_gender = ao_app->get_gender(m_chatmessage[CHAR_NAME]); + // At the start of every new message, we set the text speed to the default. + current_display_speed = 3; + chat_tick_timer->start(0); // Display the first char right away - blip_player->set_blips(f_gender); + QString f_gender = ao_app->get_gender(m_chatmessage[CHAR_NAME]); - int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); //text meme bonanza - if ((emote_mod == 0 || emote_mod == 5) && m_chatmessage[SCREENSHAKE] == "1") { - this->do_screenshake(); - } + blip_player->set_blips(f_gender); - //means text is currently ticking - text_state = 1; + int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); // text meme bonanza + if ((emote_mod == 0 || emote_mod == 5) && m_chatmessage[SCREENSHAKE] == "1") { + this->do_screenshake(); + } + + // means text is currently ticking + text_state = 1; } void Courtroom::chat_tick() { - //note: this is called fairly often - //do not perform heavy operations here + // note: this is called fairly often + // do not perform heavy operations here - QString f_message = m_chatmessage[MESSAGE]; + QString f_message = m_chatmessage[MESSAGE]; - // Due to our new text speed system, we always need to stop the timer now. - chat_tick_timer->stop(); + // Due to our new text speed system, we always need to stop the timer now. + chat_tick_timer->stop(); - if (tick_pos >= f_message.size()) { - text_state = 2; - if (anim_state < 3) { - anim_state = 3; - ui_vp_player_char->play_idle(m_chatmessage[CHAR_NAME], m_chatmessage[EMOTE]); - } - QString f_char = m_chatmessage[CHAR_NAME]; - QString f_custom_theme = ao_app->get_chat(f_char); - ui_vp_chat_arrow->play("chat_arrow", f_char, f_custom_theme); //Chat stopped being processed, indicate that. - additive_previous = additive_previous + filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt()); - real_tick_pos = ui_vp_message->toPlainText().size(); - return; + if (tick_pos >= f_message.size()) { + text_state = 2; + if (anim_state < 3) { + anim_state = 3; + ui_vp_player_char->play_idle(m_chatmessage[CHAR_NAME], + m_chatmessage[EMOTE]); } - - // Stops blips from playing when we have a formatting option. - bool formatting_char = false; - - QString f_rest = f_message; - - //Alignment characters - if (tick_pos < 2) { - if (f_rest.startsWith("~~")) { - tick_pos = f_rest.indexOf("~~"); - f_rest.remove(tick_pos, 2); - tick_pos += 2; - } - else if (f_rest.startsWith("~>")) { - tick_pos = f_rest.indexOf("~>"); - f_rest.remove(tick_pos, 2); - tick_pos += 2; - } - else if (f_rest.startsWith("<>")) { - tick_pos = f_rest.indexOf("<>"); - f_rest.remove(tick_pos, 2); - tick_pos += 2; - } + QString f_char = m_chatmessage[CHAR_NAME]; + QString f_custom_theme = ao_app->get_chat(f_char); + ui_vp_chat_arrow->play( + "chat_arrow", f_char, + f_custom_theme); // Chat stopped being processed, indicate that. + additive_previous = + additive_previous + + filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt()); + real_tick_pos = ui_vp_message->toPlainText().size(); + return; + } + + // Stops blips from playing when we have a formatting option. + bool formatting_char = false; + + QString f_rest = f_message; + + // Alignment characters + if (tick_pos < 2) { + if (f_rest.startsWith("~~")) { + tick_pos = f_rest.indexOf("~~"); + f_rest.remove(tick_pos, 2); + tick_pos += 2; + } + else if (f_rest.startsWith("~>")) { + tick_pos = f_rest.indexOf("~>"); + f_rest.remove(tick_pos, 2); + tick_pos += 2; + } + else if (f_rest.startsWith("<>")) { + tick_pos = f_rest.indexOf("<>"); + f_rest.remove(tick_pos, 2); + tick_pos += 2; + } + } + f_rest.remove(0, tick_pos); + QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_rest); + QString f_character; + int f_char_length; + + tbf.toNextBoundary(); + + if (tbf.position() == -1) + f_character = f_rest; + else + f_character = f_rest.left(tbf.position()); + + f_char_length = f_character.length(); + tick_pos += f_char_length; + + // Escape character. + if (!next_character_is_not_special) { + if (f_character == "\\") { + next_character_is_not_special = true; + formatting_char = true; + } + + // Text speed modifier. + else if (f_character == "{") { + // ++, because it INCREASES delay! + current_display_speed++; + formatting_char = true; + } + else if (f_character == "}") { + current_display_speed--; + formatting_char = true; } - f_rest.remove(0, tick_pos); - QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_rest); - QString f_character; - int f_char_length; - - tbf.toNextBoundary(); - if (tbf.position() == -1) - f_character = f_rest; - else - f_character = f_rest.left(tbf.position()); - - f_char_length = f_character.length(); - tick_pos += f_char_length; - - // Escape character. - if (!next_character_is_not_special) { - if (f_character == "\\") { - next_character_is_not_special = true; - formatting_char = true; - } + else { + // Parse markdown colors + for (int c = 0; c < max_colors; ++c) { + QString markdown_start = color_markdown_start_list.at(c); + QString markdown_end = color_markdown_end_list.at(c); + bool markdown_remove = color_markdown_remove_list.at(c); + if (markdown_start.isEmpty()) + continue; - // Text speed modifier. - else if (f_character == "{") { - // ++, because it INCREASES delay! - current_display_speed++; - formatting_char = true; - } - else if (f_character == "}") { - current_display_speed--; + if (f_character == markdown_start || f_character == markdown_end) { + if (markdown_remove) formatting_char = true; + break; } - - else { - //Parse markdown colors - for (int c = 0; c < max_colors; ++c) { - QString markdown_start = color_markdown_start_list.at(c); - QString markdown_end = color_markdown_end_list.at(c); - bool markdown_remove = color_markdown_remove_list.at(c); - if (markdown_start.isEmpty()) - continue; - - if (f_character == markdown_start || f_character == markdown_end) { - if (markdown_remove) - formatting_char = true; - break; - } - } - } + } } - else { - if (f_character == "n") - formatting_char = true; //it's a newline - if (f_character == "s") //Screenshake. - { - this->do_screenshake(); - formatting_char = true; - } - if (f_character == "f") //Flash. - { - this->do_flash(); - formatting_char = true; - } - next_character_is_not_special = false; + } + else { + if (f_character == "n") + formatting_char = true; // it's a newline + if (f_character == "s") // Screenshake. + { + this->do_screenshake(); + formatting_char = true; } - - if ((message_display_speed[current_display_speed] <= 0 && tick_pos < f_message.size() - 1) || formatting_char) { - chat_tick_timer->start(0); //Don't bother rendering anything out as we're doing the SPEED. (there's latency otherwise) - if (!formatting_char || f_character == "n" || f_character == "f" || f_character == "s") - real_tick_pos += f_char_length; //Adjust the tick position for the scrollbar convenience + if (f_character == "f") // Flash. + { + this->do_flash(); + formatting_char = true; + } + next_character_is_not_special = false; + } + + if ((message_display_speed[current_display_speed] <= 0 && + tick_pos < f_message.size() - 1) || + formatting_char) { + chat_tick_timer->start(0); // Don't bother rendering anything out as we're + // doing the SPEED. (there's latency otherwise) + if (!formatting_char || f_character == "n" || f_character == "f" || + f_character == "s") + real_tick_pos += f_char_length; // Adjust the tick position for the + // scrollbar convenience + } + else { + int msg_delay = message_display_speed[current_display_speed]; + // Do the colors, gradual showing, etc. in here + ui_vp_message->setHtml(additive_previous + + filter_ic_text(f_message, true, tick_pos, + m_chatmessage[TEXT_COLOR].toInt())); + + // This should always be done AFTER setHtml. Scroll the chat window with the + // text. + + // Make the cursor follow the message + QTextCursor cursor = ui_vp_message->textCursor(); + cursor.setPosition(real_tick_pos); + ui_vp_message->setTextCursor(cursor); + real_tick_pos += f_char_length; + + ui_vp_message->ensureCursorVisible(); + + // Keep the speed at bay. + if (current_display_speed < 0) + current_display_speed = 0; + else if (current_display_speed > 6) + current_display_speed = 6; + + // Blip player and real tick pos ticker + if (!formatting_char && (f_character != ' ' || blank_blip)) { + if (blip_ticker % blip_rate == 0) { + blip_player->blip_tick(); + } + ++blip_ticker; + } + + // Punctuation delayer + if (punctuation_chars.contains(f_character)) { + msg_delay *= punctuation_modifier; + } + + // If this color is talking + if (color_is_talking && anim_state != 2 && + anim_state < + 4) // Set it to talking as we're not on that already (though we have + // to avoid interrupting a non-interrupted preanim) + { + ui_vp_player_char->stop(); + ui_vp_player_char->play_talking(m_chatmessage[CHAR_NAME], + m_chatmessage[EMOTE]); + anim_state = 2; } - else { - int msg_delay = message_display_speed[current_display_speed]; - //Do the colors, gradual showing, etc. in here - ui_vp_message->setHtml(additive_previous + filter_ic_text(f_message, true, tick_pos, m_chatmessage[TEXT_COLOR].toInt())); - - //This should always be done AFTER setHtml. Scroll the chat window with the text. - - //Make the cursor follow the message - QTextCursor cursor = ui_vp_message->textCursor(); - cursor.setPosition(real_tick_pos); - ui_vp_message->setTextCursor(cursor); - real_tick_pos += f_char_length; - - ui_vp_message->ensureCursorVisible(); - - // Keep the speed at bay. - if (current_display_speed < 0) - current_display_speed = 0; - else if (current_display_speed > 6) - current_display_speed = 6; - - //Blip player and real tick pos ticker - if (!formatting_char && (f_character != ' ' || blank_blip)) { - if (blip_ticker % blip_rate == 0) { - blip_player->blip_tick(); - } - ++blip_ticker; - } - - //Punctuation delayer - if (punctuation_chars.contains(f_character)) { - msg_delay *= punctuation_modifier; - } - - //If this color is talking - if (color_is_talking && anim_state != 2 && anim_state < 4) //Set it to talking as we're not on that already (though we have to avoid interrupting a non-interrupted preanim) - { - ui_vp_player_char->stop(); - ui_vp_player_char->play_talking(m_chatmessage[CHAR_NAME], m_chatmessage[EMOTE]); - anim_state = 2; - } - else if (!color_is_talking && anim_state < 3 && anim_state != 3) //Set it to idle as we're not on that already - { - ui_vp_player_char->stop(); - ui_vp_player_char->play_idle(m_chatmessage[CHAR_NAME], m_chatmessage[EMOTE]); - anim_state = 3; - } - //Continue ticking - chat_tick_timer->start(msg_delay); + else if (!color_is_talking && anim_state < 3 && + anim_state != 3) // Set it to idle as we're not on that already + { + ui_vp_player_char->stop(); + ui_vp_player_char->play_idle(m_chatmessage[CHAR_NAME], + m_chatmessage[EMOTE]); + anim_state = 3; } + // Continue ticking + chat_tick_timer->start(msg_delay); + } } void Courtroom::play_sfx() { - QString sfx_name = m_chatmessage[SFX_NAME]; - if (m_chatmessage[SCREENSHAKE] == "1") //Screenshake dependant on preanim sfx delay meme - { - this->do_screenshake(); - } - if (sfx_name == "1") - return; + QString sfx_name = m_chatmessage[SFX_NAME]; + if (m_chatmessage[SCREENSHAKE] == + "1") // Screenshake dependant on preanim sfx delay meme + { + this->do_screenshake(); + } + if (sfx_name == "1") + return; - sfx_player->play(sfx_name); - if (ao_app->get_looping_sfx()) - sfx_player->set_looping(ao_app->get_sfx_looping(current_char, sfx_name) != "0"); + sfx_player->play(sfx_name); + if (ao_app->get_looping_sfx()) + sfx_player->set_looping(ao_app->get_sfx_looping(current_char, sfx_name) != + "0"); } void Courtroom::set_scene(QString f_desk_mod, QString f_side) { - //witness is default if pos is invalid - QString f_background = "witnessempty"; - QString f_desk_image = "stand"; - - if (f_side == "def" && file_exists(ao_app->get_image_suffix(ao_app->get_background_path("defenseempty")))) { - f_background = "defenseempty"; - f_desk_image = "defensedesk"; - } - else if (f_side == "pro" && file_exists(ao_app->get_image_suffix(ao_app->get_background_path("prosecutorempty")))) { - f_background = "prosecutorempty"; - f_desk_image = "prosecutiondesk"; - } - else if (f_side == "jud" && file_exists(ao_app->get_image_suffix(ao_app->get_background_path("judgestand")))) { - f_background = "judgestand"; - f_desk_image = "judgedesk"; - } - else if (f_side == "hld" && file_exists(ao_app->get_image_suffix(ao_app->get_background_path("helperstand")))) { - f_background = "helperstand"; - f_desk_image = "helperdesk"; - } - else if (f_side == "hlp" && file_exists(ao_app->get_image_suffix(ao_app->get_background_path("prohelperstand")))) { - f_background = "prohelperstand"; - f_desk_image = "prohelperdesk"; - } - else if (f_side == "jur" && file_exists(ao_app->get_image_suffix(ao_app->get_background_path("jurystand")))) { - f_background = "jurystand"; - f_desk_image = "jurydesk"; - } - else if (f_side == "sea" && file_exists(ao_app->get_image_suffix(ao_app->get_background_path("seancestand")))) { - f_background = "seancestand"; - f_desk_image = "seancedesk"; - } - - if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(f_side)))) //Unique pos path - { - f_background = f_side; - f_desk_image = f_side + "_overlay"; - } - - ui_vp_background->set_image(f_background); - ui_vp_desk->set_image(f_desk_image); - ui_vp_legacy_desk->set_legacy_desk(f_desk_image); - - if (f_desk_mod == "0" || (f_desk_mod != "1" && - (f_side == "jud" || - f_side == "hld" || - f_side == "hlp"))) { - ui_vp_desk->hide(); - ui_vp_legacy_desk->hide(); - } - else { - ui_vp_legacy_desk->hide(); - ui_vp_desk->show(); - } + // witness is default if pos is invalid + QString f_background = "witnessempty"; + QString f_desk_image = "stand"; + + if (f_side == "def" && file_exists(ao_app->get_image_suffix( + ao_app->get_background_path("defenseempty")))) { + f_background = "defenseempty"; + f_desk_image = "defensedesk"; + } + else if (f_side == "pro" && + file_exists(ao_app->get_image_suffix( + ao_app->get_background_path("prosecutorempty")))) { + f_background = "prosecutorempty"; + f_desk_image = "prosecutiondesk"; + } + else if (f_side == "jud" && file_exists(ao_app->get_image_suffix( + ao_app->get_background_path("judgestand")))) { + f_background = "judgestand"; + f_desk_image = "judgedesk"; + } + else if (f_side == "hld" && + file_exists(ao_app->get_image_suffix( + ao_app->get_background_path("helperstand")))) { + f_background = "helperstand"; + f_desk_image = "helperdesk"; + } + else if (f_side == "hlp" && + file_exists(ao_app->get_image_suffix( + ao_app->get_background_path("prohelperstand")))) { + f_background = "prohelperstand"; + f_desk_image = "prohelperdesk"; + } + else if (f_side == "jur" && file_exists(ao_app->get_image_suffix( + ao_app->get_background_path("jurystand")))) { + f_background = "jurystand"; + f_desk_image = "jurydesk"; + } + else if (f_side == "sea" && + file_exists(ao_app->get_image_suffix( + ao_app->get_background_path("seancestand")))) { + f_background = "seancestand"; + f_desk_image = "seancedesk"; + } + + if (file_exists(ao_app->get_image_suffix( + ao_app->get_background_path(f_side)))) // Unique pos path + { + f_background = f_side; + f_desk_image = f_side + "_overlay"; + } + + ui_vp_background->set_image(f_background); + ui_vp_desk->set_image(f_desk_image); + ui_vp_legacy_desk->set_legacy_desk(f_desk_image); + + if (f_desk_mod == "0" || + (f_desk_mod != "1" && + (f_side == "jud" || f_side == "hld" || f_side == "hlp"))) { + ui_vp_desk->hide(); + ui_vp_legacy_desk->hide(); + } + else { + ui_vp_legacy_desk->hide(); + ui_vp_desk->show(); + } } void Courtroom::set_ip_list(QString p_list) { - QString f_list = p_list.replace("|", ":").replace("*", "\n"); + QString f_list = p_list.replace("|", ":").replace("*", "\n"); - ui_server_chatlog->append(f_list); + ui_server_chatlog->append(f_list); } void Courtroom::set_mute(bool p_muted, int p_cid) { - if (p_cid != m_cid && p_cid != -1) - return; + if (p_cid != m_cid && p_cid != -1) + return; - if (p_muted) - ui_muted->show(); - else { - ui_muted->hide(); - ui_ic_chat_message->setFocus(); - } + if (p_muted) + ui_muted->show(); + else { + ui_muted->hide(); + ui_ic_chat_message->setFocus(); + } - ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height()); - ui_muted->set_image("muted"); + ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height()); + ui_muted->set_image("muted"); - is_muted = p_muted; - ui_ic_chat_message->setEnabled(!p_muted); + is_muted = p_muted; + ui_ic_chat_message->setEnabled(!p_muted); } void Courtroom::set_ban(int p_cid) { - if (p_cid != m_cid && p_cid != -1) - return; + if (p_cid != m_cid && p_cid != -1) + return; - call_notice("You have been banned."); + call_notice("You have been banned."); - ao_app->construct_lobby(); - ao_app->destruct_courtroom(); + ao_app->construct_lobby(); + ao_app->destruct_courtroom(); } void Courtroom::handle_song(QStringList *p_contents) { - QStringList f_contents = *p_contents; + QStringList f_contents = *p_contents; - if (f_contents.size() < 2) - return; + if (f_contents.size() < 2) + return; - QString f_song = f_contents.at(0); - QString f_song_clear = f_song.left(f_song.lastIndexOf(".")); - f_song_clear = f_song_clear.right(f_song_clear.length() - (f_song_clear.lastIndexOf("/") + 1)); - int n_char = f_contents.at(1).toInt(); + QString f_song = f_contents.at(0); + QString f_song_clear = f_song.left(f_song.lastIndexOf(".")); + f_song_clear = f_song_clear.right(f_song_clear.length() - + (f_song_clear.lastIndexOf("/") + 1)); + int n_char = f_contents.at(1).toInt(); - bool looping = true; + bool looping = true; + int channel = 0; + int effect_flags = 0; + if (n_char < 0 || n_char >= char_list.size()) { int channel = 0; - int effect_flags = 0; - if (n_char < 0 || n_char >= char_list.size()) { - int channel = 0; - if (p_contents->length() > 3 && p_contents->at(3) != "-1") - looping = false; - - if (p_contents->length() > 4) //eyyy we want to change this song's CHANNEL huh - channel = p_contents->at(4).toInt(); //let the music player handle it if it's bigger than the channel list + if (p_contents->length() > 3 && p_contents->at(3) != "-1") + looping = false; - if (p_contents->length() > 5) //Flags provided to us by server such as Fade In, Fade Out, Sync Pos etc. - { - effect_flags = p_contents->at(5).toInt(); - } + if (p_contents->length() > + 4) // eyyy we want to change this song's CHANNEL huh + channel = p_contents->at(4).toInt(); // let the music player handle it if + // it's bigger than the channel list - music_player->play(f_song, channel, looping, effect_flags); - if (channel == 0) - ui_music_name->setText(f_song_clear); + if (p_contents->length() > 5) // Flags provided to us by server such as Fade + // In, Fade Out, Sync Pos etc. + { + effect_flags = p_contents->at(5).toInt(); + } + + music_player->play(f_song, channel, looping, effect_flags); + if (channel == 0) + ui_music_name->setText(f_song_clear); + } + else { + QString str_char = char_list.at(n_char).name; + QString str_show = char_list.at(n_char).name; + + if (p_contents->length() > 2) { + if (p_contents->at(2) != "") { + str_show = p_contents->at(2); + } + } + if (p_contents->length() > 3 && p_contents->at(3) != "-1") { + // I am really confused why "-1" is "loop this song" and why anything else + // passes as "don't loop" (if we even have this length) but alright + looping = false; + } + if (p_contents->length() > + 4) // eyyy we want to change this song's CHANNEL huh + channel = p_contents->at(4).toInt(); // let the music player handle it if + // it's bigger than the channel list + + if (p_contents->length() > 5) // Flags provided to us by server such as Fade + // In, Fade Out, Sync Pos etc. + { + effect_flags = p_contents->at(5).toInt(); } - else { - QString str_char = char_list.at(n_char).name; - QString str_show = char_list.at(n_char).name; - - if (p_contents->length() > 2) { - if (p_contents->at(2) != "") { - str_show = p_contents->at(2); - } - } - if (p_contents->length() > 3 && p_contents->at(3) != "-1") { - //I am really confused why "-1" is "loop this song" and why anything else passes as "don't loop" - //(if we even have this length) but alright - looping = false; - } - if (p_contents->length() > 4) //eyyy we want to change this song's CHANNEL huh - channel = p_contents->at(4).toInt(); //let the music player handle it if it's bigger than the channel list - if (p_contents->length() > 5) //Flags provided to us by server such as Fade In, Fade Out, Sync Pos etc. - { - effect_flags = p_contents->at(5).toInt(); - } + if (!mute_map.value(n_char)) { + chatlogpiece *temp = new chatlogpiece(str_char, str_show, f_song, true); + ic_chatlog_history.append(*temp); + ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); - if (!mute_map.value(n_char)) { - chatlogpiece *temp = new chatlogpiece(str_char, str_show, f_song, true); - ic_chatlog_history.append(*temp); - ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); - - while (ic_chatlog_history.size() > log_maximum_blocks && log_maximum_blocks > 0) { - ic_chatlog_history.removeFirst(); - } + while (ic_chatlog_history.size() > log_maximum_blocks && + log_maximum_blocks > 0) { + ic_chatlog_history.removeFirst(); + } - append_ic_text(f_song_clear, str_show, "has played a song"); + append_ic_text(f_song_clear, str_show, "has played a song"); - music_player->play(f_song, channel, looping, effect_flags); - if (channel == 0) - ui_music_name->setText(f_song_clear); - } + music_player->play(f_song, channel, looping, effect_flags); + if (channel == 0) + ui_music_name->setText(f_song_clear); } + } } void Courtroom::handle_wtce(QString p_wtce, int variant) { - QString sfx_file = "courtroom_sounds.ini"; - - //witness testimony - if (p_wtce == "testimony1") { - sfx_player->play(ao_app->get_sfx("witness_testimony")); - ui_vp_wtce->play("witnesstestimony", "", "", 1500); - ui_vp_testimony->play("testimony"); - } - //cross examination - else if (p_wtce == "testimony2") { - sfx_player->play(ao_app->get_sfx("cross_examination")); - ui_vp_wtce->play("crossexamination", "", "", 1500); - ui_vp_testimony->stop(); + QString sfx_file = "courtroom_sounds.ini"; + + // witness testimony + if (p_wtce == "testimony1") { + sfx_player->play(ao_app->get_sfx("witness_testimony")); + ui_vp_wtce->play("witnesstestimony", "", "", 1500); + ui_vp_testimony->play("testimony"); + } + // cross examination + else if (p_wtce == "testimony2") { + sfx_player->play(ao_app->get_sfx("cross_examination")); + ui_vp_wtce->play("crossexamination", "", "", 1500); + ui_vp_testimony->stop(); + } + else if (p_wtce == "judgeruling") { + if (variant == 0) { + sfx_player->play(ao_app->get_sfx("not_guilty")); + ui_vp_wtce->play("notguilty", "", "", 3000); + ui_vp_testimony->stop(); } - else if (p_wtce == "judgeruling") { - if (variant == 0) { - sfx_player->play(ao_app->get_sfx("not_guilty")); - ui_vp_wtce->play("notguilty", "", "", 3000); - ui_vp_testimony->stop(); - } - else if (variant == 1) { - sfx_player->play(ao_app->get_sfx("guilty")); - ui_vp_wtce->play("guilty", "", "", 3000); - ui_vp_testimony->stop(); - } + else if (variant == 1) { + sfx_player->play(ao_app->get_sfx("guilty")); + ui_vp_wtce->play("guilty", "", "", 3000); + ui_vp_testimony->stop(); } + } } void Courtroom::set_hp_bar(int p_bar, int p_state) { - if (p_state < 0 || p_state > 10) - return; + if (p_state < 0 || p_state > 10) + return; - if (p_bar == 1) { - ui_defense_bar->set_image("defensebar" + QString::number(p_state)); - defense_bar_state = p_state; - } - else if (p_bar == 2) { - ui_prosecution_bar->set_image("prosecutionbar" + QString::number(p_state)); - prosecution_bar_state = p_state; - } + if (p_bar == 1) { + ui_defense_bar->set_image("defensebar" + QString::number(p_state)); + defense_bar_state = p_state; + } + else if (p_bar == 2) { + ui_prosecution_bar->set_image("prosecutionbar" + QString::number(p_state)); + prosecution_bar_state = p_state; + } } void Courtroom::toggle_judge_buttons(bool is_on) { - if (is_on) { - ui_witness_testimony->show(); - ui_cross_examination->show(); - ui_guilty->show(); - ui_not_guilty->show(); - ui_defense_minus->show(); - ui_defense_plus->show(); - ui_prosecution_minus->show(); - ui_prosecution_plus->show(); - } - else { - ui_witness_testimony->hide(); - ui_cross_examination->hide(); - ui_guilty->hide(); - ui_not_guilty->hide(); - ui_defense_minus->hide(); - ui_defense_plus->hide(); - ui_prosecution_minus->hide(); - ui_prosecution_plus->hide(); - } + if (is_on) { + ui_witness_testimony->show(); + ui_cross_examination->show(); + ui_guilty->show(); + ui_not_guilty->show(); + ui_defense_minus->show(); + ui_defense_plus->show(); + ui_prosecution_minus->show(); + ui_prosecution_plus->show(); + } + else { + ui_witness_testimony->hide(); + ui_cross_examination->hide(); + ui_guilty->hide(); + ui_not_guilty->hide(); + ui_defense_minus->hide(); + ui_defense_plus->hide(); + ui_prosecution_minus->hide(); + ui_prosecution_plus->hide(); + } } void Courtroom::mod_called(QString p_ip) { - ui_server_chatlog->append(p_ip); - if (!ui_guard->isChecked()) { - modcall_player->play(ao_app->get_sfx("mod_call")); - ao_app->alert(this); - } + ui_server_chatlog->append(p_ip); + if (!ui_guard->isChecked()) { + modcall_player->play(ao_app->get_sfx("mod_call")); + ao_app->alert(this); + } } -void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur, bool steno) +void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur, + bool steno) { - if (ui_casing->isChecked()) { - ui_server_chatlog->append(msg); - if ((ao_app->get_casing_defence_enabled() && def) || - (ao_app->get_casing_prosecution_enabled() && pro) || - (ao_app->get_casing_judge_enabled() && jud) || - (ao_app->get_casing_juror_enabled() && jur) || - (ao_app->get_casing_steno_enabled() && steno)) { - modcall_player->play(ao_app->get_sfx("case_call")); - ao_app->alert(this); - } + if (ui_casing->isChecked()) { + ui_server_chatlog->append(msg); + if ((ao_app->get_casing_defence_enabled() && def) || + (ao_app->get_casing_prosecution_enabled() && pro) || + (ao_app->get_casing_judge_enabled() && jud) || + (ao_app->get_casing_juror_enabled() && jur) || + (ao_app->get_casing_steno_enabled() && steno)) { + modcall_player->play(ao_app->get_sfx("case_call")); + ao_app->alert(this); } + } } void Courtroom::on_ooc_return_pressed() { - QString ooc_message = ui_ooc_chat_message->text(); + QString ooc_message = ui_ooc_chat_message->text(); - if (ooc_message == "" || ui_ooc_chat_name->text() == "") - return; + if (ooc_message == "" || ui_ooc_chat_name->text() == "") + return; - if (ooc_message.startsWith("/pos")) { - if (ooc_message == "/pos jud") { - toggle_judge_buttons(true); - } - else { - toggle_judge_buttons(false); - } - } - else if (ooc_message.startsWith("/settings")) { - ui_ooc_chat_message->clear(); - ao_app->call_settings_menu(); - append_server_chatmessage("CLIENT", tr("You opened the settings menu."), "1"); - return; - } - else if (ooc_message.startsWith("/pair")) { - ui_ooc_chat_message->clear(); - ooc_message.remove(0, 6); - - bool ok; - int whom = ooc_message.toInt(&ok); - if (ok) { - if (whom > -1) { - other_charid = whom; - QString msg = tr("You will now pair up with "); - msg.append(char_list.at(whom).name); - msg.append(tr(" if they also choose your character in return.")); - append_server_chatmessage("CLIENT", msg, "1"); - } - else { - other_charid = -1; - append_server_chatmessage("CLIENT", tr("You are no longer paired with anyone."), "1"); - } - } - else { - append_server_chatmessage("CLIENT", tr("Are you sure you typed that well? The char ID could not be recognised."), "1"); - } - return; + if (ooc_message.startsWith("/pos")) { + if (ooc_message == "/pos jud") { + toggle_judge_buttons(true); } - else if (ooc_message.startsWith("/offset")) { - ui_ooc_chat_message->clear(); - ooc_message.remove(0, 8); - - bool ok; - int off = ooc_message.toInt(&ok); - if (ok) { - if (off >= -100 && off <= 100) { - char_offset = off; - QString msg = tr("You have set your offset to "); - msg.append(QString::number(off)); - msg.append("%."); - append_server_chatmessage("CLIENT", msg, "1"); - } - else { - append_server_chatmessage("CLIENT", tr("Your offset must be between -100% and 100%!"), "1"); - } - } - else { - append_server_chatmessage("CLIENT", tr("That offset does not look like one."), "1"); - } - return; - } - else if (ooc_message.startsWith("/switch_am")) { - append_server_chatmessage("CLIENT", tr("You switched your music and area list."), "1"); - on_switch_area_music_clicked(); - ui_ooc_chat_message->clear(); - return; - } - else if (ooc_message.startsWith("/enable_blocks")) { - append_server_chatmessage("CLIENT", tr("You have forcefully enabled features that the server may not support. You may not be able to talk IC, or worse, because of this."), "1"); - ao_app->cccc_ic_support_enabled = true; - ao_app->arup_enabled = true; - ao_app->modcall_reason_enabled = true; - on_reload_theme_clicked(); - ui_ooc_chat_message->clear(); - return; - } - else if (ooc_message.startsWith("/non_int_pre")) { - if (ui_pre_non_interrupt->isChecked()) - append_server_chatmessage("CLIENT", tr("Your pre-animations interrupt again."), "1"); - else - append_server_chatmessage("CLIENT", tr("Your pre-animations will not interrupt text."), "1"); - ui_pre_non_interrupt->setChecked(!ui_pre_non_interrupt->isChecked()); - ui_ooc_chat_message->clear(); - return; + else { + toggle_judge_buttons(false); } - else if (ooc_message.startsWith("/save_chatlog")) { - QFile file("chatlog.txt"); - - if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { - append_server_chatmessage("CLIENT", tr("Couldn't open chatlog.txt to write into."), "1"); - ui_ooc_chat_message->clear(); - return; - } - - QTextStream out(&file); - - foreach (chatlogpiece item, ic_chatlog_history) { - out << item.get_full() << '\n'; - } - - file.close(); + } + else if (ooc_message.startsWith("/settings")) { + ui_ooc_chat_message->clear(); + ao_app->call_settings_menu(); + append_server_chatmessage("CLIENT", tr("You opened the settings menu."), + "1"); + return; + } + else if (ooc_message.startsWith("/pair")) { + ui_ooc_chat_message->clear(); + ooc_message.remove(0, 6); - append_server_chatmessage("CLIENT", tr("The IC chatlog has been saved."), "1"); - ui_ooc_chat_message->clear(); - return; + bool ok; + int whom = ooc_message.toInt(&ok); + if (ok) { + if (whom > -1) { + other_charid = whom; + QString msg = tr("You will now pair up with "); + msg.append(char_list.at(whom).name); + msg.append(tr(" if they also choose your character in return.")); + append_server_chatmessage("CLIENT", msg, "1"); + } + else { + other_charid = -1; + append_server_chatmessage( + "CLIENT", tr("You are no longer paired with anyone."), "1"); + } } - else if (ooc_message.startsWith("/load_case")) { - QStringList command = ooc_message.split(" ", QString::SkipEmptyParts); - - QDir casefolder("base/cases"); - if (!casefolder.exists()) { - QDir::current().mkdir("base/" + casefolder.dirName()); - append_server_chatmessage("CLIENT", tr("You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely the case file you're looking for can't be found in there."), "1"); - ui_ooc_chat_message->clear(); - return; - } - QStringList caseslist = casefolder.entryList(); - caseslist.removeOne("."); - caseslist.removeOne(".."); - caseslist.replaceInStrings(".ini", ""); - - if (command.size() < 2) { - append_server_chatmessage("CLIENT", tr("You need to give a filename to load (extension not needed)! Make sure that it is in the `base/cases/` folder, and that it is a correctly formatted ini.\nCases you can load: %1").arg(caseslist.join(", ")), "1"); - ui_ooc_chat_message->clear(); - return; - } - - if (command.size() > 2) { - append_server_chatmessage("CLIENT", tr("Too many arguments to load a case! You only need one filename, without extension."), "1"); - ui_ooc_chat_message->clear(); - return; - } - - QSettings casefile("base/cases/" + command[1] + ".ini", QSettings::IniFormat); - - QString caseauth = casefile.value("author", "").value<QString>(); - QString casedoc = casefile.value("doc", "").value<QString>(); - QString cmdoc = casefile.value("cmdoc", "").value<QString>(); - QString casestatus = casefile.value("status", "").value<QString>(); - - if (!caseauth.isEmpty()) - append_server_chatmessage("CLIENT", tr("Case made by %1.").arg(caseauth), "1"); - if (!casedoc.isEmpty()) - ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/doc " + casedoc + "#%")); - if (!casestatus.isEmpty()) - ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/status " + casestatus + "#%")); - if (!cmdoc.isEmpty()) - append_server_chatmessage("CLIENT", tr("Navigate to %1 for the CM doc.").arg(cmdoc), "1"); - - for (int i = local_evidence_list.size() - 1; i >= 0; i--) { - ao_app->send_server_packet(new AOPacket("DE#" + QString::number(i) + "#%")); - } - - foreach (QString evi, casefile.childGroups()) { - if (evi == "General") - continue; + else { + append_server_chatmessage("CLIENT", + tr("Are you sure you typed that well? The char " + "ID could not be recognised."), + "1"); + } + return; + } + else if (ooc_message.startsWith("/offset")) { + ui_ooc_chat_message->clear(); + ooc_message.remove(0, 8); - QStringList f_contents; + bool ok; + int off = ooc_message.toInt(&ok); + if (ok) { + if (off >= -100 && off <= 100) { + char_offset = off; + QString msg = tr("You have set your offset to "); + msg.append(QString::number(off)); + msg.append("%."); + append_server_chatmessage("CLIENT", msg, "1"); + } + else { + append_server_chatmessage( + "CLIENT", tr("Your offset must be between -100% and 100%!"), "1"); + } + } + else { + append_server_chatmessage("CLIENT", + tr("That offset does not look like one."), "1"); + } + return; + } + else if (ooc_message.startsWith("/switch_am")) { + append_server_chatmessage( + "CLIENT", tr("You switched your music and area list."), "1"); + on_switch_area_music_clicked(); + ui_ooc_chat_message->clear(); + return; + } + else if (ooc_message.startsWith("/enable_blocks")) { + append_server_chatmessage("CLIENT", + tr("You have forcefully enabled features that " + "the server may not support. You may not be " + "able to talk IC, or worse, because of this."), + "1"); + ao_app->cccc_ic_support_enabled = true; + ao_app->arup_enabled = true; + ao_app->modcall_reason_enabled = true; + on_reload_theme_clicked(); + ui_ooc_chat_message->clear(); + return; + } + else if (ooc_message.startsWith("/non_int_pre")) { + if (ui_pre_non_interrupt->isChecked()) + append_server_chatmessage( + "CLIENT", tr("Your pre-animations interrupt again."), "1"); + else + append_server_chatmessage( + "CLIENT", tr("Your pre-animations will not interrupt text."), "1"); + ui_pre_non_interrupt->setChecked(!ui_pre_non_interrupt->isChecked()); + ui_ooc_chat_message->clear(); + return; + } + else if (ooc_message.startsWith("/save_chatlog")) { + QFile file("chatlog.txt"); - f_contents.append(casefile.value(evi + "/name", "UNKNOWN").value<QString>()); - f_contents.append(casefile.value(evi + "/description", "UNKNOWN").value<QString>()); - f_contents.append(casefile.value(evi + "/image", "UNKNOWN.png").value<QString>()); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text | + QIODevice::Truncate)) { + append_server_chatmessage( + "CLIENT", tr("Couldn't open chatlog.txt to write into."), "1"); + ui_ooc_chat_message->clear(); + return; + } - ao_app->send_server_packet(new AOPacket("PE", f_contents)); - } + QTextStream out(&file); - append_server_chatmessage("CLIENT", tr("Your case \"%1\" was loaded!").arg(command[1]), "1"); - ui_ooc_chat_message->clear(); - return; + foreach (chatlogpiece item, ic_chatlog_history) { + out << item.get_full() << '\n'; } - else if (ooc_message.startsWith("/save_case")) { - QStringList command = ooc_message.split(" ", QString::SkipEmptyParts); - - QDir casefolder("base/cases"); - if (!casefolder.exists()) { - QDir::current().mkdir("base/" + casefolder.dirName()); - append_server_chatmessage("CLIENT", tr("You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely that you somehow deleted it."), "1"); - ui_ooc_chat_message->clear(); - return; - } - QStringList caseslist = casefolder.entryList(); - caseslist.removeOne("."); - caseslist.removeOne(".."); - caseslist.replaceInStrings(".ini", ""); - - if (command.size() < 3) { - append_server_chatmessage("CLIENT", tr("You need to give a filename to save (extension not needed) and the courtroom status!"), "1"); - ui_ooc_chat_message->clear(); - return; - } - if (command.size() > 3) { - append_server_chatmessage("CLIENT", tr("Too many arguments to save a case! You only need a filename without extension and the courtroom status!"), "1"); - ui_ooc_chat_message->clear(); - return; - } - QSettings casefile("base/cases/" + command[1] + ".ini", QSettings::IniFormat); - casefile.setValue("author", ui_ooc_chat_name->text()); - casefile.setValue("cmdoc", ""); - casefile.setValue("doc", ""); - casefile.setValue("status", command[2]); - casefile.sync(); - for (int i = 0; i < local_evidence_list.size(); i++) { - QString clean_evidence_dsc = local_evidence_list[i].description.replace(QRegularExpression("<owner = ...>..."), ""); - clean_evidence_dsc = clean_evidence_dsc.replace(clean_evidence_dsc.lastIndexOf(">"), 1, ""); - casefile.beginGroup(QString::number(i)); - casefile.sync(); - casefile.setValue("name", local_evidence_list[i].name); - casefile.setValue("description", local_evidence_list[i].description); - casefile.setValue("image", local_evidence_list[i].image); - casefile.endGroup(); - } - casefile.sync(); - append_server_chatmessage("CLIENT", tr("Succesfully saved, edit doc and cmdoc link on the ini!"), "1"); - ui_ooc_chat_message->clear(); - return; - } + file.close(); - QStringList packet_contents; - packet_contents.append(ui_ooc_chat_name->text()); - packet_contents.append(ooc_message); + append_server_chatmessage("CLIENT", tr("The IC chatlog has been saved."), + "1"); + ui_ooc_chat_message->clear(); + return; + } + else if (ooc_message.startsWith("/load_case")) { + QStringList command = ooc_message.split(" ", QString::SkipEmptyParts); + + QDir casefolder("base/cases"); + if (!casefolder.exists()) { + QDir::current().mkdir("base/" + casefolder.dirName()); + append_server_chatmessage( + "CLIENT", + tr("You don't have a `base/cases/` folder! It was just made for you, " + "but seeing as it WAS just made for you, it's likely the case " + "file you're looking for can't be found in there."), + "1"); + ui_ooc_chat_message->clear(); + return; + } + QStringList caseslist = casefolder.entryList(); + caseslist.removeOne("."); + caseslist.removeOne(".."); + caseslist.replaceInStrings(".ini", ""); + + if (command.size() < 2) { + append_server_chatmessage( + "CLIENT", + tr("You need to give a filename to load (extension not needed)! Make " + "sure that it is in the `base/cases/` folder, and that it is a " + "correctly formatted ini.\nCases you can load: %1") + .arg(caseslist.join(", ")), + "1"); + ui_ooc_chat_message->clear(); + return; + } + + if (command.size() > 2) { + append_server_chatmessage( + "CLIENT", + tr("Too many arguments to load a case! You only need one filename, " + "without extension."), + "1"); + ui_ooc_chat_message->clear(); + return; + } + + QSettings casefile("base/cases/" + command[1] + ".ini", + QSettings::IniFormat); + + QString caseauth = casefile.value("author", "").value<QString>(); + QString casedoc = casefile.value("doc", "").value<QString>(); + QString cmdoc = casefile.value("cmdoc", "").value<QString>(); + QString casestatus = casefile.value("status", "").value<QString>(); + + if (!caseauth.isEmpty()) + append_server_chatmessage("CLIENT", tr("Case made by %1.").arg(caseauth), + "1"); + if (!casedoc.isEmpty()) + ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + + "#/doc " + casedoc + "#%")); + if (!casestatus.isEmpty()) + ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + + "#/status " + casestatus + "#%")); + if (!cmdoc.isEmpty()) + append_server_chatmessage( + "CLIENT", tr("Navigate to %1 for the CM doc.").arg(cmdoc), "1"); + + for (int i = local_evidence_list.size() - 1; i >= 0; i--) { + ao_app->send_server_packet( + new AOPacket("DE#" + QString::number(i) + "#%")); + } + + foreach (QString evi, casefile.childGroups()) { + if (evi == "General") + continue; + + QStringList f_contents; + + f_contents.append( + casefile.value(evi + "/name", "UNKNOWN").value<QString>()); + f_contents.append( + casefile.value(evi + "/description", "UNKNOWN").value<QString>()); + f_contents.append( + casefile.value(evi + "/image", "UNKNOWN.png").value<QString>()); + + ao_app->send_server_packet(new AOPacket("PE", f_contents)); + } + + append_server_chatmessage( + "CLIENT", tr("Your case \"%1\" was loaded!").arg(command[1]), "1"); + ui_ooc_chat_message->clear(); + return; + } + else if (ooc_message.startsWith("/save_case")) { + QStringList command = ooc_message.split(" ", QString::SkipEmptyParts); + + QDir casefolder("base/cases"); + if (!casefolder.exists()) { + QDir::current().mkdir("base/" + casefolder.dirName()); + append_server_chatmessage( + "CLIENT", + tr("You don't have a `base/cases/` folder! It was just made for you, " + "but seeing as it WAS just made for you, it's likely that you " + "somehow deleted it."), + "1"); + ui_ooc_chat_message->clear(); + return; + } + QStringList caseslist = casefolder.entryList(); + caseslist.removeOne("."); + caseslist.removeOne(".."); + caseslist.replaceInStrings(".ini", ""); + + if (command.size() < 3) { + append_server_chatmessage( + "CLIENT", + tr("You need to give a filename to save (extension not needed) and " + "the courtroom status!"), + "1"); + ui_ooc_chat_message->clear(); + return; + } + + if (command.size() > 3) { + append_server_chatmessage( + "CLIENT", + tr("Too many arguments to save a case! You only need a filename " + "without extension and the courtroom status!"), + "1"); + ui_ooc_chat_message->clear(); + return; + } + QSettings casefile("base/cases/" + command[1] + ".ini", + QSettings::IniFormat); + casefile.setValue("author", ui_ooc_chat_name->text()); + casefile.setValue("cmdoc", ""); + casefile.setValue("doc", ""); + casefile.setValue("status", command[2]); + casefile.sync(); + for (int i = 0; i < local_evidence_list.size(); i++) { + QString clean_evidence_dsc = local_evidence_list[i].description.replace( + QRegularExpression("<owner = ...>..."), ""); + clean_evidence_dsc = clean_evidence_dsc.replace( + clean_evidence_dsc.lastIndexOf(">"), 1, ""); + casefile.beginGroup(QString::number(i)); + casefile.sync(); + casefile.setValue("name", local_evidence_list[i].name); + casefile.setValue("description", local_evidence_list[i].description); + casefile.setValue("image", local_evidence_list[i].image); + casefile.endGroup(); + } + casefile.sync(); + append_server_chatmessage( + "CLIENT", tr("Succesfully saved, edit doc and cmdoc link on the ini!"), + "1"); + ui_ooc_chat_message->clear(); + return; + } - AOPacket *f_packet = new AOPacket("CT", packet_contents); + QStringList packet_contents; + packet_contents.append(ui_ooc_chat_name->text()); + packet_contents.append(ooc_message); - if (server_ooc) - ao_app->send_server_packet(f_packet); - else - ao_app->send_ms_packet(f_packet); + AOPacket *f_packet = new AOPacket("CT", packet_contents); - ui_ooc_chat_message->clear(); + if (server_ooc) + ao_app->send_server_packet(f_packet); + else + ao_app->send_ms_packet(f_packet); - ui_ooc_chat_message->setFocus(); + ui_ooc_chat_message->clear(); + + ui_ooc_chat_message->setFocus(); } void Courtroom::on_ooc_toggle_clicked() { - if (server_ooc) { - ui_ms_chatlog->show(); - ui_server_chatlog->hide(); - ui_ooc_toggle->setText(tr("Master")); + if (server_ooc) { + ui_ms_chatlog->show(); + ui_server_chatlog->hide(); + ui_ooc_toggle->setText(tr("Master")); - server_ooc = false; - } - else { - ui_ms_chatlog->hide(); - ui_server_chatlog->show(); - ui_ooc_toggle->setText(tr("Server")); + server_ooc = false; + } + else { + ui_ms_chatlog->hide(); + ui_server_chatlog->show(); + ui_ooc_toggle->setText(tr("Server")); - server_ooc = true; - } + server_ooc = true; + } } -//Todo: multithread this due to some servers having large as hell music list +// Todo: multithread this due to some servers having large as hell music list void Courtroom::on_music_search_edited(QString p_text) { - // Iterate through all QTreeWidgetItem items - if (!ui_music_list->isHidden()) { - QTreeWidgetItemIterator it(ui_music_list); - while (*it) { - (*it)->setHidden(p_text != ""); - ++it; - } + // Iterate through all QTreeWidgetItem items + if (!ui_music_list->isHidden()) { + QTreeWidgetItemIterator it(ui_music_list); + while (*it) { + (*it)->setHidden(p_text != ""); + ++it; } + } - if (!ui_area_list->isHidden()) { - QTreeWidgetItemIterator ait(ui_area_list); - while (*ait) { - (*ait)->setHidden(p_text != ""); - ++ait; - } + if (!ui_area_list->isHidden()) { + QTreeWidgetItemIterator ait(ui_area_list); + while (*ait) { + (*ait)->setHidden(p_text != ""); + ++ait; } + } - if (p_text != "") { - if (!ui_music_list->isHidden()) { - //Search in metadata - QList<QTreeWidgetItem *> clist = ui_music_list->findItems(ui_music_search->text(), Qt::MatchContains | Qt::MatchRecursive, 1); - foreach (QTreeWidgetItem *item, clist) { - if (item->parent() != nullptr) //So the category shows up too - item->parent()->setHidden(false); - item->setHidden(false); - } - } + if (p_text != "") { + if (!ui_music_list->isHidden()) { + // Search in metadata + QList<QTreeWidgetItem *> clist = ui_music_list->findItems( + ui_music_search->text(), Qt::MatchContains | Qt::MatchRecursive, 1); + foreach (QTreeWidgetItem *item, clist) { + if (item->parent() != nullptr) // So the category shows up too + item->parent()->setHidden(false); + item->setHidden(false); + } + } - if (!ui_area_list->isHidden()) { - //Search in metadata - QList<QTreeWidgetItem *> alist = ui_area_list->findItems(ui_music_search->text(), Qt::MatchContains | Qt::MatchRecursive, 1); - foreach (QTreeWidgetItem *item, alist) { - if (item->parent() != nullptr) //So the category shows up too - item->parent()->setHidden(false); - item->setHidden(false); - } - } + if (!ui_area_list->isHidden()) { + // Search in metadata + QList<QTreeWidgetItem *> alist = ui_area_list->findItems( + ui_music_search->text(), Qt::MatchContains | Qt::MatchRecursive, 1); + foreach (QTreeWidgetItem *item, alist) { + if (item->parent() != nullptr) // So the category shows up too + item->parent()->setHidden(false); + item->setHidden(false); + } } + } } void Courtroom::on_pos_dropdown_changed(int p_index) { - if (p_index < 0 || p_index > 7) - return; + if (p_index < 0 || p_index > 7) + return; - toggle_judge_buttons(false); + toggle_judge_buttons(false); - QString f_pos = ui_pos_dropdown->itemText(p_index); + QString f_pos = ui_pos_dropdown->itemText(p_index); - if (f_pos == "") - return; + if (f_pos == "") + return; - if (f_pos == "jud") - toggle_judge_buttons(true); + if (f_pos == "jud") + toggle_judge_buttons(true); - //YEAH SENDING LIKE 20 PACKETS IF THE USER SCROLLS THROUGH, GREAT IDEA - //how about this instead - set_side(f_pos); + // YEAH SENDING LIKE 20 PACKETS IF THE USER SCROLLS THROUGH, GREAT IDEA + // how about this instead + set_side(f_pos); } void Courtroom::set_iniswap_dropdown() { - ui_iniswap_dropdown->blockSignals(true); - ui_iniswap_dropdown->clear(); - if (m_cid == -1) { - ui_iniswap_dropdown->hide(); - ui_iniswap_remove->hide(); - return; - } - QStringList iniswaps = ao_app->get_list_file(ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")); - iniswaps.prepend(char_list.at(m_cid).name); - if (iniswaps.size() <= 0) { - ui_iniswap_dropdown->hide(); + ui_iniswap_dropdown->blockSignals(true); + ui_iniswap_dropdown->clear(); + if (m_cid == -1) { + ui_iniswap_dropdown->hide(); + ui_iniswap_remove->hide(); + return; + } + QStringList iniswaps = ao_app->get_list_file( + ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")); + iniswaps.prepend(char_list.at(m_cid).name); + if (iniswaps.size() <= 0) { + ui_iniswap_dropdown->hide(); + ui_iniswap_remove->hide(); + return; + } + ui_iniswap_dropdown->show(); + ui_iniswap_dropdown->addItems(iniswaps); + + for (int i = 0; i < iniswaps.size(); ++i) { + if (iniswaps.at(i) == current_char) { + ui_iniswap_dropdown->setCurrentIndex(i); + if (i != 0) + ui_iniswap_remove->show(); + else ui_iniswap_remove->hide(); - return; + break; } - ui_iniswap_dropdown->show(); - ui_iniswap_dropdown->addItems(iniswaps); - - for (int i = 0; i < iniswaps.size(); ++i) { - if (iniswaps.at(i) == current_char) { - ui_iniswap_dropdown->setCurrentIndex(i); - if (i != 0) - ui_iniswap_remove->show(); - else - ui_iniswap_remove->hide(); - break; - } - } - ui_iniswap_dropdown->blockSignals(false); + } + ui_iniswap_dropdown->blockSignals(false); } void Courtroom::on_iniswap_dropdown_changed(int p_index) { - ui_ic_chat_message->setFocus(); - QString iniswap = ui_iniswap_dropdown->itemText(p_index); - ao_app->set_char_ini(char_list.at(m_cid).name, iniswap, "name", "Options"); - - QStringList swaplist; - for (int i = 0; i < ui_iniswap_dropdown->count(); ++i) { - QString entry = ui_iniswap_dropdown->itemText(i); - if (!swaplist.contains(entry) && entry != char_list.at(m_cid).name) - swaplist.append(entry); - } - ao_app->write_to_file(swaplist.join("\n"), ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")); - ui_iniswap_dropdown->blockSignals(true); - ui_iniswap_dropdown->setCurrentIndex(p_index); - ui_iniswap_dropdown->blockSignals(false); - update_character(m_cid); - if (p_index != 0) - ui_iniswap_remove->show(); - else - ui_iniswap_remove->hide(); + ui_ic_chat_message->setFocus(); + QString iniswap = ui_iniswap_dropdown->itemText(p_index); + ao_app->set_char_ini(char_list.at(m_cid).name, iniswap, "name", "Options"); + + QStringList swaplist; + for (int i = 0; i < ui_iniswap_dropdown->count(); ++i) { + QString entry = ui_iniswap_dropdown->itemText(i); + if (!swaplist.contains(entry) && entry != char_list.at(m_cid).name) + swaplist.append(entry); + } + ao_app->write_to_file( + swaplist.join("\n"), + ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")); + ui_iniswap_dropdown->blockSignals(true); + ui_iniswap_dropdown->setCurrentIndex(p_index); + ui_iniswap_dropdown->blockSignals(false); + update_character(m_cid); + if (p_index != 0) + ui_iniswap_remove->show(); + else + ui_iniswap_remove->hide(); } void Courtroom::on_iniswap_context_menu_requested(const QPoint &pos) { - QMenu *menu = ui_iniswap_dropdown->lineEdit()->createStandardContextMenu(); - - menu->addSeparator(); - if (file_exists(ao_app->get_character_path(current_char, "char.ini"))) - menu->addAction(QString("Edit " + current_char + "/char.ini"), this, SLOT(on_iniswap_edit_requested())); - if (ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex()) != char_list.at(m_cid).name) - menu->addAction(QString("Remove " + current_char), this, SLOT(on_iniswap_remove_clicked())); - menu->popup(ui_iniswap_dropdown->mapToGlobal(pos)); + QMenu *menu = ui_iniswap_dropdown->lineEdit()->createStandardContextMenu(); + + menu->addSeparator(); + if (file_exists(ao_app->get_character_path(current_char, "char.ini"))) + menu->addAction(QString("Edit " + current_char + "/char.ini"), this, + SLOT(on_iniswap_edit_requested())); + if (ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex()) != + char_list.at(m_cid).name) + menu->addAction(QString("Remove " + current_char), this, + SLOT(on_iniswap_remove_clicked())); + menu->popup(ui_iniswap_dropdown->mapToGlobal(pos)); } void Courtroom::on_iniswap_edit_requested() { - QString p_path = ao_app->get_character_path(current_char, "char.ini"); - if (!file_exists(p_path)) - return; - QDesktopServices::openUrl(QUrl::fromLocalFile(p_path)); + QString p_path = ao_app->get_character_path(current_char, "char.ini"); + if (!file_exists(p_path)) + return; + QDesktopServices::openUrl(QUrl::fromLocalFile(p_path)); } void Courtroom::on_iniswap_remove_clicked() { - if (ui_iniswap_dropdown->count() <= 0) { - ui_iniswap_remove->hide(); //We're not supposed to see it. Do this or the client will crash - return; - } - if (ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex()) != char_list.at(m_cid).name) { - ui_iniswap_dropdown->removeItem(ui_iniswap_dropdown->currentIndex()); - on_iniswap_dropdown_changed(0); //Reset back to original - update_character(m_cid); - } + if (ui_iniswap_dropdown->count() <= 0) { + ui_iniswap_remove->hide(); // We're not supposed to see it. Do this or the + // client will crash + return; + } + if (ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex()) != + char_list.at(m_cid).name) { + ui_iniswap_dropdown->removeItem(ui_iniswap_dropdown->currentIndex()); + on_iniswap_dropdown_changed(0); // Reset back to original + update_character(m_cid); + } } void Courtroom::set_sfx_dropdown() { - ui_sfx_dropdown->blockSignals(true); - ui_sfx_dropdown->clear(); - if (m_cid == -1) { - ui_sfx_dropdown->hide(); - ui_sfx_remove->hide(); - return; - } - QStringList soundlist = ao_app->get_list_file(ao_app->get_character_path(current_char, "soundlist.ini")); - - if (soundlist.size() <= 0) { - soundlist = ao_app->get_list_file(ao_app->get_theme_path("character_soundlist.ini")); - if (soundlist.size() <= 0) { - soundlist = ao_app->get_list_file(ao_app->get_default_theme_path("character_soundlist.ini")); - } - } - + ui_sfx_dropdown->blockSignals(true); + ui_sfx_dropdown->clear(); + if (m_cid == -1) { + ui_sfx_dropdown->hide(); + ui_sfx_remove->hide(); + return; + } + QStringList soundlist = ao_app->get_list_file( + ao_app->get_character_path(current_char, "soundlist.ini")); + + if (soundlist.size() <= 0) { + soundlist = ao_app->get_list_file( + ao_app->get_theme_path("character_soundlist.ini")); if (soundlist.size() <= 0) { - ui_sfx_dropdown->hide(); - ui_sfx_remove->hide(); - return; + soundlist = ao_app->get_list_file( + ao_app->get_default_theme_path("character_soundlist.ini")); } - soundlist.prepend("Default"); + } - ui_sfx_dropdown->show(); - ui_sfx_dropdown->addItems(soundlist); - ui_sfx_dropdown->setCurrentIndex(0); + if (soundlist.size() <= 0) { + ui_sfx_dropdown->hide(); ui_sfx_remove->hide(); - ui_sfx_dropdown->blockSignals(false); + return; + } + soundlist.prepend("Default"); + + ui_sfx_dropdown->show(); + ui_sfx_dropdown->addItems(soundlist); + ui_sfx_dropdown->setCurrentIndex(0); + ui_sfx_remove->hide(); + ui_sfx_dropdown->blockSignals(false); } void Courtroom::on_sfx_dropdown_changed(int p_index) { - ui_ic_chat_message->setFocus(); - - QStringList soundlist; - for (int i = 0; i < ui_sfx_dropdown->count(); ++i) { - QString entry = ui_sfx_dropdown->itemText(i); - if (!soundlist.contains(entry) && entry != "Default") - soundlist.append(entry); - } - - QStringList defaultlist = ao_app->get_list_file(ao_app->get_theme_path("character_soundlist.ini")); - if (defaultlist.size() <= 0) { - defaultlist = ao_app->get_list_file(ao_app->get_default_theme_path("character_soundlist.ini")); - } - - if (defaultlist.size() > 0 && defaultlist.toSet().subtract(soundlist.toSet()).size() > 0) //There's a difference from the default configuration - ao_app->write_to_file(soundlist.join("\n"), ao_app->get_character_path(current_char, "soundlist.ini")); //Create a new sound list - - ui_sfx_dropdown->blockSignals(true); - ui_sfx_dropdown->setCurrentIndex(p_index); - ui_sfx_dropdown->blockSignals(false); - if (p_index != 0) - ui_sfx_remove->show(); - else - ui_sfx_remove->hide(); + ui_ic_chat_message->setFocus(); + + QStringList soundlist; + for (int i = 0; i < ui_sfx_dropdown->count(); ++i) { + QString entry = ui_sfx_dropdown->itemText(i); + if (!soundlist.contains(entry) && entry != "Default") + soundlist.append(entry); + } + + QStringList defaultlist = + ao_app->get_list_file(ao_app->get_theme_path("character_soundlist.ini")); + if (defaultlist.size() <= 0) { + defaultlist = ao_app->get_list_file( + ao_app->get_default_theme_path("character_soundlist.ini")); + } + + if (defaultlist.size() > 0 && + defaultlist.toSet().subtract(soundlist.toSet()).size() > + 0) // There's a difference from the default configuration + ao_app->write_to_file( + soundlist.join("\n"), + ao_app->get_character_path(current_char, + "soundlist.ini")); // Create a new sound list + + ui_sfx_dropdown->blockSignals(true); + ui_sfx_dropdown->setCurrentIndex(p_index); + ui_sfx_dropdown->blockSignals(false); + if (p_index != 0) + ui_sfx_remove->show(); + else + ui_sfx_remove->hide(); } void Courtroom::on_sfx_context_menu_requested(const QPoint &pos) { - QMenu *menu = ui_sfx_dropdown->lineEdit()->createStandardContextMenu(); - - menu->addSeparator(); - if (file_exists(ao_app->get_character_path(current_char, "soundlist.ini"))) - menu->addAction(QString("Edit " + current_char + "/soundlist.ini"), this, SLOT(on_sfx_edit_requested())); - else - menu->addAction(QString("Edit theme's character_soundlist.ini"), this, SLOT(on_sfx_edit_requested())); - if (ui_sfx_dropdown->currentIndex() != 0) - menu->addAction(QString("Remove " + ui_sfx_dropdown->itemText(ui_sfx_dropdown->currentIndex())), this, SLOT(on_sfx_remove_clicked())); - menu->popup(ui_sfx_dropdown->mapToGlobal(pos)); + QMenu *menu = ui_sfx_dropdown->lineEdit()->createStandardContextMenu(); + + menu->addSeparator(); + if (file_exists(ao_app->get_character_path(current_char, "soundlist.ini"))) + menu->addAction(QString("Edit " + current_char + "/soundlist.ini"), this, + SLOT(on_sfx_edit_requested())); + else + menu->addAction(QString("Edit theme's character_soundlist.ini"), this, + SLOT(on_sfx_edit_requested())); + if (ui_sfx_dropdown->currentIndex() != 0) + menu->addAction(QString("Remove " + ui_sfx_dropdown->itemText( + ui_sfx_dropdown->currentIndex())), + this, SLOT(on_sfx_remove_clicked())); + menu->popup(ui_sfx_dropdown->mapToGlobal(pos)); } void Courtroom::on_sfx_edit_requested() { - QString p_path = ao_app->get_character_path(current_char, "soundlist.ini"); + QString p_path = ao_app->get_character_path(current_char, "soundlist.ini"); + if (!file_exists(p_path)) { + p_path = ao_app->get_theme_path("character_soundlist.ini"); if (!file_exists(p_path)) { - p_path = ao_app->get_theme_path("character_soundlist.ini"); - if (!file_exists(p_path)) { - p_path = ao_app->get_default_theme_path("character_soundlist.ini"); - if (!file_exists(p_path)) { - return; - } - } + p_path = ao_app->get_default_theme_path("character_soundlist.ini"); + if (!file_exists(p_path)) { + return; + } } - QDesktopServices::openUrl(QUrl::fromLocalFile(p_path)); + } + QDesktopServices::openUrl(QUrl::fromLocalFile(p_path)); } void Courtroom::on_sfx_remove_clicked() { - if (ui_sfx_dropdown->count() <= 0) { - ui_sfx_remove->hide(); //We're not supposed to see it. Do this or the client will crash - return; - } - if (ui_sfx_dropdown->itemText(ui_sfx_dropdown->currentIndex()) != "Default") { - ui_sfx_dropdown->removeItem(ui_sfx_dropdown->currentIndex()); - on_sfx_dropdown_changed(0); //Reset back to original - } + if (ui_sfx_dropdown->count() <= 0) { + ui_sfx_remove->hide(); // We're not supposed to see it. Do this or the + // client will crash + return; + } + if (ui_sfx_dropdown->itemText(ui_sfx_dropdown->currentIndex()) != "Default") { + ui_sfx_dropdown->removeItem(ui_sfx_dropdown->currentIndex()); + on_sfx_dropdown_changed(0); // Reset back to original + } } void Courtroom::set_effects_dropdown() { - ui_effects_dropdown->blockSignals(true); - ui_effects_dropdown->clear(); - if (m_cid == -1) { - ui_effects_dropdown->hide(); - return; - } - QStringList effectslist = ao_app->get_effects(current_char); - - if (effectslist.size() <= 0) { - ui_effects_dropdown->hide(); - return; - } - - effectslist.prepend("None"); - - ui_effects_dropdown->show(); - ui_effects_dropdown->addItems(effectslist); - - //ICON-MAKING HELL - QString p_effect = ao_app->read_char_ini(current_char, "effects", "Options"); - QString custom_path = ao_app->get_base_path() + "misc/" + p_effect + "/icons/"; - QString theme_path = ao_app->get_theme_path("effects/icons/"); - QString default_path = ao_app->get_default_theme_path("effects/icons/"); - for (int i = 0; i < ui_effects_dropdown->count(); ++i) { - QString entry = ui_effects_dropdown->itemText(i); - QString iconpath = ao_app->get_static_image_suffix(custom_path + entry); - if (!file_exists(iconpath)) { - iconpath = ao_app->get_static_image_suffix(theme_path + entry); - if (!file_exists(iconpath)) { - iconpath = ao_app->get_static_image_suffix(default_path + entry); - if (!file_exists(iconpath)) - continue; - } - } - ui_effects_dropdown->setItemIcon(i, QIcon(iconpath)); - } - - ui_effects_dropdown->setCurrentIndex(0); - ui_effects_dropdown->blockSignals(false); + ui_effects_dropdown->blockSignals(true); + ui_effects_dropdown->clear(); + if (m_cid == -1) { + ui_effects_dropdown->hide(); + return; + } + QStringList effectslist = ao_app->get_effects(current_char); + + if (effectslist.size() <= 0) { + ui_effects_dropdown->hide(); + return; + } + + effectslist.prepend("None"); + + ui_effects_dropdown->show(); + ui_effects_dropdown->addItems(effectslist); + + // ICON-MAKING HELL + QString p_effect = ao_app->read_char_ini(current_char, "effects", "Options"); + QString custom_path = + ao_app->get_base_path() + "misc/" + p_effect + "/icons/"; + QString theme_path = ao_app->get_theme_path("effects/icons/"); + QString default_path = ao_app->get_default_theme_path("effects/icons/"); + for (int i = 0; i < ui_effects_dropdown->count(); ++i) { + QString entry = ui_effects_dropdown->itemText(i); + QString iconpath = ao_app->get_static_image_suffix(custom_path + entry); + if (!file_exists(iconpath)) { + iconpath = ao_app->get_static_image_suffix(theme_path + entry); + if (!file_exists(iconpath)) { + iconpath = ao_app->get_static_image_suffix(default_path + entry); + if (!file_exists(iconpath)) + continue; + } + } + ui_effects_dropdown->setItemIcon(i, QIcon(iconpath)); + } + + ui_effects_dropdown->setCurrentIndex(0); + ui_effects_dropdown->blockSignals(false); } void Courtroom::on_effects_context_menu_requested(const QPoint &pos) { - QMenu *menu = new QMenu(); + QMenu *menu = new QMenu(); - if (!ao_app->read_char_ini(current_char, "effects", "Options").isEmpty()) - menu->addAction(QString("Open misc/" + ao_app->read_char_ini(current_char, "effects", "Options") + " folder"), this, SLOT(on_character_effects_edit_requested())); - menu->addAction(QString("Open theme's effects folder"), this, SLOT(on_effects_edit_requested())); - menu->popup(ui_effects_dropdown->mapToGlobal(pos)); + if (!ao_app->read_char_ini(current_char, "effects", "Options").isEmpty()) + menu->addAction( + QString("Open misc/" + + ao_app->read_char_ini(current_char, "effects", "Options") + + " folder"), + this, SLOT(on_character_effects_edit_requested())); + menu->addAction(QString("Open theme's effects folder"), this, + SLOT(on_effects_edit_requested())); + menu->popup(ui_effects_dropdown->mapToGlobal(pos)); } void Courtroom::on_effects_edit_requested() { - QString p_path = ao_app->get_theme_path("effects/"); + QString p_path = ao_app->get_theme_path("effects/"); + if (!dir_exists(p_path)) { + p_path = ao_app->get_default_theme_path("effects/"); if (!dir_exists(p_path)) { - p_path = ao_app->get_default_theme_path("effects/"); - if (!dir_exists(p_path)) { - return; - } + return; } - QDesktopServices::openUrl(QUrl::fromLocalFile(p_path)); + } + QDesktopServices::openUrl(QUrl::fromLocalFile(p_path)); } void Courtroom::on_character_effects_edit_requested() { - QString p_effect = ao_app->read_char_ini(current_char, "effects", "Options"); - QString p_path = ao_app->get_base_path() + "misc/" + p_effect + "/"; - if (!dir_exists(p_path)) - return; + QString p_effect = ao_app->read_char_ini(current_char, "effects", "Options"); + QString p_path = ao_app->get_base_path() + "misc/" + p_effect + "/"; + if (!dir_exists(p_path)) + return; - QDesktopServices::openUrl(QUrl::fromLocalFile(p_path)); + QDesktopServices::openUrl(QUrl::fromLocalFile(p_path)); } void Courtroom::on_effects_dropdown_changed(int p_index) { - effect = ui_effects_dropdown->itemText(p_index); - ui_ic_chat_message->setFocus(); + effect = ui_effects_dropdown->itemText(p_index); + ui_ic_chat_message->setFocus(); } bool Courtroom::effects_dropdown_find_and_set(QString effect) { - for (int i = 0; i < ui_effects_dropdown->count(); ++i) { - QString entry = ui_effects_dropdown->itemText(i); - if (entry == effect) { - ui_effects_dropdown->setCurrentIndex(i); - return true; - } + for (int i = 0; i < ui_effects_dropdown->count(); ++i) { + QString entry = ui_effects_dropdown->itemText(i); + if (entry == effect) { + ui_effects_dropdown->setCurrentIndex(i); + return true; } - return false; + } + return false; } QString Courtroom::get_char_sfx() { - QString sfx = ui_sfx_dropdown->itemText(ui_sfx_dropdown->currentIndex()); - if (sfx != "" && sfx != "Default") - return sfx; - return ao_app->get_sfx_name(current_char, current_emote); + QString sfx = ui_sfx_dropdown->itemText(ui_sfx_dropdown->currentIndex()); + if (sfx != "" && sfx != "Default") + return sfx; + return ao_app->get_sfx_name(current_char, current_emote); } int Courtroom::get_char_sfx_delay() { - // QString sfx = ui_sfx_dropdown->itemText(ui_sfx_dropdown->currentIndex()); - // if (sfx != "" && sfx != "Default") - // return 0; //todo: a way to define this - return ao_app->get_sfx_delay(current_char, current_emote); + // QString sfx = ui_sfx_dropdown->itemText(ui_sfx_dropdown->currentIndex()); + // if (sfx != "" && sfx != "Default") + // return 0; //todo: a way to define this + return ao_app->get_sfx_delay(current_char, current_emote); } void Courtroom::on_mute_list_clicked(QModelIndex p_index) { - QListWidgetItem *f_item = ui_mute_list->item(p_index.row()); - QString f_char = f_item->text(); - QString real_char; + QListWidgetItem *f_item = ui_mute_list->item(p_index.row()); + QString f_char = f_item->text(); + QString real_char; - if (f_char.endsWith(" [x]")) - real_char = f_char.left(f_char.size() - 4); - else - real_char = f_char; + if (f_char.endsWith(" [x]")) + real_char = f_char.left(f_char.size() - 4); + else + real_char = f_char; - int f_cid = -1; + int f_cid = -1; - for (int n_char = 0; n_char < char_list.size(); n_char++) { - if (char_list.at(n_char).name == real_char) - f_cid = n_char; - } + for (int n_char = 0; n_char < char_list.size(); n_char++) { + if (char_list.at(n_char).name == real_char) + f_cid = n_char; + } - if (f_cid < 0 || f_cid >= char_list.size()) { - qDebug() << "W: " << real_char << " not present in char_list"; - return; - } + if (f_cid < 0 || f_cid >= char_list.size()) { + qDebug() << "W: " << real_char << " not present in char_list"; + return; + } - if (mute_map.value(f_cid)) { - mute_map.insert(f_cid, false); - f_item->setText(real_char); - } - else { - mute_map.insert(f_cid, true); - f_item->setText(real_char + " [x]"); - } + if (mute_map.value(f_cid)) { + mute_map.insert(f_cid, false); + f_item->setText(real_char); + } + else { + mute_map.insert(f_cid, true); + f_item->setText(real_char + " [x]"); + } } void Courtroom::on_pair_list_clicked(QModelIndex p_index) { - QListWidgetItem *f_item = ui_pair_list->item(p_index.row()); - QString f_char = f_item->text(); - QString real_char; - int f_cid = -1; - - if (f_char.endsWith(" [x]")) { - real_char = f_char.left(f_char.size() - 4); - f_item->setText(real_char); - } - else { - real_char = f_char; - for (int n_char = 0; n_char < char_list.size(); n_char++) { - if (char_list.at(n_char).name == real_char) - f_cid = n_char; - } + QListWidgetItem *f_item = ui_pair_list->item(p_index.row()); + QString f_char = f_item->text(); + QString real_char; + int f_cid = -1; + + if (f_char.endsWith(" [x]")) { + real_char = f_char.left(f_char.size() - 4); + f_item->setText(real_char); + } + else { + real_char = f_char; + for (int n_char = 0; n_char < char_list.size(); n_char++) { + if (char_list.at(n_char).name == real_char) + f_cid = n_char; } + } - if (f_cid < -2 || f_cid >= char_list.size()) { - qDebug() << "W: " << real_char << " not present in char_list"; - return; - } + if (f_cid < -2 || f_cid >= char_list.size()) { + qDebug() << "W: " << real_char << " not present in char_list"; + return; + } - other_charid = f_cid; + other_charid = f_cid; - // Redo the character list. - QStringList sorted_pair_list; + // Redo the character list. + QStringList sorted_pair_list; - for (char_type i_char : char_list) - sorted_pair_list.append(i_char.name); + for (char_type i_char : char_list) + sorted_pair_list.append(i_char.name); - sorted_pair_list.sort(); + sorted_pair_list.sort(); - for (int i = 0; i < ui_pair_list->count(); i++) { - ui_pair_list->item(i)->setText(sorted_pair_list.at(i)); - } - if (other_charid != -1) { - f_item->setText(real_char + " [x]"); - } + for (int i = 0; i < ui_pair_list->count(); i++) { + ui_pair_list->item(i)->setText(sorted_pair_list.at(i)); + } + if (other_charid != -1) { + f_item->setText(real_char + " [x]"); + } } -void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item, int column) +void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item, + int column) { - if (is_muted) - return; + if (is_muted) + return; - column = 1; //Column 1 is always the metadata (which we want) - QString p_song = p_item->text(column); - - QStringList packet_contents; - packet_contents.append(p_song); - packet_contents.append(QString::number(m_cid)); - if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_support_enabled) || ao_app->effects_enabled) - packet_contents.append(ui_ic_chat_name->text()); - if (ao_app->effects_enabled) - packet_contents.append(QString::number(music_flags)); - ao_app->send_server_packet(new AOPacket("MC", packet_contents), false); + column = 1; // Column 1 is always the metadata (which we want) + QString p_song = p_item->text(column); + + QStringList packet_contents; + packet_contents.append(p_song); + packet_contents.append(QString::number(m_cid)); + if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_support_enabled) || + ao_app->effects_enabled) + packet_contents.append(ui_ic_chat_name->text()); + if (ao_app->effects_enabled) + packet_contents.append(QString::number(music_flags)); + ao_app->send_server_packet(new AOPacket("MC", packet_contents), false); } void Courtroom::on_music_list_context_menu_requested(const QPoint &pos) { - QMenu *menu = new QMenu(); + QMenu *menu = new QMenu(); - menu->addAction(QString("Expand All Categories"), this, SLOT(music_list_expand_all())); - menu->addAction(QString("Collapse All Categories"), this, SLOT(music_list_collapse_all())); - menu->addSeparator(); + menu->addAction(QString("Expand All Categories"), this, + SLOT(music_list_expand_all())); + menu->addAction(QString("Collapse All Categories"), this, + SLOT(music_list_collapse_all())); + menu->addSeparator(); - menu->addAction(new QAction("Fade Out Previous", this)); - menu->actions().back()->setCheckable(true); - menu->actions().back()->setChecked(music_flags & FADE_OUT); - connect(menu->actions().back(), SIGNAL(toggled(bool)), this, SLOT(music_fade_out(bool))); + menu->addAction(new QAction("Fade Out Previous", this)); + menu->actions().back()->setCheckable(true); + menu->actions().back()->setChecked(music_flags & FADE_OUT); + connect(menu->actions().back(), SIGNAL(toggled(bool)), this, + SLOT(music_fade_out(bool))); - menu->addAction(new QAction("Fade In", this)); - menu->actions().back()->setCheckable(true); - menu->actions().back()->setChecked(music_flags & FADE_IN); - connect(menu->actions().back(), SIGNAL(toggled(bool)), this, SLOT(music_fade_in(bool))); + menu->addAction(new QAction("Fade In", this)); + menu->actions().back()->setCheckable(true); + menu->actions().back()->setChecked(music_flags & FADE_IN); + connect(menu->actions().back(), SIGNAL(toggled(bool)), this, + SLOT(music_fade_in(bool))); - menu->addAction(new QAction("Synchronize", this)); - menu->actions().back()->setCheckable(true); - menu->actions().back()->setChecked(music_flags & SYNC_POS); - connect(menu->actions().back(), SIGNAL(toggled(bool)), this, SLOT(music_synchronize(bool))); + menu->addAction(new QAction("Synchronize", this)); + menu->actions().back()->setCheckable(true); + menu->actions().back()->setChecked(music_flags & SYNC_POS); + connect(menu->actions().back(), SIGNAL(toggled(bool)), this, + SLOT(music_synchronize(bool))); - menu->popup(ui_music_list->mapToGlobal(pos)); + menu->popup(ui_music_list->mapToGlobal(pos)); } void Courtroom::music_fade_out(bool toggle) { - if (toggle) - music_flags |= FADE_OUT; - else - music_flags &= ~FADE_OUT; + if (toggle) + music_flags |= FADE_OUT; + else + music_flags &= ~FADE_OUT; } void Courtroom::music_fade_in(bool toggle) { - if (toggle) - music_flags |= FADE_IN; - else - music_flags &= ~FADE_IN; + if (toggle) + music_flags |= FADE_IN; + else + music_flags &= ~FADE_IN; } void Courtroom::music_synchronize(bool toggle) { - if (toggle) - music_flags |= SYNC_POS; - else - music_flags &= ~SYNC_POS; + if (toggle) + music_flags |= SYNC_POS; + else + music_flags &= ~SYNC_POS; } -void Courtroom::music_list_expand_all() -{ - ui_music_list->expandAll(); -} +void Courtroom::music_list_expand_all() { ui_music_list->expandAll(); } void Courtroom::music_list_collapse_all() { - ui_music_list->collapseAll(); - QTreeWidgetItem *current = ui_music_list->selectedItems()[0]; - if (current->parent() != nullptr) - current = current->parent(); - ui_music_list->setCurrentItem(current); + ui_music_list->collapseAll(); + QTreeWidgetItem *current = ui_music_list->selectedItems()[0]; + if (current->parent() != nullptr) + current = current->parent(); + ui_music_list->setCurrentItem(current); } void Courtroom::on_area_list_double_clicked(QTreeWidgetItem *p_item, int column) { - column = 0; //The metadata - QString p_area = p_item->text(0); - - QStringList packet_contents; - packet_contents.append(p_area); - packet_contents.append(QString::number(m_cid)); - qDebug() << packet_contents; - ao_app->send_server_packet(new AOPacket("MC", packet_contents), false); + column = 0; // The metadata + QString p_area = p_item->text(0); + + QStringList packet_contents; + packet_contents.append(p_area); + packet_contents.append(QString::number(m_cid)); + qDebug() << packet_contents; + ao_app->send_server_packet(new AOPacket("MC", packet_contents), false); } void Courtroom::on_hold_it_clicked() { - if (objection_state == 1) { - ui_hold_it->set_image("holdit"); - objection_state = 0; - } - else { - ui_objection->set_image("objection"); - ui_take_that->set_image("takethat"); - ui_custom_objection->set_image("custom"); + if (objection_state == 1) { + ui_hold_it->set_image("holdit"); + objection_state = 0; + } + else { + ui_objection->set_image("objection"); + ui_take_that->set_image("takethat"); + ui_custom_objection->set_image("custom"); - ui_hold_it->set_image("holdit_selected"); - objection_state = 1; - } + ui_hold_it->set_image("holdit_selected"); + objection_state = 1; + } - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_objection_clicked() { - if (objection_state == 2) { - ui_objection->set_image("objection"); - objection_state = 0; - } - else { - ui_hold_it->set_image("holdit"); - ui_take_that->set_image("takethat"); - ui_custom_objection->set_image("custom"); + if (objection_state == 2) { + ui_objection->set_image("objection"); + objection_state = 0; + } + else { + ui_hold_it->set_image("holdit"); + ui_take_that->set_image("takethat"); + ui_custom_objection->set_image("custom"); - ui_objection->set_image("objection_selected"); - objection_state = 2; - } + ui_objection->set_image("objection_selected"); + objection_state = 2; + } - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_take_that_clicked() { - if (objection_state == 3) { - ui_take_that->set_image("takethat"); - objection_state = 0; - } - else { - ui_objection->set_image("objection"); - ui_hold_it->set_image("holdit"); - ui_custom_objection->set_image("custom"); + if (objection_state == 3) { + ui_take_that->set_image("takethat"); + objection_state = 0; + } + else { + ui_objection->set_image("objection"); + ui_hold_it->set_image("holdit"); + ui_custom_objection->set_image("custom"); - ui_take_that->set_image("takethat_selected"); - objection_state = 3; - } + ui_take_that->set_image("takethat_selected"); + objection_state = 3; + } - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_custom_objection_clicked() { - if (objection_state == 4) { - ui_custom_objection->set_image("custom"); - objection_state = 0; - } - else { - ui_objection->set_image("objection"); - ui_take_that->set_image("takethat"); - ui_hold_it->set_image("holdit"); + if (objection_state == 4) { + ui_custom_objection->set_image("custom"); + objection_state = 0; + } + else { + ui_objection->set_image("objection"); + ui_take_that->set_image("takethat"); + ui_hold_it->set_image("holdit"); - ui_custom_objection->set_image("custom_selected"); - objection_state = 4; - } + ui_custom_objection->set_image("custom_selected"); + objection_state = 4; + } - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_realization_clicked() { - if (realization_state == 0) { - realization_state = 1; - if (effects_dropdown_find_and_set("realization")) - on_effects_dropdown_changed(ui_effects_dropdown->currentIndex()); + if (realization_state == 0) { + realization_state = 1; + if (effects_dropdown_find_and_set("realization")) + on_effects_dropdown_changed(ui_effects_dropdown->currentIndex()); - ui_realization->set_image("realization_pressed"); - } - else { - realization_state = 0; - ui_effects_dropdown->setCurrentIndex(0); - on_effects_dropdown_changed(ui_effects_dropdown->currentIndex()); - ui_realization->set_image("realization"); - } + ui_realization->set_image("realization_pressed"); + } + else { + realization_state = 0; + ui_effects_dropdown->setCurrentIndex(0); + on_effects_dropdown_changed(ui_effects_dropdown->currentIndex()); + ui_realization->set_image("realization"); + } - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_screenshake_clicked() { - if (screenshake_state == 0) { - screenshake_state = 1; - ui_screenshake->set_image("screenshake_pressed"); - } - else { - screenshake_state = 0; - ui_screenshake->set_image("screenshake"); - } + if (screenshake_state == 0) { + screenshake_state = 1; + ui_screenshake->set_image("screenshake_pressed"); + } + else { + screenshake_state = 0; + ui_screenshake->set_image("screenshake"); + } - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_mute_clicked() { - if (ui_mute_list->isHidden()) { - ui_mute_list->show(); - ui_pair_list->hide(); - ui_pair_offset_spinbox->hide(); - ui_pair_order_dropdown->hide(); - ui_pair_button->set_image("pair_button"); - ui_mute->set_image("mute_pressed"); - } - else { - ui_mute_list->hide(); - ui_mute->set_image("mute"); - } + if (ui_mute_list->isHidden()) { + ui_mute_list->show(); + ui_pair_list->hide(); + ui_pair_offset_spinbox->hide(); + ui_pair_order_dropdown->hide(); + ui_pair_button->set_image("pair_button"); + ui_mute->set_image("mute_pressed"); + } + else { + ui_mute_list->hide(); + ui_mute->set_image("mute"); + } } void Courtroom::on_pair_clicked() { - if (ui_pair_list->isHidden()) { - ui_pair_list->show(); - ui_pair_offset_spinbox->show(); - ui_pair_order_dropdown->show(); - ui_mute_list->hide(); - ui_mute->set_image("mute"); - ui_pair_button->set_image("pair_button_pressed"); - } - else { - ui_pair_list->hide(); - ui_pair_offset_spinbox->hide(); - ui_pair_order_dropdown->hide(); - ui_pair_button->set_image("pair_button"); - } + if (ui_pair_list->isHidden()) { + ui_pair_list->show(); + ui_pair_offset_spinbox->show(); + ui_pair_order_dropdown->show(); + ui_mute_list->hide(); + ui_mute->set_image("mute"); + ui_pair_button->set_image("pair_button_pressed"); + } + else { + ui_pair_list->hide(); + ui_pair_offset_spinbox->hide(); + ui_pair_order_dropdown->hide(); + ui_pair_button->set_image("pair_button"); + } } void Courtroom::on_pair_order_dropdown_changed(int p_index) { - pair_order = p_index; + pair_order = p_index; } void Courtroom::on_defense_minus_clicked() { - int f_state = defense_bar_state - 1; + int f_state = defense_bar_state - 1; - if (f_state >= 0) - ao_app->send_server_packet(new AOPacket("HP#1#" + QString::number(f_state) + "#%")); + if (f_state >= 0) + ao_app->send_server_packet( + new AOPacket("HP#1#" + QString::number(f_state) + "#%")); } void Courtroom::on_defense_plus_clicked() { - int f_state = defense_bar_state + 1; + int f_state = defense_bar_state + 1; - if (f_state <= 10) - ao_app->send_server_packet(new AOPacket("HP#1#" + QString::number(f_state) + "#%")); + if (f_state <= 10) + ao_app->send_server_packet( + new AOPacket("HP#1#" + QString::number(f_state) + "#%")); } void Courtroom::on_prosecution_minus_clicked() { - int f_state = prosecution_bar_state - 1; + int f_state = prosecution_bar_state - 1; - if (f_state >= 0) - ao_app->send_server_packet(new AOPacket("HP#2#" + QString::number(f_state) + "#%")); + if (f_state >= 0) + ao_app->send_server_packet( + new AOPacket("HP#2#" + QString::number(f_state) + "#%")); } void Courtroom::on_prosecution_plus_clicked() { - int f_state = prosecution_bar_state + 1; + int f_state = prosecution_bar_state + 1; - if (f_state <= 10) - ao_app->send_server_packet(new AOPacket("HP#2#" + QString::number(f_state) + "#%")); + if (f_state <= 10) + ao_app->send_server_packet( + new AOPacket("HP#2#" + QString::number(f_state) + "#%")); } void Courtroom::set_text_color_dropdown() { - //Clear the lists - ui_text_color->clear(); - color_row_to_number.clear(); - - //Clear the stored optimization information - color_rgb_list.clear(); - color_markdown_start_list.clear(); - color_markdown_end_list.clear(); - color_markdown_remove_list.clear(); - color_markdown_talking_list.clear(); - - //Update markdown colors. TODO: make a loading function that only loads the config file once instead of several times - for (int c = 0; c < max_colors; ++c) { - QColor color = ao_app->get_chat_color(QString::number(c), current_char); - color_rgb_list.append(color); - color_markdown_start_list.append(ao_app->get_chat_markdown("c" + QString::number(c) + "_start", current_char)); - color_markdown_end_list.append(ao_app->get_chat_markdown("c" + QString::number(c) + "_end", current_char)); - color_markdown_remove_list.append(ao_app->get_chat_markdown("c" + QString::number(c) + "_remove", current_char) == "1"); - color_markdown_talking_list.append(ao_app->get_chat_markdown("c" + QString::number(c) + "_talking", current_char) == "1"); - - QString color_name = ao_app->get_chat_markdown("c" + QString::number(c) + "_name", current_char); - if (color_name.isEmpty()) //Not defined - { - if (c > 0) - continue; - color_name = tr("Default"); - } - ui_text_color->addItem(color_name); - QPixmap pixmap(16, 16); - pixmap.fill(color); - ui_text_color->setItemIcon(ui_text_color->count() - 1, QIcon(pixmap)); - color_row_to_number.append(c); + // Clear the lists + ui_text_color->clear(); + color_row_to_number.clear(); + + // Clear the stored optimization information + color_rgb_list.clear(); + color_markdown_start_list.clear(); + color_markdown_end_list.clear(); + color_markdown_remove_list.clear(); + color_markdown_talking_list.clear(); + + // Update markdown colors. TODO: make a loading function that only loads the + // config file once instead of several times + for (int c = 0; c < max_colors; ++c) { + QColor color = ao_app->get_chat_color(QString::number(c), current_char); + color_rgb_list.append(color); + color_markdown_start_list.append(ao_app->get_chat_markdown( + "c" + QString::number(c) + "_start", current_char)); + color_markdown_end_list.append(ao_app->get_chat_markdown( + "c" + QString::number(c) + "_end", current_char)); + color_markdown_remove_list.append( + ao_app->get_chat_markdown("c" + QString::number(c) + "_remove", + current_char) == "1"); + color_markdown_talking_list.append( + ao_app->get_chat_markdown("c" + QString::number(c) + "_talking", + current_char) == "1"); + + QString color_name = ao_app->get_chat_markdown( + "c" + QString::number(c) + "_name", current_char); + if (color_name.isEmpty()) // Not defined + { + if (c > 0) + continue; + color_name = tr("Default"); } + ui_text_color->addItem(color_name); + QPixmap pixmap(16, 16); + pixmap.fill(color); + ui_text_color->setItemIcon(ui_text_color->count() - 1, QIcon(pixmap)); + color_row_to_number.append(c); + } } void Courtroom::on_text_color_changed(int p_color) { - if (ui_ic_chat_message->selectionStart() != -1) //We have a selection! - { - int c = color_row_to_number.at(p_color); - QString markdown_start = color_markdown_start_list.at(c); - if (markdown_start.isEmpty()) { - qDebug() << "W: Color list dropdown selected a non-existent markdown start character"; - return; - } - QString markdown_end = color_markdown_end_list.at(c); - if (markdown_end.isEmpty()) - markdown_end = markdown_start; - int start = ui_ic_chat_message->selectionStart(); - int end = ui_ic_chat_message->selectionEnd() + 1; - ui_ic_chat_message->setCursorPosition(start); - ui_ic_chat_message->insert(markdown_start); - ui_ic_chat_message->setCursorPosition(end); - ui_ic_chat_message->insert(markdown_end); - // ui_ic_chat_message->end(false); - ui_text_color->setCurrentIndex(0); - } - else { - if (p_color != -1 && p_color < color_row_to_number.size()) - text_color = color_row_to_number.at(p_color); - else - text_color = 0; - } - ui_ic_chat_message->setFocus(); + if (ui_ic_chat_message->selectionStart() != -1) // We have a selection! + { + int c = color_row_to_number.at(p_color); + QString markdown_start = color_markdown_start_list.at(c); + if (markdown_start.isEmpty()) { + qDebug() << "W: Color list dropdown selected a non-existent markdown " + "start character"; + return; + } + QString markdown_end = color_markdown_end_list.at(c); + if (markdown_end.isEmpty()) + markdown_end = markdown_start; + int start = ui_ic_chat_message->selectionStart(); + int end = ui_ic_chat_message->selectionEnd() + 1; + ui_ic_chat_message->setCursorPosition(start); + ui_ic_chat_message->insert(markdown_start); + ui_ic_chat_message->setCursorPosition(end); + ui_ic_chat_message->insert(markdown_end); + // ui_ic_chat_message->end(false); + ui_text_color->setCurrentIndex(0); + } + else { + if (p_color != -1 && p_color < color_row_to_number.size()) + text_color = color_row_to_number.at(p_color); + else + text_color = 0; + } + ui_ic_chat_message->setFocus(); } void Courtroom::on_music_slider_moved(int p_value) { - music_player->set_volume(p_value, 0); //Set volume on music layer - ui_ic_chat_message->setFocus(); + music_player->set_volume(p_value, 0); // Set volume on music layer + ui_ic_chat_message->setFocus(); } void Courtroom::on_sfx_slider_moved(int p_value) { - sfx_player->set_volume(p_value); - //Set the ambience and other misc. music layers - for (int i = 1; i < music_player->m_channelmax; ++i) { - music_player->set_volume(p_value, i); - } - objection_player->set_volume(p_value); - ui_ic_chat_message->setFocus(); + sfx_player->set_volume(p_value); + // Set the ambience and other misc. music layers + for (int i = 1; i < music_player->m_channelmax; ++i) { + music_player->set_volume(p_value, i); + } + objection_player->set_volume(p_value); + ui_ic_chat_message->setFocus(); } void Courtroom::on_blip_slider_moved(int p_value) { - blip_player->set_volume(p_value); - ui_ic_chat_message->setFocus(); + blip_player->set_volume(p_value); + ui_ic_chat_message->setFocus(); } -void Courtroom::on_log_limit_changed(int value) -{ - log_maximum_blocks = value; -} +void Courtroom::on_log_limit_changed(int value) { log_maximum_blocks = value; } -void Courtroom::on_pair_offset_changed(int value) -{ - char_offset = value; -} +void Courtroom::on_pair_offset_changed(int value) { char_offset = value; } void Courtroom::on_witness_testimony_clicked() { - if (is_muted) - return; + if (is_muted) + return; - ao_app->send_server_packet(new AOPacket("RT#testimony1#%")); + ao_app->send_server_packet(new AOPacket("RT#testimony1#%")); - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_cross_examination_clicked() { - if (is_muted) - return; + if (is_muted) + return; - ao_app->send_server_packet(new AOPacket("RT#testimony2#%")); + ao_app->send_server_packet(new AOPacket("RT#testimony2#%")); - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_not_guilty_clicked() { - if (is_muted) - return; + if (is_muted) + return; - ao_app->send_server_packet(new AOPacket("RT#judgeruling#0#%")); + ao_app->send_server_packet(new AOPacket("RT#judgeruling#0#%")); - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_guilty_clicked() { - if (is_muted) - return; + if (is_muted) + return; - ao_app->send_server_packet(new AOPacket("RT#judgeruling#1#%")); + ao_app->send_server_packet(new AOPacket("RT#judgeruling#1#%")); - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_change_character_clicked() { - sfx_player->set_volume(0); - blip_player->set_volume(0); + sfx_player->set_volume(0); + blip_player->set_volume(0); - set_char_select(); + set_char_select(); - ui_char_select_background->show(); - ui_spectator->hide(); + ui_char_select_background->show(); + ui_spectator->hide(); } void Courtroom::on_reload_theme_clicked() { - ao_app->reload_theme(); + ao_app->reload_theme(); - enter_courtroom(); - update_character(m_cid); + enter_courtroom(); + update_character(m_cid); - anim_state = 4; - text_state = 3; + anim_state = 4; + text_state = 3; - //to update status on the background - set_background(current_background); + // to update status on the background + set_background(current_background); } void Courtroom::on_back_to_lobby_clicked() { - ao_app->construct_lobby(); - ao_app->destruct_courtroom(); + ao_app->construct_lobby(); + ao_app->destruct_courtroom(); } void Courtroom::on_char_select_left_clicked() { - --current_char_page; - set_char_select_page(); + --current_char_page; + set_char_select_page(); } void Courtroom::on_char_select_right_clicked() { - ++current_char_page; - set_char_select_page(); + ++current_char_page; + set_char_select_page(); } -void Courtroom::on_spectator_clicked() -{ - update_character(-1); -} +void Courtroom::on_spectator_clicked() { update_character(-1); } void Courtroom::on_call_mod_clicked() { - if (ao_app->modcall_reason_enabled) { - QMessageBox errorBox; - QInputDialog input; - - input.setWindowFlags(Qt::WindowSystemMenuHint); - input.setLabelText(tr("Reason:")); - input.setWindowTitle(tr("Call Moderator")); - auto code = input.exec(); - - if (code != QDialog::Accepted) - return; - - QString text = input.textValue(); - if (text.isEmpty()) { - errorBox.critical(nullptr, tr("Error"), tr("You must provide a reason.")); - return; - } - else if (text.length() > 256) { - errorBox.critical(nullptr, tr("Error"), tr("The message is too long.")); - return; - } + if (ao_app->modcall_reason_enabled) { + QMessageBox errorBox; + QInputDialog input; + + input.setWindowFlags(Qt::WindowSystemMenuHint); + input.setLabelText(tr("Reason:")); + input.setWindowTitle(tr("Call Moderator")); + auto code = input.exec(); - QStringList mod_reason; - mod_reason.append(text); + if (code != QDialog::Accepted) + return; - ao_app->send_server_packet(new AOPacket("ZZ", mod_reason)); + QString text = input.textValue(); + if (text.isEmpty()) { + errorBox.critical(nullptr, tr("Error"), tr("You must provide a reason.")); + return; } - else { - ao_app->send_server_packet(new AOPacket("ZZ#%")); + else if (text.length() > 256) { + errorBox.critical(nullptr, tr("Error"), tr("The message is too long.")); + return; } - ui_ic_chat_message->setFocus(); -} + QStringList mod_reason; + mod_reason.append(text); -void Courtroom::on_settings_clicked() -{ - ao_app->call_settings_menu(); + ao_app->send_server_packet(new AOPacket("ZZ", mod_reason)); + } + else { + ao_app->send_server_packet(new AOPacket("ZZ#%")); + } + + ui_ic_chat_message->setFocus(); } +void Courtroom::on_settings_clicked() { ao_app->call_settings_menu(); } + void Courtroom::on_announce_casing_clicked() { - ao_app->call_announce_menu(this); + ao_app->call_announce_menu(this); } -void Courtroom::on_pre_clicked() -{ - ui_ic_chat_message->setFocus(); -} +void Courtroom::on_pre_clicked() { ui_ic_chat_message->setFocus(); } -void Courtroom::on_flip_clicked() -{ - ui_ic_chat_message->setFocus(); -} +void Courtroom::on_flip_clicked() { ui_ic_chat_message->setFocus(); } void Courtroom::on_additive_clicked() { - if (ui_additive->isChecked()) { - ui_ic_chat_message->home(false); //move cursor to the start of the message - ui_ic_chat_message->insert(" "); //preface the message by whitespace - ui_ic_chat_message->end(false); //move cursor to the end of the message without selecting anything - } - ui_ic_chat_message->setFocus(); + if (ui_additive->isChecked()) { + ui_ic_chat_message->home(false); // move cursor to the start of the message + ui_ic_chat_message->insert(" "); // preface the message by whitespace + ui_ic_chat_message->end(false); // move cursor to the end of the message + // without selecting anything + } + ui_ic_chat_message->setFocus(); } -void Courtroom::on_guard_clicked() -{ - ui_ic_chat_message->setFocus(); -} +void Courtroom::on_guard_clicked() { ui_ic_chat_message->setFocus(); } void Courtroom::on_showname_enable_clicked() { - ui_ic_chatlog->clear(); - first_message_sent = false; + ui_ic_chatlog->clear(); + first_message_sent = false; - foreach (chatlogpiece item, ic_chatlog_history) { - if (ui_showname_enable->isChecked()) { - if (item.is_song()) - append_ic_text(item.get_message(), item.get_showname(), "has played a song"); - else - append_ic_text(item.get_message(), item.get_showname()); - } - else { - if (item.is_song()) - append_ic_text(item.get_message(), item.get_name(), "has played a song"); - else - append_ic_text(item.get_message(), item.get_name()); - } + foreach (chatlogpiece item, ic_chatlog_history) { + if (ui_showname_enable->isChecked()) { + if (item.is_song()) + append_ic_text(item.get_message(), item.get_showname(), + "has played a song"); + else + append_ic_text(item.get_message(), item.get_showname()); } + else { + if (item.is_song()) + append_ic_text(item.get_message(), item.get_name(), + "has played a song"); + else + append_ic_text(item.get_message(), item.get_name()); + } + } - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_evidence_button_clicked() { - if (ui_evidence->isHidden()) { - ui_evidence->show(); - ui_evidence_overlay->hide(); - } - else { - ui_evidence->hide(); - } + if (ui_evidence->isHidden()) { + ui_evidence->show(); + ui_evidence_overlay->hide(); + } + else { + ui_evidence->hide(); + } } void Courtroom::on_switch_area_music_clicked() { - ui_music_search->setText(""); - on_music_search_edited(ui_music_search->text()); - if (ui_area_list->isHidden()) { - ui_area_list->show(); - ui_music_list->hide(); - } - else { - ui_area_list->hide(); - ui_music_list->show(); - } + ui_music_search->setText(""); + on_music_search_edited(ui_music_search->text()); + if (ui_area_list->isHidden()) { + ui_area_list->show(); + ui_music_list->hide(); + } + else { + ui_area_list->hide(); + ui_music_list->show(); + } } void Courtroom::ping_server() { - ao_app->send_server_packet(new AOPacket("CH#" + QString::number(m_cid) + "#%")); + ao_app->send_server_packet( + new AOPacket("CH#" + QString::number(m_cid) + "#%")); } void Courtroom::on_casing_clicked() { - if (ao_app->casing_alerts_enabled) { - if (ui_casing->isChecked()) { - QStringList f_packet; - - f_packet.append(ao_app->get_casing_can_host_cases()); - f_packet.append(QString::number(ao_app->get_casing_cm_enabled())); - f_packet.append(QString::number(ao_app->get_casing_defence_enabled())); - f_packet.append(QString::number(ao_app->get_casing_prosecution_enabled())); - f_packet.append(QString::number(ao_app->get_casing_judge_enabled())); - f_packet.append(QString::number(ao_app->get_casing_juror_enabled())); - f_packet.append(QString::number(ao_app->get_casing_steno_enabled())); - - ao_app->send_server_packet(new AOPacket("SETCASE", f_packet)); - } - else - ao_app->send_server_packet(new AOPacket("SETCASE#\"\"#0#0#0#0#0#0#%")); + if (ao_app->casing_alerts_enabled) { + if (ui_casing->isChecked()) { + QStringList f_packet; + + f_packet.append(ao_app->get_casing_can_host_cases()); + f_packet.append(QString::number(ao_app->get_casing_cm_enabled())); + f_packet.append(QString::number(ao_app->get_casing_defence_enabled())); + f_packet.append( + QString::number(ao_app->get_casing_prosecution_enabled())); + f_packet.append(QString::number(ao_app->get_casing_judge_enabled())); + f_packet.append(QString::number(ao_app->get_casing_juror_enabled())); + f_packet.append(QString::number(ao_app->get_casing_steno_enabled())); + + ao_app->send_server_packet(new AOPacket("SETCASE", f_packet)); } + else + ao_app->send_server_packet(new AOPacket("SETCASE#\"\"#0#0#0#0#0#0#%")); + } } -void Courtroom::announce_case(QString title, bool def, bool pro, bool jud, bool jur, bool steno) +void Courtroom::announce_case(QString title, bool def, bool pro, bool jud, + bool jur, bool steno) { - if (ao_app->casing_alerts_enabled) { - QStringList f_packet; + if (ao_app->casing_alerts_enabled) { + QStringList f_packet; - f_packet.append(title); - f_packet.append(QString::number(def)); - f_packet.append(QString::number(pro)); - f_packet.append(QString::number(jud)); - f_packet.append(QString::number(jur)); - f_packet.append(QString::number(steno)); + f_packet.append(title); + f_packet.append(QString::number(def)); + f_packet.append(QString::number(pro)); + f_packet.append(QString::number(jud)); + f_packet.append(QString::number(jur)); + f_packet.append(QString::number(steno)); - ao_app->send_server_packet(new AOPacket("CASEA", f_packet)); - } + ao_app->send_server_packet(new AOPacket("CASEA", f_packet)); + } } Courtroom::~Courtroom() { - delete music_player; - delete sfx_player; - delete objection_player; - delete blip_player; + delete music_player; + delete sfx_player; + delete objection_player; + delete blip_player; } #if (defined(_WIN32) || defined(_WIN64)) void Courtroom::load_bass_opus_plugin() { #ifdef BASSAUDIO - BASS_PluginLoad("bassopus.dll", 0); + BASS_PluginLoad("bassopus.dll", 0); #endif } #elif (defined(LINUX) || defined(__linux__)) void Courtroom::load_bass_opus_plugin() { #ifdef BASSAUDIO - BASS_PluginLoad("libbassopus.so", 0); + BASS_PluginLoad("libbassopus.so", 0); #endif } #elif defined __APPLE__ void Courtroom::load_bass_opus_plugin() { - QString libpath = ao_app->get_base_path() + "../../Frameworks/libbassopus.dylib"; - QByteArray ba = libpath.toLocal8Bit(); + QString libpath = + ao_app->get_base_path() + "../../Frameworks/libbassopus.dylib"; + QByteArray ba = libpath.toLocal8Bit(); #ifdef BASSAUDIO - BASS_PluginLoad(ba.data(), 0); + BASS_PluginLoad(ba.data(), 0); #endif } #else diff --git a/src/debug_functions.cpp b/src/debug_functions.cpp index ba189ec0..b8321640 100644 --- a/src/debug_functions.cpp +++ b/src/debug_functions.cpp @@ -5,22 +5,25 @@ void call_error(QString p_message) { - QMessageBox *msgBox = new QMessageBox; + QMessageBox *msgBox = new QMessageBox; - msgBox->setText(QCoreApplication::translate("debug_functions", "Error: %1").arg(p_message)); - msgBox->setWindowTitle(QCoreApplication::translate("debug_functions", "Error")); + msgBox->setText(QCoreApplication::translate("debug_functions", "Error: %1") + .arg(p_message)); + msgBox->setWindowTitle( + QCoreApplication::translate("debug_functions", "Error")); - //msgBox->setWindowModality(Qt::NonModal); - msgBox->exec(); + // msgBox->setWindowModality(Qt::NonModal); + msgBox->exec(); } void call_notice(QString p_message) { - QMessageBox *msgBox = new QMessageBox; + QMessageBox *msgBox = new QMessageBox; - msgBox->setText(p_message); - msgBox->setWindowTitle(QCoreApplication::translate("debug_functions", "Notice")); + msgBox->setText(p_message); + msgBox->setWindowTitle( + QCoreApplication::translate("debug_functions", "Notice")); - //msgBox->setWindowModality(Qt::NonModal); - msgBox->exec(); + // msgBox->setWindowModality(Qt::NonModal); + msgBox->exec(); } diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index 05a94948..aea07e5e 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -3,129 +3,120 @@ namespace AttorneyOnline { #ifdef DISCORD - Discord::Discord() - { - DiscordEventHandlers handlers; - std::memset(&handlers, 0, sizeof(handlers)); - handlers = {}; - handlers.ready = [] { - qInfo() << "Discord RPC ready"; - }; - handlers.disconnected = [](int errorCode, const char *message) { - qInfo() << "Discord RPC disconnected! " << message << errorCode; - }; - handlers.errored = [](int errorCode, const char *message) { - qWarning() << "Discord RPC errored out! " << message << errorCode; - }; - qInfo() << "Initializing Discord RPC"; - Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr); - } - - Discord::~Discord() - { - Discord_Shutdown(); - } - - void Discord::state_lobby() - { - DiscordRichPresence presence; - std::memset(&presence, 0, sizeof(presence)); - presence.largeImageKey = "ao2-logo"; - presence.largeImageText = "Objection!"; - presence.instance = 1; - - presence.state = "In Lobby"; - presence.details = "Idle"; - Discord_UpdatePresence(&presence); - } - - void Discord::state_server(std::string name, std::string server_id) - { - qDebug() << "Discord RPC: Setting server state"; - - DiscordRichPresence presence; - std::memset(&presence, 0, sizeof(presence)); - presence.largeImageKey = "ao2-logo"; - presence.largeImageText = "Objection!"; - presence.instance = 1; - - auto timestamp = static_cast<int64_t>(std::time(nullptr)); - - presence.state = "In a Server"; - presence.details = name.c_str(); - presence.matchSecret = server_id.c_str(); - presence.startTimestamp = this->timestamp; - - this->server_id = server_id; - this->server_name = name; - this->timestamp = timestamp; - Discord_UpdatePresence(&presence); - } - - void Discord::state_character(std::string name) - { - auto name_internal = QString(name.c_str()).toLower().replace(' ', '_').toStdString(); - auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString(); - const std::string playing_as = "Playing as " + name_friendly; - qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str() << ")"; - - DiscordRichPresence presence; - std::memset(&presence, 0, sizeof(presence)); - presence.largeImageKey = "ao2-logo"; - presence.largeImageText = "Objection!"; - presence.instance = 1; - presence.details = this->server_name.c_str(); - presence.matchSecret = this->server_id.c_str(); - presence.startTimestamp = this->timestamp; - - presence.state = playing_as.c_str(); - presence.smallImageKey = name_internal.c_str(); - // presence.smallImageText = name_internal.c_str(); - Discord_UpdatePresence(&presence); - } - - void Discord::state_spectate() - { - qDebug() << "Discord RPC: Setting specator state"; - - DiscordRichPresence presence; - std::memset(&presence, 0, sizeof(presence)); - presence.largeImageKey = "ao2-logo"; - presence.largeImageText = "Objection!"; - presence.instance = 1; - presence.details = this->server_name.c_str(); - presence.matchSecret = this->server_id.c_str(); - presence.startTimestamp = this->timestamp; - - presence.state = "Spectating"; - Discord_UpdatePresence(&presence); - } +Discord::Discord() +{ + DiscordEventHandlers handlers; + std::memset(&handlers, 0, sizeof(handlers)); + handlers = {}; + handlers.ready = [] { qInfo() << "Discord RPC ready"; }; + handlers.disconnected = [](int errorCode, const char *message) { + qInfo() << "Discord RPC disconnected! " << message << errorCode; + }; + handlers.errored = [](int errorCode, const char *message) { + qWarning() << "Discord RPC errored out! " << message << errorCode; + }; + qInfo() << "Initializing Discord RPC"; + Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr); +} + +Discord::~Discord() { Discord_Shutdown(); } + +void Discord::state_lobby() +{ + DiscordRichPresence presence; + std::memset(&presence, 0, sizeof(presence)); + presence.largeImageKey = "ao2-logo"; + presence.largeImageText = "Objection!"; + presence.instance = 1; + + presence.state = "In Lobby"; + presence.details = "Idle"; + Discord_UpdatePresence(&presence); +} + +void Discord::state_server(std::string name, std::string server_id) +{ + qDebug() << "Discord RPC: Setting server state"; + + DiscordRichPresence presence; + std::memset(&presence, 0, sizeof(presence)); + presence.largeImageKey = "ao2-logo"; + presence.largeImageText = "Objection!"; + presence.instance = 1; + + auto timestamp = static_cast<int64_t>(std::time(nullptr)); + + presence.state = "In a Server"; + presence.details = name.c_str(); + presence.matchSecret = server_id.c_str(); + presence.startTimestamp = this->timestamp; + + this->server_id = server_id; + this->server_name = name; + this->timestamp = timestamp; + Discord_UpdatePresence(&presence); +} + +void Discord::state_character(std::string name) +{ + auto name_internal = + QString(name.c_str()).toLower().replace(' ', '_').toStdString(); + auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString(); + const std::string playing_as = "Playing as " + name_friendly; + qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str() + << ")"; + + DiscordRichPresence presence; + std::memset(&presence, 0, sizeof(presence)); + presence.largeImageKey = "ao2-logo"; + presence.largeImageText = "Objection!"; + presence.instance = 1; + presence.details = this->server_name.c_str(); + presence.matchSecret = this->server_id.c_str(); + presence.startTimestamp = this->timestamp; + + presence.state = playing_as.c_str(); + presence.smallImageKey = name_internal.c_str(); + // presence.smallImageText = name_internal.c_str(); + Discord_UpdatePresence(&presence); +} + +void Discord::state_spectate() +{ + qDebug() << "Discord RPC: Setting specator state"; + + DiscordRichPresence presence; + std::memset(&presence, 0, sizeof(presence)); + presence.largeImageKey = "ao2-logo"; + presence.largeImageText = "Objection!"; + presence.instance = 1; + presence.details = this->server_name.c_str(); + presence.matchSecret = this->server_id.c_str(); + presence.startTimestamp = this->timestamp; + + presence.state = "Spectating"; + Discord_UpdatePresence(&presence); +} #else - Discord::Discord() - { - } - - Discord::~Discord() - { - } - - void Discord::state_lobby() - { - } - - void Discord::state_server(std::string name, std::string server_id) - { - qDebug() << "Discord RPC: Setting server state"; - } - - void Discord::state_character(std::string name) - { - qDebug() << "Discord RPC: Setting character state"; - } - - void Discord::state_spectate() - { - qDebug() << "Discord RPC: Setting specator state"; - } +Discord::Discord() {} + +Discord::~Discord() {} + +void Discord::state_lobby() {} + +void Discord::state_server(std::string name, std::string server_id) +{ + qDebug() << "Discord RPC: Setting server state"; +} + +void Discord::state_character(std::string name) +{ + qDebug() << "Discord RPC: Setting character state"; +} + +void Discord::state_spectate() +{ + qDebug() << "Discord RPC: Setting specator state"; +} #endif } // namespace AttorneyOnline diff --git a/src/emotes.cpp b/src/emotes.cpp index 59952971..8de55244 100644 --- a/src/emotes.cpp +++ b/src/emotes.cpp @@ -4,189 +4,203 @@ void Courtroom::initialize_emotes() { - ui_emotes = new QWidget(this); + ui_emotes = new QWidget(this); - ui_emote_left = new AOButton(this, ao_app); - ui_emote_right = new AOButton(this, ao_app); + ui_emote_left = new AOButton(this, ao_app); + ui_emote_right = new AOButton(this, ao_app); - ui_emote_dropdown = new QComboBox(this); + ui_emote_dropdown = new QComboBox(this); - connect(ui_emote_left, SIGNAL(clicked()), this, SLOT(on_emote_left_clicked())); - connect(ui_emote_right, SIGNAL(clicked()), this, SLOT(on_emote_right_clicked())); + connect(ui_emote_left, SIGNAL(clicked()), this, + SLOT(on_emote_left_clicked())); + connect(ui_emote_right, SIGNAL(clicked()), this, + SLOT(on_emote_right_clicked())); - connect(ui_emote_dropdown, SIGNAL(activated(int)), this, SLOT(on_emote_dropdown_changed(int))); + connect(ui_emote_dropdown, SIGNAL(activated(int)), this, + SLOT(on_emote_dropdown_changed(int))); } void Courtroom::refresh_emotes() { - //Should properly refresh the emote list - qDeleteAll(ui_emote_list.begin(), ui_emote_list.end()); - ui_emote_list.clear(); + // Should properly refresh the emote list + qDeleteAll(ui_emote_list.begin(), ui_emote_list.end()); + ui_emote_list.clear(); - set_size_and_pos(ui_emotes, "emotes"); + set_size_and_pos(ui_emotes, "emotes"); - set_size_and_pos(ui_emote_left, "emote_left"); - ui_emote_left->set_image("arrow_left"); + set_size_and_pos(ui_emote_left, "emote_left"); + ui_emote_left->set_image("arrow_left"); - set_size_and_pos(ui_emote_right, "emote_right"); - ui_emote_right->set_image("arrow_right"); + set_size_and_pos(ui_emote_right, "emote_right"); + ui_emote_right->set_image("arrow_right"); - QPoint f_spacing = ao_app->get_button_spacing("emote_button_spacing", "courtroom_design.ini"); - QPoint p_point = ao_app->get_button_spacing("emote_button_size", "courtroom_design.ini"); + QPoint f_spacing = ao_app->get_button_spacing("emote_button_spacing", + "courtroom_design.ini"); + QPoint p_point = + ao_app->get_button_spacing("emote_button_size", "courtroom_design.ini"); - const int button_width = p_point.x(); - int x_spacing = f_spacing.x(); - int x_mod_count = 0; + const int button_width = p_point.x(); + int x_spacing = f_spacing.x(); + int x_mod_count = 0; - const int button_height = p_point.y(); - int y_spacing = f_spacing.y(); - int y_mod_count = 0; + const int button_height = p_point.y(); + int y_spacing = f_spacing.y(); + int y_mod_count = 0; - emote_columns = ((ui_emotes->width() - button_width) / (x_spacing + button_width)) + 1; - emote_rows = ((ui_emotes->height() - button_height) / (y_spacing + button_height)) + 1; + emote_columns = + ((ui_emotes->width() - button_width) / (x_spacing + button_width)) + 1; + emote_rows = + ((ui_emotes->height() - button_height) / (y_spacing + button_height)) + 1; - max_emotes_on_page = emote_columns * emote_rows; + max_emotes_on_page = emote_columns * emote_rows; - for (int n = 0; n < max_emotes_on_page; ++n) { - int x_pos = (button_width + x_spacing) * x_mod_count; - int y_pos = (button_height + y_spacing) * y_mod_count; + for (int n = 0; n < max_emotes_on_page; ++n) { + int x_pos = (button_width + x_spacing) * x_mod_count; + int y_pos = (button_height + y_spacing) * y_mod_count; - AOEmoteButton *f_emote = new AOEmoteButton(ui_emotes, ao_app, x_pos, y_pos, button_width, button_height); + AOEmoteButton *f_emote = new AOEmoteButton(ui_emotes, ao_app, x_pos, y_pos, + button_width, button_height); - ui_emote_list.append(f_emote); + ui_emote_list.append(f_emote); - f_emote->set_id(n); + f_emote->set_id(n); - connect(f_emote, SIGNAL(emote_clicked(int)), this, SLOT(on_emote_clicked(int))); + connect(f_emote, SIGNAL(emote_clicked(int)), this, + SLOT(on_emote_clicked(int))); - ++x_mod_count; + ++x_mod_count; - if (x_mod_count == emote_columns) { - ++y_mod_count; - x_mod_count = 0; - } + if (x_mod_count == emote_columns) { + ++y_mod_count; + x_mod_count = 0; } + } } void Courtroom::set_emote_page() { - if (m_cid == -1) - return; + if (m_cid == -1) + return; - int total_emotes = ao_app->get_emote_number(current_char); + int total_emotes = ao_app->get_emote_number(current_char); - ui_emote_left->hide(); - ui_emote_right->hide(); + ui_emote_left->hide(); + ui_emote_right->hide(); - for (AOEmoteButton *i_button : ui_emote_list) { - i_button->hide(); - } + for (AOEmoteButton *i_button : ui_emote_list) { + i_button->hide(); + } - int total_pages = total_emotes / max_emotes_on_page; - int emotes_on_page = 0; + int total_pages = total_emotes / max_emotes_on_page; + int emotes_on_page = 0; - if (total_emotes % max_emotes_on_page != 0) { - ++total_pages; - //i. e. not on the last page - if (total_pages > current_emote_page + 1) - emotes_on_page = max_emotes_on_page; - else - emotes_on_page = total_emotes % max_emotes_on_page; - } + if (total_emotes % max_emotes_on_page != 0) { + ++total_pages; + // i. e. not on the last page + if (total_pages > current_emote_page + 1) + emotes_on_page = max_emotes_on_page; else - emotes_on_page = max_emotes_on_page; + emotes_on_page = total_emotes % max_emotes_on_page; + } + else + emotes_on_page = max_emotes_on_page; - if (total_pages > current_emote_page + 1) - ui_emote_right->show(); + if (total_pages > current_emote_page + 1) + ui_emote_right->show(); - if (current_emote_page > 0) - ui_emote_left->show(); + if (current_emote_page > 0) + ui_emote_left->show(); - for (int n_emote = 0; n_emote < emotes_on_page && n_emote < ui_emote_list.size(); ++n_emote) { - int n_real_emote = n_emote + current_emote_page * max_emotes_on_page; - AOEmoteButton *f_emote = ui_emote_list.at(n_emote); + for (int n_emote = 0; + n_emote < emotes_on_page && n_emote < ui_emote_list.size(); ++n_emote) { + int n_real_emote = n_emote + current_emote_page * max_emotes_on_page; + AOEmoteButton *f_emote = ui_emote_list.at(n_emote); - if (n_real_emote == current_emote) - f_emote->set_char_image(current_char, n_real_emote, "_on"); - else - f_emote->set_char_image(current_char, n_real_emote, "_off"); + if (n_real_emote == current_emote) + f_emote->set_char_image(current_char, n_real_emote, "_on"); + else + f_emote->set_char_image(current_char, n_real_emote, "_off"); - f_emote->show(); - f_emote->setToolTip(QString::number(n_real_emote + 1) + ": " + ao_app->get_emote_comment(current_char, n_real_emote)); - } + f_emote->show(); + f_emote->setToolTip(QString::number(n_real_emote + 1) + ": " + + ao_app->get_emote_comment(current_char, n_real_emote)); + } } void Courtroom::set_emote_dropdown() { - ui_emote_dropdown->clear(); + ui_emote_dropdown->clear(); - int total_emotes = ao_app->get_emote_number(current_char); - QStringList emote_list; + int total_emotes = ao_app->get_emote_number(current_char); + QStringList emote_list; - for (int n = 0; n < total_emotes; ++n) { - emote_list.append(QString::number(n + 1) + ": " + ao_app->get_emote_comment(current_char, n)); - } + for (int n = 0; n < total_emotes; ++n) { + emote_list.append(QString::number(n + 1) + ": " + + ao_app->get_emote_comment(current_char, n)); + } - ui_emote_dropdown->addItems(emote_list); + ui_emote_dropdown->addItems(emote_list); } void Courtroom::select_emote(int p_id) { - int min = current_emote_page * max_emotes_on_page; - int max = (max_emotes_on_page - 1) + current_emote_page * max_emotes_on_page; + int min = current_emote_page * max_emotes_on_page; + int max = (max_emotes_on_page - 1) + current_emote_page * max_emotes_on_page; - if (current_emote >= min && current_emote <= max) - ui_emote_list.at(current_emote % max_emotes_on_page)->set_char_image(current_char, current_emote, "_off"); + if (current_emote >= min && current_emote <= max) + ui_emote_list.at(current_emote % max_emotes_on_page) + ->set_char_image(current_char, current_emote, "_off"); - int old_emote = current_emote; + int old_emote = current_emote; - current_emote = p_id; + current_emote = p_id; - if (current_emote >= min && current_emote <= max) - ui_emote_list.at(current_emote % max_emotes_on_page)->set_char_image(current_char, current_emote, "_on"); + if (current_emote >= min && current_emote <= max) + ui_emote_list.at(current_emote % max_emotes_on_page) + ->set_char_image(current_char, current_emote, "_on"); - int emote_mod = ao_app->get_emote_mod(current_char, current_emote); + int emote_mod = ao_app->get_emote_mod(current_char, current_emote); - if (old_emote == current_emote) { - ui_pre->setChecked(!ui_pre->isChecked()); - } - else if (!ao_app->is_stickypres_enabled()) { - if (emote_mod == 1 || emote_mod == 4) - ui_pre->setChecked(true); - else - ui_pre->setChecked(false); - } + if (old_emote == current_emote) { + ui_pre->setChecked(!ui_pre->isChecked()); + } + else if (!ao_app->is_stickypres_enabled()) { + if (emote_mod == 1 || emote_mod == 4) + ui_pre->setChecked(true); + else + ui_pre->setChecked(false); + } - ui_emote_dropdown->setCurrentIndex(current_emote); + ui_emote_dropdown->setCurrentIndex(current_emote); - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_emote_clicked(int p_id) { - select_emote(p_id + max_emotes_on_page * current_emote_page); + select_emote(p_id + max_emotes_on_page * current_emote_page); } void Courtroom::on_emote_left_clicked() { - --current_emote_page; + --current_emote_page; - set_emote_page(); + set_emote_page(); - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_emote_right_clicked() { - qDebug() << "emote right clicked"; - ++current_emote_page; + qDebug() << "emote right clicked"; + ++current_emote_page; - set_emote_page(); + set_emote_page(); - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_emote_dropdown_changed(int p_index) { - select_emote(p_index); + select_emote(p_index); } diff --git a/src/encryption_functions.cpp b/src/encryption_functions.cpp index f26d4d47..6669fe15 100644 --- a/src/encryption_functions.cpp +++ b/src/encryption_functions.cpp @@ -4,55 +4,55 @@ QString fanta_encrypt(QString temp_input, unsigned int p_key) { - //using standard stdlib types is actually easier here because of implicit char<->int conversion - //which in turn makes encryption arithmetic easier + // using standard stdlib types is actually easier here because of implicit + // char<->int conversion which in turn makes encryption arithmetic easier - unsigned int key = p_key; - unsigned int C1 = 53761; - unsigned int C2 = 32618; + unsigned int key = p_key; + unsigned int C1 = 53761; + unsigned int C2 = 32618; - QVector<uint_fast8_t> temp_result; - std::string input = temp_input.toUtf8().constData(); + QVector<uint_fast8_t> temp_result; + std::string input = temp_input.toUtf8().constData(); - for (unsigned int pos = 0; pos < input.size(); ++pos) { - uint_fast8_t output = input.at(pos) ^ (key >> 8) % 256; - temp_result.append(output); - key = (temp_result.at(pos) + key) * C1 + C2; - } + for (unsigned int pos = 0; pos < input.size(); ++pos) { + uint_fast8_t output = input.at(pos) ^ (key >> 8) % 256; + temp_result.append(output); + key = (temp_result.at(pos) + key) * C1 + C2; + } - std::string result = ""; + std::string result = ""; - for (uint_fast8_t i_int : temp_result) { - result += omni::int_to_hex(i_int); - } + for (uint_fast8_t i_int : temp_result) { + result += omni::int_to_hex(i_int); + } - QString final_result = QString::fromStdString(result); + QString final_result = QString::fromStdString(result); - return final_result; + return final_result; } QString fanta_decrypt(QString temp_input, unsigned int key) { - std::string input = temp_input.toUtf8().constData(); + std::string input = temp_input.toUtf8().constData(); - QVector<unsigned int> unhexed_vector; + QVector<unsigned int> unhexed_vector; - for (unsigned int i = 0; i < input.length(); i += 2) { - std::string byte = input.substr(i, 2); - unsigned int hex_int = strtoul(byte.c_str(), nullptr, 16); - unhexed_vector.append(hex_int); - } + for (unsigned int i = 0; i < input.length(); i += 2) { + std::string byte = input.substr(i, 2); + unsigned int hex_int = strtoul(byte.c_str(), nullptr, 16); + unhexed_vector.append(hex_int); + } - unsigned int C1 = 53761; - unsigned int C2 = 32618; + unsigned int C1 = 53761; + unsigned int C2 = 32618; - std::string result = ""; + std::string result = ""; - for (int pos = 0; pos < unhexed_vector.size(); ++pos) { - unsigned char output = unhexed_vector.at(pos) ^ (key >> 8) % 256; - result += output; - key = (unhexed_vector.at(pos) + key) * C1 + C2; - } + for (int pos = 0; pos < unhexed_vector.size(); ++pos) { + unsigned char output = unhexed_vector.at(pos) ^ (key >> 8) % 256; + result += output; + key = (unhexed_vector.at(pos) + key) * C1 + C2; + } - return QString::fromStdString(result); + return QString::fromStdString(result); } diff --git a/src/evidence.cpp b/src/evidence.cpp index 50ed9a4f..edfad5db 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -2,708 +2,776 @@ void Courtroom::initialize_evidence() { - ui_evidence = new AOImage(this, ao_app); - - //ui_evidence_name = new QLabel(ui_evidence); - ui_evidence_name = new AOLineEdit(ui_evidence); - ui_evidence_name->setAlignment(Qt::AlignCenter); - ui_evidence_name->setFrame(false); - - ui_evidence_buttons = new QWidget(ui_evidence); - - ui_evidence_left = new AOButton(ui_evidence, ao_app); - ui_evidence_right = new AOButton(ui_evidence, ao_app); - ui_evidence_present = new AOButton(ui_evidence, ao_app); - ui_evidence_present->setToolTip(tr("Present this piece of evidence to everyone on your next spoken message")); - - ui_evidence_switch = new AOButton(ui_evidence, ao_app); - ui_evidence_transfer = new AOButton(ui_evidence, ao_app); - - ui_evidence_save = new AOButton(ui_evidence, ao_app); - ui_evidence_save->setToolTip(tr("Save evidence to an .ini file.")); - ui_evidence_load = new AOButton(ui_evidence, ao_app); - ui_evidence_load->setToolTip(tr("Load evidence from an .ini file.")); - - ui_evidence_overlay = new AOImage(ui_evidence, ao_app); - - ui_evidence_delete = new AOButton(ui_evidence_overlay, ao_app); - ui_evidence_delete->setToolTip(tr("Destroy this piece of evidence")); - ui_evidence_image_name = new AOLineEdit(ui_evidence_overlay); - ui_evidence_image_button = new AOButton(ui_evidence_overlay, ao_app); - ui_evidence_image_button->setText(tr("Choose...")); - ui_evidence_x = new AOButton(ui_evidence_overlay, ao_app); - ui_evidence_x->setToolTip(tr("Close the evidence display/editing overlay.\n" - "You will be prompted if there's any unsaved changes.")); - ui_evidence_ok = new AOButton(ui_evidence_overlay, ao_app); - ui_evidence_ok->setToolTip(tr("Save any changes made to this piece of evidence and send them to server.")); - - ui_evidence_description = new AOTextEdit(ui_evidence_overlay); - ui_evidence_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "color: white;"); - ui_evidence_description->setFrameStyle(QFrame::NoFrame); - ui_evidence_description->setToolTip("Double-click to edit. Press [X] to update your changes."); - - connect(ui_evidence_name, SIGNAL(returnPressed()), this, SLOT(on_evidence_name_edited())); - connect(ui_evidence_name, SIGNAL(double_clicked()), this, SLOT(on_evidence_name_double_clicked())); - connect(ui_evidence_left, SIGNAL(clicked()), this, SLOT(on_evidence_left_clicked())); - connect(ui_evidence_right, SIGNAL(clicked()), this, SLOT(on_evidence_right_clicked())); - connect(ui_evidence_present, SIGNAL(clicked()), this, SLOT(on_evidence_present_clicked())); - connect(ui_evidence_switch, SIGNAL(clicked()), this, SLOT(on_evidence_switch_clicked())); - connect(ui_evidence_transfer, SIGNAL(clicked()), this, SLOT(on_evidence_transfer_clicked())); - connect(ui_evidence_save, SIGNAL(clicked()), this, SLOT(on_evidence_save_clicked())); - connect(ui_evidence_load, SIGNAL(clicked()), this, SLOT(on_evidence_load_clicked())); - - connect(ui_evidence_delete, SIGNAL(clicked()), this, SLOT(on_evidence_delete_clicked())); - connect(ui_evidence_image_name, SIGNAL(returnPressed()), this, SLOT(on_evidence_image_name_edited())); - connect(ui_evidence_image_name, SIGNAL(double_clicked()), this, SLOT(on_evidence_image_name_double_clicked())); - connect(ui_evidence_image_button, SIGNAL(clicked()), this, SLOT(on_evidence_image_button_clicked())); - connect(ui_evidence_x, SIGNAL(clicked()), this, SLOT(on_evidence_x_clicked())); - connect(ui_evidence_ok, SIGNAL(clicked()), this, SLOT(on_evidence_ok_clicked())); - - connect(ui_evidence_name, SIGNAL(textChanged(QString)), this, SLOT(on_evidence_edited())); - connect(ui_evidence_image_name, SIGNAL(textChanged(QString)), this, SLOT(on_evidence_edited())); - connect(ui_evidence_description, SIGNAL(textChanged()), this, SLOT(on_evidence_edited())); - - ui_evidence->hide(); + ui_evidence = new AOImage(this, ao_app); + + // ui_evidence_name = new QLabel(ui_evidence); + ui_evidence_name = new AOLineEdit(ui_evidence); + ui_evidence_name->setAlignment(Qt::AlignCenter); + ui_evidence_name->setFrame(false); + + ui_evidence_buttons = new QWidget(ui_evidence); + + ui_evidence_left = new AOButton(ui_evidence, ao_app); + ui_evidence_right = new AOButton(ui_evidence, ao_app); + ui_evidence_present = new AOButton(ui_evidence, ao_app); + ui_evidence_present->setToolTip(tr("Present this piece of evidence to " + "everyone on your next spoken message")); + + ui_evidence_switch = new AOButton(ui_evidence, ao_app); + ui_evidence_transfer = new AOButton(ui_evidence, ao_app); + + ui_evidence_save = new AOButton(ui_evidence, ao_app); + ui_evidence_save->setToolTip(tr("Save evidence to an .ini file.")); + ui_evidence_load = new AOButton(ui_evidence, ao_app); + ui_evidence_load->setToolTip(tr("Load evidence from an .ini file.")); + + ui_evidence_overlay = new AOImage(ui_evidence, ao_app); + + ui_evidence_delete = new AOButton(ui_evidence_overlay, ao_app); + ui_evidence_delete->setToolTip(tr("Destroy this piece of evidence")); + ui_evidence_image_name = new AOLineEdit(ui_evidence_overlay); + ui_evidence_image_button = new AOButton(ui_evidence_overlay, ao_app); + ui_evidence_image_button->setText(tr("Choose...")); + ui_evidence_x = new AOButton(ui_evidence_overlay, ao_app); + ui_evidence_x->setToolTip( + tr("Close the evidence display/editing overlay.\n" + "You will be prompted if there's any unsaved changes.")); + ui_evidence_ok = new AOButton(ui_evidence_overlay, ao_app); + ui_evidence_ok->setToolTip(tr("Save any changes made to this piece of " + "evidence and send them to server.")); + + ui_evidence_description = new AOTextEdit(ui_evidence_overlay); + ui_evidence_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" + "color: white;"); + ui_evidence_description->setFrameStyle(QFrame::NoFrame); + ui_evidence_description->setToolTip( + "Double-click to edit. Press [X] to update your changes."); + + connect(ui_evidence_name, SIGNAL(returnPressed()), this, + SLOT(on_evidence_name_edited())); + connect(ui_evidence_name, SIGNAL(double_clicked()), this, + SLOT(on_evidence_name_double_clicked())); + connect(ui_evidence_left, SIGNAL(clicked()), this, + SLOT(on_evidence_left_clicked())); + connect(ui_evidence_right, SIGNAL(clicked()), this, + SLOT(on_evidence_right_clicked())); + connect(ui_evidence_present, SIGNAL(clicked()), this, + SLOT(on_evidence_present_clicked())); + connect(ui_evidence_switch, SIGNAL(clicked()), this, + SLOT(on_evidence_switch_clicked())); + connect(ui_evidence_transfer, SIGNAL(clicked()), this, + SLOT(on_evidence_transfer_clicked())); + connect(ui_evidence_save, SIGNAL(clicked()), this, + SLOT(on_evidence_save_clicked())); + connect(ui_evidence_load, SIGNAL(clicked()), this, + SLOT(on_evidence_load_clicked())); + + connect(ui_evidence_delete, SIGNAL(clicked()), this, + SLOT(on_evidence_delete_clicked())); + connect(ui_evidence_image_name, SIGNAL(returnPressed()), this, + SLOT(on_evidence_image_name_edited())); + connect(ui_evidence_image_name, SIGNAL(double_clicked()), this, + SLOT(on_evidence_image_name_double_clicked())); + connect(ui_evidence_image_button, SIGNAL(clicked()), this, + SLOT(on_evidence_image_button_clicked())); + connect(ui_evidence_x, SIGNAL(clicked()), this, + SLOT(on_evidence_x_clicked())); + connect(ui_evidence_ok, SIGNAL(clicked()), this, + SLOT(on_evidence_ok_clicked())); + + connect(ui_evidence_name, SIGNAL(textChanged(QString)), this, + SLOT(on_evidence_edited())); + connect(ui_evidence_image_name, SIGNAL(textChanged(QString)), this, + SLOT(on_evidence_edited())); + connect(ui_evidence_description, SIGNAL(textChanged()), this, + SLOT(on_evidence_edited())); + + ui_evidence->hide(); } void Courtroom::refresh_evidence() { - set_font(ui_evidence_name, "", "evidence_name"); - set_font(ui_evidence_image_name, "", "evidence_image_name"); - set_font(ui_evidence_description, "", "evidence_description"); - - //Should properly refresh the evidence list - qDeleteAll(ui_evidence_list.begin(), ui_evidence_list.end()); - ui_evidence_list.clear(); - - set_size_and_pos(ui_evidence_button, "evidence_button"); - ui_evidence_button->set_image("evidence_button"); - ui_evidence_button->setToolTip(tr("Bring up the Evidence screen.")); - - set_size_and_pos(ui_evidence, "evidence_background"); - if (current_evidence_global) - ui_evidence->set_image("evidence_background"); - else - ui_evidence->set_image("evidence_background_private"); - - set_size_and_pos(ui_evidence_name, "evidence_name"); - - set_size_and_pos(ui_evidence_buttons, "evidence_buttons"); - - set_size_and_pos(ui_evidence_left, "evidence_left"); - ui_evidence_left->set_image("arrow_left"); - - set_size_and_pos(ui_evidence_right, "evidence_right"); - ui_evidence_right->set_image("arrow_right"); - - set_size_and_pos(ui_evidence_present, "evidence_present"); - ui_evidence_present->set_image("present"); - - set_size_and_pos(ui_evidence_overlay, "evidence_overlay"); - if (current_evidence_global) - ui_evidence_overlay->set_image("evidence_overlay"); - else - ui_evidence_overlay->set_image("evidence_overlay_private"); - - set_size_and_pos(ui_evidence_delete, "evidence_delete"); - ui_evidence_delete->set_image("evidence_delete"); - - set_size_and_pos(ui_evidence_image_name, "evidence_image_name"); - - set_size_and_pos(ui_evidence_image_button, "evidence_image_button"); - - set_size_and_pos(ui_evidence_x, "evidence_x"); - ui_evidence_x->set_image("evidence_x"); - - set_size_and_pos(ui_evidence_ok, "evidence_ok"); - ui_evidence_ok->set_image("evidence_ok"); - - set_size_and_pos(ui_evidence_switch, "evidence_switch"); - if (current_evidence_global) { - ui_evidence_switch->set_image("evidence_global"); - ui_evidence_switch->setToolTip(tr("Switch evidence to private inventory.")); - } - else { - ui_evidence_switch->set_image("evidence_private"); - ui_evidence_switch->setToolTip(tr("Switch evidence to global inventory.")); - } - - set_size_and_pos(ui_evidence_transfer, "evidence_transfer"); - if (current_evidence_global) { - ui_evidence_transfer->set_image("evidence_transfer"); - ui_evidence_transfer->setToolTip(tr("Transfer evidence to private inventory.")); - } - else { - ui_evidence_transfer->set_image("evidence_transfer_private"); - ui_evidence_transfer->setToolTip(tr("Transfer evidence to global inventory.")); - } - - set_size_and_pos(ui_evidence_save, "evidence_save"); - ui_evidence_save->set_image("evidence_save"); - if (current_evidence_global) - ui_evidence_save->hide(); - else - ui_evidence_save->show(); - - set_size_and_pos(ui_evidence_load, "evidence_load"); - ui_evidence_load->set_image("evidence_load"); - if (current_evidence_global) - ui_evidence_load->hide(); - else - ui_evidence_load->show(); - - set_size_and_pos(ui_evidence_description, "evidence_description"); - - QPoint f_spacing = ao_app->get_button_spacing("evidence_button_spacing", "courtroom_design.ini"); - QPoint p_point = ao_app->get_button_spacing("evidence_button_size", "courtroom_design.ini"); - - const int button_width = p_point.x(); - int x_spacing = f_spacing.x(); - int x_mod_count = 0; - - const int button_height = p_point.y(); - int y_spacing = f_spacing.y(); - int y_mod_count = 0; - - evidence_columns = ((ui_evidence_buttons->width() - button_width) / (x_spacing + button_width)) + 1; - evidence_rows = ((ui_evidence_buttons->height() - button_height) / (y_spacing + button_height)) + 1; - - max_evidence_on_page = evidence_columns * evidence_rows; - - for (int n = 0; n < max_evidence_on_page; ++n) { - int x_pos = (button_width + x_spacing) * x_mod_count; - int y_pos = (button_height + y_spacing) * y_mod_count; - - AOEvidenceButton *f_evidence = new AOEvidenceButton(ui_evidence_buttons, ao_app, x_pos, y_pos, button_width, button_height); - - ui_evidence_list.append(f_evidence); - - f_evidence->set_id(n); - - connect(f_evidence, SIGNAL(evidence_clicked(int)), this, SLOT(on_evidence_clicked(int))); - connect(f_evidence, SIGNAL(evidence_double_clicked(int)), this, SLOT(on_evidence_double_clicked(int))); - connect(f_evidence, SIGNAL(on_hover(int, bool)), this, SLOT(on_evidence_hover(int, bool))); - - ++x_mod_count; - - if (x_mod_count == evidence_columns) { - ++y_mod_count; - x_mod_count = 0; - } + set_font(ui_evidence_name, "", "evidence_name"); + set_font(ui_evidence_image_name, "", "evidence_image_name"); + set_font(ui_evidence_description, "", "evidence_description"); + + // Should properly refresh the evidence list + qDeleteAll(ui_evidence_list.begin(), ui_evidence_list.end()); + ui_evidence_list.clear(); + + set_size_and_pos(ui_evidence_button, "evidence_button"); + ui_evidence_button->set_image("evidence_button"); + ui_evidence_button->setToolTip(tr("Bring up the Evidence screen.")); + + set_size_and_pos(ui_evidence, "evidence_background"); + if (current_evidence_global) + ui_evidence->set_image("evidence_background"); + else + ui_evidence->set_image("evidence_background_private"); + + set_size_and_pos(ui_evidence_name, "evidence_name"); + + set_size_and_pos(ui_evidence_buttons, "evidence_buttons"); + + set_size_and_pos(ui_evidence_left, "evidence_left"); + ui_evidence_left->set_image("arrow_left"); + + set_size_and_pos(ui_evidence_right, "evidence_right"); + ui_evidence_right->set_image("arrow_right"); + + set_size_and_pos(ui_evidence_present, "evidence_present"); + ui_evidence_present->set_image("present"); + + set_size_and_pos(ui_evidence_overlay, "evidence_overlay"); + if (current_evidence_global) + ui_evidence_overlay->set_image("evidence_overlay"); + else + ui_evidence_overlay->set_image("evidence_overlay_private"); + + set_size_and_pos(ui_evidence_delete, "evidence_delete"); + ui_evidence_delete->set_image("evidence_delete"); + + set_size_and_pos(ui_evidence_image_name, "evidence_image_name"); + + set_size_and_pos(ui_evidence_image_button, "evidence_image_button"); + + set_size_and_pos(ui_evidence_x, "evidence_x"); + ui_evidence_x->set_image("evidence_x"); + + set_size_and_pos(ui_evidence_ok, "evidence_ok"); + ui_evidence_ok->set_image("evidence_ok"); + + set_size_and_pos(ui_evidence_switch, "evidence_switch"); + if (current_evidence_global) { + ui_evidence_switch->set_image("evidence_global"); + ui_evidence_switch->setToolTip(tr("Switch evidence to private inventory.")); + } + else { + ui_evidence_switch->set_image("evidence_private"); + ui_evidence_switch->setToolTip(tr("Switch evidence to global inventory.")); + } + + set_size_and_pos(ui_evidence_transfer, "evidence_transfer"); + if (current_evidence_global) { + ui_evidence_transfer->set_image("evidence_transfer"); + ui_evidence_transfer->setToolTip( + tr("Transfer evidence to private inventory.")); + } + else { + ui_evidence_transfer->set_image("evidence_transfer_private"); + ui_evidence_transfer->setToolTip( + tr("Transfer evidence to global inventory.")); + } + + set_size_and_pos(ui_evidence_save, "evidence_save"); + ui_evidence_save->set_image("evidence_save"); + if (current_evidence_global) + ui_evidence_save->hide(); + else + ui_evidence_save->show(); + + set_size_and_pos(ui_evidence_load, "evidence_load"); + ui_evidence_load->set_image("evidence_load"); + if (current_evidence_global) + ui_evidence_load->hide(); + else + ui_evidence_load->show(); + + set_size_and_pos(ui_evidence_description, "evidence_description"); + + QPoint f_spacing = ao_app->get_button_spacing("evidence_button_spacing", + "courtroom_design.ini"); + QPoint p_point = ao_app->get_button_spacing("evidence_button_size", + "courtroom_design.ini"); + + const int button_width = p_point.x(); + int x_spacing = f_spacing.x(); + int x_mod_count = 0; + + const int button_height = p_point.y(); + int y_spacing = f_spacing.y(); + int y_mod_count = 0; + + evidence_columns = ((ui_evidence_buttons->width() - button_width) / + (x_spacing + button_width)) + + 1; + evidence_rows = ((ui_evidence_buttons->height() - button_height) / + (y_spacing + button_height)) + + 1; + + max_evidence_on_page = evidence_columns * evidence_rows; + + for (int n = 0; n < max_evidence_on_page; ++n) { + int x_pos = (button_width + x_spacing) * x_mod_count; + int y_pos = (button_height + y_spacing) * y_mod_count; + + AOEvidenceButton *f_evidence = new AOEvidenceButton( + ui_evidence_buttons, ao_app, x_pos, y_pos, button_width, button_height); + + ui_evidence_list.append(f_evidence); + + f_evidence->set_id(n); + + connect(f_evidence, SIGNAL(evidence_clicked(int)), this, + SLOT(on_evidence_clicked(int))); + connect(f_evidence, SIGNAL(evidence_double_clicked(int)), this, + SLOT(on_evidence_double_clicked(int))); + connect(f_evidence, SIGNAL(on_hover(int, bool)), this, + SLOT(on_evidence_hover(int, bool))); + + ++x_mod_count; + + if (x_mod_count == evidence_columns) { + ++y_mod_count; + x_mod_count = 0; } + } } void Courtroom::set_evidence_list(QVector<evi_type> &p_evi_list) { - global_evidence_list = p_evi_list; - if (!current_evidence_global) - return; //We're on private evidence editing, wait for user to do their thing - - QVector<evi_type> old_list = local_evidence_list; - local_evidence_list.clear(); - local_evidence_list = p_evi_list; - - set_evidence_page(); - - if (ui_evidence_overlay->isVisible()) //Update the currently edited evidence for this user + global_evidence_list = p_evi_list; + if (!current_evidence_global) + return; // We're on private evidence editing, wait for user to do their + // thing + + QVector<evi_type> old_list = local_evidence_list; + local_evidence_list.clear(); + local_evidence_list = p_evi_list; + + set_evidence_page(); + + if (ui_evidence_overlay + ->isVisible()) // Update the currently edited evidence for this user + { + if (current_evidence >= local_evidence_list.size()) { + evidence_close(); + ui_evidence_name->setText(""); + } + else if (ui_evidence_description->isReadOnly()) // We haven't double clicked + // to edit it or anything { - if (current_evidence >= local_evidence_list.size()) { - evidence_close(); - ui_evidence_name->setText(""); - } - else if (ui_evidence_description->isReadOnly()) //We haven't double clicked to edit it or anything - { - on_evidence_double_clicked(current_evidence); - } - //Todo: make a function that compares two pieces of evidence for any differences - else if (compare_evidence_changed(old_list.at(current_evidence), local_evidence_list.at(current_evidence))) { - QMessageBox *msgBox = new QMessageBox; - - msgBox->setText("The piece of evidence you've been editing has changed."); - msgBox->setInformativeText("Do you wish to keep your changes?"); - msgBox->setDetailedText("Name: " + local_evidence_list.at(current_evidence).name + "\nImage: " + local_evidence_list.at(current_evidence).image + "\nDescription:\n" + local_evidence_list.at(current_evidence).description); - msgBox->setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox->setDefaultButton(QMessageBox::LastButton); - //msgBox->setWindowModality(Qt::NonModal); - int ret = msgBox->exec(); - switch (ret) { - case QMessageBox::Yes: - // "Keep changes" - break; - case QMessageBox::No: - // "Discard changes and keep theirs" - on_evidence_double_clicked(current_evidence); - break; - default: - // should never be reached - break; - } - } + on_evidence_double_clicked(current_evidence); + } + // Todo: make a function that compares two pieces of evidence for any + // differences + else if (compare_evidence_changed( + old_list.at(current_evidence), + local_evidence_list.at(current_evidence))) { + QMessageBox *msgBox = new QMessageBox; + + msgBox->setText("The piece of evidence you've been editing has changed."); + msgBox->setInformativeText("Do you wish to keep your changes?"); + msgBox->setDetailedText( + "Name: " + local_evidence_list.at(current_evidence).name + + "\nImage: " + local_evidence_list.at(current_evidence).image + + "\nDescription:\n" + + local_evidence_list.at(current_evidence).description); + msgBox->setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox->setDefaultButton(QMessageBox::LastButton); + // msgBox->setWindowModality(Qt::NonModal); + int ret = msgBox->exec(); + switch (ret) { + case QMessageBox::Yes: + // "Keep changes" + break; + case QMessageBox::No: + // "Discard changes and keep theirs" + on_evidence_double_clicked(current_evidence); + break; + default: + // should never be reached + break; + } } + } } void Courtroom::set_evidence_page() { - int total_evidence = local_evidence_list.size(); - - ui_evidence_left->hide(); - ui_evidence_right->hide(); + int total_evidence = local_evidence_list.size(); - for (AOEvidenceButton *i_button : ui_evidence_list) { - i_button->hide(); - } + ui_evidence_left->hide(); + ui_evidence_right->hide(); - //to account for the "add evidence" button - ++total_evidence; + for (AOEvidenceButton *i_button : ui_evidence_list) { + i_button->hide(); + } - int total_pages = total_evidence / max_evidence_on_page; - int evidence_on_page = 0; + // to account for the "add evidence" button + ++total_evidence; - if ((total_evidence % max_evidence_on_page) != 0) { - ++total_pages; - //i. e. not on the last page - if (total_pages > current_evidence_page + 1) - evidence_on_page = max_evidence_on_page; - else - evidence_on_page = total_evidence % max_evidence_on_page; - } - else - evidence_on_page = max_evidence_on_page; + int total_pages = total_evidence / max_evidence_on_page; + int evidence_on_page = 0; + if ((total_evidence % max_evidence_on_page) != 0) { + ++total_pages; + // i. e. not on the last page if (total_pages > current_evidence_page + 1) - ui_evidence_right->show(); - - if (current_evidence_page > 0) - ui_evidence_left->show(); - - for (int n_evidence_button = 0; n_evidence_button < evidence_on_page; ++n_evidence_button) { - int n_real_evidence = n_evidence_button + current_evidence_page * max_evidence_on_page; - AOEvidenceButton *f_evidence_button = ui_evidence_list.at(n_evidence_button); - - f_evidence_button->set_selected(false); - f_evidence_button->setToolTip(""); - if (n_real_evidence == (total_evidence - 1)) { - f_evidence_button->set_theme_image("addevidence.png"); - } - else if (n_real_evidence < (total_evidence - 1)) { - f_evidence_button->set_image(local_evidence_list.at(n_real_evidence).image); - - if (n_real_evidence == current_evidence) - f_evidence_button->set_selected(true); + evidence_on_page = max_evidence_on_page; + else + evidence_on_page = total_evidence % max_evidence_on_page; + } + else + evidence_on_page = max_evidence_on_page; + + if (total_pages > current_evidence_page + 1) + ui_evidence_right->show(); + + if (current_evidence_page > 0) + ui_evidence_left->show(); + + for (int n_evidence_button = 0; n_evidence_button < evidence_on_page; + ++n_evidence_button) { + int n_real_evidence = + n_evidence_button + current_evidence_page * max_evidence_on_page; + AOEvidenceButton *f_evidence_button = + ui_evidence_list.at(n_evidence_button); + + f_evidence_button->set_selected(false); + f_evidence_button->setToolTip(""); + if (n_real_evidence == (total_evidence - 1)) { + f_evidence_button->set_theme_image("addevidence.png"); + } + else if (n_real_evidence < (total_evidence - 1)) { + f_evidence_button->set_image( + local_evidence_list.at(n_real_evidence).image); - f_evidence_button->setToolTip(QString::number(n_real_evidence + 1) + ": " + local_evidence_list.at(n_real_evidence).name); - } - else - f_evidence_button->set_image(""); + if (n_real_evidence == current_evidence) + f_evidence_button->set_selected(true); - f_evidence_button->show(); + f_evidence_button->setToolTip( + QString::number(n_real_evidence + 1) + ": " + + local_evidence_list.at(n_real_evidence).name); } + else + f_evidence_button->set_image(""); + + f_evidence_button->show(); + } } void Courtroom::on_evidence_name_edited() { - ui_evidence_name->setReadOnly(true); - if (current_evidence >= local_evidence_list.size()) - return; + ui_evidence_name->setReadOnly(true); + if (current_evidence >= local_evidence_list.size()) + return; } void Courtroom::on_evidence_name_double_clicked() { - if (ui_evidence_overlay->isVisible()) { - ui_evidence_name->setReadOnly(false); - } - else { - ui_evidence_name->setReadOnly(true); - } + if (ui_evidence_overlay->isVisible()) { + ui_evidence_name->setReadOnly(false); + } + else { + ui_evidence_name->setReadOnly(true); + } } void Courtroom::on_evidence_image_name_double_clicked() { - ui_evidence_image_name->setReadOnly(false); + ui_evidence_image_name->setReadOnly(false); } void Courtroom::on_evidence_image_name_edited() { - ui_evidence_image_name->setReadOnly(true); - if (current_evidence >= local_evidence_list.size()) - return; + ui_evidence_image_name->setReadOnly(true); + if (current_evidence >= local_evidence_list.size()) + return; } void Courtroom::on_evidence_image_button_clicked() { - QDir dir(ao_app->get_base_path() + "evidence"); - QFileDialog dialog(this); - dialog.setFileMode(QFileDialog::ExistingFile); - dialog.setNameFilter(tr("Images (*.png)")); - dialog.setViewMode(QFileDialog::List); - dialog.setDirectory(dir); + QDir dir(ao_app->get_base_path() + "evidence"); + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::ExistingFile); + dialog.setNameFilter(tr("Images (*.png)")); + dialog.setViewMode(QFileDialog::List); + dialog.setDirectory(dir); - QStringList filenames; + QStringList filenames; - if (dialog.exec()) - filenames = dialog.selectedFiles(); + if (dialog.exec()) + filenames = dialog.selectedFiles(); - if (filenames.size() != 1) - return; + if (filenames.size() != 1) + return; - QString filename = filenames.at(0); - filename = dir.relativeFilePath(filename); - ui_evidence_image_name->setText(filename); - on_evidence_image_name_edited(); + QString filename = filenames.at(0); + filename = dir.relativeFilePath(filename); + ui_evidence_image_name->setText(filename); + on_evidence_image_name_edited(); } void Courtroom::on_evidence_clicked(int p_id) { - ui_evidence_name->setReadOnly(true); + ui_evidence_name->setReadOnly(true); - int f_real_id = p_id + max_evidence_on_page * current_evidence_page; - - if (f_real_id == local_evidence_list.size()) { - if (current_evidence_global) - ao_app->send_server_packet(new AOPacket("PE#<name>#<description>#empty.png#%")); - else { - evi_type f_evi; - f_evi.name = "<name>"; - f_evi.description = "<description>"; - f_evi.image = "empty.png"; - - local_evidence_list.append(f_evi); - private_evidence_list = local_evidence_list; - set_evidence_page(); - } - return; + int f_real_id = p_id + max_evidence_on_page * current_evidence_page; + + if (f_real_id == local_evidence_list.size()) { + if (current_evidence_global) + ao_app->send_server_packet( + new AOPacket("PE#<name>#<description>#empty.png#%")); + else { + evi_type f_evi; + f_evi.name = "<name>"; + f_evi.description = "<description>"; + f_evi.image = "empty.png"; + + local_evidence_list.append(f_evi); + private_evidence_list = local_evidence_list; + set_evidence_page(); } - else if (f_real_id > local_evidence_list.size()) - return; + return; + } + else if (f_real_id > local_evidence_list.size()) + return; - ui_evidence_name->setText(local_evidence_list.at(f_real_id).name); + ui_evidence_name->setText(local_evidence_list.at(f_real_id).name); - for (AOEvidenceButton *i_button : ui_evidence_list) - i_button->set_selected(false); + for (AOEvidenceButton *i_button : ui_evidence_list) + i_button->set_selected(false); - ui_evidence_list.at(p_id)->set_selected(true); + ui_evidence_list.at(p_id)->set_selected(true); - current_evidence = f_real_id; + current_evidence = f_real_id; - // ui_ic_chat_message->setFocus(); + // ui_ic_chat_message->setFocus(); } void Courtroom::on_evidence_double_clicked(int p_id) { - int f_real_id = p_id + max_evidence_on_page * current_evidence_page; + int f_real_id = p_id + max_evidence_on_page * current_evidence_page; - if (f_real_id >= local_evidence_list.size()) - return; + if (f_real_id >= local_evidence_list.size()) + return; - current_evidence = f_real_id; + current_evidence = f_real_id; - evi_type f_evi = local_evidence_list.at(f_real_id); + evi_type f_evi = local_evidence_list.at(f_real_id); - ui_evidence_description->clear(); - ui_evidence_description->appendPlainText(f_evi.description); - ui_evidence_description->setReadOnly(true); - ui_evidence_description->setToolTip("Double-click to edit..."); + ui_evidence_description->clear(); + ui_evidence_description->appendPlainText(f_evi.description); + ui_evidence_description->setReadOnly(true); + ui_evidence_description->setToolTip("Double-click to edit..."); - ui_evidence_name->setText(f_evi.name); - ui_evidence_name->setReadOnly(true); - ui_evidence_name->setToolTip("Double-click to edit..."); - ui_evidence_image_name->setText(f_evi.image); - ui_evidence_image_name->setReadOnly(true); - ui_evidence_image_name->setToolTip("Double-click to edit..."); + ui_evidence_name->setText(f_evi.name); + ui_evidence_name->setReadOnly(true); + ui_evidence_name->setToolTip("Double-click to edit..."); + ui_evidence_image_name->setText(f_evi.image); + ui_evidence_image_name->setReadOnly(true); + ui_evidence_image_name->setToolTip("Double-click to edit..."); - ui_evidence_overlay->show(); - ui_evidence_ok->hide(); + ui_evidence_overlay->show(); + ui_evidence_ok->hide(); - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_evidence_hover(int p_id, bool p_state) { - ui_evidence_name->setReadOnly(true); - int final_id = p_id + max_evidence_on_page * current_evidence_page; - - if (p_state) { - if (final_id == local_evidence_list.size()) - ui_evidence_name->setText(tr("Add new evidence...")); - else if (final_id < local_evidence_list.size()) - ui_evidence_name->setText(local_evidence_list.at(final_id).name); - } - else if (current_evidence < local_evidence_list.size()) - ui_evidence_name->setText(local_evidence_list.at(current_evidence).name); - else - ui_evidence_name->setText(""); + ui_evidence_name->setReadOnly(true); + int final_id = p_id + max_evidence_on_page * current_evidence_page; + + if (p_state) { + if (final_id == local_evidence_list.size()) + ui_evidence_name->setText(tr("Add new evidence...")); + else if (final_id < local_evidence_list.size()) + ui_evidence_name->setText(local_evidence_list.at(final_id).name); + } + else if (current_evidence < local_evidence_list.size()) + ui_evidence_name->setText(local_evidence_list.at(current_evidence).name); + else + ui_evidence_name->setText(""); } void Courtroom::on_evidence_left_clicked() { - --current_evidence_page; + --current_evidence_page; - set_evidence_page(); + set_evidence_page(); - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_evidence_right_clicked() { - ++current_evidence_page; + ++current_evidence_page; - set_evidence_page(); + set_evidence_page(); - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_evidence_present_clicked() { - if (!current_evidence_global) { - ui_evidence_present->hide(); - is_presenting_evidence = false; - return; //otherwise we get force-disconnected - } - if (is_presenting_evidence) - ui_evidence_present->set_image("present"); - else - ui_evidence_present->set_image("present_disabled"); + if (!current_evidence_global) { + ui_evidence_present->hide(); + is_presenting_evidence = false; + return; // otherwise we get force-disconnected + } + if (is_presenting_evidence) + ui_evidence_present->set_image("present"); + else + ui_evidence_present->set_image("present_disabled"); - is_presenting_evidence = !is_presenting_evidence; + is_presenting_evidence = !is_presenting_evidence; - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_evidence_delete_clicked() { - evidence_close(); - if (current_evidence_global) - ao_app->send_server_packet(new AOPacket("DE#" + QString::number(current_evidence) + "#%")); - else { - local_evidence_list.remove(current_evidence); - private_evidence_list = local_evidence_list; - set_evidence_page(); - } + evidence_close(); + if (current_evidence_global) + ao_app->send_server_packet( + new AOPacket("DE#" + QString::number(current_evidence) + "#%")); + else { + local_evidence_list.remove(current_evidence); + private_evidence_list = local_evidence_list; + set_evidence_page(); + } - current_evidence = 0; + current_evidence = 0; - ui_ic_chat_message->setFocus(); + ui_ic_chat_message->setFocus(); } void Courtroom::on_evidence_x_clicked() { - if (current_evidence >= local_evidence_list.size()) //Should never happen but you never know. - return; - - evi_type fake_evidence; - fake_evidence.name = ui_evidence_name->text(); - fake_evidence.description = ui_evidence_description->toPlainText(); - fake_evidence.image = ui_evidence_image_name->text(); - if (!compare_evidence_changed(fake_evidence, local_evidence_list.at(current_evidence))) { - evidence_close(); - return; - } - QMessageBox *msgBox = new QMessageBox; - msgBox->setText("Evidence has been modified."); - msgBox->setInformativeText("Do you want to save your changes?"); - msgBox->setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - msgBox->setDefaultButton(QMessageBox::Save); - int ret = msgBox->exec(); - switch (ret) { - case QMessageBox::Save: - evidence_close(); - on_evidence_ok_clicked(); - break; - case QMessageBox::Discard: - evidence_close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked, do nothing - break; - default: - // should never be reached - break; - } + if (current_evidence >= + local_evidence_list.size()) // Should never happen but you never know. + return; + + evi_type fake_evidence; + fake_evidence.name = ui_evidence_name->text(); + fake_evidence.description = ui_evidence_description->toPlainText(); + fake_evidence.image = ui_evidence_image_name->text(); + if (!compare_evidence_changed(fake_evidence, + local_evidence_list.at(current_evidence))) { + evidence_close(); + return; + } + QMessageBox *msgBox = new QMessageBox; + msgBox->setText("Evidence has been modified."); + msgBox->setInformativeText("Do you want to save your changes?"); + msgBox->setStandardButtons(QMessageBox::Save | QMessageBox::Discard | + QMessageBox::Cancel); + msgBox->setDefaultButton(QMessageBox::Save); + int ret = msgBox->exec(); + switch (ret) { + case QMessageBox::Save: + evidence_close(); + on_evidence_ok_clicked(); + break; + case QMessageBox::Discard: + evidence_close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked, do nothing + break; + default: + // should never be reached + break; + } } void Courtroom::on_evidence_ok_clicked() { - ui_evidence_name->setReadOnly(true); - ui_evidence_description->setReadOnly(true); - ui_evidence_image_name->setReadOnly(true); - if (current_evidence < local_evidence_list.size()) { - evi_type f_evi = local_evidence_list.at(current_evidence); - if (current_evidence_global) { - QStringList f_contents; - f_contents.append(QString::number(current_evidence)); - f_contents.append(ui_evidence_name->text()); - f_contents.append(ui_evidence_description->toPlainText()); - f_contents.append(ui_evidence_image_name->text()); - - ao_app->send_server_packet(new AOPacket("EE", f_contents)); - } - else { - f_evi.name = ui_evidence_name->text(); - f_evi.description = ui_evidence_description->toPlainText(); - f_evi.image = ui_evidence_image_name->text(); - local_evidence_list.replace(current_evidence, f_evi); - private_evidence_list = local_evidence_list; - ui_evidence_ok->hide(); - set_evidence_page(); - } + ui_evidence_name->setReadOnly(true); + ui_evidence_description->setReadOnly(true); + ui_evidence_image_name->setReadOnly(true); + if (current_evidence < local_evidence_list.size()) { + evi_type f_evi = local_evidence_list.at(current_evidence); + if (current_evidence_global) { + QStringList f_contents; + f_contents.append(QString::number(current_evidence)); + f_contents.append(ui_evidence_name->text()); + f_contents.append(ui_evidence_description->toPlainText()); + f_contents.append(ui_evidence_image_name->text()); + + ao_app->send_server_packet(new AOPacket("EE", f_contents)); + } + else { + f_evi.name = ui_evidence_name->text(); + f_evi.description = ui_evidence_description->toPlainText(); + f_evi.image = ui_evidence_image_name->text(); + local_evidence_list.replace(current_evidence, f_evi); + private_evidence_list = local_evidence_list; + ui_evidence_ok->hide(); + set_evidence_page(); } + } } void Courtroom::on_evidence_switch_clicked() { - evidence_close(); - evidence_switch(!current_evidence_global); - if (current_evidence_global) { - ui_evidence_switch->set_image("evidence_global"); - ui_evidence->set_image("evidence_background"); - ui_evidence_overlay->set_image("evidence_overlay"); - ui_evidence_transfer->set_image("evidence_transfer"); - ui_evidence_transfer->setToolTip(tr("Transfer evidence to private inventory.")); - ui_evidence_switch->setToolTip(tr("Current evidence is global. Click to switch to private.")); - } - else { - ui_evidence_switch->set_image("evidence_private"); - ui_evidence->set_image("evidence_background_private"); - ui_evidence_overlay->set_image("evidence_overlay_private"); - ui_evidence_transfer->set_image("evidence_transfer_private"); - ui_evidence_transfer->setToolTip(tr("Transfer evidence to global inventory.")); - ui_evidence_switch->setToolTip(tr("Current evidence is private. Click to switch to global.")); - } + evidence_close(); + evidence_switch(!current_evidence_global); + if (current_evidence_global) { + ui_evidence_switch->set_image("evidence_global"); + ui_evidence->set_image("evidence_background"); + ui_evidence_overlay->set_image("evidence_overlay"); + ui_evidence_transfer->set_image("evidence_transfer"); + ui_evidence_transfer->setToolTip( + tr("Transfer evidence to private inventory.")); + ui_evidence_switch->setToolTip( + tr("Current evidence is global. Click to switch to private.")); + } + else { + ui_evidence_switch->set_image("evidence_private"); + ui_evidence->set_image("evidence_background_private"); + ui_evidence_overlay->set_image("evidence_overlay_private"); + ui_evidence_transfer->set_image("evidence_transfer_private"); + ui_evidence_transfer->setToolTip( + tr("Transfer evidence to global inventory.")); + ui_evidence_switch->setToolTip( + tr("Current evidence is private. Click to switch to global.")); + } } void Courtroom::on_evidence_transfer_clicked() { - if (current_evidence >= local_evidence_list.size()) - return; - - QString name; - if (!current_evidence_global) //Transfer private evidence to global - { - evi_type f_evi = local_evidence_list.at(current_evidence); - - QStringList f_contents; - f_contents.append(f_evi.name); - f_contents.append(f_evi.description); - f_contents.append(f_evi.image); - - name = f_evi.name; - ao_app->send_server_packet(new AOPacket("PE", f_contents)); - } - else //Transfer global evidence to private - { - evi_type f_evi = local_evidence_list.at(current_evidence); - name = f_evi.name; - private_evidence_list.append(f_evi); - } - - QMessageBox *msgBox = new QMessageBox; - msgBox->setText("\"" + name + "\" has been transferred."); - msgBox->setStandardButtons(QMessageBox::Ok); - msgBox->setDefaultButton(QMessageBox::Ok); - msgBox->exec(); + if (current_evidence >= local_evidence_list.size()) + return; + + QString name; + if (!current_evidence_global) // Transfer private evidence to global + { + evi_type f_evi = local_evidence_list.at(current_evidence); + + QStringList f_contents; + f_contents.append(f_evi.name); + f_contents.append(f_evi.description); + f_contents.append(f_evi.image); + + name = f_evi.name; + ao_app->send_server_packet(new AOPacket("PE", f_contents)); + } + else // Transfer global evidence to private + { + evi_type f_evi = local_evidence_list.at(current_evidence); + name = f_evi.name; + private_evidence_list.append(f_evi); + } + + QMessageBox *msgBox = new QMessageBox; + msgBox->setText("\"" + name + "\" has been transferred."); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->exec(); } void Courtroom::on_evidence_edited() { - if (current_evidence >= local_evidence_list.size()) //Should never happen but you never know. - return; - evi_type fake_evidence; - fake_evidence.name = ui_evidence_name->text(); - fake_evidence.description = ui_evidence_description->toPlainText(); - fake_evidence.image = ui_evidence_image_name->text(); - if (compare_evidence_changed(fake_evidence, local_evidence_list.at(current_evidence))) - ui_evidence_ok->show(); - else - ui_evidence_ok->hide(); + if (current_evidence >= + local_evidence_list.size()) // Should never happen but you never know. + return; + evi_type fake_evidence; + fake_evidence.name = ui_evidence_name->text(); + fake_evidence.description = ui_evidence_description->toPlainText(); + fake_evidence.image = ui_evidence_image_name->text(); + if (compare_evidence_changed(fake_evidence, + local_evidence_list.at(current_evidence))) + ui_evidence_ok->show(); + else + ui_evidence_ok->hide(); } void Courtroom::evidence_close() { - ui_evidence_description->setReadOnly(true); - ui_evidence_description->setToolTip(""); - ui_evidence_name->setReadOnly(true); - ui_evidence_name->setToolTip(""); - ui_evidence_image_name->setReadOnly(true); - ui_evidence_image_name->setToolTip(""); - ui_evidence_overlay->hide(); - ui_ic_chat_message->setFocus(); + ui_evidence_description->setReadOnly(true); + ui_evidence_description->setToolTip(""); + ui_evidence_name->setReadOnly(true); + ui_evidence_name->setToolTip(""); + ui_evidence_image_name->setReadOnly(true); + ui_evidence_image_name->setToolTip(""); + ui_evidence_overlay->hide(); + ui_ic_chat_message->setFocus(); } void Courtroom::evidence_switch(bool global) { - current_evidence_global = global; - is_presenting_evidence = false; - ui_evidence_present->set_image("present"); - local_evidence_list.clear(); - if (current_evidence_global) { - local_evidence_list = global_evidence_list; - ui_evidence_present->show(); - ui_evidence_save->hide(); - ui_evidence_load->hide(); - } - else { - local_evidence_list = private_evidence_list; - ui_evidence_present->hide(); - ui_evidence_save->show(); - ui_evidence_load->show(); - } - set_evidence_page(); + current_evidence_global = global; + is_presenting_evidence = false; + ui_evidence_present->set_image("present"); + local_evidence_list.clear(); + if (current_evidence_global) { + local_evidence_list = global_evidence_list; + ui_evidence_present->show(); + ui_evidence_save->hide(); + ui_evidence_load->hide(); + } + else { + local_evidence_list = private_evidence_list; + ui_evidence_present->hide(); + ui_evidence_save->show(); + ui_evidence_load->show(); + } + set_evidence_page(); } void Courtroom::on_evidence_save_clicked() { - if (current_evidence_global) - return; //Don't allow saving/loading operations when in global inventory mode for now - - QString p_path = QFileDialog::getSaveFileName(this, tr("Save Inventory"), "base/inventories/", tr("Ini Files (*.ini)")); - if (p_path.isEmpty()) - return; - - evidence_close(); - ui_evidence_name->setText(""); - - QSettings inventory(p_path, QSettings::IniFormat); - inventory.clear(); - for (int i = 0; i < local_evidence_list.size(); i++) { - inventory.beginGroup(QString::number(i)); - inventory.setValue("name", local_evidence_list[i].name); - inventory.setValue("description", local_evidence_list[i].description); - inventory.setValue("image", local_evidence_list[i].image); - inventory.endGroup(); - } - inventory.sync(); + if (current_evidence_global) + return; // Don't allow saving/loading operations when in global inventory + // mode for now + + QString p_path = QFileDialog::getSaveFileName( + this, tr("Save Inventory"), "base/inventories/", tr("Ini Files (*.ini)")); + if (p_path.isEmpty()) + return; + + evidence_close(); + ui_evidence_name->setText(""); + + QSettings inventory(p_path, QSettings::IniFormat); + inventory.clear(); + for (int i = 0; i < local_evidence_list.size(); i++) { + inventory.beginGroup(QString::number(i)); + inventory.setValue("name", local_evidence_list[i].name); + inventory.setValue("description", local_evidence_list[i].description); + inventory.setValue("image", local_evidence_list[i].image); + inventory.endGroup(); + } + inventory.sync(); } void Courtroom::on_evidence_load_clicked() { - if (current_evidence_global) - return; //Don't allow saving/loading operations when in global inventory mode for now - - QString p_path = QFileDialog::getOpenFileName(this, tr("Open Inventory"), "base/inventories/", tr("Ini Files (*.ini)")); - if (p_path.isEmpty()) - return; - - evidence_close(); - ui_evidence_name->setText(""); - - QSettings inventory(p_path, QSettings::IniFormat); - local_evidence_list.clear(); - foreach (QString evi, inventory.childGroups()) { - if (evi == "General") - continue; - - evi_type f_evi; - f_evi.name = inventory.value(evi + "/name", "UNKNOWN").value<QString>(); - f_evi.description = inventory.value(evi + "/description", "UNKNOWN").value<QString>(); - f_evi.image = inventory.value(evi + "/image", "UNKNOWN.png").value<QString>(); - local_evidence_list.append(f_evi); - } - private_evidence_list = local_evidence_list; - set_evidence_page(); + if (current_evidence_global) + return; // Don't allow saving/loading operations when in global inventory + // mode for now + + QString p_path = QFileDialog::getOpenFileName( + this, tr("Open Inventory"), "base/inventories/", tr("Ini Files (*.ini)")); + if (p_path.isEmpty()) + return; + + evidence_close(); + ui_evidence_name->setText(""); + + QSettings inventory(p_path, QSettings::IniFormat); + local_evidence_list.clear(); + foreach (QString evi, inventory.childGroups()) { + if (evi == "General") + continue; + + evi_type f_evi; + f_evi.name = inventory.value(evi + "/name", "UNKNOWN").value<QString>(); + f_evi.description = + inventory.value(evi + "/description", "UNKNOWN").value<QString>(); + f_evi.image = + inventory.value(evi + "/image", "UNKNOWN.png").value<QString>(); + local_evidence_list.append(f_evi); + } + private_evidence_list = local_evidence_list; + set_evidence_page(); } bool Courtroom::compare_evidence_changed(evi_type evi_a, evi_type evi_b) { - return evi_a.name != evi_b.name || evi_a.image != evi_b.image || evi_a.description != evi_b.description; + return evi_a.name != evi_b.name || evi_a.image != evi_b.image || + evi_a.description != evi_b.description; } diff --git a/src/file_functions.cpp b/src/file_functions.cpp index e2b28824..e64a46bf 100644 --- a/src/file_functions.cpp +++ b/src/file_functions.cpp @@ -2,21 +2,21 @@ bool file_exists(QString file_path) { - QFileInfo check_file(file_path); + QFileInfo check_file(file_path); - return check_file.exists() && check_file.isFile(); + return check_file.exists() && check_file.isFile(); } bool dir_exists(QString dir_path) { - QDir check_dir(dir_path); + QDir check_dir(dir_path); - return check_dir.exists(); + return check_dir.exists(); } bool exists(QString p_path) { - QFile file(p_path); + QFile file(p_path); - return file.exists(); + return file.exists(); } diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp index 21d72ece..96c72eb5 100644 --- a/src/hardware_functions.cpp +++ b/src/hardware_functions.cpp @@ -10,14 +10,15 @@ static BOOL bIsRetrieved; QString get_hdid() { - bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial, nullptr, nullptr, nullptr, 0); - - if (bIsRetrieved) - return QString::number(dwVolSerial, 16); - else - //a totally random string - //what could possibly go wrong - return "gxsps32sa9fnwic92mfbs0"; + bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial, + nullptr, nullptr, nullptr, 0); + + if (bIsRetrieved) + return QString::number(dwVolSerial, 16); + else + // a totally random string + // what could possibly go wrong + return "gxsps32sa9fnwic92mfbs0"; } #elif (defined(LINUX) || defined(__linux__)) @@ -27,24 +28,24 @@ QString get_hdid() QString get_hdid() { - QFile fstab_file("/etc/fstab"); - if (!fstab_file.open(QIODevice::ReadOnly)) - return "gxcps32sa9fnwic92mfbs0"; + QFile fstab_file("/etc/fstab"); + if (!fstab_file.open(QIODevice::ReadOnly)) + return "gxcps32sa9fnwic92mfbs0"; - QTextStream in(&fstab_file); + QTextStream in(&fstab_file); - while (!in.atEnd()) { - QString line = in.readLine(); + while (!in.atEnd()) { + QString line = in.readLine(); - if (line.startsWith("UUID")) { - QStringList line_elements = line.split("="); + if (line.startsWith("UUID")) { + QStringList line_elements = line.split("="); - if (line_elements.size() > 1) - return line_elements.at(1).left(23).trimmed(); - } + if (line_elements.size() > 1) + return line_elements.at(1).left(23).trimmed(); } + } - return "gxcpz32sa9fnwic92mfbs0"; + return "gxcpz32sa9fnwic92mfbs0"; } #elif defined __APPLE__ @@ -53,25 +54,25 @@ QString get_hdid() QString get_hdid() { - CFStringRef serial; - char buffer[64] = {0}; - QString hdid; - io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, - IOServiceMatching("IOPlatformExpertDevice")); - if (platformExpert) { - CFTypeRef serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, - CFSTR(kIOPlatformSerialNumberKey), - kCFAllocatorDefault, 0); - if (serialNumberAsCFString) { - serial = (CFStringRef)serialNumberAsCFString; - } - if (CFStringGetCString(serial, buffer, 64, kCFStringEncodingUTF8)) { - hdid = buffer; - } - - IOObjectRelease(platformExpert); + CFStringRef serial; + char buffer[64] = {0}; + QString hdid; + io_service_t platformExpert = IOServiceGetMatchingService( + kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); + if (platformExpert) { + CFTypeRef serialNumberAsCFString = IORegistryEntryCreateCFProperty( + platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, + 0); + if (serialNumberAsCFString) { + serial = (CFStringRef)serialNumberAsCFString; } - return hdid; + if (CFStringGetCString(serial, buffer, 64, kCFStringEncodingUTF8)) { + hdid = buffer; + } + + IOObjectRelease(platformExpert); + } + return hdid; } #else diff --git a/src/hex_functions.cpp b/src/hex_functions.cpp index 63293c14..1e35718f 100644 --- a/src/hex_functions.cpp +++ b/src/hex_functions.cpp @@ -1,17 +1,17 @@ #include "hex_functions.h" namespace omni { - std::string int_to_hex(unsigned int input) - { - if (input > 255) - return "FF"; +std::string int_to_hex(unsigned int input) +{ + if (input > 255) + return "FF"; - std::stringstream stream; - stream << std::setfill('0') << std::setw(sizeof(char) * 2) - << std::hex << input; - std::string result(stream.str()); - std::transform(result.begin(), result.end(), result.begin(), ::toupper); + std::stringstream stream; + stream << std::setfill('0') << std::setw(sizeof(char) * 2) << std::hex + << input; + std::string result(stream.str()); + std::transform(result.begin(), result.end(), result.begin(), ::toupper); - return result; - } + return result; +} } // namespace omni diff --git a/src/lobby.cpp b/src/lobby.cpp index 30a8ed02..99172a9f 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -7,515 +7,523 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() { - ao_app = p_ao_app; - - this->setWindowTitle(tr("Attorney Online 2")); - this->setWindowIcon(QIcon(":/logo.png")); - - ui_background = new AOImage(this, ao_app); - ui_public_servers = new AOButton(this, ao_app); - ui_favorites = new AOButton(this, ao_app); - ui_refresh = new AOButton(this, ao_app); - ui_add_to_fav = new AOButton(this, ao_app); - ui_connect = new AOButton(this, ao_app); - ui_version = new QLabel(this); - ui_about = new AOButton(this, ao_app); - ui_settings = new AOButton(this, ao_app); - - ui_server_list = new QTreeWidget(this); - ui_server_list->setHeaderLabels({"#", "Name"}); //, "Players"}); - ui_server_list->hideColumn(0); - - ui_server_search = new QLineEdit(this); - ui_server_search->setFrame(false); - ui_server_search->setPlaceholderText(tr("Search")); - - ui_player_count = new QLabel(this); - ui_description = new AOTextArea(this); - ui_description->setOpenExternalLinks(true); - ui_chatbox = new AOTextArea(this); - ui_chatbox->setOpenExternalLinks(true); - ui_chatname = new QLineEdit(this); - ui_chatname->setPlaceholderText(tr("Name")); - ui_chatname->setText(ao_app->get_ooc_name()); - ui_chatmessage = new QLineEdit(this); - ui_loading_background = new AOImage(this, ao_app); - ui_loading_text = new QTextEdit(ui_loading_background); - ui_progress_bar = new QProgressBar(ui_loading_background); - ui_progress_bar->setMinimum(0); - ui_progress_bar->setMaximum(100); - ui_progress_bar->setStyleSheet("QProgressBar{ color: white; }"); - ui_cancel = new AOButton(ui_loading_background, ao_app); - - connect(ui_public_servers, SIGNAL(clicked()), this, SLOT(on_public_servers_clicked())); - connect(ui_favorites, SIGNAL(clicked()), this, SLOT(on_favorites_clicked())); - connect(ui_refresh, SIGNAL(pressed()), this, SLOT(on_refresh_pressed())); - connect(ui_refresh, SIGNAL(released()), this, SLOT(on_refresh_released())); - connect(ui_add_to_fav, SIGNAL(pressed()), this, SLOT(on_add_to_fav_pressed())); - connect(ui_add_to_fav, SIGNAL(released()), this, SLOT(on_add_to_fav_released())); - connect(ui_connect, SIGNAL(pressed()), this, SLOT(on_connect_pressed())); - connect(ui_connect, SIGNAL(released()), this, SLOT(on_connect_released())); - connect(ui_about, SIGNAL(clicked()), this, SLOT(on_about_clicked())); - connect(ui_settings, SIGNAL(clicked()), this, SLOT(on_settings_clicked())); - connect(ui_server_list, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(on_server_list_clicked(QTreeWidgetItem *, int))); - connect(ui_server_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(on_server_list_doubleclicked(QTreeWidgetItem *, int))); - connect(ui_server_search, SIGNAL(textChanged(QString)), this, SLOT(on_server_search_edited(QString))); - connect(ui_chatmessage, SIGNAL(returnPressed()), this, SLOT(on_chatfield_return_pressed())); - connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled())); + ao_app = p_ao_app; + + this->setWindowTitle(tr("Attorney Online 2")); + this->setWindowIcon(QIcon(":/logo.png")); + + ui_background = new AOImage(this, ao_app); + ui_public_servers = new AOButton(this, ao_app); + ui_favorites = new AOButton(this, ao_app); + ui_refresh = new AOButton(this, ao_app); + ui_add_to_fav = new AOButton(this, ao_app); + ui_connect = new AOButton(this, ao_app); + ui_version = new QLabel(this); + ui_about = new AOButton(this, ao_app); + ui_settings = new AOButton(this, ao_app); + + ui_server_list = new QTreeWidget(this); + ui_server_list->setHeaderLabels({"#", "Name"}); //, "Players"}); + ui_server_list->hideColumn(0); + + ui_server_search = new QLineEdit(this); + ui_server_search->setFrame(false); + ui_server_search->setPlaceholderText(tr("Search")); + + ui_player_count = new QLabel(this); + ui_description = new AOTextArea(this); + ui_description->setOpenExternalLinks(true); + ui_chatbox = new AOTextArea(this); + ui_chatbox->setOpenExternalLinks(true); + ui_chatname = new QLineEdit(this); + ui_chatname->setPlaceholderText(tr("Name")); + ui_chatname->setText(ao_app->get_ooc_name()); + ui_chatmessage = new QLineEdit(this); + ui_loading_background = new AOImage(this, ao_app); + ui_loading_text = new QTextEdit(ui_loading_background); + ui_progress_bar = new QProgressBar(ui_loading_background); + ui_progress_bar->setMinimum(0); + ui_progress_bar->setMaximum(100); + ui_progress_bar->setStyleSheet("QProgressBar{ color: white; }"); + ui_cancel = new AOButton(ui_loading_background, ao_app); + + connect(ui_public_servers, SIGNAL(clicked()), this, + SLOT(on_public_servers_clicked())); + connect(ui_favorites, SIGNAL(clicked()), this, SLOT(on_favorites_clicked())); + connect(ui_refresh, SIGNAL(pressed()), this, SLOT(on_refresh_pressed())); + connect(ui_refresh, SIGNAL(released()), this, SLOT(on_refresh_released())); + connect(ui_add_to_fav, SIGNAL(pressed()), this, + SLOT(on_add_to_fav_pressed())); + connect(ui_add_to_fav, SIGNAL(released()), this, + SLOT(on_add_to_fav_released())); + connect(ui_connect, SIGNAL(pressed()), this, SLOT(on_connect_pressed())); + connect(ui_connect, SIGNAL(released()), this, SLOT(on_connect_released())); + connect(ui_about, SIGNAL(clicked()), this, SLOT(on_about_clicked())); + connect(ui_settings, SIGNAL(clicked()), this, SLOT(on_settings_clicked())); + connect(ui_server_list, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, + SLOT(on_server_list_clicked(QTreeWidgetItem *, int))); + connect(ui_server_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), + this, SLOT(on_server_list_doubleclicked(QTreeWidgetItem *, int))); + connect(ui_server_search, SIGNAL(textChanged(QString)), this, + SLOT(on_server_search_edited(QString))); + connect(ui_chatmessage, SIGNAL(returnPressed()), this, + SLOT(on_chatfield_return_pressed())); + connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled())); + + ui_connect->setEnabled(false); + + list_servers(); + + set_widgets(); +} + +// sets images, position and size +void Lobby::set_widgets() +{ + ao_app->reload_theme(); - ui_connect->setEnabled(false); + QString filename = "lobby_design.ini"; - list_servers(); + pos_size_type f_lobby = ao_app->get_element_dimensions("lobby", filename); - set_widgets(); -} + if (f_lobby.width < 0 || f_lobby.height < 0) { + qDebug() << "W: did not find lobby width or height in " << filename; -//sets images, position and size -void Lobby::set_widgets() -{ - ao_app->reload_theme(); + // Most common symptom of bad config files and missing assets. + call_notice( + tr("It doesn't look like your client is set up correctly.\n" + "Did you download all resources correctly from tiny.cc/getao, " + "including the large 'base' folder?")); - QString filename = "lobby_design.ini"; + this->resize(517, 666); + } + else { + this->resize(f_lobby.width, f_lobby.height); + } - pos_size_type f_lobby = ao_app->get_element_dimensions("lobby", filename); + set_size_and_pos(ui_background, "lobby"); + ui_background->set_image("lobbybackground"); - if (f_lobby.width < 0 || f_lobby.height < 0) { - qDebug() << "W: did not find lobby width or height in " << filename; + set_size_and_pos(ui_public_servers, "public_servers"); + ui_public_servers->set_image("publicservers_selected"); - // Most common symptom of bad config files and missing assets. - call_notice(tr("It doesn't look like your client is set up correctly.\n" - "Did you download all resources correctly from tiny.cc/getao, " - "including the large 'base' folder?")); + set_size_and_pos(ui_favorites, "favorites"); + ui_favorites->set_image("favorites"); - this->resize(517, 666); - } - else { - this->resize(f_lobby.width, f_lobby.height); - } + set_size_and_pos(ui_refresh, "refresh"); + ui_refresh->set_image("refresh"); - set_size_and_pos(ui_background, "lobby"); - ui_background->set_image("lobbybackground"); + set_size_and_pos(ui_add_to_fav, "add_to_fav"); + ui_add_to_fav->set_image("addtofav"); - set_size_and_pos(ui_public_servers, "public_servers"); - ui_public_servers->set_image("publicservers_selected"); + set_size_and_pos(ui_connect, "connect"); + ui_connect->set_image("connect"); - set_size_and_pos(ui_favorites, "favorites"); - ui_favorites->set_image("favorites"); + set_size_and_pos(ui_version, "version"); + ui_version->setText(tr("Version: KFO%1").arg(ao_app->get_version_string())); - set_size_and_pos(ui_refresh, "refresh"); - ui_refresh->set_image("refresh"); + set_size_and_pos(ui_about, "about"); + ui_about->set_image("about"); - set_size_and_pos(ui_add_to_fav, "add_to_fav"); - ui_add_to_fav->set_image("addtofav"); + set_size_and_pos(ui_settings, "settings"); + ui_settings->setText(tr("Settings")); + ui_settings->set_image("settings"); + ui_settings->setToolTip( + tr("Allows you to change various aspects of the client.")); - set_size_and_pos(ui_connect, "connect"); - ui_connect->set_image("connect"); + set_size_and_pos(ui_server_list, "server_list"); + ui_server_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);" + "font: bold;"); - set_size_and_pos(ui_version, "version"); - ui_version->setText(tr("Version: KFO%1").arg(ao_app->get_version_string())); + set_size_and_pos(ui_server_search, "server_search"); + ui_server_search->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); - set_size_and_pos(ui_about, "about"); - ui_about->set_image("about"); + set_size_and_pos(ui_player_count, "player_count"); + ui_player_count->setText(tr("Offline")); + ui_player_count->setStyleSheet("font: bold;" + "color: white;" + "qproperty-alignment: AlignCenter;"); - set_size_and_pos(ui_settings, "settings"); - ui_settings->setText(tr("Settings")); - ui_settings->set_image("settings"); - ui_settings->setToolTip(tr("Allows you to change various aspects of the client.")); + set_size_and_pos(ui_description, "description"); + ui_description->setReadOnly(true); + ui_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" + "color: white;"); - set_size_and_pos(ui_server_list, "server_list"); - ui_server_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "font: bold;"); + set_size_and_pos(ui_chatbox, "chatbox"); + ui_chatbox->setReadOnly(true); + ui_chatbox->setStyleSheet( + "QTextBrowser{background-color: rgba(0, 0, 0, 0);}"); - set_size_and_pos(ui_server_search, "server_search"); - ui_server_search->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); + set_size_and_pos(ui_chatname, "chatname"); + ui_chatname->setStyleSheet("background-color: rgba(0, 0, 0, 0);" + "selection-background-color: rgba(0, 0, 0, 0);"); - set_size_and_pos(ui_player_count, "player_count"); - ui_player_count->setText(tr("Offline")); - ui_player_count->setStyleSheet("font: bold;" - "color: white;" - "qproperty-alignment: AlignCenter;"); - - set_size_and_pos(ui_description, "description"); - ui_description->setReadOnly(true); - ui_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "color: white;"); - - set_size_and_pos(ui_chatbox, "chatbox"); - ui_chatbox->setReadOnly(true); - ui_chatbox->setStyleSheet("QTextBrowser{background-color: rgba(0, 0, 0, 0);}"); - - set_size_and_pos(ui_chatname, "chatname"); - ui_chatname->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "selection-background-color: rgba(0, 0, 0, 0);"); - - set_size_and_pos(ui_chatmessage, "chatmessage"); - ui_chatmessage->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "selection-background-color: rgba(0, 0, 0, 0);"); - - ui_loading_background->resize(this->width(), this->height()); - ui_loading_background->set_image("loadingbackground"); - - set_size_and_pos(ui_loading_text, "loading_label"); - ui_loading_text->setFont(QFont("Arial", 20, QFont::Bold)); - ui_loading_text->setReadOnly(true); - ui_loading_text->setAlignment(Qt::AlignCenter); - ui_loading_text->setFrameStyle(QFrame::NoFrame); - ui_loading_text->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "color: rgba(255, 128, 0, 255);"); - ui_loading_text->append(tr("Loading")); - - set_size_and_pos(ui_progress_bar, "progress_bar"); - set_size_and_pos(ui_cancel, "cancel"); - ui_cancel->setText(tr("Cancel")); - - ui_loading_background->hide(); - - set_fonts(); - set_stylesheets(); + set_size_and_pos(ui_chatmessage, "chatmessage"); + ui_chatmessage->setStyleSheet( + "background-color: rgba(0, 0, 0, 0);" + "selection-background-color: rgba(0, 0, 0, 0);"); + + ui_loading_background->resize(this->width(), this->height()); + ui_loading_background->set_image("loadingbackground"); + + set_size_and_pos(ui_loading_text, "loading_label"); + ui_loading_text->setFont(QFont("Arial", 20, QFont::Bold)); + ui_loading_text->setReadOnly(true); + ui_loading_text->setAlignment(Qt::AlignCenter); + ui_loading_text->setFrameStyle(QFrame::NoFrame); + ui_loading_text->setStyleSheet("background-color: rgba(0, 0, 0, 0);" + "color: rgba(255, 128, 0, 255);"); + ui_loading_text->append(tr("Loading")); + + set_size_and_pos(ui_progress_bar, "progress_bar"); + set_size_and_pos(ui_cancel, "cancel"); + ui_cancel->setText(tr("Cancel")); + + ui_loading_background->hide(); + + set_fonts(); + set_stylesheets(); } void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier) { - QString filename = "lobby_design.ini"; + QString filename = "lobby_design.ini"; - pos_size_type design_ini_result = ao_app->get_element_dimensions(p_identifier, filename); + pos_size_type design_ini_result = + ao_app->get_element_dimensions(p_identifier, filename); - if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find " << p_identifier << " in " << filename; - p_widget->hide(); - } - else { - p_widget->move(design_ini_result.x, design_ini_result.y); - p_widget->resize(design_ini_result.width, design_ini_result.height); - } + if (design_ini_result.width < 0 || design_ini_result.height < 0) { + qDebug() << "W: could not find " << p_identifier << " in " << filename; + p_widget->hide(); + } + else { + p_widget->move(design_ini_result.x, design_ini_result.y); + p_widget->resize(design_ini_result.width, design_ini_result.height); + } } void Lobby::set_fonts() { - set_font(ui_player_count, "player_count"); - set_font(ui_description, "description"); - set_font(ui_chatbox, "chatbox"); - set_font(ui_chatname, "chatname"); - set_font(ui_chatmessage, "chatmessage"); - set_font(ui_loading_text, "loading_text"); - set_font(ui_server_list, "server_list"); + set_font(ui_player_count, "player_count"); + set_font(ui_description, "description"); + set_font(ui_chatbox, "chatbox"); + set_font(ui_chatname, "chatname"); + set_font(ui_chatmessage, "chatmessage"); + set_font(ui_loading_text, "loading_text"); + set_font(ui_server_list, "server_list"); } void Lobby::set_stylesheet(QWidget *widget, QString target_tag) { - QString f_file = "lobby_stylesheets.css"; - QString style_sheet_string = ao_app->get_tagged_stylesheet(target_tag, f_file); - if (style_sheet_string != "") - widget->setStyleSheet(style_sheet_string); + QString f_file = "lobby_stylesheets.css"; + QString style_sheet_string = + ao_app->get_tagged_stylesheet(target_tag, f_file); + if (style_sheet_string != "") + widget->setStyleSheet(style_sheet_string); } void Lobby::set_stylesheets() { - set_stylesheet(ui_player_count, "[PLAYER COUNT]"); - set_stylesheet(ui_description, "[DESCRIPTION]"); - set_stylesheet(ui_chatbox, "[CHAT BOX]"); - set_stylesheet(ui_chatname, "[CHAT NAME]"); - set_stylesheet(ui_chatmessage, "[CHAT MESSAGE]"); - set_stylesheet(ui_loading_text, "[LOADING TEXT]"); - set_stylesheet(ui_server_list, "[SERVER LIST]"); + set_stylesheet(ui_player_count, "[PLAYER COUNT]"); + set_stylesheet(ui_description, "[DESCRIPTION]"); + set_stylesheet(ui_chatbox, "[CHAT BOX]"); + set_stylesheet(ui_chatname, "[CHAT NAME]"); + set_stylesheet(ui_chatmessage, "[CHAT MESSAGE]"); + set_stylesheet(ui_loading_text, "[LOADING TEXT]"); + set_stylesheet(ui_server_list, "[SERVER LIST]"); } void Lobby::set_font(QWidget *widget, QString p_identifier) { - QString design_file = "lobby_fonts.ini"; - int f_weight = ao_app->get_font_size(p_identifier, design_file); - QString class_name = widget->metaObject()->className(); - QString font_name = ao_app->get_font_name("font_" + p_identifier, design_file); - QFont font(font_name, f_weight); - bool use = ao_app->get_font_size("use_custom_fonts", design_file) == 1; - if (use) { - widget->setFont(font); - QColor f_color = ao_app->get_color(p_identifier + "_color", design_file); - bool bold = ao_app->get_font_size(p_identifier + "_bold", design_file) == 1; // is the font bold or not? - bool center = ao_app->get_font_size(p_identifier + "_center", design_file) == 1; // should it be centered? - QString is_bold = ""; - if (bold) - is_bold = "bold"; - QString is_center = ""; - if (center) - is_center = "qproperty-alignment: AlignCenter;"; - QString style_sheet_string = class_name + " { background-color: rgba(0, 0, 0, 0);\n" + - "color: rgba(" + - QString::number(f_color.red()) + ", " + - QString::number(f_color.green()) + ", " + - QString::number(f_color.blue()) + ", 255);\n" + - is_center + "\n" + - "font: " + is_bold + "; }"; - widget->setStyleSheet(style_sheet_string); - } - return; + QString design_file = "lobby_fonts.ini"; + int f_weight = ao_app->get_font_size(p_identifier, design_file); + QString class_name = widget->metaObject()->className(); + QString font_name = + ao_app->get_font_name("font_" + p_identifier, design_file); + QFont font(font_name, f_weight); + bool use = ao_app->get_font_size("use_custom_fonts", design_file) == 1; + if (use) { + widget->setFont(font); + QColor f_color = ao_app->get_color(p_identifier + "_color", design_file); + bool bold = ao_app->get_font_size(p_identifier + "_bold", design_file) == + 1; // is the font bold or not? + bool center = + ao_app->get_font_size(p_identifier + "_center", design_file) == + 1; // should it be centered? + QString is_bold = ""; + if (bold) + is_bold = "bold"; + QString is_center = ""; + if (center) + is_center = "qproperty-alignment: AlignCenter;"; + QString style_sheet_string = + class_name + " { background-color: rgba(0, 0, 0, 0);\n" + + "color: rgba(" + QString::number(f_color.red()) + ", " + + QString::number(f_color.green()) + ", " + + QString::number(f_color.blue()) + ", 255);\n" + is_center + "\n" + + "font: " + is_bold + "; }"; + widget->setStyleSheet(style_sheet_string); + } + return; } void Lobby::set_loading_text(QString p_text) { - ui_loading_text->clear(); - ui_loading_text->setAlignment(Qt::AlignCenter); - ui_loading_text->append(p_text); + ui_loading_text->clear(); + ui_loading_text->setAlignment(Qt::AlignCenter); + ui_loading_text->append(p_text); } QString Lobby::get_chatlog() { - QString return_value = ui_chatbox->toPlainText(); + QString return_value = ui_chatbox->toPlainText(); - return return_value; + return return_value; } int Lobby::get_selected_server() { - return ui_server_list->currentItem()->text(0).toInt(); + return ui_server_list->currentItem()->text(0).toInt(); } void Lobby::set_loading_value(int p_value) { - ui_progress_bar->setValue(p_value); + ui_progress_bar->setValue(p_value); } void Lobby::on_public_servers_clicked() { - ui_public_servers->set_image("publicservers_selected"); - ui_favorites->set_image("favorites"); + ui_public_servers->set_image("publicservers_selected"); + ui_favorites->set_image("favorites"); - list_servers(); + list_servers(); - public_servers_selected = true; + public_servers_selected = true; } void Lobby::on_favorites_clicked() { - ui_favorites->set_image("favorites_selected"); - ui_public_servers->set_image("publicservers"); + ui_favorites->set_image("favorites_selected"); + ui_public_servers->set_image("publicservers"); - ao_app->set_favorite_list(); - //ao_app->favorite_list = read_serverlist_txt(); + ao_app->set_favorite_list(); + // ao_app->favorite_list = read_serverlist_txt(); - list_favorites(); + list_favorites(); - public_servers_selected = false; + public_servers_selected = false; } -void Lobby::on_refresh_pressed() -{ - ui_refresh->set_image("refresh_pressed"); -} +void Lobby::on_refresh_pressed() { ui_refresh->set_image("refresh_pressed"); } void Lobby::on_refresh_released() { - ui_refresh->set_image("refresh"); + ui_refresh->set_image("refresh"); - AOPacket *f_packet = new AOPacket("ALL#%"); + AOPacket *f_packet = new AOPacket("ALL#%"); - ao_app->send_ms_packet(f_packet); + ao_app->send_ms_packet(f_packet); } void Lobby::on_add_to_fav_pressed() { - ui_add_to_fav->set_image("addtofav_pressed"); + ui_add_to_fav->set_image("addtofav_pressed"); } void Lobby::on_add_to_fav_released() { - ui_add_to_fav->set_image("addtofav"); + ui_add_to_fav->set_image("addtofav"); - //you cant add favorites from favorites m8 - if (!public_servers_selected) - return; + // you cant add favorites from favorites m8 + if (!public_servers_selected) + return; - ao_app->add_favorite_server(get_selected_server()); + ao_app->add_favorite_server(get_selected_server()); } -void Lobby::on_connect_pressed() -{ - ui_connect->set_image("connect_pressed"); -} +void Lobby::on_connect_pressed() { ui_connect->set_image("connect_pressed"); } void Lobby::on_connect_released() { - ui_connect->set_image("connect"); + ui_connect->set_image("connect"); - AOPacket *f_packet; + AOPacket *f_packet; - f_packet = new AOPacket("askchaa#%"); + f_packet = new AOPacket("askchaa#%"); - ao_app->send_server_packet(f_packet); + ao_app->send_server_packet(f_packet); } void Lobby::on_about_clicked() { - QString msg = tr("<h2>Attorney Online %1</h2>" - "The courtroom drama simulator" - "<p><b>Source code:</b> " - "<a href='https://github.com/AttorneyOnline/AO2-Client'>" - "https://github.com/AttorneyOnline/AO2-Client</a>" - "<p><b>Major development:</b><br>" - "OmniTroid, stonedDiscord, longbyte1, gameboyprinter, Cerapter" - "<p><b>2.8 Major Release development:</b><br>" - "Crystalwarrior, Iamgoofball" - "<p><b>2.8 Quality Assurance:</b><br>" - "WillDean, Captain N, Mr M, Riel, Seimmet, Fury McFlurry," - "CedricDewitt, Chewable Tablets, Fantos, Futugaze," - "Geck, Minx, Pandae, Sierra, CrazyJC, CaseyMayCazy," - "GreenBowers, Robotic Overlord, Veritas, Gin-Gi" - "<p><b>Special thanks:</b><br>" - "Remy, Iamgoofball, Hibiki, Qubrick (webAO), Ruekasu (UI design), " - "Draxirch (UI design), Unishred, Argoneus (tsuserver), Fiercy, " - "Noevain, Cronnicossy, the AO2 community, server hosts, game masters," - "case makers, content creators and players!") - .arg(ao_app->get_version_string()); - QMessageBox::about(this, "About", msg); -} - -void Lobby::on_settings_clicked() -{ - ao_app->call_settings_menu(); -} - -//clicked on an item in the serverlist + QString msg = + tr("<h2>Attorney Online %1</h2>" + "The courtroom drama simulator" + "<p><b>Source code:</b> " + "<a href='https://github.com/AttorneyOnline/AO2-Client'>" + "https://github.com/AttorneyOnline/AO2-Client</a>" + "<p><b>Major development:</b><br>" + "OmniTroid, stonedDiscord, longbyte1, gameboyprinter, Cerapter" + "<p><b>2.8 Major Release development:</b><br>" + "Crystalwarrior, Iamgoofball" + "<p><b>2.8 Quality Assurance:</b><br>" + "WillDean, Captain N, Mr M, Riel, Seimmet, Fury McFlurry," + "CedricDewitt, Chewable Tablets, Fantos, Futugaze," + "Geck, Minx, Pandae, Sierra, CrazyJC, CaseyMayCazy," + "GreenBowers, Robotic Overlord, Veritas, Gin-Gi" + "<p><b>Special thanks:</b><br>" + "Remy, Iamgoofball, Hibiki, Qubrick (webAO), Ruekasu (UI design), " + "Draxirch (UI design), Unishred, Argoneus (tsuserver), Fiercy, " + "Noevain, Cronnicossy, the AO2 community, server hosts, game masters," + "case makers, content creators and players!") + .arg(ao_app->get_version_string()); + QMessageBox::about(this, "About", msg); +} + +void Lobby::on_settings_clicked() { ao_app->call_settings_menu(); } + +// clicked on an item in the serverlist void Lobby::on_server_list_clicked(QTreeWidgetItem *p_item, int column) { - column = 0; - if (p_item->text(column).toInt() != last_index) { - server_type f_server; - int n_server = p_item->text(column).toInt(); - last_index = n_server; + column = 0; + if (p_item->text(column).toInt() != last_index) { + server_type f_server; + int n_server = p_item->text(column).toInt(); + last_index = n_server; - if (n_server < 0) - return; + if (n_server < 0) + return; - if (public_servers_selected) { - QVector<server_type> f_server_list = ao_app->get_server_list(); + if (public_servers_selected) { + QVector<server_type> f_server_list = ao_app->get_server_list(); - if (n_server >= f_server_list.size()) - return; + if (n_server >= f_server_list.size()) + return; - f_server = f_server_list.at(n_server); - } - else { - if (n_server >= ao_app->get_favorite_list().size()) - return; + f_server = f_server_list.at(n_server); + } + else { + if (n_server >= ao_app->get_favorite_list().size()) + return; - f_server = ao_app->get_favorite_list().at(n_server); - } + f_server = ao_app->get_favorite_list().at(n_server); + } - ui_description->clear(); - ui_description->append_linked(f_server.desc); + ui_description->clear(); + ui_description->append_linked(f_server.desc); - ui_description->moveCursor(QTextCursor::Start); - ui_description->ensureCursorVisible(); + ui_description->moveCursor(QTextCursor::Start); + ui_description->ensureCursorVisible(); - ui_player_count->setText(tr("Offline")); + ui_player_count->setText(tr("Offline")); - ui_connect->setEnabled(false); + ui_connect->setEnabled(false); - ao_app->net_manager->connect_to_server(f_server); - } + ao_app->net_manager->connect_to_server(f_server); + } } -//doubleclicked on an item in the serverlist so we'll connect right away +// doubleclicked on an item in the serverlist so we'll connect right away void Lobby::on_server_list_doubleclicked(QTreeWidgetItem *p_item, int column) { - on_server_list_clicked(p_item, column); - on_connect_released(); + on_server_list_clicked(p_item, column); + on_connect_released(); } void Lobby::on_server_search_edited(QString p_text) { - // Iterate through all QTreeWidgetItem items - QTreeWidgetItemIterator it(ui_server_list); - while (*it) { - (*it)->setHidden(p_text != ""); - ++it; - } - - if (p_text != "") { - //Search in metadata - QList<QTreeWidgetItem *> clist = ui_server_list->findItems(ui_server_search->text(), Qt::MatchContains | Qt::MatchRecursive, 1); - foreach (QTreeWidgetItem *item, clist) { - if (item->parent() != nullptr) //So the category shows up too - item->parent()->setHidden(false); - item->setHidden(false); - } + // Iterate through all QTreeWidgetItem items + QTreeWidgetItemIterator it(ui_server_list); + while (*it) { + (*it)->setHidden(p_text != ""); + ++it; + } + + if (p_text != "") { + // Search in metadata + QList<QTreeWidgetItem *> clist = ui_server_list->findItems( + ui_server_search->text(), Qt::MatchContains | Qt::MatchRecursive, 1); + foreach (QTreeWidgetItem *item, clist) { + if (item->parent() != nullptr) // So the category shows up too + item->parent()->setHidden(false); + item->setHidden(false); } + } } void Lobby::on_chatfield_return_pressed() { - //no you can't send empty messages - if (ui_chatname->text() == "" || ui_chatmessage->text() == "") - return; + // no you can't send empty messages + if (ui_chatname->text() == "" || ui_chatmessage->text() == "") + return; - QString f_header = "CT"; - QStringList f_contents{ui_chatname->text(), ui_chatmessage->text()}; + QString f_header = "CT"; + QStringList f_contents{ui_chatname->text(), ui_chatmessage->text()}; - AOPacket *f_packet = new AOPacket(f_header, f_contents); + AOPacket *f_packet = new AOPacket(f_header, f_contents); - ao_app->send_ms_packet(f_packet); + ao_app->send_ms_packet(f_packet); - ui_chatmessage->clear(); + ui_chatmessage->clear(); } void Lobby::list_servers() { - public_servers_selected = true; - ui_favorites->set_image("favorites"); - ui_public_servers->set_image("publicservers_selected"); + public_servers_selected = true; + ui_favorites->set_image("favorites"); + ui_public_servers->set_image("publicservers_selected"); - ui_server_list->setSortingEnabled(false); - ui_server_list->clear(); + ui_server_list->setSortingEnabled(false); + ui_server_list->clear(); - ui_server_search->setText(""); + ui_server_search->setText(""); - int i = 0; - for (server_type i_server : ao_app->get_server_list()) { - QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_server_list); - treeItem->setText(0, QString::number(i)); - treeItem->setText(1, i_server.name); - i++; - } - ui_server_list->setSortingEnabled(true); + int i = 0; + for (server_type i_server : ao_app->get_server_list()) { + QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_server_list); + treeItem->setText(0, QString::number(i)); + treeItem->setText(1, i_server.name); + i++; + } + ui_server_list->setSortingEnabled(true); } void Lobby::list_favorites() { - ui_server_list->setSortingEnabled(false); - ui_server_list->clear(); - - int i = 0; - for (server_type i_server : ao_app->get_favorite_list()) { - QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_server_list); - treeItem->setText(0, QString::number(i)); - treeItem->setText(1, i_server.name); - // treeItem->setText(2, "-"); - i++; - } - ui_server_list->setSortingEnabled(true); + ui_server_list->setSortingEnabled(false); + ui_server_list->clear(); + + int i = 0; + for (server_type i_server : ao_app->get_favorite_list()) { + QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_server_list); + treeItem->setText(0, QString::number(i)); + treeItem->setText(1, i_server.name); + // treeItem->setText(2, "-"); + i++; + } + ui_server_list->setSortingEnabled(true); } void Lobby::append_chatmessage(QString f_name, QString f_message) { - ui_chatbox->append_chatmessage(f_name, f_message, ao_app->get_color("ooc_default_color", "courtroom_design.ini").name()); + ui_chatbox->append_chatmessage( + f_name, f_message, + ao_app->get_color("ooc_default_color", "courtroom_design.ini").name()); } void Lobby::append_error(QString f_message) { - ui_chatbox->append_error(f_message); + ui_chatbox->append_error(f_message); } void Lobby::set_player_count(int players_online, int max_players) { - QString f_string = tr("Online: %1/%2").arg(QString::number(players_online)).arg(QString::number(max_players)); - ui_player_count->setText(f_string); + QString f_string = tr("Online: %1/%2") + .arg(QString::number(players_online)) + .arg(QString::number(max_players)); + ui_player_count->setText(f_string); } -void Lobby::enable_connect_button() -{ - ui_connect->setEnabled(true); -} +void Lobby::enable_connect_button() { ui_connect->setEnabled(true); } -Lobby::~Lobby() -{ -} +Lobby::~Lobby() {} diff --git a/src/main.cpp b/src/main.cpp index 9370bcea..ba5b5167 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,40 +12,41 @@ int main(int argc, char *argv[]) { #if QT_VERSION > QT_VERSION_CHECK(5, 6, 0) - // High-DPI support is for Qt version >=5.6. - // However, many Linux distros still haven't brought their stable/LTS - // packages up to Qt 5.6, so this is conditional. - AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + // High-DPI support is for Qt version >=5.6. + // However, many Linux distros still haven't brought their stable/LTS + // packages up to Qt 5.6, so this is conditional. + AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif - AOApplication main_app(argc, argv); + AOApplication main_app(argc, argv); - QSettings *configini = main_app.configini; + QSettings *configini = main_app.configini; - QPluginLoader apngPlugin("qapng"); - if (!apngPlugin.load()) - qCritical() << "QApng plugin could not be loaded"; + QPluginLoader apngPlugin("qapng"); + if (!apngPlugin.load()) + qCritical() << "QApng plugin could not be loaded"; - QPluginLoader webpPlugin("qwebp"); - if (!webpPlugin.load()) - qCritical() << "QWebp plugin could not be loaded"; + QPluginLoader webpPlugin("qwebp"); + if (!webpPlugin.load()) + qCritical() << "QWebp plugin could not be loaded"; - QString p_language = configini->value("language", QLocale::system().name()).toString(); - if (p_language == " " || p_language == "") - p_language = QLocale::system().name(); + QString p_language = + configini->value("language", QLocale::system().name()).toString(); + if (p_language == " " || p_language == "") + p_language = QLocale::system().name(); - QTranslator qtTranslator; - qtTranslator.load("qt_" + p_language, - QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - main_app.installTranslator(&qtTranslator); + QTranslator qtTranslator; + qtTranslator.load("qt_" + p_language, + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + main_app.installTranslator(&qtTranslator); - QTranslator appTranslator; - qDebug() << ":/resource/translations/ao_" + p_language; - appTranslator.load("ao_" + p_language, ":/resource/translations/"); - main_app.installTranslator(&appTranslator); + QTranslator appTranslator; + qDebug() << ":/resource/translations/ao_" + p_language; + appTranslator.load("ao_" + p_language, ":/resource/translations/"); + main_app.installTranslator(&appTranslator); - main_app.construct_lobby(); - main_app.net_manager->connect_to_master(); - main_app.w_lobby->show(); - return main_app.exec(); + main_app.construct_lobby(); + main_app.net_manager->connect_to_master(); + main_app.w_lobby->show(); + return main_app.exec(); } diff --git a/src/misc_functions.cpp b/src/misc_functions.cpp index fa49ba48..cc144153 100644 --- a/src/misc_functions.cpp +++ b/src/misc_functions.cpp @@ -2,8 +2,8 @@ void delay(int p_milliseconds) { - QTime dieTime = QTime::currentTime().addMSecs(p_milliseconds); + QTime dieTime = QTime::currentTime().addMSecs(p_milliseconds); - while (QTime::currentTime() < dieTime) - QCoreApplication::processEvents(QEventLoop::AllEvents, 100); + while (QTime::currentTime() < dieTime) + QCoreApplication::processEvents(QEventLoop::AllEvents, 100); } diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp index 19f02415..cf89d0ab 100644 --- a/src/networkmanager.cpp +++ b/src/networkmanager.cpp @@ -6,220 +6,234 @@ NetworkManager::NetworkManager(AOApplication *parent) : QObject(parent) { - ao_app = parent; - - ms_socket = new QTcpSocket(this); - server_socket = new QTcpSocket(this); - - ms_reconnect_timer = new QTimer(this); - ms_reconnect_timer->setSingleShot(true); - QObject::connect(ms_reconnect_timer, SIGNAL(timeout()), this, SLOT(retry_ms_connect())); - - QObject::connect(ms_socket, SIGNAL(readyRead()), this, SLOT(handle_ms_packet())); - QObject::connect(server_socket, SIGNAL(readyRead()), this, SLOT(handle_server_packet())); - QObject::connect(server_socket, SIGNAL(disconnected()), ao_app, SLOT(server_disconnected())); - - QString master_config = ao_app->configini->value("master", "").value<QString>(); - if (master_config != "") - ms_nosrv_hostname = master_config; + ao_app = parent; + + ms_socket = new QTcpSocket(this); + server_socket = new QTcpSocket(this); + + ms_reconnect_timer = new QTimer(this); + ms_reconnect_timer->setSingleShot(true); + QObject::connect(ms_reconnect_timer, SIGNAL(timeout()), this, + SLOT(retry_ms_connect())); + + QObject::connect(ms_socket, SIGNAL(readyRead()), this, + SLOT(handle_ms_packet())); + QObject::connect(server_socket, SIGNAL(readyRead()), this, + SLOT(handle_server_packet())); + QObject::connect(server_socket, SIGNAL(disconnected()), ao_app, + SLOT(server_disconnected())); + + QString master_config = + ao_app->configini->value("master", "").value<QString>(); + if (master_config != "") + ms_nosrv_hostname = master_config; } -NetworkManager::~NetworkManager() -{ -} +NetworkManager::~NetworkManager() {} void NetworkManager::connect_to_master() { - ms_socket->close(); - ms_socket->abort(); + ms_socket->close(); + ms_socket->abort(); #ifdef MS_FAILOVER_SUPPORTED - perform_srv_lookup(); + perform_srv_lookup(); #else - connect_to_master_nosrv(); + connect_to_master_nosrv(); #endif } void NetworkManager::connect_to_master_nosrv() { - QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); + QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, + SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); - QObject::connect(ms_socket, SIGNAL(connected()), - this, SLOT(on_ms_nosrv_connect_success())); - ms_socket->connectToHost(ms_nosrv_hostname, ms_port); + QObject::connect(ms_socket, SIGNAL(connected()), this, + SLOT(on_ms_nosrv_connect_success())); + ms_socket->connectToHost(ms_nosrv_hostname, ms_port); } void NetworkManager::connect_to_server(server_type p_server) { - server_socket->close(); - server_socket->abort(); + server_socket->close(); + server_socket->abort(); - server_socket->connectToHost(p_server.ip, p_server.port); + server_socket->connectToHost(p_server.ip, p_server.port); } void NetworkManager::ship_ms_packet(QString p_packet) { - if (!ms_socket->isOpen()) { - retry_ms_connect(); - } - else { - ms_socket->write(p_packet.toUtf8()); - } + if (!ms_socket->isOpen()) { + retry_ms_connect(); + } + else { + ms_socket->write(p_packet.toUtf8()); + } } void NetworkManager::ship_server_packet(QString p_packet) { - server_socket->write(p_packet.toUtf8()); + server_socket->write(p_packet.toUtf8()); } void NetworkManager::handle_ms_packet() { - QByteArray buffer = ms_socket->readAll(); - QString in_data = QString::fromUtf8(buffer, buffer.size()); - - if (!in_data.endsWith("%")) { - ms_partial_packet = true; - ms_temp_packet += in_data; - return; + QByteArray buffer = ms_socket->readAll(); + QString in_data = QString::fromUtf8(buffer, buffer.size()); + + if (!in_data.endsWith("%")) { + ms_partial_packet = true; + ms_temp_packet += in_data; + return; + } + + else { + if (ms_partial_packet) { + in_data = ms_temp_packet + in_data; + ms_temp_packet = ""; + ms_partial_packet = false; } + } - else { - if (ms_partial_packet) { - in_data = ms_temp_packet + in_data; - ms_temp_packet = ""; - ms_partial_packet = false; - } - } + QStringList packet_list = + in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts)); - QStringList packet_list = in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts)); + for (QString packet : packet_list) { + AOPacket *f_packet = new AOPacket(packet); - for (QString packet : packet_list) { - AOPacket *f_packet = new AOPacket(packet); - - ao_app->ms_packet_received(f_packet); - } + ao_app->ms_packet_received(f_packet); + } } void NetworkManager::perform_srv_lookup() { #ifdef MS_FAILOVER_SUPPORTED - ms_dns = new QDnsLookup(QDnsLookup::SRV, ms_srv_hostname, this); + ms_dns = new QDnsLookup(QDnsLookup::SRV, ms_srv_hostname, this); - connect(ms_dns, SIGNAL(finished()), this, SLOT(on_srv_lookup())); - ms_dns->lookup(); + connect(ms_dns, SIGNAL(finished()), this, SLOT(on_srv_lookup())); + ms_dns->lookup(); #endif } void NetworkManager::on_srv_lookup() { #ifdef MS_FAILOVER_SUPPORTED - bool connected = false; - if (ms_dns->error() != QDnsLookup::NoError) { - qWarning("SRV lookup of the master server DNS failed."); - ms_dns->deleteLater(); - } - else { - const auto srv_records = ms_dns->serviceRecords(); - - for (const QDnsServiceRecord &record : srv_records) { + bool connected = false; + if (ms_dns->error() != QDnsLookup::NoError) { + qWarning("SRV lookup of the master server DNS failed."); + ms_dns->deleteLater(); + } + else { + const auto srv_records = ms_dns->serviceRecords(); + + for (const QDnsServiceRecord &record : srv_records) { #ifdef DEBUG_NETWORK - qDebug() << "Connecting to " << record.target() << ":" << record.port(); + qDebug() << "Connecting to " << record.target() << ":" << record.port(); #endif - ms_socket->connectToHost(record.target(), record.port()); - QTime timer; - timer.start(); - do { - ao_app->processEvents(); - if (ms_socket->state() == QAbstractSocket::ConnectedState) { - connected = true; - break; - } - else if (ms_socket->state() != QAbstractSocket::ConnectingState && ms_socket->state() != QAbstractSocket::HostLookupState && ms_socket->error() != -1) { - qDebug() << ms_socket->error(); - qWarning() << "Error connecting to master server:" << ms_socket->errorString(); - ms_socket->abort(); - ms_socket->close(); - break; - } - } while (timer.elapsed() < timeout_milliseconds); // Very expensive spin-wait loop - it will bring CPU to 100%! - if (connected) { - // Connect a one-shot signal in case the master server disconnects randomly - QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); - break; - } - else { - ms_socket->abort(); - ms_socket->close(); - } + ms_socket->connectToHost(record.target(), record.port()); + QTime timer; + timer.start(); + do { + ao_app->processEvents(); + if (ms_socket->state() == QAbstractSocket::ConnectedState) { + connected = true; + break; + } + else if (ms_socket->state() != QAbstractSocket::ConnectingState && + ms_socket->state() != QAbstractSocket::HostLookupState && + ms_socket->error() != -1) { + qDebug() << ms_socket->error(); + qWarning() << "Error connecting to master server:" + << ms_socket->errorString(); + ms_socket->abort(); + ms_socket->close(); + break; } + } while (timer.elapsed() < + timeout_milliseconds); // Very expensive spin-wait loop - it will + // bring CPU to 100%! + if (connected) { + // Connect a one-shot signal in case the master server disconnects + // randomly + QObject::connect( + ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, + SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); + break; + } + else { + ms_socket->abort(); + ms_socket->close(); + } } + } - // Failover to non-SRV connection - if (!connected) - connect_to_master_nosrv(); - else - emit ms_connect_finished(connected, false); + // Failover to non-SRV connection + if (!connected) + connect_to_master_nosrv(); + else + emit ms_connect_finished(connected, false); #endif } void NetworkManager::on_ms_nosrv_connect_success() { - emit ms_connect_finished(true, false); + emit ms_connect_finished(true, false); - QObject::disconnect(ms_socket, SIGNAL(connected()), - this, SLOT(on_ms_nosrv_connect_success())); + QObject::disconnect(ms_socket, SIGNAL(connected()), this, + SLOT(on_ms_nosrv_connect_success())); - QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); + QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, + SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); } void NetworkManager::on_ms_socket_error(QAbstractSocket::SocketError error) { - qWarning() << "Master server socket error:" << ms_socket->errorString() - << "(" << error << ")"; + qWarning() << "Master server socket error:" << ms_socket->errorString() << "(" + << error << ")"; - // Disconnect the one-shot signal - this way, failover connect attempts - // don't trigger a full retry - QObject::disconnect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); + // Disconnect the one-shot signal - this way, failover connect attempts + // don't trigger a full retry + QObject::disconnect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), + this, + SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); - emit ms_connect_finished(false, true); + emit ms_connect_finished(false, true); - ms_reconnect_timer->start(ms_reconnect_delay * 1000); + ms_reconnect_timer->start(ms_reconnect_delay * 1000); } void NetworkManager::retry_ms_connect() { - if (!ms_reconnect_timer->isActive() && ms_socket->state() != QAbstractSocket::ConnectingState) - connect_to_master(); + if (!ms_reconnect_timer->isActive() && + ms_socket->state() != QAbstractSocket::ConnectingState) + connect_to_master(); } void NetworkManager::handle_server_packet() { - QByteArray buffer = server_socket->readAll(); - QString in_data = QString::fromUtf8(buffer, buffer.size()); - - if (!in_data.endsWith("%")) { - partial_packet = true; - temp_packet += in_data; - return; + QByteArray buffer = server_socket->readAll(); + QString in_data = QString::fromUtf8(buffer, buffer.size()); + + if (!in_data.endsWith("%")) { + partial_packet = true; + temp_packet += in_data; + return; + } + + else { + if (partial_packet) { + in_data = temp_packet + in_data; + temp_packet = ""; + partial_packet = false; } + } - else { - if (partial_packet) { - in_data = temp_packet + in_data; - temp_packet = ""; - partial_packet = false; - } - } + QStringList packet_list = + in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts)); - QStringList packet_list = in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts)); + for (QString packet : packet_list) { + AOPacket *f_packet = new AOPacket(packet); - for (QString packet : packet_list) { - AOPacket *f_packet = new AOPacket(packet); - - ao_app->server_packet_received(f_packet); - } + ao_app->server_packet_received(f_packet); + } } diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 68f568ba..81a9a30f 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -9,691 +9,742 @@ void AOApplication::ms_packet_received(AOPacket *p_packet) { - p_packet->net_decode(); + p_packet->net_decode(); - QString header = p_packet->get_header(); - QStringList f_contents = p_packet->get_contents(); + QString header = p_packet->get_header(); + QStringList f_contents = p_packet->get_contents(); #ifdef DEBUG_NETWORK - if (header != "CHECK") - qDebug() << "R(ms):" << p_packet->to_string(); + if (header != "CHECK") + qDebug() << "R(ms):" << p_packet->to_string(); #endif - if (header == "ALL") { - server_list.clear(); + if (header == "ALL") { + server_list.clear(); - for (QString i_string : p_packet->get_contents()) { - server_type f_server; - QStringList sub_contents = i_string.split("&"); + for (QString i_string : p_packet->get_contents()) { + server_type f_server; + QStringList sub_contents = i_string.split("&"); - if (sub_contents.size() < 4) { - qDebug() << "W: malformed packet"; - continue; - } + if (sub_contents.size() < 4) { + qDebug() << "W: malformed packet"; + continue; + } - f_server.name = sub_contents.at(0); - f_server.desc = sub_contents.at(1); - f_server.ip = sub_contents.at(2); - f_server.port = sub_contents.at(3).toInt(); + f_server.name = sub_contents.at(0); + f_server.desc = sub_contents.at(1); + f_server.ip = sub_contents.at(2); + f_server.port = sub_contents.at(3).toInt(); - server_list.append(f_server); - } - - if (lobby_constructed) { - w_lobby->list_servers(); - } + server_list.append(f_server); } - else if (header == "CT") { - QString f_name, f_message; - if (f_contents.size() == 1) { - f_name = ""; - f_message = f_contents.at(0); - } - else if (f_contents.size() >= 2) { - f_name = f_contents.at(0); - f_message = f_contents.at(1); - } - else - goto end; - - if (lobby_constructed) { - w_lobby->append_chatmessage(f_name, f_message); - } - if (courtroom_constructed && courtroom_loaded) { - w_courtroom->append_ms_chatmessage(f_name, f_message); - } + if (lobby_constructed) { + w_lobby->list_servers(); } - else if (header == "AO2CHECK") { - send_ms_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%")); - send_ms_packet(new AOPacket("HI#" + get_hdid() + "#%")); - - if (f_contents.size() < 1) - goto end; - - QStringList version_contents = f_contents.at(0).split("."); - - if (version_contents.size() < 3) - goto end; - - int f_release = version_contents.at(0).toInt(); - int f_major = version_contents.at(1).toInt(); - int f_minor = version_contents.at(2).toInt(); - - if (get_release() > f_release) - goto end; - else if (get_release() == f_release) { - if (get_major_version() > f_major) - goto end; - else if (get_major_version() == f_major) { - if (get_minor_version() >= f_minor) - goto end; - } - } + } + else if (header == "CT") { + QString f_name, f_message; - call_notice(tr("Outdated version! Your version: %1\n" - "Please go to aceattorneyonline.com to update.") - .arg(get_version_string())); - destruct_courtroom(); - destruct_lobby(); + if (f_contents.size() == 1) { + f_name = ""; + f_message = f_contents.at(0); } - -end: - - delete p_packet; -} - -void AOApplication::server_packet_received(AOPacket *p_packet) -{ - p_packet->net_decode(); - - QString header = p_packet->get_header(); - QStringList f_contents = p_packet->get_contents(); - QString f_packet = p_packet->to_string(); - -#ifdef DEBUG_NETWORK - if (header != "checkconnection") - qDebug() << "R:" << f_packet; -#endif - - if (header == "decryptor") { - if (f_contents.size() == 0) - goto end; - - //you may ask where 322 comes from. that would be a good question. - s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt(); - - //default(legacy) values - encryption_needed = true; - yellow_text_enabled = false; - prezoom_enabled = false; - flipping_enabled = false; - custom_objection_enabled = false; - improved_loading_enabled = false; - desk_mod_enabled = false; - evidence_enabled = false; - cccc_ic_support_enabled = false; - arup_enabled = false; - casing_alerts_enabled = false; - modcall_reason_enabled = false; - looping_sfx_support_enabled = false; - additive_enabled = false; - effects_enabled = false; - - //workaround for tsuserver4 - if (f_contents.at(0) == "NOENCRYPT") - encryption_needed = false; - - QString f_hdid; - f_hdid = get_hdid(); - - AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%"); - send_server_packet(hi_packet); + else if (f_contents.size() >= 2) { + f_name = f_contents.at(0); + f_message = f_contents.at(1); } - else if (header == "ID") { - if (f_contents.size() < 2) - goto end; + else + goto end; - s_pv = f_contents.at(0).toInt(); - server_software = f_contents.at(1); - - w_lobby->enable_connect_button(); - - send_server_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%")); - } - else if (header == "CT") { - if (f_contents.size() < 2) - goto end; - - if (courtroom_constructed) { - if (f_contents.size() == 3) - w_courtroom->append_server_chatmessage(f_contents.at(0), f_contents.at(1), f_contents.at(2)); - else - w_courtroom->append_server_chatmessage(f_contents.at(0), f_contents.at(1), "0"); - } + if (lobby_constructed) { + w_lobby->append_chatmessage(f_name, f_message); } - else if (header == "FL") { - if (f_packet.contains("yellowtext", Qt::CaseInsensitive)) - yellow_text_enabled = true; - if (f_packet.contains("prezoom", Qt::CaseInsensitive)) - prezoom_enabled = true; - if (f_packet.contains("flipping", Qt::CaseInsensitive)) - flipping_enabled = true; - if (f_packet.contains("customobjections", Qt::CaseInsensitive)) - custom_objection_enabled = true; - if (f_packet.contains("fastloading", Qt::CaseInsensitive)) - improved_loading_enabled = true; - if (f_packet.contains("noencryption", Qt::CaseInsensitive)) - encryption_needed = false; - if (f_packet.contains("deskmod", Qt::CaseInsensitive)) - desk_mod_enabled = true; - if (f_packet.contains("evidence", Qt::CaseInsensitive)) - evidence_enabled = true; - if (f_packet.contains("cccc_ic_support", Qt::CaseInsensitive)) - cccc_ic_support_enabled = true; - if (f_packet.contains("arup", Qt::CaseInsensitive)) - arup_enabled = true; - if (f_packet.contains("casing_alerts", Qt::CaseInsensitive)) - casing_alerts_enabled = true; - if (f_packet.contains("modcall_reason", Qt::CaseInsensitive)) - modcall_reason_enabled = true; - if (f_packet.contains("looping_sfx", Qt::CaseInsensitive)) - looping_sfx_support_enabled = true; - if (f_packet.contains("additive", Qt::CaseInsensitive)) - additive_enabled = true; - if (f_packet.contains("effects", Qt::CaseInsensitive)) - effects_enabled = true; + if (courtroom_constructed && courtroom_loaded) { + w_courtroom->append_ms_chatmessage(f_name, f_message); } - else if (header == "PN") { - if (f_contents.size() < 2) - goto end; + } + else if (header == "AO2CHECK") { + send_ms_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%")); + send_ms_packet(new AOPacket("HI#" + get_hdid() + "#%")); - w_lobby->set_player_count(f_contents.at(0).toInt(), f_contents.at(1).toInt()); - } - else if (header == "SI") { - if (f_contents.size() != 3) - goto end; - - char_list_size = f_contents.at(0).toInt(); - evidence_list_size = f_contents.at(1).toInt(); - music_list_size = f_contents.at(2).toInt(); - - if (char_list_size < 1 || evidence_list_size < 0 || music_list_size < 0) - goto end; - - loaded_chars = 0; - loaded_evidence = 0; - loaded_music = 0; - generated_chars = 0; - - destruct_courtroom(); - construct_courtroom(); - - courtroom_loaded = false; - - QString window_title = tr("Attorney Online 2"); - int selected_server = w_lobby->get_selected_server(); - - QString server_address = "", server_name = ""; - if (w_lobby->public_servers_selected) { - if (selected_server >= 0 && selected_server < server_list.size()) { - auto info = server_list.at(selected_server); - server_name = info.name; - server_address = QString("%1:%2").arg(info.ip, QString::number(info.port)); - qDebug() << server_address; - window_title += ": " + server_name; - } - } - else { - if (selected_server >= 0 && selected_server < favorite_list.size()) { - auto info = favorite_list.at(selected_server); - server_name = info.name; - server_address = QString("%1:%2").arg(info.ip, QString::number(info.port)); - qDebug() << server_address; - window_title += ": " + server_name; - } - } - - w_courtroom->set_window_title(window_title); + if (f_contents.size() < 1) + goto end; - w_lobby->show_loading_overlay(); - w_lobby->set_loading_text(tr("Loading")); - w_lobby->set_loading_value(0); + QStringList version_contents = f_contents.at(0).split("."); - AOPacket *f_packet; + if (version_contents.size() < 3) + goto end; - if (improved_loading_enabled) - f_packet = new AOPacket("RC#%"); - else - f_packet = new AOPacket("askchar2#%"); + int f_release = version_contents.at(0).toInt(); + int f_major = version_contents.at(1).toInt(); + int f_minor = version_contents.at(2).toInt(); - send_server_packet(f_packet); - - //Remove any characters not accepted in folder names for the server_name here - this->log_filename = QDateTime::currentDateTime().toUTC().toString("'logs/" + server_name.remove(QRegExp("[\\\\/:*?\"<>|\']")) + "/'ddd MMMM yyyy hh.mm.ss t'.log'"); - this->write_to_file("Joined server " + server_name + " on address " + server_address + " on " + QDateTime::currentDateTime().toUTC().toString(), log_filename, true); - QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256); - hash.addData(server_address.toUtf8()); - if (is_discord_enabled()) - discord->state_server(server_name.toStdString(), hash.result().toBase64().toStdString()); + if (get_release() > f_release) + goto end; + else if (get_release() == f_release) { + if (get_major_version() > f_major) + goto end; + else if (get_major_version() == f_major) { + if (get_minor_version() >= f_minor) + goto end; + } } - else if (header == "CI") { - if (!courtroom_constructed) - goto end; - - for (int n_element = 0; n_element < f_contents.size(); n_element += 2) { - if (f_contents.at(n_element).toInt() != loaded_chars) - break; - //this means we are on the last element and checking n + 1 element will be game over so - if (n_element == f_contents.size() - 1) - break; + call_notice(tr("Outdated version! Your version: %1\n" + "Please go to aceattorneyonline.com to update.") + .arg(get_version_string())); + destruct_courtroom(); + destruct_lobby(); + } - QStringList sub_elements = f_contents.at(n_element + 1).split("&"); - if (sub_elements.size() < 2) - break; +end: - char_type f_char; - f_char.name = sub_elements.at(0); - f_char.description = sub_elements.at(1); - f_char.evidence_string = sub_elements.at(3); - //temporary. the CharsCheck packet sets this properly - f_char.taken = false; + delete p_packet; +} - ++loaded_chars; +void AOApplication::server_packet_received(AOPacket *p_packet) +{ + p_packet->net_decode(); - w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size)); + QString header = p_packet->get_header(); + QStringList f_contents = p_packet->get_contents(); + QString f_packet = p_packet->to_string(); - w_courtroom->append_char(f_char); +#ifdef DEBUG_NETWORK + if (header != "checkconnection") + qDebug() << "R:" << f_packet; +#endif - int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size; - int loading_value = int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100); - w_lobby->set_loading_value(loading_value); + if (header == "decryptor") { + if (f_contents.size() == 0) + goto end; + + // you may ask where 322 comes from. that would be a good question. + s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt(); + + // default(legacy) values + encryption_needed = true; + yellow_text_enabled = false; + prezoom_enabled = false; + flipping_enabled = false; + custom_objection_enabled = false; + improved_loading_enabled = false; + desk_mod_enabled = false; + evidence_enabled = false; + cccc_ic_support_enabled = false; + arup_enabled = false; + casing_alerts_enabled = false; + modcall_reason_enabled = false; + looping_sfx_support_enabled = false; + additive_enabled = false; + effects_enabled = false; + + // workaround for tsuserver4 + if (f_contents.at(0) == "NOENCRYPT") + encryption_needed = false; + + QString f_hdid; + f_hdid = get_hdid(); + + AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%"); + send_server_packet(hi_packet); + } + else if (header == "ID") { + if (f_contents.size() < 2) + goto end; + + s_pv = f_contents.at(0).toInt(); + server_software = f_contents.at(1); + + w_lobby->enable_connect_button(); + + send_server_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%")); + } + else if (header == "CT") { + if (f_contents.size() < 2) + goto end; + + if (courtroom_constructed) { + if (f_contents.size() == 3) + w_courtroom->append_server_chatmessage( + f_contents.at(0), f_contents.at(1), f_contents.at(2)); + else + w_courtroom->append_server_chatmessage(f_contents.at(0), + f_contents.at(1), "0"); + } + } + else if (header == "FL") { + if (f_packet.contains("yellowtext", Qt::CaseInsensitive)) + yellow_text_enabled = true; + if (f_packet.contains("prezoom", Qt::CaseInsensitive)) + prezoom_enabled = true; + if (f_packet.contains("flipping", Qt::CaseInsensitive)) + flipping_enabled = true; + if (f_packet.contains("customobjections", Qt::CaseInsensitive)) + custom_objection_enabled = true; + if (f_packet.contains("fastloading", Qt::CaseInsensitive)) + improved_loading_enabled = true; + if (f_packet.contains("noencryption", Qt::CaseInsensitive)) + encryption_needed = false; + if (f_packet.contains("deskmod", Qt::CaseInsensitive)) + desk_mod_enabled = true; + if (f_packet.contains("evidence", Qt::CaseInsensitive)) + evidence_enabled = true; + if (f_packet.contains("cccc_ic_support", Qt::CaseInsensitive)) + cccc_ic_support_enabled = true; + if (f_packet.contains("arup", Qt::CaseInsensitive)) + arup_enabled = true; + if (f_packet.contains("casing_alerts", Qt::CaseInsensitive)) + casing_alerts_enabled = true; + if (f_packet.contains("modcall_reason", Qt::CaseInsensitive)) + modcall_reason_enabled = true; + if (f_packet.contains("looping_sfx", Qt::CaseInsensitive)) + looping_sfx_support_enabled = true; + if (f_packet.contains("additive", Qt::CaseInsensitive)) + additive_enabled = true; + if (f_packet.contains("effects", Qt::CaseInsensitive)) + effects_enabled = true; + } + else if (header == "PN") { + if (f_contents.size() < 2) + goto end; + + w_lobby->set_player_count(f_contents.at(0).toInt(), + f_contents.at(1).toInt()); + } + else if (header == "SI") { + if (f_contents.size() != 3) + goto end; + + char_list_size = f_contents.at(0).toInt(); + evidence_list_size = f_contents.at(1).toInt(); + music_list_size = f_contents.at(2).toInt(); + + if (char_list_size < 1 || evidence_list_size < 0 || music_list_size < 0) + goto end; + + loaded_chars = 0; + loaded_evidence = 0; + loaded_music = 0; + generated_chars = 0; + + destruct_courtroom(); + construct_courtroom(); + + courtroom_loaded = false; + + QString window_title = tr("Attorney Online 2"); + int selected_server = w_lobby->get_selected_server(); + + QString server_address = "", server_name = ""; + if (w_lobby->public_servers_selected) { + if (selected_server >= 0 && selected_server < server_list.size()) { + auto info = server_list.at(selected_server); + server_name = info.name; + server_address = + QString("%1:%2").arg(info.ip, QString::number(info.port)); + qDebug() << server_address; + window_title += ": " + server_name; + } + } + else { + if (selected_server >= 0 && selected_server < favorite_list.size()) { + auto info = favorite_list.at(selected_server); + server_name = info.name; + server_address = + QString("%1:%2").arg(info.ip, QString::number(info.port)); + qDebug() << server_address; + window_title += ": " + server_name; + } + } + + w_courtroom->set_window_title(window_title); + + w_lobby->show_loading_overlay(); + w_lobby->set_loading_text(tr("Loading")); + w_lobby->set_loading_value(0); + + AOPacket *f_packet; + + if (improved_loading_enabled) + f_packet = new AOPacket("RC#%"); + else + f_packet = new AOPacket("askchar2#%"); + + send_server_packet(f_packet); + + // Remove any characters not accepted in folder names for the server_name + // here + this->log_filename = QDateTime::currentDateTime().toUTC().toString( + "'logs/" + server_name.remove(QRegExp("[\\\\/:*?\"<>|\']")) + + "/'ddd MMMM yyyy hh.mm.ss t'.log'"); + this->write_to_file("Joined server " + server_name + " on address " + + server_address + " on " + + QDateTime::currentDateTime().toUTC().toString(), + log_filename, true); + QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256); + hash.addData(server_address.toUtf8()); + if (is_discord_enabled()) + discord->state_server(server_name.toStdString(), + hash.result().toBase64().toStdString()); + } + else if (header == "CI") { + if (!courtroom_constructed) + goto end; + + for (int n_element = 0; n_element < f_contents.size(); n_element += 2) { + if (f_contents.at(n_element).toInt() != loaded_chars) + break; + + // this means we are on the last element and checking n + 1 element will + // be game over so + if (n_element == f_contents.size() - 1) + break; + + QStringList sub_elements = f_contents.at(n_element + 1).split("&"); + if (sub_elements.size() < 2) + break; + + char_type f_char; + f_char.name = sub_elements.at(0); + f_char.description = sub_elements.at(1); + f_char.evidence_string = sub_elements.at(3); + // temporary. the CharsCheck packet sets this properly + f_char.taken = false; + + ++loaded_chars; + + w_lobby->set_loading_text("Loading chars:\n" + + QString::number(loaded_chars) + "/" + + QString::number(char_list_size)); + + w_courtroom->append_char(f_char); + + int total_loading_size = + char_list_size * 2 + evidence_list_size + music_list_size; + int loading_value = int( + ((loaded_chars + generated_chars + loaded_music + loaded_evidence) / + static_cast<double>(total_loading_size)) * + 100); + w_lobby->set_loading_value(loading_value); + } + + if (improved_loading_enabled) + send_server_packet(new AOPacket("RE#%")); + else { + QString next_packet_number = + QString::number(((loaded_chars - 1) / 10) + 1); + send_server_packet(new AOPacket("AN#" + next_packet_number + "#%")); + } + } + else if (header == "EI") { + if (!courtroom_constructed) + goto end; + + // +1 because evidence starts at 1 rather than 0 for whatever reason + // enjoy fanta + if (f_contents.at(0).toInt() != loaded_evidence + 1) + goto end; + + if (f_contents.size() < 2) + goto end; + + QStringList sub_elements = f_contents.at(1).split("&"); + if (sub_elements.size() < 4) + goto end; + + evi_type f_evi; + f_evi.name = sub_elements.at(0); + f_evi.description = sub_elements.at(1); + // no idea what the number at position 2 is. probably an identifier? + f_evi.image = sub_elements.at(3); + + ++loaded_evidence; + + w_lobby->set_loading_text(tr("Loading evidence:\n%1/%2") + .arg(QString::number(loaded_evidence)) + .arg(QString::number(evidence_list_size))); + + w_courtroom->append_evidence(f_evi); + + int total_loading_size = + char_list_size * 2 + evidence_list_size + music_list_size; + int loading_value = + int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / + static_cast<double>(total_loading_size)) * + 100); + w_lobby->set_loading_value(loading_value); + + QString next_packet_number = QString::number(loaded_evidence); + send_server_packet(new AOPacket("AE#" + next_packet_number + "#%")); + } + else if (header == "EM") { + if (!courtroom_constructed) + goto end; + + bool musics_time = false; + int areas = 0; + + for (int n_element = 0; n_element < f_contents.size(); n_element += 2) { + if (f_contents.at(n_element).toInt() != loaded_music) + break; + + if (n_element == f_contents.size() - 1) + break; + + QString f_music = f_contents.at(n_element + 1); + + ++loaded_music; + + w_lobby->set_loading_text(tr("Loading music:\n%1/%2") + .arg(QString::number(loaded_music)) + .arg(QString::number(music_list_size))); + + if (musics_time) { + w_courtroom->append_music(f_music); + } + else { + if (f_music.endsWith(".wav") || f_music.endsWith(".mp3") || + f_music.endsWith(".mp4") || f_music.endsWith(".ogg") || + f_music.endsWith(".opus")) { + musics_time = true; + areas--; + w_courtroom->fix_last_area(); + w_courtroom->append_music(f_music); } - - if (improved_loading_enabled) - send_server_packet(new AOPacket("RE#%")); else { - QString next_packet_number = QString::number(((loaded_chars - 1) / 10) + 1); - send_server_packet(new AOPacket("AN#" + next_packet_number + "#%")); - } - } - else if (header == "EI") { - if (!courtroom_constructed) - goto end; - - // +1 because evidence starts at 1 rather than 0 for whatever reason - //enjoy fanta - if (f_contents.at(0).toInt() != loaded_evidence + 1) - goto end; - - if (f_contents.size() < 2) - goto end; - - QStringList sub_elements = f_contents.at(1).split("&"); - if (sub_elements.size() < 4) - goto end; - - evi_type f_evi; - f_evi.name = sub_elements.at(0); - f_evi.description = sub_elements.at(1); - //no idea what the number at position 2 is. probably an identifier? - f_evi.image = sub_elements.at(3); - - ++loaded_evidence; - - w_lobby->set_loading_text(tr("Loading evidence:\n%1/%2").arg(QString::number(loaded_evidence)).arg(QString::number(evidence_list_size))); - - w_courtroom->append_evidence(f_evi); - - int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size; - int loading_value = int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100); - w_lobby->set_loading_value(loading_value); - - QString next_packet_number = QString::number(loaded_evidence); - send_server_packet(new AOPacket("AE#" + next_packet_number + "#%")); - } - else if (header == "EM") { - if (!courtroom_constructed) - goto end; - - bool musics_time = false; - int areas = 0; - - for (int n_element = 0; n_element < f_contents.size(); n_element += 2) { - if (f_contents.at(n_element).toInt() != loaded_music) - break; - - if (n_element == f_contents.size() - 1) - break; - - QString f_music = f_contents.at(n_element + 1); - - ++loaded_music; - - w_lobby->set_loading_text(tr("Loading music:\n%1/%2").arg(QString::number(loaded_music)).arg(QString::number(music_list_size))); - - if (musics_time) { - w_courtroom->append_music(f_music); - } - else { - if (f_music.endsWith(".wav") || - f_music.endsWith(".mp3") || - f_music.endsWith(".mp4") || - f_music.endsWith(".ogg") || - f_music.endsWith(".opus")) { - musics_time = true; - areas--; - w_courtroom->fix_last_area(); - w_courtroom->append_music(f_music); - } - else { - w_courtroom->append_area(f_music); - areas++; - } - } - - for (int area_n = 0; area_n < areas; area_n++) { - w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown"); - } - - int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size; - int loading_value = int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100); - w_lobby->set_loading_value(loading_value); + w_courtroom->append_area(f_music); + areas++; } - - QString next_packet_number = QString::number(((loaded_music - 1) / 10) + 1); - send_server_packet(new AOPacket("AM#" + next_packet_number + "#%")); - } - else if (header == "CharsCheck") { - if (!courtroom_constructed) - goto end; - - for (int n_char = 0; n_char < f_contents.size(); ++n_char) { - if (f_contents.at(n_char) == "-1") - w_courtroom->set_taken(n_char, true); - else - w_courtroom->set_taken(n_char, false); + } + + for (int area_n = 0; area_n < areas; area_n++) { + w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown"); + } + + int total_loading_size = + char_list_size * 2 + evidence_list_size + music_list_size; + int loading_value = int( + ((loaded_chars + generated_chars + loaded_music + loaded_evidence) / + static_cast<double>(total_loading_size)) * + 100); + w_lobby->set_loading_value(loading_value); + } + + QString next_packet_number = QString::number(((loaded_music - 1) / 10) + 1); + send_server_packet(new AOPacket("AM#" + next_packet_number + "#%")); + } + else if (header == "CharsCheck") { + if (!courtroom_constructed) + goto end; + + for (int n_char = 0; n_char < f_contents.size(); ++n_char) { + if (f_contents.at(n_char) == "-1") + w_courtroom->set_taken(n_char, true); + else + w_courtroom->set_taken(n_char, false); + } + } + + else if (header == "SC") { + if (!courtroom_constructed) + goto end; + + for (int n_element = 0; n_element < f_contents.size(); ++n_element) { + QStringList sub_elements = f_contents.at(n_element).split("&"); + + char_type f_char; + f_char.name = sub_elements.at(0); + if (sub_elements.size() >= 2) + f_char.description = sub_elements.at(1); + + // temporary. the CharsCheck packet sets this properly + f_char.taken = false; + + ++loaded_chars; + + w_lobby->set_loading_text(tr("Loading chars:\n%1/%2") + .arg(QString::number(loaded_chars)) + .arg(QString::number(char_list_size))); + + w_courtroom->append_char(f_char); + + int total_loading_size = + char_list_size * 2 + evidence_list_size + music_list_size; + int loading_value = int( + ((loaded_chars + generated_chars + loaded_music + loaded_evidence) / + static_cast<double>(total_loading_size)) * + 100); + w_lobby->set_loading_value(loading_value); + } + + send_server_packet(new AOPacket("RM#%")); + } + else if (header == "SM") { + if (!courtroom_constructed) + goto end; + + bool musics_time = false; + int areas = 0; + + for (int n_element = 0; n_element < f_contents.size(); ++n_element) { + ++loaded_music; + + w_lobby->set_loading_text(tr("Loading music:\n%1/%2") + .arg(QString::number(loaded_music)) + .arg(QString::number(music_list_size))); + + if (musics_time) { + w_courtroom->append_music(f_contents.at(n_element)); + } + else { + if (f_contents.at(n_element).endsWith(".wav") || + f_contents.at(n_element).endsWith(".mp3") || + f_contents.at(n_element).endsWith(".mp4") || + f_contents.at(n_element).endsWith(".ogg") || + f_contents.at(n_element).endsWith(".opus")) { + musics_time = true; + w_courtroom->fix_last_area(); + w_courtroom->append_music(f_contents.at(n_element)); + areas--; } - } - - else if (header == "SC") { - if (!courtroom_constructed) - goto end; - - for (int n_element = 0; n_element < f_contents.size(); ++n_element) { - QStringList sub_elements = f_contents.at(n_element).split("&"); - - char_type f_char; - f_char.name = sub_elements.at(0); - if (sub_elements.size() >= 2) - f_char.description = sub_elements.at(1); - - //temporary. the CharsCheck packet sets this properly - f_char.taken = false; - - ++loaded_chars; - - w_lobby->set_loading_text(tr("Loading chars:\n%1/%2").arg(QString::number(loaded_chars)).arg(QString::number(char_list_size))); - - w_courtroom->append_char(f_char); - - int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size; - int loading_value = int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100); - w_lobby->set_loading_value(loading_value); + else { + w_courtroom->append_area(f_contents.at(n_element)); + areas++; } + } - send_server_packet(new AOPacket("RM#%")); - } - else if (header == "SM") { - if (!courtroom_constructed) - goto end; - - bool musics_time = false; - int areas = 0; - - for (int n_element = 0; n_element < f_contents.size(); ++n_element) { - ++loaded_music; - - w_lobby->set_loading_text(tr("Loading music:\n%1/%2").arg(QString::number(loaded_music)).arg(QString::number(music_list_size))); - - if (musics_time) { - w_courtroom->append_music(f_contents.at(n_element)); - } - else { - if (f_contents.at(n_element).endsWith(".wav") || - f_contents.at(n_element).endsWith(".mp3") || - f_contents.at(n_element).endsWith(".mp4") || - f_contents.at(n_element).endsWith(".ogg") || - f_contents.at(n_element).endsWith(".opus")) { - musics_time = true; - w_courtroom->fix_last_area(); - w_courtroom->append_music(f_contents.at(n_element)); - areas--; - } - else { - w_courtroom->append_area(f_contents.at(n_element)); - areas++; - } - } - - for (int area_n = 0; area_n < areas; area_n++) { - w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown"); - } - - int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size; - int loading_value = int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100); - w_lobby->set_loading_value(loading_value); - } + for (int area_n = 0; area_n < areas; area_n++) { + w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown"); + } - send_server_packet(new AOPacket("RD#%")); + int total_loading_size = + char_list_size * 2 + evidence_list_size + music_list_size; + int loading_value = int( + ((loaded_chars + generated_chars + loaded_music + loaded_evidence) / + static_cast<double>(total_loading_size)) * + 100); + w_lobby->set_loading_value(loading_value); } - else if (header == "FM") //Fetch music ONLY - { - if (!courtroom_constructed) - goto end; - w_courtroom->clear_music(); + send_server_packet(new AOPacket("RD#%")); + } + else if (header == "FM") // Fetch music ONLY + { + if (!courtroom_constructed) + goto end; - for (int n_element = 0; n_element < f_contents.size(); ++n_element) { - w_courtroom->append_music(f_contents.at(n_element)); - } + w_courtroom->clear_music(); - w_courtroom->list_music(); + for (int n_element = 0; n_element < f_contents.size(); ++n_element) { + w_courtroom->append_music(f_contents.at(n_element)); } - else if (header == "FA") //Fetch areas ONLY - { - if (!courtroom_constructed) - goto end; - w_courtroom->clear_areas(); + w_courtroom->list_music(); + } + else if (header == "FA") // Fetch areas ONLY + { + if (!courtroom_constructed) + goto end; - for (int n_element = 0; n_element < f_contents.size(); ++n_element) { - w_courtroom->append_area(f_contents.at(n_element)); - } + w_courtroom->clear_areas(); - w_courtroom->list_areas(); + for (int n_element = 0; n_element < f_contents.size(); ++n_element) { + w_courtroom->append_area(f_contents.at(n_element)); } - else if (header == "DONE") { - if (!courtroom_constructed) - goto end; - if (lobby_constructed) - w_courtroom->append_ms_chatmessage("", w_lobby->get_chatlog()); + w_courtroom->list_areas(); + } + else if (header == "DONE") { + if (!courtroom_constructed) + goto end; - w_courtroom->character_loading_finished(); - w_courtroom->done_received(); + if (lobby_constructed) + w_courtroom->append_ms_chatmessage("", w_lobby->get_chatlog()); - courtroom_loaded = true; + w_courtroom->character_loading_finished(); + w_courtroom->done_received(); - destruct_lobby(); - } - else if (header == "BN") { - if (f_contents.size() < 1) - goto end; - - if (courtroom_constructed) { - if (f_contents.size() >= 2) //We have a pos included in the background packet! - w_courtroom->set_side(f_contents.at(1)); - w_courtroom->set_background(f_contents.at(0), f_contents.size() >= 2); - } - } - else if (header == "SP") { - if (f_contents.size() < 1) - goto end; + courtroom_loaded = true; - if (courtroom_constructed) //We were sent a "set position" packet - { - w_courtroom->set_side(f_contents.at(0)); - } - } - else if (header == "SD") //Send pos dropdown - { - if (f_contents.size() < 1) - goto end; + destruct_lobby(); + } + else if (header == "BN") { + if (f_contents.size() < 1) + goto end; - w_courtroom->set_pos_dropdown(f_contents.at(0).split("*")); + if (courtroom_constructed) { + if (f_contents.size() >= + 2) // We have a pos included in the background packet! + w_courtroom->set_side(f_contents.at(1)); + w_courtroom->set_background(f_contents.at(0), f_contents.size() >= 2); } - //server accepting char request(CC) packet - else if (header == "PV") { - if (f_contents.size() < 3) - goto end; + } + else if (header == "SP") { + if (f_contents.size() < 1) + goto end; - if (courtroom_constructed) - w_courtroom->update_character(f_contents.at(2).toInt()); - } - else if (header == "MS") { - if (courtroom_constructed && courtroom_loaded) - w_courtroom->handle_chatmessage(&p_packet->get_contents()); - } - else if (header == "MC") { - if (courtroom_constructed && courtroom_loaded) - w_courtroom->handle_song(&p_packet->get_contents()); - } - else if (header == "RT") { - if (f_contents.size() < 1) - goto end; - if (courtroom_constructed) { - if (f_contents.size() == 1) - w_courtroom->handle_wtce(f_contents.at(0), 0); - else if (f_contents.size() == 2) { - w_courtroom->handle_wtce(f_contents.at(0), f_contents.at(1).toInt()); - } - } - } - else if (header == "HP") { - if (courtroom_constructed && f_contents.size() > 1) - w_courtroom->set_hp_bar(f_contents.at(0).toInt(), f_contents.at(1).toInt()); - } - else if (header == "LE") { - if (courtroom_constructed) { - QVector<evi_type> f_evi_list; - - for (QString f_string : f_contents) { - QStringList sub_contents = f_string.split("&"); - - if (sub_contents.size() < 3) - continue; - - evi_type f_evi; - f_evi.name = sub_contents.at(0); - f_evi.description = sub_contents.at(1); - f_evi.image = sub_contents.at(2); - - f_evi_list.append(f_evi); - } + if (courtroom_constructed) // We were sent a "set position" packet + { + w_courtroom->set_side(f_contents.at(0)); + } + } + else if (header == "SD") // Send pos dropdown + { + if (f_contents.size() < 1) + goto end; + + w_courtroom->set_pos_dropdown(f_contents.at(0).split("*")); + } + // server accepting char request(CC) packet + else if (header == "PV") { + if (f_contents.size() < 3) + goto end; + + if (courtroom_constructed) + w_courtroom->update_character(f_contents.at(2).toInt()); + } + else if (header == "MS") { + if (courtroom_constructed && courtroom_loaded) + w_courtroom->handle_chatmessage(&p_packet->get_contents()); + } + else if (header == "MC") { + if (courtroom_constructed && courtroom_loaded) + w_courtroom->handle_song(&p_packet->get_contents()); + } + else if (header == "RT") { + if (f_contents.size() < 1) + goto end; + if (courtroom_constructed) { + if (f_contents.size() == 1) + w_courtroom->handle_wtce(f_contents.at(0), 0); + else if (f_contents.size() == 2) { + w_courtroom->handle_wtce(f_contents.at(0), f_contents.at(1).toInt()); + } + } + } + else if (header == "HP") { + if (courtroom_constructed && f_contents.size() > 1) + w_courtroom->set_hp_bar(f_contents.at(0).toInt(), + f_contents.at(1).toInt()); + } + else if (header == "LE") { + if (courtroom_constructed) { + QVector<evi_type> f_evi_list; + + for (QString f_string : f_contents) { + QStringList sub_contents = f_string.split("&"); + + if (sub_contents.size() < 3) + continue; - w_courtroom->set_evidence_list(f_evi_list); - } - } - else if (header == "ARUP") { - if (courtroom_constructed) { - int arup_type = f_contents.at(0).toInt(); - for (int n_element = 1; n_element < f_contents.size(); n_element++) { - w_courtroom->arup_modify(arup_type, n_element - 1, f_contents.at(n_element)); - } - } - } - else if (header == "IL") { - if (courtroom_constructed && f_contents.size() > 0) - w_courtroom->set_ip_list(f_contents.at(0)); - } - else if (header == "MU") { - if (courtroom_constructed && f_contents.size() > 0) - w_courtroom->set_mute(true, f_contents.at(0).toInt()); - } - else if (header == "UM") { - if (courtroom_constructed && f_contents.size() > 0) - w_courtroom->set_mute(false, f_contents.at(0).toInt()); - } - else if (header == "KK") { - if (courtroom_constructed && f_contents.size() >= 1) { - call_notice(tr("You have been kicked from the server.\nReason: %1").arg(f_contents.at(0))); - construct_lobby(); - destruct_courtroom(); - } - } - else if (header == "KB") { - if (courtroom_constructed && f_contents.size() >= 1) { - call_notice(tr("You have been banned from the server.\nReason: %1").arg(f_contents.at(0))); - construct_lobby(); - destruct_courtroom(); - } - } - else if (header == "BD") { - call_notice(tr("You are banned on this server.\nReason: %1").arg(f_contents.at(0))); - } - else if (header == "ZZ") { - if (courtroom_constructed && f_contents.size() > 0) - w_courtroom->mod_called(f_contents.at(0)); - } - else if (header == "CASEA") { - if (courtroom_constructed && f_contents.size() > 6) - w_courtroom->case_called(f_contents.at(0), f_contents.at(1) == "1", f_contents.at(2) == "1", f_contents.at(3) == "1", f_contents.at(4) == "1", f_contents.at(5) == "1"); - } + evi_type f_evi; + f_evi.name = sub_contents.at(0); + f_evi.description = sub_contents.at(1); + f_evi.image = sub_contents.at(2); + + f_evi_list.append(f_evi); + } + + w_courtroom->set_evidence_list(f_evi_list); + } + } + else if (header == "ARUP") { + if (courtroom_constructed) { + int arup_type = f_contents.at(0).toInt(); + for (int n_element = 1; n_element < f_contents.size(); n_element++) { + w_courtroom->arup_modify(arup_type, n_element - 1, + f_contents.at(n_element)); + } + } + } + else if (header == "IL") { + if (courtroom_constructed && f_contents.size() > 0) + w_courtroom->set_ip_list(f_contents.at(0)); + } + else if (header == "MU") { + if (courtroom_constructed && f_contents.size() > 0) + w_courtroom->set_mute(true, f_contents.at(0).toInt()); + } + else if (header == "UM") { + if (courtroom_constructed && f_contents.size() > 0) + w_courtroom->set_mute(false, f_contents.at(0).toInt()); + } + else if (header == "KK") { + if (courtroom_constructed && f_contents.size() >= 1) { + call_notice(tr("You have been kicked from the server.\nReason: %1") + .arg(f_contents.at(0))); + construct_lobby(); + destruct_courtroom(); + } + } + else if (header == "KB") { + if (courtroom_constructed && f_contents.size() >= 1) { + call_notice(tr("You have been banned from the server.\nReason: %1") + .arg(f_contents.at(0))); + construct_lobby(); + destruct_courtroom(); + } + } + else if (header == "BD") { + call_notice( + tr("You are banned on this server.\nReason: %1").arg(f_contents.at(0))); + } + else if (header == "ZZ") { + if (courtroom_constructed && f_contents.size() > 0) + w_courtroom->mod_called(f_contents.at(0)); + } + else if (header == "CASEA") { + if (courtroom_constructed && f_contents.size() > 6) + w_courtroom->case_called(f_contents.at(0), f_contents.at(1) == "1", + f_contents.at(2) == "1", f_contents.at(3) == "1", + f_contents.at(4) == "1", + f_contents.at(5) == "1"); + } end: - delete p_packet; + delete p_packet; } void AOApplication::send_ms_packet(AOPacket *p_packet) { - p_packet->net_encode(); + p_packet->net_encode(); - QString f_packet = p_packet->to_string(); + QString f_packet = p_packet->to_string(); - net_manager->ship_ms_packet(f_packet); + net_manager->ship_ms_packet(f_packet); #ifdef DEBUG_NETWORK - qDebug() << "S(ms):" << f_packet; + qDebug() << "S(ms):" << f_packet; #endif - delete p_packet; + delete p_packet; } void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded) { - if (encoded) - p_packet->net_encode(); + if (encoded) + p_packet->net_encode(); - QString f_packet = p_packet->to_string(); + QString f_packet = p_packet->to_string(); - if (encryption_needed) { + if (encryption_needed) { #ifdef DEBUG_NETWORK - qDebug() << "S(e):" << f_packet; + qDebug() << "S(e):" << f_packet; #endif - p_packet->encrypt_header(s_decryptor); - f_packet = p_packet->to_string(); - } - else { + p_packet->encrypt_header(s_decryptor); + f_packet = p_packet->to_string(); + } + else { #ifdef DEBUG_NETWORK - qDebug() << "S:" << f_packet; + qDebug() << "S:" << f_packet; #endif - } + } - net_manager->ship_server_packet(f_packet); + net_manager->ship_server_packet(f_packet); - delete p_packet; + delete p_packet; } diff --git a/src/path_functions.cpp b/src/path_functions.cpp index ebf4b629..07c9517c 100644 --- a/src/path_functions.cpp +++ b/src/path_functions.cpp @@ -10,157 +10,157 @@ #include "base_override.h" #endif -//this is a quite broad generalization -//the most common OSes(mac and windows) are _usually_ case insensitive -//however, there do exist mac installations with case sensitive filesystems -//in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac +// this is a quite broad generalization +// the most common OSes(mac and windows) are _usually_ case insensitive +// however, there do exist mac installations with case sensitive filesystems +// in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac #if (defined(LINUX) || defined(__linux__)) #define CASE_SENSITIVE_FILESYSTEM #endif QString AOApplication::get_base_path() { - QString base_path = ""; + QString base_path = ""; #ifdef ANDROID - QString sdcard_storage = getenv("SECONDARY_STORAGE"); - if (dir_exists(sdcard_storage + "/AO2/")) { - base_path = sdcard_storage + "/AO2/"; - } - else { - QString external_storage = getenv("EXTERNAL_STORAGE"); - base_path = external_storage + "/AO2/"; - } + QString sdcard_storage = getenv("SECONDARY_STORAGE"); + if (dir_exists(sdcard_storage + "/AO2/")) { + base_path = sdcard_storage + "/AO2/"; + } + else { + QString external_storage = getenv("EXTERNAL_STORAGE"); + base_path = external_storage + "/AO2/"; + } #elif defined __APPLE__ - base_path = applicationDirPath() + "/../../../base/"; + base_path = applicationDirPath() + "/../../../base/"; #else - base_path = applicationDirPath() + "/base/"; + base_path = applicationDirPath() + "/base/"; #endif - return base_path; + return base_path; } -QString AOApplication::get_data_path() -{ - return get_base_path() + "data/"; -} +QString AOApplication::get_data_path() { return get_base_path() + "data/"; } QString AOApplication::get_default_theme_path(QString p_file) { - QString path = get_base_path() + "themes/default/" + p_file; + QString path = get_base_path() + "themes/default/" + p_file; #ifndef CASE_SENSITIVE_FILESYSTEM - return path; + return path; #else - return get_case_sensitive_path(path); + return get_case_sensitive_path(path); #endif } QString AOApplication::get_custom_theme_path(QString p_theme, QString p_file) { - QString path = get_base_path() + "themes/" + p_theme + "/" + p_file; + QString path = get_base_path() + "themes/" + p_theme + "/" + p_file; #ifndef CASE_SENSITIVE_FILESYSTEM - return path; + return path; #else - return get_case_sensitive_path(path); + return get_case_sensitive_path(path); #endif } QString AOApplication::get_theme_path(QString p_file) { - QString path = get_base_path() + "themes/" + current_theme + "/" + p_file; + QString path = get_base_path() + "themes/" + current_theme + "/" + p_file; #ifndef CASE_SENSITIVE_FILESYSTEM - return path; + return path; #else - return get_case_sensitive_path(path); + return get_case_sensitive_path(path); #endif } QString AOApplication::get_character_path(QString p_char, QString p_file) { - QString path = get_base_path() + "characters/" + p_char + "/" + p_file; + QString path = get_base_path() + "characters/" + p_char + "/" + p_file; #ifndef CASE_SENSITIVE_FILESYSTEM - return path; + return path; #else - return get_case_sensitive_path(path); + return get_case_sensitive_path(path); #endif } QString AOApplication::get_sounds_path(QString p_file) { - QString path = get_base_path() + "sounds/general/" + p_file; + QString path = get_base_path() + "sounds/general/" + p_file; #ifndef CASE_SENSITIVE_FILESYSTEM - return path; + return path; #else - return get_case_sensitive_path(path); + return get_case_sensitive_path(path); #endif } QString AOApplication::get_music_path(QString p_song) { - QString path = get_base_path() + "sounds/music/" + p_song; + QString path = get_base_path() + "sounds/music/" + p_song; #ifndef CASE_SENSITIVE_FILESYSTEM - return path; + return path; #else - return get_case_sensitive_path(path); + return get_case_sensitive_path(path); #endif } QString AOApplication::get_background_path(QString p_file) { - QString path = get_base_path() + "background/" + w_courtroom->get_current_background() + "/" + p_file; - if (courtroom_constructed) { + QString path = get_base_path() + "background/" + + w_courtroom->get_current_background() + "/" + p_file; + if (courtroom_constructed) { #ifndef CASE_SENSITIVE_FILESYSTEM - return path; + return path; #else - return get_case_sensitive_path(path); + return get_case_sensitive_path(path); #endif - } - return get_default_background_path(p_file); + } + return get_default_background_path(p_file); } QString AOApplication::get_default_background_path(QString p_file) { - QString path = get_base_path() + "background/default/" + p_file; + QString path = get_base_path() + "background/default/" + p_file; #ifndef CASE_SENSITIVE_FILESYSTEM - return path; + return path; #else - return get_case_sensitive_path(path); + return get_case_sensitive_path(path); #endif } QString AOApplication::get_evidence_path(QString p_file) { - QString path = get_base_path() + "evidence/" + p_file; + QString path = get_base_path() + "evidence/" + p_file; #ifndef CASE_SENSITIVE_FILESYSTEM - return path; + return path; #else - return get_case_sensitive_path(path); + return get_case_sensitive_path(path); #endif } QString AOApplication::get_case_sensitive_path(QString p_file) { - //first, check to see if it's actually there (also serves as base case for recursion) - if (exists(p_file)) - return p_file; + // first, check to see if it's actually there (also serves as base case for + // recursion) + if (exists(p_file)) + return p_file; - QFileInfo file(p_file); + QFileInfo file(p_file); - QString file_basename = file.fileName(); - QString file_parent_dir = get_case_sensitive_path(file.absolutePath()); + QString file_basename = file.fileName(); + QString file_parent_dir = get_case_sensitive_path(file.absolutePath()); - //second, does it exist in the new parent dir? - if (exists(file_parent_dir + "/" + file_basename)) - return file_parent_dir + "/" + file_basename; + // second, does it exist in the new parent dir? + if (exists(file_parent_dir + "/" + file_basename)) + return file_parent_dir + "/" + file_basename; - //last resort, dirlist parent dir and find case insensitive match - QRegExp file_rx = QRegExp(file_basename, Qt::CaseInsensitive, QRegExp::FixedString); - QStringList files = QDir(file_parent_dir).entryList(); + // last resort, dirlist parent dir and find case insensitive match + QRegExp file_rx = + QRegExp(file_basename, Qt::CaseInsensitive, QRegExp::FixedString); + QStringList files = QDir(file_parent_dir).entryList(); - int result = files.indexOf(file_rx); + int result = files.indexOf(file_rx); - if (result != -1) - return file_parent_dir + "/" + files.at(result); + if (result != -1) + return file_parent_dir + "/" + files.at(result); - //if nothing is found, let the caller handle the missing file - return file_parent_dir + "/" + file_basename; + // if nothing is found, let the caller handle the missing file + return file_parent_dir + "/" + file_basename; } diff --git a/src/scrolltext.cpp b/src/scrolltext.cpp index 543f0f62..afd0aaba 100644 --- a/src/scrolltext.cpp +++ b/src/scrolltext.cpp @@ -2,124 +2,124 @@ ScrollText::ScrollText(QWidget *parent) : QWidget(parent), scrollPos(0) { - staticText.setTextFormat(Qt::PlainText); + staticText.setTextFormat(Qt::PlainText); - // setFixedHeight(fontMetrics().height()*2); //The theme sets this - leftMargin = height() / 3; + // setFixedHeight(fontMetrics().height()*2); //The theme sets this + leftMargin = height() / 3; - setSeparator(" --- "); + setSeparator(" --- "); - connect(&timer, SIGNAL(timeout()), this, SLOT(timer_timeout())); - timer.setInterval(50); + connect(&timer, SIGNAL(timeout()), this, SLOT(timer_timeout())); + timer.setInterval(50); } -QString ScrollText::text() const -{ - return _text; -} +QString ScrollText::text() const { return _text; } void ScrollText::setText(QString text) { - _text = text; - updateText(); - update(); + _text = text; + updateText(); + update(); } -QString ScrollText::separator() const -{ - return _separator; -} +QString ScrollText::separator() const { return _separator; } void ScrollText::setSeparator(QString separator) { - _separator = separator; - updateText(); - update(); + _separator = separator; + updateText(); + update(); } void ScrollText::updateText() { - timer.stop(); - - singleTextWidth = fontMetrics().horizontalAdvance(_text); - scrollEnabled = (singleTextWidth > width() - leftMargin * 2); - - if (scrollEnabled) { - scrollPos = -64; - staticText.setText(_text + _separator); - timer.start(); - } - else - staticText.setText(_text); - - staticText.prepare(QTransform(), font()); - wholeTextSize = QSize(fontMetrics().horizontalAdvance(staticText.text()), fontMetrics().height()); + timer.stop(); + + singleTextWidth = fontMetrics().horizontalAdvance(_text); + scrollEnabled = (singleTextWidth > width() - leftMargin * 2); + + if (scrollEnabled) { + scrollPos = -64; + staticText.setText(_text + _separator); + timer.start(); + } + else + staticText.setText(_text); + + staticText.prepare(QTransform(), font()); + wholeTextSize = QSize(fontMetrics().horizontalAdvance(staticText.text()), + fontMetrics().height()); } void ScrollText::paintEvent(QPaintEvent *) { - QPainter p(this); - - if (scrollEnabled) { - buffer.fill(qRgba(0, 0, 0, 0)); - QPainter pb(&buffer); - pb.setPen(p.pen()); - pb.setFont(p.font()); - - int x = qMin(-scrollPos, 0) + leftMargin; - while (x < width()) { - pb.drawStaticText(QPointF(x, (height() - wholeTextSize.height()) / 2), staticText); - x += wholeTextSize.width(); - } - - //Apply Alpha Channel - pb.setCompositionMode(QPainter::CompositionMode_DestinationIn); - pb.setClipRect(width() - 15, 0, 15, height()); - pb.drawImage(0, 0, alphaChannel); - pb.setClipRect(0, 0, 15, height()); - //initial situation: don't apply alpha channel in the left half of the image at all; apply it more and more until scrollPos gets positive - if (scrollPos < 0) - pb.setOpacity(static_cast<qreal>((qMax(-8, scrollPos) + 8) / 8.0)); - pb.drawImage(0, 0, alphaChannel); - - //pb.end(); - p.drawImage(0, 0, buffer); - } - else { - p.drawStaticText(QPointF(leftMargin, (height() - wholeTextSize.height()) / 2), staticText); + QPainter p(this); + + if (scrollEnabled) { + buffer.fill(qRgba(0, 0, 0, 0)); + QPainter pb(&buffer); + pb.setPen(p.pen()); + pb.setFont(p.font()); + + int x = qMin(-scrollPos, 0) + leftMargin; + while (x < width()) { + pb.drawStaticText(QPointF(x, (height() - wholeTextSize.height()) / 2), + staticText); + x += wholeTextSize.width(); } + + // Apply Alpha Channel + pb.setCompositionMode(QPainter::CompositionMode_DestinationIn); + pb.setClipRect(width() - 15, 0, 15, height()); + pb.drawImage(0, 0, alphaChannel); + pb.setClipRect(0, 0, 15, height()); + // initial situation: don't apply alpha channel in the left half of the + // image at all; apply it more and more until scrollPos gets positive + if (scrollPos < 0) + pb.setOpacity(static_cast<qreal>((qMax(-8, scrollPos) + 8) / 8.0)); + pb.drawImage(0, 0, alphaChannel); + + // pb.end(); + p.drawImage(0, 0, buffer); + } + else { + p.drawStaticText( + QPointF(leftMargin, (height() - wholeTextSize.height()) / 2), + staticText); + } } void ScrollText::resizeEvent(QResizeEvent *) { - //When the widget is resized, we need to update the alpha channel. - - alphaChannel = QImage(size(), QImage::Format_ARGB32_Premultiplied); - buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied); - - //Create Alpha Channel: - if (width() > 64) { - //create first scanline - QRgb *scanline1 = reinterpret_cast<QRgb *>(alphaChannel.scanLine(0)); - for (int x = 1; x < 16; ++x) - scanline1[x - 1] = scanline1[width() - x] = qRgba(0, 0, 0, x << 4); - for (int x = 15; x < width() - 15; ++x) - scanline1[x] = qRgb(0, 0, 0); - //copy scanline to the other ones - for (int y = 1; y < height(); ++y) - memcpy(alphaChannel.scanLine(y), scanline1, static_cast<uint>(width() * 4)); - } - else - alphaChannel.fill(qRgb(0, 0, 0)); - - //Update scrolling state - bool newScrollEnabled = (singleTextWidth > width() - leftMargin); - if (newScrollEnabled != scrollEnabled) - updateText(); + // When the widget is resized, we need to update the alpha channel. + + alphaChannel = QImage(size(), QImage::Format_ARGB32_Premultiplied); + buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied); + + // Create Alpha Channel: + if (width() > 64) { + // create first scanline + QRgb *scanline1 = reinterpret_cast<QRgb *>(alphaChannel.scanLine(0)); + for (int x = 1; x < 16; ++x) + scanline1[x - 1] = scanline1[width() - x] = qRgba(0, 0, 0, x << 4); + for (int x = 15; x < width() - 15; ++x) + scanline1[x] = qRgb(0, 0, 0); + // copy scanline to the other ones + for (int y = 1; y < height(); ++y) + memcpy(alphaChannel.scanLine(y), scanline1, + static_cast<uint>(width() * 4)); + } + else + alphaChannel.fill(qRgb(0, 0, 0)); + + // Update scrolling state + bool newScrollEnabled = (singleTextWidth > width() - leftMargin); + if (newScrollEnabled != scrollEnabled) + updateText(); } void ScrollText::timer_timeout() { - scrollPos = (scrollPos + 2) % wholeTextSize.width(); - update(); + scrollPos = (scrollPos + 2) % wholeTextSize.width(); + update(); } diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 18da8538..615a6a14 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -2,1030 +2,1073 @@ QString AOApplication::read_theme() { - QString result = configini->value("theme", "default").value<QString>(); - return result; + QString result = configini->value("theme", "default").value<QString>(); + return result; } int AOApplication::read_blip_rate() { - int result = configini->value("blip_rate", 2).toInt(); + int result = configini->value("blip_rate", 2).toInt(); - if (result < 1) - return 1; + if (result < 1) + return 1; - return result; + return result; } QString AOApplication::get_ooc_name() { - QString result = configini->value("ooc_name").value<QString>(); - return result; + QString result = configini->value("ooc_name").value<QString>(); + return result; } int AOApplication::get_default_music() { - int result = configini->value("default_music", 50).toInt(); - return result; + int result = configini->value("default_music", 50).toInt(); + return result; } int AOApplication::get_default_sfx() { - int result = configini->value("default_sfx", 50).toInt(); - return result; + int result = configini->value("default_sfx", 50).toInt(); + return result; } int AOApplication::get_default_blip() { - int result = configini->value("default_blip", 50).toInt(); - return result; + int result = configini->value("default_blip", 50).toInt(); + return result; } int AOApplication::get_max_log_size() { - int result = configini->value("log_maximum", 200).toInt(); - return result; + int result = configini->value("log_maximum", 200).toInt(); + return result; } bool AOApplication::get_log_goes_downwards() { - QString result = configini->value("log_goes_downwards", "true").value<QString>(); - return result.startsWith("true"); + QString result = + configini->value("log_goes_downwards", "true").value<QString>(); + return result.startsWith("true"); } bool AOApplication::get_showname_enabled_by_default() { - QString result = configini->value("show_custom_shownames", "true").value<QString>(); - return result.startsWith("true"); + QString result = + configini->value("show_custom_shownames", "true").value<QString>(); + return result.startsWith("true"); } QString AOApplication::get_default_username() { - QString result = configini->value("default_username", "").value<QString>(); - if (result.isEmpty()) - return get_ooc_name(); - else - return result; + QString result = configini->value("default_username", "").value<QString>(); + if (result.isEmpty()) + return get_ooc_name(); + else + return result; } QString AOApplication::get_audio_output_device() { - QString result = configini->value("default_audio_device", "default").value<QString>(); - return result; + QString result = + configini->value("default_audio_device", "default").value<QString>(); + return result; } QStringList AOApplication::get_call_words() { - return get_list_file(get_base_path() + "callwords.ini"); + return get_list_file(get_base_path() + "callwords.ini"); } QStringList AOApplication::get_list_file(QString p_file) { - QStringList return_value; + QStringList return_value; - QFile p_ini; + QFile p_ini; - p_ini.setFileName(p_file); + p_ini.setFileName(p_file); - if (!p_ini.open(QIODevice::ReadOnly)) - return return_value; + if (!p_ini.open(QIODevice::ReadOnly)) + return return_value; - QTextStream in(&p_ini); + QTextStream in(&p_ini); - while (!in.atEnd()) { - QString line = in.readLine(); - return_value.append(line); - } + while (!in.atEnd()) { + QString line = in.readLine(); + return_value.append(line); + } - return return_value; + return return_value; } QString AOApplication::read_file(QString filename) { - QFile f_log(filename); + QFile f_log(filename); - if (!f_log.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug() << "Couldn't open" << filename; - return ""; - } + if (!f_log.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "Couldn't open" << filename; + return ""; + } - QTextStream in(&f_log); - QString text = in.readAll(); - f_log.close(); - return text; + QTextStream in(&f_log); + QString text = in.readAll(); + f_log.close(); + return text; } bool AOApplication::write_to_file(QString p_text, QString p_file, bool make_dir) { - QString path = QFileInfo(p_file).path(); - if (make_dir) { - //Create the dir if it doesn't exist yet - QDir dir(path); - if (!dir.exists()) - if (!dir.mkpath(".")) - return false; - } + QString path = QFileInfo(p_file).path(); + if (make_dir) { + // Create the dir if it doesn't exist yet + QDir dir(path); + if (!dir.exists()) + if (!dir.mkpath(".")) + return false; + } - QFile f_log(p_file); - if (f_log.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { - QTextStream out(&f_log); + QFile f_log(p_file); + if (f_log.open(QIODevice::WriteOnly | QIODevice::Text | + QIODevice::Truncate)) { + QTextStream out(&f_log); - out << p_text; + out << p_text; - f_log.flush(); - f_log.close(); - return true; - } - return false; + f_log.flush(); + f_log.close(); + return true; + } + return false; } -bool AOApplication::append_to_file(QString p_text, QString p_file, bool make_dir) +bool AOApplication::append_to_file(QString p_text, QString p_file, + bool make_dir) { - QString path = QFileInfo(p_file).path(); - //Create the dir if it doesn't exist yet - if (make_dir) { - QDir dir(path); - if (!dir.exists()) - if (!dir.mkpath(".")) - return false; - } + QString path = QFileInfo(p_file).path(); + // Create the dir if it doesn't exist yet + if (make_dir) { + QDir dir(path); + if (!dir.exists()) + if (!dir.mkpath(".")) + return false; + } - QFile f_log(p_file); - if (f_log.open(QIODevice::WriteOnly | QIODevice::Append)) { - QTextStream out(&f_log); + QFile f_log(p_file); + if (f_log.open(QIODevice::WriteOnly | QIODevice::Append)) { + QTextStream out(&f_log); - out << "\r\n" - << p_text; + out << "\r\n" << p_text; - f_log.flush(); - f_log.close(); - return true; - } - return false; + f_log.flush(); + f_log.close(); + return true; + } + return false; } void AOApplication::write_to_serverlist_txt(QString p_line) { - QFile serverlist_txt; - QString serverlist_txt_path = get_base_path() + "serverlist.txt"; + QFile serverlist_txt; + QString serverlist_txt_path = get_base_path() + "serverlist.txt"; - serverlist_txt.setFileName(serverlist_txt_path); + serverlist_txt.setFileName(serverlist_txt_path); - if (!serverlist_txt.open(QIODevice::WriteOnly | QIODevice::Append)) { - return; - } + if (!serverlist_txt.open(QIODevice::WriteOnly | QIODevice::Append)) { + return; + } - QTextStream out(&serverlist_txt); + QTextStream out(&serverlist_txt); - out << "\r\n" - << p_line; + out << "\r\n" << p_line; - serverlist_txt.close(); + serverlist_txt.close(); } QVector<server_type> AOApplication::read_serverlist_txt() { - QVector<server_type> f_server_list; + QVector<server_type> f_server_list; - QFile serverlist_txt; - QString serverlist_txt_path = get_base_path() + "serverlist.txt"; + QFile serverlist_txt; + QString serverlist_txt_path = get_base_path() + "serverlist.txt"; - serverlist_txt.setFileName(serverlist_txt_path); + serverlist_txt.setFileName(serverlist_txt_path); - if (!serverlist_txt.open(QIODevice::ReadOnly)) { - return f_server_list; - } + if (!serverlist_txt.open(QIODevice::ReadOnly)) { + return f_server_list; + } - QTextStream in(&serverlist_txt); + QTextStream in(&serverlist_txt); - while (!in.atEnd()) { - QString line = in.readLine(); - server_type f_server; - QStringList line_contents = line.split(":"); + while (!in.atEnd()) { + QString line = in.readLine(); + server_type f_server; + QStringList line_contents = line.split(":"); - if (line_contents.size() < 3) - continue; + if (line_contents.size() < 3) + continue; - f_server.ip = line_contents.at(0); - f_server.port = line_contents.at(1).toInt(); - f_server.name = line_contents.at(2); - f_server.desc = ""; + f_server.ip = line_contents.at(0); + f_server.port = line_contents.at(1).toInt(); + f_server.name = line_contents.at(2); + f_server.desc = ""; - f_server_list.append(f_server); - } + f_server_list.append(f_server); + } - return f_server_list; + return f_server_list; } -QString AOApplication::read_design_ini(QString p_identifier, QString p_design_path) +QString AOApplication::read_design_ini(QString p_identifier, + QString p_design_path) { - QSettings settings(p_design_path, QSettings::IniFormat); - QVariant value = settings.value(p_identifier); - if (value.type() == QVariant::StringList) { - return value.toStringList().join(","); - } - else { - return value.toString(); - } + QSettings settings(p_design_path, QSettings::IniFormat); + QVariant value = settings.value(p_identifier); + if (value.type() == QVariant::StringList) { + return value.toStringList().join(","); + } + else { + return value.toString(); + } } QPoint AOApplication::get_button_spacing(QString p_identifier, QString p_file) { - QString design_ini_path = get_theme_path(p_file); - QString default_path = get_default_theme_path(p_file); - QString f_result = read_design_ini(p_identifier, design_ini_path); + QString design_ini_path = get_theme_path(p_file); + QString default_path = get_default_theme_path(p_file); + QString f_result = read_design_ini(p_identifier, design_ini_path); - QPoint return_value; + QPoint return_value; - return_value.setX(0); - return_value.setY(0); + return_value.setX(0); + return_value.setY(0); - if (f_result == "") { - f_result = read_design_ini(p_identifier, default_path); + if (f_result == "") { + f_result = read_design_ini(p_identifier, default_path); - if (f_result == "") - return return_value; - } + if (f_result == "") + return return_value; + } - QStringList sub_line_elements = f_result.split(","); + QStringList sub_line_elements = f_result.split(","); - if (sub_line_elements.size() < 2) - return return_value; + if (sub_line_elements.size() < 2) + return return_value; - return_value.setX(sub_line_elements.at(0).toInt()); - return_value.setY(sub_line_elements.at(1).toInt()); + return_value.setX(sub_line_elements.at(0).toInt()); + return_value.setY(sub_line_elements.at(1).toInt()); - return return_value; + return return_value; } -pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QString p_file, QString p_char) +pos_size_type AOApplication::get_element_dimensions(QString p_identifier, + QString p_file, + QString p_char) { - QString char_ini_path = get_base_path() + "misc/" + get_chat(p_char) + "/" + p_file; - QString design_ini_path = get_theme_path(p_file); - QString default_path = get_default_theme_path(p_file); - QString f_result = read_design_ini(p_identifier, char_ini_path); + QString char_ini_path = + get_base_path() + "misc/" + get_chat(p_char) + "/" + p_file; + QString design_ini_path = get_theme_path(p_file); + QString default_path = get_default_theme_path(p_file); + QString f_result = read_design_ini(p_identifier, char_ini_path); - pos_size_type return_value; + pos_size_type return_value; - return_value.x = 0; - return_value.y = 0; - return_value.width = -1; - return_value.height = -1; + return_value.x = 0; + return_value.y = 0; + return_value.width = -1; + return_value.height = -1; + if (f_result == "") { + f_result = read_design_ini(p_identifier, design_ini_path); if (f_result == "") { - f_result = read_design_ini(p_identifier, design_ini_path); - if (f_result == "") { - f_result = read_design_ini(p_identifier, default_path); + f_result = read_design_ini(p_identifier, default_path); - if (f_result == "") - return return_value; - } + if (f_result == "") + return return_value; } + } - QStringList sub_line_elements = f_result.split(","); + QStringList sub_line_elements = f_result.split(","); - if (sub_line_elements.size() < 4) - return return_value; + if (sub_line_elements.size() < 4) + return return_value; - return_value.x = sub_line_elements.at(0).toInt(); - return_value.y = sub_line_elements.at(1).toInt(); - return_value.width = sub_line_elements.at(2).toInt(); - return_value.height = sub_line_elements.at(3).toInt(); + return_value.x = sub_line_elements.at(0).toInt(); + return_value.y = sub_line_elements.at(1).toInt(); + return_value.width = sub_line_elements.at(2).toInt(); + return_value.height = sub_line_elements.at(3).toInt(); - return return_value; + return return_value; } -QString AOApplication::get_design_element(QString p_identifier, QString p_file, QString p_char) +QString AOApplication::get_design_element(QString p_identifier, QString p_file, + QString p_char) { - QString char_ini_path = get_base_path() + "misc/" + get_chat(p_char) + "/" + p_file; - QString design_ini_path = get_theme_path(p_file); - QString default_path = get_default_theme_path(p_file); - QString f_result = read_design_ini(p_identifier, char_ini_path); - if (f_result == "") { - f_result = read_design_ini(p_identifier, design_ini_path); - if (f_result == "") - f_result = read_design_ini(p_identifier, default_path); - } - return f_result; + QString char_ini_path = + get_base_path() + "misc/" + get_chat(p_char) + "/" + p_file; + QString design_ini_path = get_theme_path(p_file); + QString default_path = get_default_theme_path(p_file); + QString f_result = read_design_ini(p_identifier, char_ini_path); + if (f_result == "") { + f_result = read_design_ini(p_identifier, design_ini_path); + if (f_result == "") + f_result = read_design_ini(p_identifier, default_path); + } + return f_result; } QString AOApplication::get_font_name(QString p_identifier, QString p_file) { - QString design_ini_path = get_theme_path(p_file); - QString f_result = read_design_ini(p_identifier, design_ini_path); - QString default_path = get_default_theme_path(p_file); - if (f_result == "") { - f_result = read_design_ini(p_identifier, default_path); - if (f_result == "") - return ""; - } - return f_result; + QString design_ini_path = get_theme_path(p_file); + QString f_result = read_design_ini(p_identifier, design_ini_path); + QString default_path = get_default_theme_path(p_file); + if (f_result == "") { + f_result = read_design_ini(p_identifier, default_path); + if (f_result == "") + return ""; + } + return f_result; } int AOApplication::get_font_size(QString p_identifier, QString p_file) { - QString design_ini_path = get_theme_path(p_file); - QString default_path = get_default_theme_path(p_file); - QString f_result = read_design_ini(p_identifier, design_ini_path); + QString design_ini_path = get_theme_path(p_file); + QString default_path = get_default_theme_path(p_file); + QString f_result = read_design_ini(p_identifier, design_ini_path); - if (f_result == "") { - f_result = read_design_ini(p_identifier, default_path); + if (f_result == "") { + f_result = read_design_ini(p_identifier, default_path); - if (f_result == "") - return 10; - } + if (f_result == "") + return 10; + } - return f_result.toInt(); + return f_result.toInt(); } QColor AOApplication::get_color(QString p_identifier, QString p_file) { - QString design_ini_path = get_theme_path(p_file); - QString default_path = get_default_theme_path(p_file); - QString f_result = read_design_ini(p_identifier, design_ini_path); + QString design_ini_path = get_theme_path(p_file); + QString default_path = get_default_theme_path(p_file); + QString f_result = read_design_ini(p_identifier, design_ini_path); - QColor return_color(0, 0, 0); + QColor return_color(0, 0, 0); - if (f_result == "") { - f_result = read_design_ini(p_identifier, default_path); + if (f_result == "") { + f_result = read_design_ini(p_identifier, default_path); - if (f_result == "") - return return_color; - } + if (f_result == "") + return return_color; + } - QStringList color_list = f_result.split(","); + QStringList color_list = f_result.split(","); - if (color_list.size() < 3) - return return_color; + if (color_list.size() < 3) + return return_color; - return_color.setRed(color_list.at(0).toInt()); - return_color.setGreen(color_list.at(1).toInt()); - return_color.setBlue(color_list.at(2).toInt()); + return_color.setRed(color_list.at(0).toInt()); + return_color.setGreen(color_list.at(1).toInt()); + return_color.setBlue(color_list.at(2).toInt()); - return return_color; + return return_color; } QString AOApplication::get_stylesheet(QString p_file) { - QString design_ini_path = get_theme_path(p_file); - QString default_path = get_default_theme_path(p_file); + QString design_ini_path = get_theme_path(p_file); + QString default_path = get_default_theme_path(p_file); - QFile design_ini; + QFile design_ini; - design_ini.setFileName(design_ini_path); + design_ini.setFileName(design_ini_path); - if (!design_ini.open(QIODevice::ReadOnly)) { - design_ini.setFileName(default_path); - if (!design_ini.open(QIODevice::ReadOnly)) - return ""; - } + if (!design_ini.open(QIODevice::ReadOnly)) { + design_ini.setFileName(default_path); + if (!design_ini.open(QIODevice::ReadOnly)) + return ""; + } - QTextStream in(&design_ini); + QTextStream in(&design_ini); - QString f_text; + QString f_text; - while (!in.atEnd()) { - f_text.append(in.readLine()); - } + while (!in.atEnd()) { + f_text.append(in.readLine()); + } - design_ini.close(); - return f_text; + design_ini.close(); + return f_text; } QString AOApplication::get_tagged_stylesheet(QString target_tag, QString p_file) { - QString design_ini_path = get_theme_path(p_file); + QString design_ini_path = get_theme_path(p_file); - QFile design_ini; + QFile design_ini; - design_ini.setFileName(design_ini_path); + design_ini.setFileName(design_ini_path); - if (!design_ini.open(QIODevice::ReadOnly)) - return ""; + if (!design_ini.open(QIODevice::ReadOnly)) + return ""; - QTextStream in(&design_ini); + QTextStream in(&design_ini); - QString f_text; + QString f_text; - bool tag_found = false; + bool tag_found = false; - while (!in.atEnd()) { - QString line = in.readLine(); + while (!in.atEnd()) { + QString line = in.readLine(); - if (line.startsWith(target_tag, Qt::CaseInsensitive)) { - tag_found = true; - continue; - } + if (line.startsWith(target_tag, Qt::CaseInsensitive)) { + tag_found = true; + continue; + } - if (tag_found) { - if ((line.startsWith("[") && line.endsWith("]"))) - break; - f_text.append(line); - } + if (tag_found) { + if ((line.startsWith("[") && line.endsWith("]"))) + break; + f_text.append(line); } + } - design_ini.close(); - return f_text; + design_ini.close(); + return f_text; } QString AOApplication::get_chat_markdown(QString p_identifier, QString p_chat) { - 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); + 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); - if (f_result == "") - f_result = read_design_ini(p_identifier, default_path); + if (f_result == "") + f_result = read_design_ini(p_identifier, default_path); - return f_result.toLatin1(); + return f_result.toLatin1(); } QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat) { - QColor return_color(255, 255, 255); + QColor return_color(255, 255, 255); + + switch (p_identifier.toInt()) { + case 0: // White + return_color = QColor(255, 255, 255); + break; + case 1: // Green + return_color = QColor(0, 255, 0); + break; + case 2: // Red + return_color = QColor(255, 0, 0); + break; + case 3: // Orange + return_color = QColor(255, 165, 0); + break; + case 4: // Blue + return_color = QColor(45, 150, 255); + break; + case 5: // Yellow + return_color = QColor(255, 255, 0); + break; + case 6: // Pink + return_color = QColor(255, 192, 203); + break; + case 7: // Cyan + return_color = QColor(0, 255, 255); + break; + case 8: // Grey + return_color = QColor(187, 187, 187); + break; + default: + return_color = QColor(255, 255, 255); + break; + } + 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("c" + p_identifier, design_ini_path); + + if (f_result == "") { + f_result = read_design_ini(p_identifier, default_path); - switch (p_identifier.toInt()) { - case 0: //White - return_color = QColor(255, 255, 255); - break; - case 1: //Green - return_color = QColor(0, 255, 0); - break; - case 2: //Red - return_color = QColor(255, 0, 0); - break; - case 3: //Orange - return_color = QColor(255, 165, 0); - break; - case 4: //Blue - return_color = QColor(45, 150, 255); - break; - case 5: //Yellow - return_color = QColor(255, 255, 0); - break; - case 6: //Pink - return_color = QColor(255, 192, 203); - break; - case 7: //Cyan - return_color = QColor(0, 255, 255); - break; - case 8: //Grey - return_color = QColor(187, 187, 187); - break; - default: - return_color = QColor(255, 255, 255); - break; - } - 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("c" + p_identifier, design_ini_path); - - if (f_result == "") { - f_result = read_design_ini(p_identifier, default_path); - - if (f_result == "") - return return_color; - } + if (f_result == "") + return return_color; + } - QStringList color_list = f_result.split(","); + QStringList color_list = f_result.split(","); - if (color_list.size() < 3) - return return_color; + if (color_list.size() < 3) + return return_color; - return_color.setRed(color_list.at(0).toInt()); - return_color.setGreen(color_list.at(1).toInt()); - return_color.setBlue(color_list.at(2).toInt()); + return_color.setRed(color_list.at(0).toInt()); + return_color.setGreen(color_list.at(1).toInt()); + return_color.setBlue(color_list.at(2).toInt()); - return return_color; + return return_color; } QString AOApplication::get_sfx(QString p_identifier) { - QString design_ini_path = get_theme_path("courtroom_sounds.ini"); - QString default_path = get_default_theme_path("courtroom_sounds.ini"); - QString f_result = read_design_ini(p_identifier, design_ini_path); + QString design_ini_path = get_theme_path("courtroom_sounds.ini"); + QString default_path = get_default_theme_path("courtroom_sounds.ini"); + QString f_result = read_design_ini(p_identifier, design_ini_path); - QString return_sfx = ""; + QString return_sfx = ""; - if (f_result == "") { - f_result = read_design_ini(p_identifier, default_path); + if (f_result == "") { + f_result = read_design_ini(p_identifier, default_path); - if (f_result == "") - return return_sfx; - } + if (f_result == "") + return return_sfx; + } - return_sfx = f_result; + return_sfx = f_result; - return return_sfx; + return return_sfx; } QString AOApplication::get_sfx_suffix(QString sound_to_check) { - if (file_exists(sound_to_check)) - return sound_to_check; - if (file_exists(sound_to_check + ".opus")) - return sound_to_check + ".opus"; - if (file_exists(sound_to_check + ".ogg")) - return sound_to_check + ".ogg"; - if (file_exists(sound_to_check + ".mp3")) - return sound_to_check + ".mp3"; - if (file_exists(sound_to_check + ".mp4")) - return sound_to_check + ".mp4"; - return sound_to_check + ".wav"; + if (file_exists(sound_to_check)) + return sound_to_check; + if (file_exists(sound_to_check + ".opus")) + return sound_to_check + ".opus"; + if (file_exists(sound_to_check + ".ogg")) + return sound_to_check + ".ogg"; + if (file_exists(sound_to_check + ".mp3")) + return sound_to_check + ".mp3"; + if (file_exists(sound_to_check + ".mp4")) + return sound_to_check + ".mp4"; + return sound_to_check + ".wav"; } QString AOApplication::get_image_suffix(QString path_to_check) { - if (file_exists(path_to_check)) - return path_to_check; - if (file_exists(path_to_check + ".webp")) - return path_to_check + ".webp"; - if (file_exists(path_to_check + ".apng")) - return path_to_check + ".apng"; - if (file_exists(path_to_check + ".gif")) - return path_to_check + ".gif"; - return path_to_check + ".png"; + if (file_exists(path_to_check)) + return path_to_check; + if (file_exists(path_to_check + ".webp")) + return path_to_check + ".webp"; + if (file_exists(path_to_check + ".apng")) + return path_to_check + ".apng"; + if (file_exists(path_to_check + ".gif")) + return path_to_check + ".gif"; + return path_to_check + ".png"; } QString AOApplication::get_static_image_suffix(QString path_to_check) { - return path_to_check + ".png"; + return path_to_check + ".png"; } -//returns whatever is to the right of "search_line =" within target_tag and terminator_tag, trimmed -//returns the empty string if the search line couldnt be found -QString AOApplication::read_char_ini(QString p_char, QString p_search_line, QString target_tag) +// returns whatever is to the right of "search_line =" within target_tag and +// terminator_tag, trimmed returns the empty string if the search line couldnt be +// found +QString AOApplication::read_char_ini(QString p_char, QString p_search_line, + QString target_tag) { - QSettings settings(get_character_path(p_char, "char.ini"), QSettings::IniFormat); - settings.beginGroup(target_tag); - QString value = settings.value(p_search_line).toString(); - settings.endGroup(); - return value; + QSettings settings(get_character_path(p_char, "char.ini"), + QSettings::IniFormat); + settings.beginGroup(target_tag); + QString value = settings.value(p_search_line).toString(); + settings.endGroup(); + return value; } -void AOApplication::set_char_ini(QString p_char, QString value, QString p_search_line, QString target_tag) +void AOApplication::set_char_ini(QString p_char, QString value, + QString p_search_line, QString target_tag) { - QSettings settings(get_character_path(p_char, "char.ini"), QSettings::IniFormat); - settings.beginGroup(target_tag); - settings.setValue(p_search_line, value); - settings.endGroup(); + QSettings settings(get_character_path(p_char, "char.ini"), + QSettings::IniFormat); + settings.beginGroup(target_tag); + settings.setValue(p_search_line, value); + settings.endGroup(); } -//returns all the values of target_tag +// returns all the values of target_tag QStringList AOApplication::read_ini_tags(QString p_path, QString target_tag) { - QStringList r_values; - QSettings settings(p_path, QSettings::IniFormat); - if (!target_tag.isEmpty()) - settings.beginGroup(target_tag); - QStringList keys = settings.allKeys(); - foreach (QString key, keys) { - QString value = settings.value(key).toString(); - r_values << key + "=" + value; - } - if (!settings.group().isEmpty()) - settings.endGroup(); - return r_values; + QStringList r_values; + QSettings settings(p_path, QSettings::IniFormat); + if (!target_tag.isEmpty()) + settings.beginGroup(target_tag); + QStringList keys = settings.allKeys(); + foreach (QString key, keys) { + QString value = settings.value(key).toString(); + r_values << key + "=" + value; + } + if (!settings.group().isEmpty()) + settings.endGroup(); + return r_values; } QString AOApplication::get_char_name(QString p_char) { - QString f_result = read_char_ini(p_char, "name", "Options"); + QString f_result = read_char_ini(p_char, "name", "Options"); - if (f_result == "") - return p_char; - return f_result; + if (f_result == "") + return p_char; + return f_result; } QString AOApplication::get_showname(QString p_char) { - QString f_result = read_char_ini(p_char, "showname", "Options"); - QString f_needed = read_char_ini(p_char, "needs_showname", "Options"); + QString f_result = read_char_ini(p_char, "showname", "Options"); + QString f_needed = read_char_ini(p_char, "needs_showname", "Options"); - if (f_needed.startsWith("false")) - return ""; - if (f_result == "") - return p_char; - return f_result; + if (f_needed.startsWith("false")) + return ""; + if (f_result == "") + return p_char; + return f_result; } QString AOApplication::get_char_side(QString p_char) { - QString f_result = read_char_ini(p_char, "side", "Options"); + QString f_result = read_char_ini(p_char, "side", "Options"); - if (f_result == "") - return "wit"; - return f_result; + if (f_result == "") + return "wit"; + return f_result; } QString AOApplication::get_gender(QString p_char) { - QString f_result = read_char_ini(p_char, "gender", "Options"); + QString f_result = read_char_ini(p_char, "gender", "Options"); - if (f_result == "") - return "sfx-blipmale"; + if (f_result == "") + return "sfx-blipmale"; - if (!file_exists(get_sfx_suffix(get_sounds_path(f_result)))) { - if (file_exists(get_sfx_suffix(get_sounds_path("../blips/" + f_result)))) - return "../blips/" + f_result; //Return the cool kids variant + if (!file_exists(get_sfx_suffix(get_sounds_path(f_result)))) { + if (file_exists(get_sfx_suffix(get_sounds_path("../blips/" + f_result)))) + return "../blips/" + f_result; // Return the cool kids variant - return "sfx-blip" + f_result; //Return legacy variant - } - return f_result; + return "sfx-blip" + f_result; // Return legacy variant + } + return f_result; } QString AOApplication::get_chat(QString p_char) { - QString f_result = read_char_ini(p_char, "chat", "Options"); + QString f_result = read_char_ini(p_char, "chat", "Options"); - //handling the correct order of chat is a bit complicated, we let the caller do it - return f_result; + // handling the correct order of chat is a bit complicated, we let the caller + // do it + return f_result; } QString AOApplication::get_chat_font(QString p_char) { - QString f_result = read_char_ini(p_char, "chat_font", "Options"); + QString f_result = read_char_ini(p_char, "chat_font", "Options"); - return f_result; + return f_result; } int AOApplication::get_chat_size(QString p_char) { - QString f_result = read_char_ini(p_char, "chat_size", "Options"); + QString f_result = read_char_ini(p_char, "chat_size", "Options"); - if (f_result == "") - return -1; - return f_result.toInt(); + if (f_result == "") + return -1; + return f_result.toInt(); } QString AOApplication::get_char_shouts(QString p_char) { - QString f_result = read_char_ini(p_char, "shouts", "Options"); - if (f_result == "") - return "default"; - return f_result; + QString f_result = read_char_ini(p_char, "shouts", "Options"); + if (f_result == "") + return "default"; + return f_result; } int AOApplication::get_preanim_duration(QString p_char, QString p_emote) { - QString f_result = read_char_ini(p_char, p_emote, "Time"); + QString f_result = read_char_ini(p_char, p_emote, "Time"); - if (f_result == "") - return -1; - return f_result.toInt(); + if (f_result == "") + return -1; + return f_result.toInt(); } int AOApplication::get_ao2_preanim_duration(QString p_char, QString p_emote) { - QString f_result = read_char_ini(p_char, "%" + p_emote, "Time"); + QString f_result = read_char_ini(p_char, "%" + p_emote, "Time"); - if (f_result == "") - return -1; - return f_result.toInt(); + if (f_result == "") + return -1; + return f_result.toInt(); } int AOApplication::get_emote_number(QString p_char) { - QString f_result = read_char_ini(p_char, "number", "Emotions"); + QString f_result = read_char_ini(p_char, "number", "Emotions"); - if (f_result == "") - return 0; - return f_result.toInt(); + if (f_result == "") + return 0; + return f_result.toInt(); } QString AOApplication::get_emote_comment(QString p_char, int p_emote) { - QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "Emotions"); + QString f_result = + read_char_ini(p_char, QString::number(p_emote + 1), "Emotions"); - QStringList result_contents = f_result.split("#"); + QStringList result_contents = f_result.split("#"); - if (result_contents.size() < 4) { - qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote; - return "normal"; - } - return result_contents.at(0); + if (result_contents.size() < 4) { + qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote; + return "normal"; + } + return result_contents.at(0); } QString AOApplication::get_pre_emote(QString p_char, int p_emote) { - QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "Emotions"); + QString f_result = + read_char_ini(p_char, QString::number(p_emote + 1), "Emotions"); - QStringList result_contents = f_result.split("#"); + QStringList result_contents = f_result.split("#"); - if (result_contents.size() < 4) { - qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote; - return ""; - } - return result_contents.at(1); + if (result_contents.size() < 4) { + qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote; + return ""; + } + return result_contents.at(1); } QString AOApplication::get_emote(QString p_char, int p_emote) { - QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "Emotions"); + QString f_result = + read_char_ini(p_char, QString::number(p_emote + 1), "Emotions"); - QStringList result_contents = f_result.split("#"); + QStringList result_contents = f_result.split("#"); - if (result_contents.size() < 4) { - qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote; - return "normal"; - } - return result_contents.at(2); + if (result_contents.size() < 4) { + qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote; + return "normal"; + } + return result_contents.at(2); } int AOApplication::get_emote_mod(QString p_char, int p_emote) { - QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "Emotions"); + QString f_result = + read_char_ini(p_char, QString::number(p_emote + 1), "Emotions"); - QStringList result_contents = f_result.split("#"); + QStringList result_contents = f_result.split("#"); - if (result_contents.size() < 4) { - qDebug() << "W: misformatted char.ini: " << p_char << ", " << QString::number(p_emote); - return 0; - } - return result_contents.at(3).toInt(); + if (result_contents.size() < 4) { + qDebug() << "W: misformatted char.ini: " << p_char << ", " + << QString::number(p_emote); + return 0; + } + return result_contents.at(3).toInt(); } int AOApplication::get_desk_mod(QString p_char, int p_emote) { - QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "Emotions"); + QString f_result = + read_char_ini(p_char, QString::number(p_emote + 1), "Emotions"); - QStringList result_contents = f_result.split("#"); + QStringList result_contents = f_result.split("#"); - if (result_contents.size() < 5) - return -1; + if (result_contents.size() < 5) + return -1; - QString string_result = result_contents.at(4); - if (string_result == "") - return -1; + QString string_result = result_contents.at(4); + if (string_result == "") + return -1; - return string_result.toInt(); + return string_result.toInt(); } QString AOApplication::get_sfx_name(QString p_char, int p_emote) { - QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "SoundN"); + QString f_result = + read_char_ini(p_char, QString::number(p_emote + 1), "SoundN"); - if (f_result == "") - return "1"; - return f_result; + if (f_result == "") + return "1"; + return f_result; } QString AOApplication::get_emote_blip(QString p_char, int p_emote) { - QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "SoundB"); - return f_result; + QString f_result = + read_char_ini(p_char, QString::number(p_emote + 1), "SoundB"); + return f_result; } int AOApplication::get_sfx_delay(QString p_char, int p_emote) { - QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "SoundT"); + QString f_result = + read_char_ini(p_char, QString::number(p_emote + 1), "SoundT"); - if (f_result == "") - return 1; - return f_result.toInt(); + if (f_result == "") + return 1; + return f_result.toInt(); } QString AOApplication::get_sfx_looping(QString p_char, QString p_sfx) { - QString f_result = read_char_ini(p_char, p_sfx, "SoundL"); + QString f_result = read_char_ini(p_char, p_sfx, "SoundL"); - if (f_result == "") - return "0"; - return f_result; + if (f_result == "") + return "0"; + return f_result; } -QString AOApplication::get_sfx_frame(QString p_char, QString p_emote, int n_frame) +QString AOApplication::get_sfx_frame(QString p_char, QString p_emote, + int n_frame) { - QString f_result = read_char_ini(p_char, QString::number(n_frame), p_emote.append("_FrameSFX")); + QString f_result = read_char_ini(p_char, QString::number(n_frame), + p_emote.append("_FrameSFX")); - if (f_result == "") - return ""; - return f_result; + if (f_result == "") + return ""; + return f_result; } -QString AOApplication::get_screenshake_frame(QString p_char, QString p_emote, int n_frame) +QString AOApplication::get_screenshake_frame(QString p_char, QString p_emote, + int n_frame) { - QString f_result = read_char_ini(p_char, QString::number(n_frame), p_emote.append("_FrameScreenshake")); + QString f_result = read_char_ini(p_char, QString::number(n_frame), + p_emote.append("_FrameScreenshake")); - if (f_result == "") - return ""; - return f_result; + if (f_result == "") + return ""; + return f_result; } -QString AOApplication::get_flash_frame(QString p_char, QString p_emote, int n_frame) +QString AOApplication::get_flash_frame(QString p_char, QString p_emote, + int n_frame) { - QString f_result = read_char_ini(p_char, QString::number(n_frame), p_emote.append("_FrameRealization")); + QString f_result = read_char_ini(p_char, QString::number(n_frame), + p_emote.append("_FrameRealization")); - if (f_result == "") - return ""; - return f_result; + if (f_result == "") + return ""; + return f_result; } int AOApplication::get_text_delay(QString p_char, QString p_emote) { - QString f_result = read_char_ini(p_char, p_emote, "TextDelay"); + QString f_result = read_char_ini(p_char, p_emote, "TextDelay"); - if (f_result == "") - return -1; - return f_result.toInt(); + if (f_result == "") + return -1; + return f_result.toInt(); } QStringList AOApplication::get_theme_effects() { - QString p_path = get_theme_path("effects/effects.ini"); - QString default_path = get_default_theme_path("effects/effects.ini"); + QString p_path = get_theme_path("effects/effects.ini"); + QString default_path = get_default_theme_path("effects/effects.ini"); - QStringList effects; - if (!file_exists(p_path)) { - p_path = default_path; - if (!file_exists(p_path)) - return effects; - } + QStringList effects; + if (!file_exists(p_path)) { + p_path = default_path; + if (!file_exists(p_path)) + return effects; + } - QStringList lines = read_file(p_path).split("\n"); - foreach (QString effect, lines) { - effect = effect.split("=")[0].trimmed(); - if (!effect.isEmpty() && !effects.contains(effect)) - effects.append(effect); - } - return effects; + QStringList lines = read_file(p_path).split("\n"); + foreach (QString effect, lines) { + effect = effect.split("=")[0].trimmed(); + if (!effect.isEmpty() && !effects.contains(effect)) + effects.append(effect); + } + return effects; } QStringList AOApplication::get_effects(QString p_char) { - QString p_effect = read_char_ini(p_char, "effects", "Options"); - QString p_path = get_base_path() + "misc/" + p_effect + "/effects.ini"; + QString p_effect = read_char_ini(p_char, "effects", "Options"); + QString p_path = get_base_path() + "misc/" + p_effect + "/effects.ini"; - QStringList effects = get_theme_effects(); - if (!file_exists(p_path)) - return effects; + QStringList effects = get_theme_effects(); + if (!file_exists(p_path)) + return effects; - QStringList lines = read_file(p_path).split("\n"); - foreach (QString effect, lines) { - effect = effect.split("=")[0].trimmed(); - if (!effect.isEmpty() && !effects.contains(effect)) - effects.append(effect); - } + QStringList lines = read_file(p_path).split("\n"); + foreach (QString effect, lines) { + effect = effect.split("=")[0].trimmed(); + if (!effect.isEmpty() && !effects.contains(effect)) + effects.append(effect); + } - return effects; + return effects; } -QString AOApplication::get_effect(QString effect, QString p_char, QString p_folder) +QString AOApplication::get_effect(QString effect, QString p_char, + QString p_folder) { - QString p_effect = p_folder; - if (p_folder == "") - p_effect = read_char_ini(p_char, "effects", "Options"); + QString p_effect = p_folder; + if (p_folder == "") + p_effect = read_char_ini(p_char, "effects", "Options"); - QString p_path = get_image_suffix(get_base_path() + "misc/" + p_effect + "/" + effect); - QString design_ini_path = get_image_suffix(get_theme_path("effects/" + effect)); - QString default_path = get_image_suffix(get_default_theme_path("effects/" + effect)); + QString p_path = + get_image_suffix(get_base_path() + "misc/" + p_effect + "/" + effect); + QString design_ini_path = + get_image_suffix(get_theme_path("effects/" + effect)); + QString default_path = + get_image_suffix(get_default_theme_path("effects/" + effect)); + if (!file_exists(p_path)) { + p_path = design_ini_path; if (!file_exists(p_path)) { - p_path = design_ini_path; - if (!file_exists(p_path)) { - p_path = default_path; - if (!file_exists(p_path)) { - return ""; - } - } + p_path = default_path; + if (!file_exists(p_path)) { + return ""; + } } + } - return p_path; + return p_path; } QString AOApplication::get_effect_sound(QString fx_name, QString p_char) { - QString p_effect = read_char_ini(p_char, "effects", "Options"); - QString p_path = get_base_path() + "misc/" + p_effect + "/effects.ini"; - QString design_ini_path = get_theme_path("effects/effects.ini"); - QString default_path = get_default_theme_path("effects/effects.ini"); + QString p_effect = read_char_ini(p_char, "effects", "Options"); + QString p_path = get_base_path() + "misc/" + p_effect + "/effects.ini"; + QString design_ini_path = get_theme_path("effects/effects.ini"); + QString default_path = get_default_theme_path("effects/effects.ini"); - QString f_result = read_design_ini(fx_name, p_path); + QString f_result = read_design_ini(fx_name, p_path); + if (f_result == "") { + f_result = read_design_ini(fx_name, design_ini_path); if (f_result == "") { - f_result = read_design_ini(fx_name, design_ini_path); - if (f_result == "") { - f_result = read_design_ini(fx_name, default_path); - } + f_result = read_design_ini(fx_name, default_path); } - return f_result; + } + return f_result; } QString AOApplication::get_custom_realization(QString p_char) { - QString f_result = read_char_ini(p_char, "realization", "Options"); + QString f_result = read_char_ini(p_char, "realization", "Options"); - if (f_result == "") - return get_sfx("realization"); - else - return get_sfx_suffix(get_sounds_path(f_result)); + if (f_result == "") + return get_sfx("realization"); + else + return get_sfx_suffix(get_sounds_path(f_result)); } bool AOApplication::get_blank_blip() { - QString result = configini->value("blank_blip", "false").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("blank_blip", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::get_looping_sfx() { - QString result = configini->value("looping_sfx", "true").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("looping_sfx", "true").value<QString>(); + return result.startsWith("true"); } bool AOApplication::objection_stop_music() { - QString result = configini->value("objection_stop_music", "false").value<QString>(); - return result.startsWith("true"); + QString result = + configini->value("objection_stop_music", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::is_discord_enabled() { - QString result = configini->value("discord", "true").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("discord", "true").value<QString>(); + return result.startsWith("true"); } bool AOApplication::is_shake_enabled() { - QString result = configini->value("shake", "true").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("shake", "true").value<QString>(); + return result.startsWith("true"); } bool AOApplication::is_effects_enabled() { - QString result = configini->value("effects", "true").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("effects", "true").value<QString>(); + return result.startsWith("true"); } bool AOApplication::is_frame_network_enabled() { - QString result = configini->value("framenetwork", "true").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("framenetwork", "true").value<QString>(); + return result.startsWith("true"); } bool AOApplication::is_colorlog_enabled() { - QString result = configini->value("colorlog", "true").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("colorlog", "true").value<QString>(); + return result.startsWith("true"); } bool AOApplication::is_stickysounds_enabled() { - QString result = configini->value("stickysounds", "false").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("stickysounds", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::is_stickyeffects_enabled() { - QString result = configini->value("stickyeffects", "false").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("stickyeffects", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::is_stickypres_enabled() { - QString result = configini->value("stickypres", "false").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("stickypres", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::get_casing_enabled() { - QString result = configini->value("casing_enabled", "false").value<QString>(); - return result.startsWith("true"); + QString result = configini->value("casing_enabled", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::get_casing_defence_enabled() { - QString result = configini->value("casing_defence_enabled", "false").value<QString>(); - return result.startsWith("true"); + QString result = + configini->value("casing_defence_enabled", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::get_casing_prosecution_enabled() { - QString result = configini->value("casing_prosecution_enabled", "false").value<QString>(); - return result.startsWith("true"); + QString result = + configini->value("casing_prosecution_enabled", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::get_casing_judge_enabled() { - QString result = configini->value("casing_judge_enabled", "false").value<QString>(); - return result.startsWith("true"); + QString result = + configini->value("casing_judge_enabled", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::get_casing_juror_enabled() { - QString result = configini->value("casing_juror_enabled", "false").value<QString>(); - return result.startsWith("true"); + QString result = + configini->value("casing_juror_enabled", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::get_casing_steno_enabled() { - QString result = configini->value("casing_steno_enabled", "false").value<QString>(); - return result.startsWith("true"); + QString result = + configini->value("casing_steno_enabled", "false").value<QString>(); + return result.startsWith("true"); } bool AOApplication::get_casing_cm_enabled() { - QString result = configini->value("casing_cm_enabled", "false").value<QString>(); - return result.startsWith("true"); + QString result = + configini->value("casing_cm_enabled", "false").value<QString>(); + return result.startsWith("true"); } QString AOApplication::get_casing_can_host_cases() { - QString result = configini->value("casing_can_host_cases", "Turnabout Check Your Settings").value<QString>(); - return result; + QString result = + configini->value("casing_can_host_cases", "Turnabout Check Your Settings") + .value<QString>(); + return result; } |
