aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCerapter <cerap@protonmail.com>2018-09-03 12:55:57 +0200
committerCerapter <cerap@protonmail.com>2018-09-03 12:55:57 +0200
commit22e0cb8e1a97e57a6235c23afc6508f5e441aefc (patch)
treec52badf9edec4561b4b158002266037d3f0d9a50
parent739142f8ddd194b7f4ed42fe813979655d04262a (diff)
Dual characters on screen Part 2.
- UI option to change pairup. - Fixed a bug on the prosecution side. - Dual characters now allow for iniswapped characters. - Zooming now doesn't stay on the field, instead, the game defaults to the last emote.
-rw-r--r--courtroom.cpp136
-rw-r--r--courtroom.h12
-rw-r--r--datatypes.h1
-rw-r--r--server/aoprotocol.py8
-rw-r--r--server/client_manager.py1
5 files changed, 140 insertions, 18 deletions
diff --git a/courtroom.cpp b/courtroom.cpp
index c02f94e4..dd03212b 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -119,6 +119,12 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
//ui_area_list = new QListWidget(this);
ui_music_list = new QListWidget(this);
+ 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("% offset");
+ ui_pair_button = new AOButton(this, ao_app);
+
ui_ic_chat_name = new QLineEdit(this);
ui_ic_chat_name->setFrame(false);
ui_ic_chat_name->setPlaceholderText("Showname");
@@ -310,6 +316,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(ui_showname_enable, SIGNAL(clicked()), this, SLOT(on_showname_enable_clicked()));
+ connect(ui_pair_button, SIGNAL(clicked()), this, SLOT(on_pair_clicked()));
+ connect(ui_pair_list, SIGNAL(clicked(QModelIndex)), this, SLOT(on_pair_list_clicked(QModelIndex)));
+ connect(ui_pair_offset_spinbox, SIGNAL(valueChanged(int)), this, SLOT(on_pair_offset_changed(int)));
+
connect(ui_evidence_button, SIGNAL(clicked()), this, SLOT(on_evidence_button_clicked()));
set_widgets();
@@ -341,6 +351,21 @@ void Courtroom::set_mute_list()
}
}
+void Courtroom::set_pair_list()
+{
+ QStringList sorted_pair_list;
+
+ for (char_type i_char : char_list)
+ sorted_pair_list.append(i_char.name);
+
+ sorted_pair_list.sort();
+
+ for (QString i_name : sorted_pair_list)
+ {
+ ui_pair_list->addItem(i_name);
+ }
+}
+
void Courtroom::set_widgets()
{
blip_rate = ao_app->read_blip_rate();
@@ -430,6 +455,13 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_mute_list, "mute_list");
ui_mute_list->hide();
+ set_size_and_pos(ui_pair_list, "pair_list");
+ ui_pair_list->hide();
+ set_size_and_pos(ui_pair_offset_spinbox, "pair_offset_spinbox");
+ ui_pair_offset_spinbox->hide();
+ set_size_and_pos(ui_pair_button, "pair_button");
+ ui_pair_button->set_image("pair_button.png");
+
//set_size_and_pos(ui_area_list, "area_list");
//ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
@@ -697,6 +729,7 @@ void Courtroom::done_received()
set_char_select_page();
set_mute_list();
+ set_pair_list();
set_char_select();
@@ -1009,7 +1042,8 @@ void Courtroom::on_chat_return_pressed()
}
// If there is someone this user would like to appear with.
- if (other_charid > -1)
+ // And said someone is not ourselves!
+ if (other_charid > -1 && other_charid != m_cid)
{
// First, we'll add a filler in case we haven't set an IC showname.
if (ui_ic_chat_name->text().isEmpty())
@@ -1285,7 +1319,7 @@ void Courtroom::handle_chatmessage_2()
{
vert2_offset = -1 * hor2_offset / 20;
}
- ui_vp_sideplayer_char->move(ui_viewport->width() * hor2_offset, ui_viewport->height() * vert2_offset);
+ ui_vp_sideplayer_char->move(ui_viewport->width() * hor2_offset / 100, ui_viewport->height() * vert2_offset / 100);
// Finally, we reorder them based on who is more to the right.
if (hor2_offset <= hor_offset)
@@ -1303,9 +1337,28 @@ void Courtroom::handle_chatmessage_2()
}
else
{
- // In every other case, the talker is on top.
- ui_vp_sideplayer_char->raise();
- ui_vp_player_char->raise();
+ // In every other case, the person more to the left is on top.
+ // With one exception, hlp.
+ // These cases also don't move the characters down.
+ int hor_offset = m_chatmessage[SELF_OFFSET].toInt();
+ ui_vp_player_char->move(ui_viewport->width() * hor_offset / 100, 0);
+
+ // We do the same with the second character.
+ int hor2_offset = m_chatmessage[OTHER_OFFSET].toInt();
+ ui_vp_sideplayer_char->move(ui_viewport->width() * hor2_offset / 100, 0);
+
+ // Finally, we reorder them based on who is more to the left.
+ // The person more to the left is more in the front.
+ if (hor2_offset >= hor_offset)
+ {
+ ui_vp_sideplayer_char->raise();
+ ui_vp_player_char->raise();
+ }
+ else
+ {
+ ui_vp_player_char->raise();
+ ui_vp_sideplayer_char->raise();
+ }
ui_vp_desk->raise();
ui_vp_legacy_desk->raise();
}
@@ -1314,7 +1367,7 @@ void Courtroom::handle_chatmessage_2()
ui_vp_sideplayer_char->set_flipped(true);
else
ui_vp_sideplayer_char->set_flipped(false);
- ui_vp_sideplayer_char->play_idle(char_list.at(got_other_charid).name, m_chatmessage[OTHER_EMOTE]);
+ ui_vp_sideplayer_char->play_idle(m_chatmessage[OTHER_NAME], m_chatmessage[OTHER_EMOTE]);
}
else
{
@@ -1366,6 +1419,7 @@ void Courtroom::handle_chatmessage_3()
{
ui_vp_desk->hide();
ui_vp_legacy_desk->hide();
+ ui_vp_sideplayer_char->hide(); // Hide the second character if we're zooming!
if (side == "pro" ||
side == "hlp" ||
@@ -2599,25 +2653,51 @@ void Courtroom::on_mute_list_clicked(QModelIndex p_index)
mute_map.insert(f_cid, true);
f_item->setText(real_char + " [x]");
}
+}
+void Courtroom::on_pair_list_clicked(QModelIndex p_index)
+{
+ QListWidgetItem *f_item = ui_pair_list->item(p_index.row());
+ QString f_char = f_item->text();
+ QString real_char;
-
- /*
if (f_char.endsWith(" [x]"))
{
real_char = f_char.left(f_char.size() - 4);
- mute_map.remove(real_char);
- mute_map.insert(real_char, false);
f_item->setText(real_char);
}
else
- {
real_char = f_char;
- mute_map.remove(real_char);
- mute_map.insert(real_char, true);
- f_item->setText(real_char + " [x]");
+
+ int f_cid = -1;
+
+ for (int n_char = 0 ; n_char < char_list.size() ; n_char++)
+ {
+ if (char_list.at(n_char).name == real_char)
+ f_cid = n_char;
+ }
+
+ if (f_cid < 0 || f_cid >= char_list.size())
+ {
+ qDebug() << "W: " << real_char << " not present in char_list";
+ return;
}
- */
+
+ other_charid = f_cid;
+
+ // Redo the character list.
+ QStringList sorted_pair_list;
+
+ for (char_type i_char : char_list)
+ sorted_pair_list.append(i_char.name);
+
+ sorted_pair_list.sort();
+
+ for (int i = 0; i < ui_pair_list->count(); i++) {
+ ui_pair_list->item(i)->setText(sorted_pair_list.at(i));
+ }
+
+ f_item->setText(real_char + " [x]");
}
void Courtroom::on_music_list_double_clicked(QModelIndex p_model)
@@ -2738,6 +2818,9 @@ void Courtroom::on_mute_clicked()
if (ui_mute_list->isHidden())
{
ui_mute_list->show();
+ ui_pair_list->hide();
+ ui_pair_offset_spinbox->hide();
+ ui_pair_button->set_image("pair_button.png");
ui_mute->set_image("mute_pressed.png");
}
else
@@ -2747,6 +2830,24 @@ void Courtroom::on_mute_clicked()
}
}
+void Courtroom::on_pair_clicked()
+{
+ if (ui_pair_list->isHidden())
+ {
+ ui_pair_list->show();
+ ui_pair_offset_spinbox->show();
+ ui_mute_list->hide();
+ ui_mute->set_image("mute.png");
+ ui_pair_button->set_image("pair_button_pressed.png");
+ }
+ else
+ {
+ ui_pair_list->hide();
+ ui_pair_offset_spinbox->hide();
+ ui_pair_button->set_image("pair_button.png");
+ }
+}
+
void Courtroom::on_defense_minus_clicked()
{
int f_state = defense_bar_state - 1;
@@ -2809,6 +2910,11 @@ void Courtroom::on_log_limit_changed(int value)
log_maximum_blocks = value;
}
+void Courtroom::on_pair_offset_changed(int value)
+{
+ offset_with_pair = value;
+}
+
void Courtroom::on_witness_testimony_clicked()
{
if (is_muted)
diff --git a/courtroom.h b/courtroom.h
index ad00b725..194298f6 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -85,6 +85,9 @@ public:
//sets the local mute list based on characters available on the server
void set_mute_list();
+ // Sets the local pair list based on the characters available on the server.
+ void set_pair_list();
+
//sets desk and bg based on pos in chatmessage
void set_scene();
@@ -246,7 +249,7 @@ private:
//every time point in char.inis times this equals the final time
const int time_mod = 40;
- static const int chatmessage_size = 21;
+ static const int chatmessage_size = 22;
QString m_chatmessage[chatmessage_size];
bool chatmessage_is_empty = false;
@@ -350,6 +353,10 @@ private:
QListWidget *ui_area_list;
QListWidget *ui_music_list;
+ AOButton *ui_pair_button;
+ QListWidget *ui_pair_list;
+ QSpinBox *ui_pair_offset_spinbox;
+
QLineEdit *ui_ic_chat_message;
QLineEdit *ui_ic_chat_name;
@@ -487,6 +494,7 @@ private slots:
void chat_tick();
void on_mute_list_clicked(QModelIndex p_index);
+ void on_pair_list_clicked(QModelIndex p_index);
void on_chat_return_pressed();
@@ -525,6 +533,7 @@ private slots:
void on_realization_clicked();
void on_mute_clicked();
+ void on_pair_clicked();
void on_defense_minus_clicked();
void on_defense_plus_clicked();
@@ -538,6 +547,7 @@ private slots:
void on_blip_slider_moved(int p_value);
void on_log_limit_changed(int value);
+ void on_pair_offset_changed(int value);
void on_ooc_toggle_clicked();
diff --git a/datatypes.h b/datatypes.h
index fdf91bd6..63ad836a 100644
--- a/datatypes.h
+++ b/datatypes.h
@@ -95,6 +95,7 @@ enum CHAT_MESSAGE
TEXT_COLOR,
SHOWNAME,
OTHER_CHARID,
+ OTHER_NAME,
OTHER_EMOTE,
SELF_OFFSET,
OTHER_OFFSET,
diff --git a/server/aoprotocol.py b/server/aoprotocol.py
index 800ae6ac..31b45d9d 100644
--- a/server/aoprotocol.py
+++ b/server/aoprotocol.py
@@ -420,11 +420,14 @@ class AOProtocol(asyncio.Protocol):
# and an other offset.
self.client.charid_pair = charid_pair
self.client.offset_pair = offset_pair
- self.client.last_sprite = anim
+ if anim_type not in (5, 6):
+ self.client.last_sprite = anim
self.client.flip = flip
+ self.client.claimed_folder = folder
other_offset = 0
other_emote = ''
other_flip = 0
+ other_folder = ''
confirmed = False
if charid_pair > -1:
@@ -434,6 +437,7 @@ class AOProtocol(asyncio.Protocol):
other_offset = target.offset_pair
other_emote = target.last_sprite
other_flip = target.flip
+ other_folder = target.claimed_folder
break
if not confirmed:
@@ -442,7 +446,7 @@ class AOProtocol(asyncio.Protocol):
self.client.area.send_command('MS', msg_type, pre, folder, anim, msg, pos, sfx, anim_type, cid,
sfx_delay, button, self.client.evi_list[evidence], flip, ding, color, showname,
- charid_pair, other_emote, offset_pair, other_offset, other_flip)
+ charid_pair, other_folder, other_emote, offset_pair, other_offset, other_flip)
self.client.area.set_next_msg_delay(len(msg))
logger.log_server('[IC][{}][{}]{}'.format(self.client.area.abbreviation, self.client.get_char_name(), msg), self.client)
diff --git a/server/client_manager.py b/server/client_manager.py
index ec9a26a9..bb2bcd92 100644
--- a/server/client_manager.py
+++ b/server/client_manager.py
@@ -63,6 +63,7 @@ class ClientManager:
self.offset_pair = 0
self.last_sprite = ''
self.flip = 0
+ self.claimed_folder = ''
#flood-guard stuff
self.mus_counter = 0