Skip to content
Merged
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
3 changes: 2 additions & 1 deletion include/courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ class Courtroom : public QMainWindow {
void set_scene(QString f_desk_mod, QString f_side);

// sets ui_vp_player_char according to SELF_OFFSET, only a function bc it's used with desk_mod 4 and 5
void set_self_offset(QString p_list);
// sets ui_effects_layer according to the SELF_OFFSET, unless it is overwritten by effects.ini
void set_self_offset(QString p_list, QString p_effect);

// takes in serverD-formatted IP list as prints a converted version to server
// OOC admittedly poorly named
Expand Down
19 changes: 16 additions & 3 deletions src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2404,7 +2404,7 @@ void Courtroom::display_character()
else
ui_vp_player_char->set_flipped(false);
// Move the character on the viewport according to the offsets
set_self_offset(m_chatmessage[SELF_OFFSET]);
set_self_offset(m_chatmessage[SELF_OFFSET], m_chatmessage[EFFECTS]);
}

void Courtroom::display_pair_character(QString other_charid, QString other_offset)
Expand Down Expand Up @@ -3321,7 +3321,7 @@ void Courtroom::start_chat_ticking()
// handle expanded desk mods
switch(m_chatmessage[DESK_MOD].toInt()) {
case 4:
set_self_offset(m_chatmessage[SELF_OFFSET]);
set_self_offset(m_chatmessage[SELF_OFFSET], QString("||"));
Copy link
Member

Choose a reason for hiding this comment

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

QString("||") is not necessary. You may either use "||" or QStringLiteral("||") (some also prefer QLatin1String for efficiency, but the performance benefit is negligible)

[[fallthrough]];
case 2:
set_scene("1", m_chatmessage[SIDE]);
Expand Down Expand Up @@ -3762,15 +3762,28 @@ void Courtroom::set_scene(QString f_desk_mod, QString f_side)
}
}

void Courtroom::set_self_offset(QString p_list) {
void Courtroom::set_self_offset(QString p_list, QString p_effect) {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure why this method takes in a QString when it should really take in a QStringList.

QStringList self_offsets = p_list.split("&");
QStringList play_effect = p_effect.split("|");
int self_offset = self_offsets[0].toInt();
int self_offset_v;
if (self_offsets.length() <= 1)
self_offset_v = 0;
else
self_offset_v = self_offsets[1].toInt();
ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, ui_viewport->height() * self_offset_v / 100);

//If an effect is ignoring the users offset, we force it to the default position of the viewport.
if (ao_app->get_effect_property(play_effect[0], current_char, "ignore_offset") == "true") {
Copy link
Member

@oldmud0 oldmud0 Feb 21, 2022

Choose a reason for hiding this comment

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

Very good, thank you. Let's document this.

EDIT: Let's pretend I didn't see that global variable there

ui_vp_effect->move(ui_viewport->x(), ui_viewport->y());
return;
}

//Offset is not disabled, we move the effects layer to match the position of our character
//We need to add the viewport as an offset as effects are not bound to it.
int effect_x = (ui_viewport->width() * self_offset / 100) + ui_viewport->x();
int effect_y = (ui_viewport->height() * self_offset_v / 100) + ui_viewport->y();
ui_vp_effect->move(effect_x, effect_y);
}

void Courtroom::set_ip_list(QString p_list)
Expand Down