aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/courtroom.h8
-rw-r--r--include/lobby.h1
-rw-r--r--src/courtroom.cpp149
-rw-r--r--src/lobby.cpp3
-rw-r--r--src/packet_distribution.cpp5
5 files changed, 128 insertions, 38 deletions
diff --git a/include/courtroom.h b/include/courtroom.h
index 172b9f15..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;
@@ -705,6 +709,7 @@ private slots:
void music_random();
void music_list_expand_all();
void music_list_collapse_all();
+ void music_stop();
void on_area_list_double_clicked(QTreeWidgetItem *p_item, int column);
void select_emote(int p_id);
@@ -778,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/include/lobby.h b/include/lobby.h
index 42f52977..4278534c 100644
--- a/include/lobby.h
+++ b/include/lobby.h
@@ -46,6 +46,7 @@ public:
void set_loading_value(int p_value);
bool public_servers_selected = true;
+ bool doubleclicked = false;
~Lobby();
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 300d2747..96e2a533 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -245,7 +245,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"));
@@ -389,6 +392,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)));
@@ -589,12 +594,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");
@@ -1599,13 +1610,11 @@ void Courtroom::on_chat_return_pressed()
int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote);
// needed or else legacy won't understand what we're saying
- if (objection_state > 0) {
- if (ui_pre->isChecked()) {
- if (f_emote_mod == 4 || f_emote_mod == 5)
- f_emote_mod = 6;
- else
- f_emote_mod = 2;
- }
+ if (objection_state > 0 && ui_pre->isChecked()) {
+ if (f_emote_mod == 4 || f_emote_mod == 5)
+ f_emote_mod = 6;
+ else
+ f_emote_mod = 2;
}
else if (ui_pre->isChecked() && !ui_pre_non_interrupt->isChecked()) {
if (f_emote_mod == 0)
@@ -1697,7 +1706,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()) {
@@ -2088,10 +2097,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() >
@@ -2130,12 +2148,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:
@@ -2626,8 +2646,12 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
// Format the name of the actor
ui_ic_chatlog->textCursor().insertText(p_name, bold);
+ // Special case for stopping the music
+ if (p_action == tr("has stopped the music")) {
+ ui_ic_chatlog->textCursor().insertText(" " + p_action + ".", normal);
+ }
// If action not blank:
- if (p_action != "") {
+ else if (p_action != "") {
// Format the action in normal
ui_ic_chatlog->textCursor().insertText(" " + p_action, normal);
if (log_newline)
@@ -3163,9 +3187,10 @@ void Courtroom::handle_song(QStringList *p_contents)
{
effect_flags = p_contents->at(5).toInt();
}
-
music_player->play(f_song, channel, looping, effect_flags);
- if (channel == 0) {
+ if (f_song == "~stop.mp3")
+ ui_music_name->setText(tr("None"));
+ else if (channel == 0) {
if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song))))
ui_music_name->setText(f_song_clear);
else
@@ -3174,7 +3199,7 @@ void Courtroom::handle_song(QStringList *p_contents)
}
else {
QString str_char = char_list.at(n_char).name;
- QString str_show = char_list.at(n_char).name;
+ QString str_show = ao_app->get_showname(str_char);
if (p_contents->length() > 2) {
if (p_contents->at(2) != "") {
@@ -3196,12 +3221,20 @@ void Courtroom::handle_song(QStringList *p_contents)
}
if (!mute_map.value(n_char)) {
- log_ic_text(str_char, str_show, f_song, tr("has played a song"),
- m_chatmessage[TEXT_COLOR].toInt());
- append_ic_text(f_song_clear, str_show, tr("has played a song"));
-
+ if (f_song == "~stop.mp3") {
+ log_ic_text(str_char, str_show, "", tr("has stopped the music"),
+ m_chatmessage[TEXT_COLOR].toInt());
+ append_ic_text("", str_show, tr("has stopped the music"));
+ }
+ else {
+ log_ic_text(str_char, str_show, f_song, tr("has played a song"),
+ m_chatmessage[TEXT_COLOR].toInt());
+ append_ic_text(f_song_clear, str_show, tr("has played a song"));
+ }
music_player->play(f_song, channel, looping, effect_flags);
- if (channel == 0) {
+ if (f_song == "~stop.mp3")
+ ui_music_name->setText(tr("None"));
+ else if (channel == 0) {
if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song))))
ui_music_name->setText(f_song_clear);
else
@@ -3364,9 +3397,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 {
@@ -3380,6 +3412,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");
@@ -3921,7 +3977,7 @@ void Courtroom::set_effects_dropdown()
return;
}
- effectslist.prepend("None");
+ effectslist.prepend(tr("None"));
ui_effects_dropdown->show();
ui_effects_dropdown->addItems(effectslist);
@@ -4099,10 +4155,10 @@ void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item,
{
if (is_muted)
return;
-
+ if (p_item->parent() == nullptr) // i.e. we've clicked a category
+ return;
column = 1; // Column 1 is always the metadata (which we want)
QString p_song = p_item->text(column);
-
QStringList packet_contents;
packet_contents.append(p_song);
packet_contents.append(QString::number(m_cid));
@@ -4117,7 +4173,7 @@ void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item,
void Courtroom::on_music_list_context_menu_requested(const QPoint &pos)
{
QMenu *menu = new QMenu();
-
+ menu->addAction(QString(tr("Stop Current Song")), this, SLOT(music_stop()));
menu->addAction(QString(tr("Play Random Song")), this, SLOT(music_random()));
menu->addSeparator();
menu->addAction(QString(tr("Expand All Categories")), this,
@@ -4195,6 +4251,22 @@ void Courtroom::music_list_collapse_all()
ui_music_list->setCurrentItem(current);
}
+void Courtroom::music_stop()
+{ // send a fake music packet with a nonexistent song
+ if (is_muted) // this requires a special exception for "~stop.mp3" in
+ return; // tsuserver3, as it will otherwise reject songs not on
+ QStringList packet_contents; // its music list
+ packet_contents.append(
+ "~stop.mp3"); // this is our fake song, playing it triggers special code
+ packet_contents.append(QString::number(m_cid));
+ if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_support_enabled) ||
+ ao_app->effects_enabled)
+ packet_contents.append(ui_ic_chat_name->text());
+ if (ao_app->effects_enabled)
+ packet_contents.append(QString::number(music_flags));
+ ao_app->send_server_packet(new AOPacket("MC", packet_contents), false);
+}
+
void Courtroom::on_area_list_double_clicked(QTreeWidgetItem *p_item, int column)
{
column = 0; // The metadata
@@ -4336,6 +4408,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");
@@ -4351,6 +4424,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");
@@ -4359,6 +4433,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");
}
@@ -4515,6 +4590,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)
diff --git a/src/lobby.cpp b/src/lobby.cpp
index 8945d4e3..79a565a8 100644
--- a/src/lobby.cpp
+++ b/src/lobby.cpp
@@ -442,8 +442,9 @@ void Lobby::on_server_list_clicked(QTreeWidgetItem *p_item, int column)
// doubleclicked on an item in the serverlist so we'll connect right away
void Lobby::on_server_list_doubleclicked(QTreeWidgetItem *p_item, int column)
{
+ doubleclicked = true;
on_server_list_clicked(p_item, column);
- on_connect_released();
+ //on_connect_released();
}
void Lobby::on_server_search_edited(QString p_text)
diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp
index ab9ec3f0..f7125797 100644
--- a/src/packet_distribution.cpp
+++ b/src/packet_distribution.cpp
@@ -212,6 +212,11 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
w_lobby->set_player_count(f_contents.at(0).toInt(),
f_contents.at(1).toInt());
+
+ if (w_lobby->doubleclicked) {
+ send_server_packet(new AOPacket("askchaa#%"));
+ w_lobby->doubleclicked = false;
+ }
}
else if (header == "SI") {
if (f_contents.size() != 3)