aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorin1tiate <32779090+in1tiate@users.noreply.github.com>2020-11-10 08:43:18 -0600
committerGitHub <noreply@github.com>2020-11-10 08:43:18 -0600
commitfe3224d7e8ebc81e5389e46f38f2e1120a78f9b8 (patch)
tree8c673947001abf454e6b8ce3706abaf972aa3e3c
parent1502a1859336e92a2c92e960475f2c5fa1ed3f3f (diff)
Add vertical offset feature (#333)
-rw-r--r--include/courtroom.h7
-rw-r--r--src/courtroom.cpp82
2 files changed, 72 insertions, 17 deletions
diff --git a/include/courtroom.h b/include/courtroom.h
index 4631166a..df13c696 100644
--- a/include/courtroom.h
+++ b/include/courtroom.h
@@ -280,9 +280,12 @@ private:
// The character ID of the character this user wants to appear alongside with.
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;
+ // The vertical offset this user has given.
+ int char_vert_offset = 0;
+
// 0 = in front, 1 = behind
int pair_order = 0;
@@ -524,6 +527,7 @@ private:
AOButton *ui_pair_button;
QListWidget *ui_pair_list;
QSpinBox *ui_pair_offset_spinbox;
+ QSpinBox *ui_pair_vert_offset_spinbox;
QComboBox *ui_pair_order_dropdown;
@@ -779,6 +783,7 @@ private slots:
void on_log_limit_changed(int value);
void on_pair_offset_changed(int value);
+ void on_pair_vert_offset_changed(int value);
void on_ooc_toggle_clicked();
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index e27603bb..74e9cde7 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -242,7 +242,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_pair_list = new QListWidget(this);
ui_pair_offset_spinbox = new QSpinBox(this);
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->addItem(tr("To front"));
@@ -386,6 +389,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
SLOT(on_pair_list_clicked(QModelIndex)));
connect(ui_pair_offset_spinbox, SIGNAL(valueChanged(int)), this,
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,
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");
ui_pair_offset_spinbox->hide();
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."));
ui_pair_order_dropdown->hide();
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."));
set_size_and_pos(ui_pair_button, "pair_button");
@@ -1692,7 +1703,7 @@ void Courtroom::on_chat_return_pressed()
packet_contents.append("-1");
}
// 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.
if (ui_pre_non_interrupt->isChecked() && ui_pre->isChecked()) {
@@ -2083,10 +2094,19 @@ void Courtroom::handle_chatmessage_2()
if (got_other_charid > -1) {
// If there is, show them!
ui_vp_sideplayer_char->show();
-
- int other_offset = m_chatmessage[OTHER_OFFSET].toInt();
+ QStringList other_offsets = m_chatmessage[OTHER_OFFSET].split("&");
+ 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,
- 0);
+ ui_viewport->height() * other_offset_v / 100);
QStringList args = m_chatmessage[OTHER_CHARID].split("^");
if (args.size() >
@@ -2125,12 +2145,14 @@ void Courtroom::handle_chatmessage_2()
}
// Set ourselves according to SELF_OFFSET
- bool ok;
- int self_offset = m_chatmessage[SELF_OFFSET].toInt(&ok);
- if (ok)
- ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, 0);
- else
- ui_vp_player_char->move(0, 0);
+ QStringList self_offsets = m_chatmessage[SELF_OFFSET].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);
switch (emote_mod) {
case 1:
@@ -3372,9 +3394,8 @@ void Courtroom::on_ooc_return_pressed()
if (ok) {
if (off >= -100 && off <= 100) {
char_offset = off;
- QString msg = tr("You have set your offset to ");
- msg.append(QString::number(off));
- msg.append("%.");
+ QString msg = tr("You have set your offset to %1%%.")
+ .arg(QString::number(off));
append_server_chatmessage("CLIENT", msg, "1");
}
else {
@@ -3388,6 +3409,30 @@ void Courtroom::on_ooc_return_pressed()
}
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")) {
append_server_chatmessage(
"CLIENT", tr("You switched your music and area list."), "1");
@@ -4360,6 +4405,7 @@ void Courtroom::on_mute_clicked()
ui_mute_list->show();
ui_pair_list->hide();
ui_pair_offset_spinbox->hide();
+ ui_pair_vert_offset_spinbox->hide();
ui_pair_order_dropdown->hide();
ui_pair_button->set_image("pair_button");
ui_mute->set_image("mute_pressed");
@@ -4375,6 +4421,7 @@ void Courtroom::on_pair_clicked()
if (ui_pair_list->isHidden()) {
ui_pair_list->show();
ui_pair_offset_spinbox->show();
+ ui_pair_vert_offset_spinbox->show();
ui_pair_order_dropdown->show();
ui_mute_list->hide();
ui_mute->set_image("mute");
@@ -4383,6 +4430,7 @@ void Courtroom::on_pair_clicked()
else {
ui_pair_list->hide();
ui_pair_offset_spinbox->hide();
+ ui_pair_vert_offset_spinbox->hide();
ui_pair_order_dropdown->hide();
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_vert_offset_changed(int value) { char_vert_offset = value; }
+
void Courtroom::on_witness_testimony_clicked()
{
if (is_muted)