Add vertical offset feature (#333)

This commit is contained in:
in1tiate 2020-11-10 08:43:18 -06:00 committed by GitHub
parent 1502a18593
commit fe3224d7e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 17 deletions

View File

@ -280,9 +280,12 @@ private:
// The character ID of the character this user wants to appear alongside with. // The character ID of the character this user wants to appear alongside with.
int other_charid = -1; int other_charid = -1;
// The offset this user has given if they want to appear alongside someone. // The horizontal offset this user has given if they want to appear alongside someone.
int char_offset = 0; int char_offset = 0;
// The vertical offset this user has given.
int char_vert_offset = 0;
// 0 = in front, 1 = behind // 0 = in front, 1 = behind
int pair_order = 0; int pair_order = 0;
@ -524,6 +527,7 @@ private:
AOButton *ui_pair_button; AOButton *ui_pair_button;
QListWidget *ui_pair_list; QListWidget *ui_pair_list;
QSpinBox *ui_pair_offset_spinbox; QSpinBox *ui_pair_offset_spinbox;
QSpinBox *ui_pair_vert_offset_spinbox;
QComboBox *ui_pair_order_dropdown; QComboBox *ui_pair_order_dropdown;
@ -779,6 +783,7 @@ private slots:
void on_log_limit_changed(int value); void on_log_limit_changed(int value);
void on_pair_offset_changed(int value); void on_pair_offset_changed(int value);
void on_pair_vert_offset_changed(int value);
void on_ooc_toggle_clicked(); void on_ooc_toggle_clicked();

View File

@ -242,7 +242,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_pair_list = new QListWidget(this); ui_pair_list = new QListWidget(this);
ui_pair_offset_spinbox = new QSpinBox(this); ui_pair_offset_spinbox = new QSpinBox(this);
ui_pair_offset_spinbox->setRange(-100, 100); ui_pair_offset_spinbox->setRange(-100, 100);
ui_pair_offset_spinbox->setSuffix(tr("% offset")); ui_pair_offset_spinbox->setSuffix(tr("% x offset"));
ui_pair_vert_offset_spinbox = new QSpinBox(this);
ui_pair_vert_offset_spinbox->setRange(-100, 100);
ui_pair_vert_offset_spinbox->setSuffix(tr("% y offset"));
ui_pair_order_dropdown = new QComboBox(this); ui_pair_order_dropdown = new QComboBox(this);
ui_pair_order_dropdown->addItem(tr("To front")); ui_pair_order_dropdown->addItem(tr("To front"));
@ -386,6 +389,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
SLOT(on_pair_list_clicked(QModelIndex))); SLOT(on_pair_list_clicked(QModelIndex)));
connect(ui_pair_offset_spinbox, SIGNAL(valueChanged(int)), this, connect(ui_pair_offset_spinbox, SIGNAL(valueChanged(int)), this,
SLOT(on_pair_offset_changed(int))); SLOT(on_pair_offset_changed(int)));
connect(ui_pair_vert_offset_spinbox, SIGNAL(valueChanged(int)), this,
SLOT(on_pair_vert_offset_changed(int)));
connect(ui_pair_order_dropdown, SIGNAL(currentIndexChanged(int)), this, connect(ui_pair_order_dropdown, SIGNAL(currentIndexChanged(int)), this,
SLOT(on_pair_order_dropdown_changed(int))); SLOT(on_pair_order_dropdown_changed(int)));
@ -586,12 +591,18 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_pair_offset_spinbox, "pair_offset_spinbox"); set_size_and_pos(ui_pair_offset_spinbox, "pair_offset_spinbox");
ui_pair_offset_spinbox->hide(); ui_pair_offset_spinbox->hide();
ui_pair_offset_spinbox->setToolTip( ui_pair_offset_spinbox->setToolTip(
tr("Change the percentage offset of your character's position from the " tr("Change the horizontal percentage offset of your character's position from the "
"center of the screen."));
set_size_and_pos(ui_pair_vert_offset_spinbox, "pair_vert_offset_spinbox");
ui_pair_vert_offset_spinbox->hide();
ui_pair_vert_offset_spinbox->setToolTip(
tr("Change the vertical percentage offset of your character's position from the "
"center of the screen.")); "center of the screen."));
ui_pair_order_dropdown->hide(); ui_pair_order_dropdown->hide();
set_size_and_pos(ui_pair_order_dropdown, "pair_order_dropdown"); set_size_and_pos(ui_pair_order_dropdown, "pair_order_dropdown");
ui_pair_offset_spinbox->setToolTip( ui_pair_order_dropdown->setToolTip(
tr("Change the order of appearance for your character.")); tr("Change the order of appearance for your character."));
set_size_and_pos(ui_pair_button, "pair_button"); set_size_and_pos(ui_pair_button, "pair_button");
@ -1692,7 +1703,7 @@ void Courtroom::on_chat_return_pressed()
packet_contents.append("-1"); packet_contents.append("-1");
} }
// Send the offset as it's gonna be used regardless // Send the offset as it's gonna be used regardless
packet_contents.append(QString::number(char_offset)); packet_contents.append(QString::number(char_offset) + "&" + QString::number(char_vert_offset));
// Finally, we send over if we want our pres to not interrupt. // Finally, we send over if we want our pres to not interrupt.
if (ui_pre_non_interrupt->isChecked() && ui_pre->isChecked()) { if (ui_pre_non_interrupt->isChecked() && ui_pre->isChecked()) {
@ -2083,10 +2094,19 @@ void Courtroom::handle_chatmessage_2()
if (got_other_charid > -1) { if (got_other_charid > -1) {
// If there is, show them! // If there is, show them!
ui_vp_sideplayer_char->show(); ui_vp_sideplayer_char->show();
QStringList other_offsets = m_chatmessage[OTHER_OFFSET].split("&");
int other_offset = m_chatmessage[OTHER_OFFSET].toInt(); int other_offset;
int other_offset_v;
if (other_offsets.length() <= 1) {
other_offset = m_chatmessage[OTHER_OFFSET].toInt();
other_offset_v = 0;
}
else {
other_offset = other_offsets[0].toInt();
other_offset_v = other_offsets[1].toInt();
}
ui_vp_sideplayer_char->move(ui_viewport->width() * other_offset / 100, ui_vp_sideplayer_char->move(ui_viewport->width() * other_offset / 100,
0); ui_viewport->height() * other_offset_v / 100);
QStringList args = m_chatmessage[OTHER_CHARID].split("^"); QStringList args = m_chatmessage[OTHER_CHARID].split("^");
if (args.size() > if (args.size() >
@ -2125,12 +2145,14 @@ void Courtroom::handle_chatmessage_2()
} }
// Set ourselves according to SELF_OFFSET // Set ourselves according to SELF_OFFSET
bool ok; QStringList self_offsets = m_chatmessage[SELF_OFFSET].split("&");
int self_offset = m_chatmessage[SELF_OFFSET].toInt(&ok); int self_offset = self_offsets[0].toInt();
if (ok) int self_offset_v;
ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, 0); if (self_offsets.length() <= 1)
self_offset_v = 0;
else else
ui_vp_player_char->move(0, 0); 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);
switch (emote_mod) { switch (emote_mod) {
case 1: case 1:
@ -3372,9 +3394,8 @@ void Courtroom::on_ooc_return_pressed()
if (ok) { if (ok) {
if (off >= -100 && off <= 100) { if (off >= -100 && off <= 100) {
char_offset = off; char_offset = off;
QString msg = tr("You have set your offset to "); QString msg = tr("You have set your offset to %1%%.")
msg.append(QString::number(off)); .arg(QString::number(off));
msg.append("%.");
append_server_chatmessage("CLIENT", msg, "1"); append_server_chatmessage("CLIENT", msg, "1");
} }
else { else {
@ -3388,6 +3409,30 @@ void Courtroom::on_ooc_return_pressed()
} }
return; return;
} }
else if (ooc_message.startsWith("/voffset")) {
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_vert_offset = off;
QString msg = tr("You have set your vertical offset to %1%%.")
.arg(QString::number(off));
append_server_chatmessage("CLIENT", msg, "1");
}
else {
append_server_chatmessage(
"CLIENT", tr("Your vertical offset must be between -100% and 100%!"), "1");
}
}
else {
append_server_chatmessage("CLIENT",
tr("That vertical offset does not look like one."), "1");
}
return;
}
else if (ooc_message.startsWith("/switch_am")) { else if (ooc_message.startsWith("/switch_am")) {
append_server_chatmessage( append_server_chatmessage(
"CLIENT", tr("You switched your music and area list."), "1"); "CLIENT", tr("You switched your music and area list."), "1");
@ -4360,6 +4405,7 @@ void Courtroom::on_mute_clicked()
ui_mute_list->show(); ui_mute_list->show();
ui_pair_list->hide(); ui_pair_list->hide();
ui_pair_offset_spinbox->hide(); ui_pair_offset_spinbox->hide();
ui_pair_vert_offset_spinbox->hide();
ui_pair_order_dropdown->hide(); ui_pair_order_dropdown->hide();
ui_pair_button->set_image("pair_button"); ui_pair_button->set_image("pair_button");
ui_mute->set_image("mute_pressed"); ui_mute->set_image("mute_pressed");
@ -4375,6 +4421,7 @@ void Courtroom::on_pair_clicked()
if (ui_pair_list->isHidden()) { if (ui_pair_list->isHidden()) {
ui_pair_list->show(); ui_pair_list->show();
ui_pair_offset_spinbox->show(); ui_pair_offset_spinbox->show();
ui_pair_vert_offset_spinbox->show();
ui_pair_order_dropdown->show(); ui_pair_order_dropdown->show();
ui_mute_list->hide(); ui_mute_list->hide();
ui_mute->set_image("mute"); ui_mute->set_image("mute");
@ -4383,6 +4430,7 @@ void Courtroom::on_pair_clicked()
else { else {
ui_pair_list->hide(); ui_pair_list->hide();
ui_pair_offset_spinbox->hide(); ui_pair_offset_spinbox->hide();
ui_pair_vert_offset_spinbox->hide();
ui_pair_order_dropdown->hide(); ui_pair_order_dropdown->hide();
ui_pair_button->set_image("pair_button"); ui_pair_button->set_image("pair_button");
} }
@ -4539,6 +4587,8 @@ 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_pair_vert_offset_changed(int value) { char_vert_offset = value; }
void Courtroom::on_witness_testimony_clicked() void Courtroom::on_witness_testimony_clicked()
{ {
if (is_muted) if (is_muted)