diff options
| author | in1tiate <32779090+in1tiate@users.noreply.github.com> | 2024-05-14 11:02:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-14 18:02:32 +0200 |
| commit | c9eabf35dafa22f7ad7f012c23f63f1605a47668 (patch) | |
| tree | d64919dae244228a136a445cc64510f24ba7dfe4 /src | |
| parent | 951766666621fa77e257e6b5616fe4ab1eb2a52f (diff) | |
Add [Options] override for blips and shownames for parity with 2.5 (#953)
* 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?
* include new function, rewrite description
* check for custom blips support in packet
* add custom blips enabled bool
* increase MS_MAXIMUM, add custom blips QLineEdit
* add BLIPNAME to chat message
* introducing custom blips
* introducing custom blips I said
* unfold if
* unfold other if
* retool custom blips code, add ini parser
* remove extraneous debug calls
* fix incorrect default value on get_showname
* restructure ini format
* fix parser again
---------
Co-authored-by: Lernos <lernoskey@gmail.com>
Co-authored-by: stonedDiscord <Tukz@gmx.de>
Diffstat (limited to 'src')
| -rw-r--r-- | src/courtroom.cpp | 16 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 13 | ||||
| -rw-r--r-- | src/text_file_functions.cpp | 49 |
3 files changed, 57 insertions, 21 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3056fd92..c360d6b5 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1593,7 +1593,7 @@ void Courtroom::enter_courtroom() else ui_flip->hide(); - if (ao_app->additive_text_supported) + if (ao_app->additive_supported) ui_additive->show(); else ui_additive->hide(); @@ -2019,13 +2019,12 @@ void Courtroom::on_chat_return_pressed() // If the server we're on supports CCCC stuff, we should use it! if (ao_app->cccc_ic_supported) { - // If there is a showname entered, use that -- else, just send an empty - // packet-part. + // If there is a showname entered, use that -- else, just send whatever the ini calls for. if (!ui_ic_chat_name->text().isEmpty()) { packet_contents.append(ui_ic_chat_name->text()); } else { - packet_contents.append(""); + packet_contents.append(ao_app->get_showname(current_char, current_emote)); } // Similarly, we send over whom we're paired with, unless we have chosen @@ -2088,7 +2087,7 @@ void Courtroom::on_chat_return_pressed() } } - if (ao_app->additive_text_supported) { + if (ao_app->additive_supported) { packet_contents.append(ui_additive->isChecked() ? "1" : "0"); } if (ao_app->effects_supported) { @@ -2111,6 +2110,7 @@ void Courtroom::on_chat_return_pressed() } } + packet_contents.append(ao_app->get_blipname(current_char, current_emote)); ao_app->send_server_packet(new AOPacket("MS", packet_contents)); } @@ -3658,7 +3658,11 @@ 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_supported && !m_chatmessage[BLIPNAME].isEmpty()) { + f_blips = ao_app->get_blips(m_chatmessage[BLIPNAME]); + } blip_player->set_blips(f_blips); // means text is currently ticking diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 9bd4d8f6..e5a17d27 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -53,9 +53,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet) casing_alerts_supported = false; modcall_reason_supported = false; looping_sfx_supported = false; - additive_text_supported = false; + additive_supported = false; effects_supported = false; y_offset_supported = false; + custom_blips_supported = false; QString f_hdid; f_hdid = get_hdid(); @@ -101,10 +102,13 @@ void AOApplication::server_packet_received(AOPacket *p_packet) casing_alerts_supported = false; modcall_reason_supported = false; looping_sfx_supported = false; - additive_text_supported = false; + additive_supported = false; effects_supported = false; expanded_desk_mods_supported = false; auth_packet_supported = false; + custom_blips_supported = false; + log_to_demo = false; + if (f_packet.contains("yellowtext", Qt::CaseInsensitive)) yellow_text_supported = true; if (f_packet.contains("prezoom", Qt::CaseInsensitive)) @@ -128,7 +132,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (f_packet.contains("looping_sfx", Qt::CaseInsensitive)) looping_sfx_supported = true; if (f_packet.contains("additive", Qt::CaseInsensitive)) - additive_text_supported = true; + additive_supported = true; if (f_packet.contains("effects", Qt::CaseInsensitive)) effects_supported = true; if (f_packet.contains("y_offset", Qt::CaseInsensitive)) @@ -137,7 +141,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) expanded_desk_mods_supported = true; if (f_packet.contains("auth_packet", Qt::CaseInsensitive)) auth_packet_supported = true; - log_to_demo = false; + if (f_packet.contains("custom_blips", Qt::CaseInsensitive)) + custom_blips_supported = true; } else if (header == "PN") { if (!lobby_constructed || f_contents.size() < 2) diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 51dc95ad..7c5bbde0 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -442,11 +442,23 @@ QStringList AOApplication::read_ini_tags(VPath p_path, QString target_tag) return r_values; } -QString AOApplication::get_showname(QString p_char) +QString AOApplication::get_showname(QString p_char, int p_emote) { QString f_result = read_char_ini(p_char, "showname", "Options"); QString f_needed = read_char_ini(p_char, "needs_showname", "Options"); + if (p_emote != -1) { + int override_idx = + read_char_ini(p_char, QString::number(p_emote + 1), "OptionsN").toInt(); + if (override_idx > 0) { + QString override_key = "Options" + QString::number(override_idx); + QString temp_f_result = read_char_ini(p_char, "showname", override_key); + if (!temp_f_result.isEmpty()) { + f_result = temp_f_result; + } + } + } + if (f_needed.startsWith("false")) return ""; if (f_result == "") @@ -463,24 +475,39 @@ 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, int p_emote) { QString f_result = read_char_ini(p_char, "blips", "Options"); - if (f_result == "") { - f_result = read_char_ini(p_char, "gender", "Options"); // not very PC, FanatSors - if (f_result == "") - f_result = "male"; + if (p_emote != -1) { + int override_idx = + read_char_ini(p_char, QString::number(p_emote + 1), "OptionsN").toInt(); + if (override_idx > 0) { + QString override_key = "Options" + QString::number(override_idx); + QString temp_f_result = read_char_ini(p_char, "blips", override_key); + if (!temp_f_result.isEmpty()) { + f_result = temp_f_result; + } + } } - 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 + if (f_result == "") { + f_result = + read_char_ini(p_char, "gender", "Options"); // not very PC, FanatSors + 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 + + return "sfx-blip" + p_blipname; // Return legacy variant + } + return p_blipname; +} QString AOApplication::get_emote_property(QString p_char, QString p_emote, QString p_property) |
