From 3f8d81a3f73c0bef1fcf1e3ea7675751868320f9 Mon Sep 17 00:00:00 2001 From: Lernos Date: Sun, 5 Jun 2022 14:58:26 +0300 Subject: [PATCH 01/10] split get_blips into two functions Because otherwise it would always return only what was read from char.ini, and we want it to be able to read our custom QLineEdit too, right? --- src/text_file_functions.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index b5bd69685..050543ee4 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -603,7 +603,7 @@ QString AOApplication::get_char_side(QString p_char) return f_result; } -QString AOApplication::get_blips(QString p_char) +QString AOApplication::get_blipname(QString p_char) { QString f_result = read_char_ini(p_char, "blips", "Options"); @@ -612,14 +612,17 @@ QString AOApplication::get_blips(QString p_char) if (f_result == "") f_result = "male"; } + return f_result; +} +QString AOApplication::get_blips(QString p_blipname) +{ + if (!file_exists(get_sfx_suffix(get_sounds_path(p_blipname)))) { + if (file_exists(get_sfx_suffix(get_sounds_path("../blips/" + p_blipname)))) + return "../blips/" + p_blipname; // 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 "sfx-blip" + p_blipname; // Return legacy variant } - return f_result; + return p_blipname; } QString AOApplication::get_emote_property(QString p_char, QString p_emote, From 71ff2fc0ed7bd5bd6a97e042eaaa7f5bd7a60278 Mon Sep 17 00:00:00 2001 From: Lernos Date: Sun, 5 Jun 2022 15:01:15 +0300 Subject: [PATCH 02/10] include new function, rewrite description --- include/aoapplication.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index 4809c3fcb..16931578c 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -467,8 +467,11 @@ class AOApplication : public QApplication { // Returns the desk modifier for p_char's p_emote int get_desk_mod(QString p_char, int p_emote); - // Returns p_char's blips (previously called their "gender") - QString get_blips(QString p_char); + // Returns p_char's blipname by reading char.ini for blips (previously called "gender") + QString get_blipname(QString p_char); + + // Returns p_blipname's sound(path) to play in the client + QString get_blips(QString p_blipname); // Get a property of a given emote, or get it from "options" if emote doesn't have it QString get_emote_property(QString p_char, QString p_emote, QString p_property); From 1b4e0b121cfc337faf37d7cd9326fd7cc99b1b89 Mon Sep 17 00:00:00 2001 From: Lernos Date: Sun, 5 Jun 2022 15:04:58 +0300 Subject: [PATCH 03/10] check for custom blips support in packet --- src/packet_distribution.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index e03261390..168fa84ed 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -53,6 +53,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) additive_enabled = false; effects_enabled = false; y_offset_enabled = false; + custom_blips_enabled = false; QString f_hdid; f_hdid = get_hdid(); @@ -103,6 +104,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) effects_enabled = false; expanded_desk_mods_enabled = false; auth_packet_enabled = false; + custom_blips_enabled = false; if (f_packet.contains("yellowtext", Qt::CaseInsensitive)) yellow_text_enabled = true; if (f_packet.contains("prezoom", Qt::CaseInsensitive)) @@ -135,6 +137,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) expanded_desk_mods_enabled = true; if (f_packet.contains("auth_packet", Qt::CaseInsensitive)) auth_packet_enabled = true; + if (f_packet.contains("custom_blips", Qt::CaseInsensitive)) + custom_blips_enabled = true; } else if (header == "PN") { if (f_contents.size() < 2) From 00348879346a1564b1233093308faffe92331d49 Mon Sep 17 00:00:00 2001 From: Lernos Date: Sun, 5 Jun 2022 15:05:38 +0300 Subject: [PATCH 04/10] add custom blips enabled bool --- include/aoapplication.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/aoapplication.h b/include/aoapplication.h index 16931578c..708dd3209 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -104,6 +104,7 @@ class AOApplication : public QApplication { bool y_offset_enabled = false; bool expanded_desk_mods_enabled = false; bool auth_packet_enabled = false; + bool custom_blips_enabled = false; ///////////////loading info/////////////////// From 30cec4ba8bcbcd818d91043a71cd60d9c4f073c5 Mon Sep 17 00:00:00 2001 From: Lernos Date: Sun, 5 Jun 2022 15:07:01 +0300 Subject: [PATCH 05/10] increase MS_MAXIMUM, add custom blips QLineEdit --- include/courtroom.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/courtroom.h b/include/courtroom.h index 13c639a87..b263423b2 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -477,7 +477,7 @@ class Courtroom : public QMainWindow { // Minumum and maximum number of parameters in the MS packet static const int MS_MINIMUM = 15; - static const int MS_MAXIMUM = 30; + static const int MS_MAXIMUM = 31; QString m_chatmessage[MS_MAXIMUM]; QString previous_ic_message = ""; @@ -673,6 +673,7 @@ class Courtroom : public QMainWindow { QLineEdit *ui_ic_chat_message; AOLineEditFilter *ui_ic_chat_message_filter; QLineEdit *ui_ic_chat_name; + QLineEdit *ui_custom_blips; QLineEdit *ui_ooc_chat_message; QLineEdit *ui_ooc_chat_name; From ff3464a23ae45ec8053580619b571232ea62536c Mon Sep 17 00:00:00 2001 From: Lernos Date: Sun, 5 Jun 2022 15:08:21 +0300 Subject: [PATCH 06/10] add BLIPNAME to chat message --- include/datatypes.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/datatypes.h b/include/datatypes.h index 2f03d39f0..5ae55af43 100644 --- a/include/datatypes.h +++ b/include/datatypes.h @@ -98,7 +98,8 @@ enum CHAT_MESSAGE { FRAME_REALIZATION, FRAME_SFX, ADDITIVE, - EFFECTS + EFFECTS, + BLIPNAME, }; enum EMOTE_MOD { From a2af3891969f17466775a89b8b2937b1fffb92f1 Mon Sep 17 00:00:00 2001 From: Lernos Date: Sun, 5 Jun 2022 15:23:50 +0300 Subject: [PATCH 07/10] introducing custom blips --- src/courtroom.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 1c0437891..980f9306b 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -177,6 +177,11 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_ic_chat_name->setPlaceholderText(tr("Showname")); ui_ic_chat_name->setText(p_ao_app->get_default_showname()); ui_ic_chat_name->setObjectName("ui_ic_chat_name"); + + ui_custom_blips = new QLineEdit(this); + ui_custom_blips->setFrame(false); + ui_custom_blips->setPlaceholderText(tr("Blips")); + ui_custom_blips->setObjectName("ui_custom_blips"); ui_ic_chat_message = new QLineEdit(this); ui_ic_chat_message->setFrame(false); @@ -649,6 +654,15 @@ void Courtroom::set_widgets() ui_ic_chat_name->hide(); ui_ic_chat_name->setEnabled(false); } + + if (ao_app->custom_blips_enabled) { + ui_custom_blips->show(); + ui_custom_blips->setEnabled(true); + } + else { + ui_custom_blips->hide(); + ui_custom_blips->setEnabled(false); + } if (ao_app->casing_alerts_enabled) { ui_announce_casing->show(); @@ -818,6 +832,7 @@ void Courtroom::set_widgets() } set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); set_size_and_pos(ui_ic_chat_name, "ao2_ic_chat_name"); + set_size_and_pos(ui_custom_blips, "ao2_custom_blips"); ui_vp_chatbox->set_image("chatblank"); ui_vp_chatbox->hide(); @@ -1558,9 +1573,12 @@ void Courtroom::update_character(int p_cid) if (m_cid != -1) { ui_ic_chat_name->setPlaceholderText(char_list.at(m_cid).name); + QString f_blipname = ao_app->get_blipname(f_char); + ui_custom_blips->setPlaceholderText(f_blipname); } else { ui_ic_chat_name->setPlaceholderText("Spectator"); + ui_custom_blips->setPlaceholderText("None"); } ui_char_select_background->hide(); ui_ic_chat_message->setEnabled(m_cid != -1); @@ -2083,6 +2101,10 @@ void Courtroom::on_chat_return_pressed() } } + if (ao_app->custom_blips_enabled) { + if (ui_custom_blips->text().isEmpty()) { packet_contents.append(ui_custom_blips->placeholderText()); } + else { packet_contents.append(ui_custom_blips->text()); } + } ao_app->send_server_packet(new AOPacket("MS", packet_contents)); } @@ -3476,7 +3498,9 @@ void Courtroom::start_chat_ticking() if (last_misc != current_misc || char_color_rgb_list.size() < max_colors) gen_char_rgb_list(current_misc); - QString f_blips = ao_app->get_blips(m_chatmessage[CHAR_NAME]); + QString f_blips = ao_app->get_blipname(m_chatmessage[CHAR_NAME]); + f_blips = ao_app->get_blips(f_blips); + if (ao_app->custom_blips_enabled && !ui_custom_blips->text().isEmpty()) {f_blips = ao_app->get_blips(m_chatmessage[BLIPNAME]);} blip_player->set_blips(f_blips); // means text is currently ticking From 8e129ceb78bbae3c6bbe352d55bb900ae3ac5951 Mon Sep 17 00:00:00 2001 From: Lernos Date: Sun, 5 Jun 2022 15:54:34 +0300 Subject: [PATCH 08/10] introducing custom blips I said --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 980f9306b..569d9b778 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3500,7 +3500,7 @@ void Courtroom::start_chat_ticking() QString f_blips = ao_app->get_blipname(m_chatmessage[CHAR_NAME]); f_blips = ao_app->get_blips(f_blips); - if (ao_app->custom_blips_enabled && !ui_custom_blips->text().isEmpty()) {f_blips = ao_app->get_blips(m_chatmessage[BLIPNAME]);} + if (ao_app->custom_blips_enabled && !m_chatmessage[BLIPNAME].isEmpty()) {f_blips = ao_app->get_blips(m_chatmessage[BLIPNAME]);} blip_player->set_blips(f_blips); // means text is currently ticking From f22cb535296bf3f59907e4078a1ae7a171675afd Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sat, 3 Sep 2022 01:17:24 +0200 Subject: [PATCH 09/10] unfold if --- src/courtroom.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index d740fc8ee..5a354908d 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2140,8 +2140,12 @@ void Courtroom::on_chat_return_pressed() } if (ao_app->custom_blips_enabled) { - if (ui_custom_blips->text().isEmpty()) { packet_contents.append(ui_custom_blips->placeholderText()); } - else { packet_contents.append(ui_custom_blips->text()); } + if (ui_custom_blips->text().isEmpty()) { + packet_contents.append(ui_custom_blips->placeholderText()); + } + else { + packet_contents.append(ui_custom_blips->text()); + } } ao_app->send_server_packet(new AOPacket("MS", packet_contents)); } From 579f54a55e1be90a3c29d89f4cf992278624d0fa Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sat, 3 Sep 2022 01:17:57 +0200 Subject: [PATCH 10/10] unfold other if --- src/courtroom.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 5a354908d..f19e92c3c 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3689,7 +3689,9 @@ void Courtroom::start_chat_ticking() QString f_blips = ao_app->get_blipname(m_chatmessage[CHAR_NAME]); f_blips = ao_app->get_blips(f_blips); - if (ao_app->custom_blips_enabled && !m_chatmessage[BLIPNAME].isEmpty()) {f_blips = ao_app->get_blips(m_chatmessage[BLIPNAME]);} + if (ao_app->custom_blips_enabled && !m_chatmessage[BLIPNAME].isEmpty()) { + f_blips = ao_app->get_blips(m_chatmessage[BLIPNAME]); + } blip_player->set_blips(f_blips); // means text is currently ticking