Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing custom blips: as easy as a custom showname! #780

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions include/aoapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,23 @@ class AOApplication : public QApplication {

/////////////////server metadata//////////////////

bool yellow_text_supported = false;
bool prezoom_supported = false;
bool flipping_supported = false;
bool custom_objection_supported = false;
bool desk_mod_supported = false;
bool evidence_supported = false;
bool cccc_ic_supported = false;
bool arup_supported = false;
bool casing_alerts_supported = false;
bool modcall_reason_supported = false;
bool looping_sfx_supported = false;
bool additive_text_supported = false;
bool effects_supported = false;
bool y_offset_supported = false;
bool expanded_desk_mods_supported = false;
bool auth_packet_supported = false;
bool yellow_text_enabled = false;
bool prezoom_enabled = false;
bool flipping_enabled = false;
bool custom_objection_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 y_offset_enabled = false;
bool expanded_desk_mods_enabled = false;
bool auth_packet_enabled = false;
bool custom_blips_enabled = false;

///////////////loading info///////////////////

Expand Down Expand Up @@ -336,8 +337,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);
Expand Down
3 changes: 2 additions & 1 deletion include/courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,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 = "";
Expand Down Expand Up @@ -692,6 +692,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;
Expand Down
1 change: 1 addition & 0 deletions include/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ enum CHAT_MESSAGE {
FRAME_SFX,
ADDITIVE,
EFFECTS,
BLIPNAME,
};

enum EMOTE_MOD_TYPE {
Expand Down
32 changes: 31 additions & 1 deletion src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ic_chat_name->setPlaceholderText(tr("Showname"));
ui_ic_chat_name->setText(Options::getInstance().shownameOnJoin());
ui_ic_chat_name->setObjectName("ui_ic_chat_name");

ui_custom_blips = new QLineEdit(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah also this definitely should be a dropdown. It's not ideal to just throw the player into the darkness and make them scroll through the files themselves.

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);
Expand Down Expand Up @@ -679,6 +684,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);
}

// We also show the non-server-dependent client additions.
// Once again, if the theme can't display it, set_move_and_pos will catch
Expand Down Expand Up @@ -823,6 +837,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");

initialize_chatbox();

Expand Down Expand Up @@ -1574,9 +1589,12 @@ void Courtroom::update_character(int p_cid, QString char_name, bool reset_emote)

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);
Expand Down Expand Up @@ -2111,6 +2129,14 @@ 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));
}

Expand Down Expand Up @@ -3658,7 +3684,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_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
Expand Down
68 changes: 37 additions & 31 deletions src/packet_distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
goto end;

// default(legacy) values
yellow_text_supported = false;
prezoom_supported = false;
flipping_supported = false;
custom_objection_supported = false;
desk_mod_supported = false;
evidence_supported = false;
cccc_ic_supported = false;
arup_supported = false;
casing_alerts_supported = false;
modcall_reason_supported = false;
looping_sfx_supported = false;
additive_text_supported = false;
effects_supported = false;
y_offset_supported = false;
yellow_text_enabled = false;
prezoom_enabled = false;
flipping_enabled = false;
custom_objection_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;
y_offset_enabled = false;
custom_blips_enabled = false;

QString f_hdid;
f_hdid = get_hdid();
Expand Down Expand Up @@ -90,21 +91,24 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
f_contents.at(1), "0");
}
else if (header == "FL") {
yellow_text_supported = false;
prezoom_supported = false;
flipping_supported = false;
custom_objection_supported = false;
desk_mod_supported = false;
evidence_supported = false;
cccc_ic_supported = false;
arup_supported = false;
casing_alerts_supported = false;
modcall_reason_supported = false;
looping_sfx_supported = false;
additive_text_supported = false;
effects_supported = false;
expanded_desk_mods_supported = false;
auth_packet_supported = false;
yellow_text_enabled = false;
prezoom_enabled = false;
flipping_enabled = false;
custom_objection_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;
expanded_desk_mods_enabled = false;
auth_packet_enabled = false;
custom_blips_enabled = false;
log_to_demo = false;

if (f_packet.contains("yellowtext", Qt::CaseInsensitive))
yellow_text_supported = true;
if (f_packet.contains("prezoom", Qt::CaseInsensitive))
Expand Down Expand Up @@ -136,8 +140,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (f_packet.contains("expanded_desk_mods", Qt::CaseInsensitive))
expanded_desk_mods_supported = true;
if (f_packet.contains("auth_packet", Qt::CaseInsensitive))
auth_packet_supported = true;
log_to_demo = false;
auth_packet_enabled = true;
if (f_packet.contains("custom_blips", Qt::CaseInsensitive))
custom_blips_enabled = true;

}
else if (header == "PN") {
if (!lobby_constructed || f_contents.size() < 2)
Expand Down
17 changes: 10 additions & 7 deletions src/text_file_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,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");

Expand All @@ -472,14 +472,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,
Expand Down
Loading