1844 lines
48 KiB
C++
1844 lines
48 KiB
C++
#include "courtroom.h"
|
|
|
|
#include "aoapplication.h"
|
|
#include "lobby.h"
|
|
#include "hardware_functions.h"
|
|
#include "file_functions.h"
|
|
#include "datatypes.h"
|
|
#include "debug_functions.h"
|
|
|
|
#include <QDebug>
|
|
#include <QScrollBar>
|
|
|
|
Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
|
{
|
|
ao_app = p_ao_app;
|
|
|
|
//initializing sound device
|
|
BASS_Init(-1, 44100, BASS_DEVICE_LATENCY, 0, NULL);
|
|
|
|
keepalive_timer = new QTimer(this);
|
|
keepalive_timer->start(60000);
|
|
|
|
chat_tick_timer = new QTimer(this);
|
|
|
|
text_delay_timer = new QTimer(this);
|
|
text_delay_timer->setSingleShot(true);
|
|
|
|
sfx_delay_timer = new QTimer(this);
|
|
sfx_delay_timer->setSingleShot(true);
|
|
|
|
realization_timer = new QTimer(this);
|
|
realization_timer->setSingleShot(true);
|
|
|
|
testimony_show_timer = new QTimer(this);
|
|
testimony_show_timer->setSingleShot(true);
|
|
|
|
testimony_hide_timer = new QTimer(this);
|
|
testimony_hide_timer->setSingleShot(true);
|
|
|
|
char_button_mapper = new QSignalMapper(this);
|
|
|
|
music_player = new AOMusicPlayer(this, ao_app);
|
|
music_player->set_volume(0);
|
|
sfx_player = new AOSfxPlayer(this, ao_app);
|
|
sfx_player->set_volume(0);
|
|
blip_player = new AOBlipPlayer(this, ao_app);
|
|
blip_player->set_volume(0);
|
|
|
|
modcall_player = new AOSfxPlayer(this, ao_app);
|
|
modcall_player->set_volume(50);
|
|
|
|
ui_background = new AOImage(this, ao_app);
|
|
|
|
ui_viewport = new QWidget(this);
|
|
ui_vp_background = new AOScene(ui_viewport, ao_app);
|
|
ui_vp_speedlines = new AOMovie(ui_viewport, ao_app);
|
|
ui_vp_player_char = new AOCharMovie(ui_viewport, ao_app);
|
|
ui_vp_desk = new AOScene(ui_viewport, ao_app);
|
|
ui_vp_legacy_desk = new AOScene(ui_viewport, ao_app);
|
|
ui_vp_chatbox = new AOImage(ui_viewport, ao_app);
|
|
ui_vp_showname = new QLabel(ui_vp_chatbox);
|
|
ui_vp_message = new QPlainTextEdit(ui_vp_chatbox);
|
|
ui_vp_message->setFrameStyle(QFrame::NoFrame);
|
|
ui_vp_message->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
ui_vp_testimony = new AOImage(ui_viewport, ao_app);
|
|
ui_vp_realization = new AOImage(this, ao_app);
|
|
ui_vp_wtce = new AOMovie(ui_viewport, ao_app);
|
|
ui_vp_objection = new AOMovie(ui_viewport, ao_app);
|
|
|
|
ui_ic_chatlog = new QPlainTextEdit(this);
|
|
ui_ic_chatlog->setReadOnly(true);
|
|
|
|
ui_ms_chatlog = new QPlainTextEdit(this);
|
|
ui_ms_chatlog->setReadOnly(true);
|
|
ui_ms_chatlog->hide();
|
|
|
|
ui_server_chatlog = new QPlainTextEdit(this);
|
|
ui_server_chatlog->setReadOnly(true);
|
|
|
|
ui_mute_list = new QListWidget(this);
|
|
//ui_area_list = new QListWidget(this);
|
|
ui_music_list = new QListWidget(this);
|
|
|
|
ui_ic_chat_message = new QLineEdit(this);
|
|
ui_ic_chat_message->setFrame(false);
|
|
|
|
ui_muted = new AOImage(ui_ic_chat_message, ao_app);
|
|
ui_muted->hide();
|
|
|
|
ui_ooc_chat_message = new QLineEdit(this);
|
|
ui_ooc_chat_message->setFrame(false);
|
|
|
|
ui_ooc_chat_name = new QLineEdit(this);
|
|
ui_ooc_chat_name->setFrame(false);
|
|
ui_ooc_chat_name->setPlaceholderText("Name");
|
|
|
|
//ui_area_password = new QLineEdit(this);
|
|
//ui_area_password->setFrame(false);
|
|
ui_music_search = new QLineEdit(this);
|
|
ui_music_search->setFrame(false);
|
|
|
|
//////////emotes//////////////////////
|
|
|
|
ui_emotes = new QWidget(this);
|
|
|
|
///////////////////////////////////////
|
|
|
|
ui_defense_bar = new AOImage(this, ao_app);
|
|
ui_prosecution_bar = new AOImage(this, ao_app);
|
|
|
|
ui_music_label = new QLabel(this);
|
|
ui_sfx_label = new QLabel(this);
|
|
ui_blip_label = new QLabel(this);
|
|
|
|
ui_hold_it = new AOButton(this, ao_app);
|
|
ui_objection = new AOButton(this, ao_app);
|
|
ui_take_that = new AOButton(this, ao_app);
|
|
|
|
ui_ooc_toggle = new AOButton(this, ao_app);
|
|
ui_witness_testimony = new AOButton(this, ao_app);
|
|
ui_cross_examination = new AOButton(this, ao_app);
|
|
|
|
ui_change_character = new AOButton(this, ao_app);
|
|
ui_reload_theme = new AOButton(this, ao_app);
|
|
ui_call_mod = new AOButton(this, ao_app);
|
|
|
|
ui_pre = new QCheckBox(this);
|
|
ui_pre->setText("Pre");
|
|
ui_flip = new QCheckBox(this);
|
|
ui_flip->setText("Flip");
|
|
ui_flip->hide();
|
|
ui_guard = new QCheckBox(this);
|
|
ui_guard->setText("Guard");
|
|
ui_guard->hide();
|
|
|
|
ui_custom_objection = new AOButton(this, ao_app);
|
|
ui_realization = new AOButton(this, ao_app);
|
|
ui_mute = new AOButton(this, ao_app);
|
|
|
|
ui_defense_plus = new AOButton(this, ao_app);
|
|
ui_defense_minus = new AOButton(this, ao_app);
|
|
|
|
ui_prosecution_plus = new AOButton(this, ao_app);
|
|
ui_prosecution_minus = new AOButton(this, ao_app);
|
|
|
|
ui_text_color = new QComboBox(this);
|
|
ui_text_color->addItem("White");
|
|
ui_text_color->addItem("Green");
|
|
ui_text_color->addItem("Red");
|
|
ui_text_color->addItem("Orange");
|
|
ui_text_color->addItem("Blue");
|
|
if (ao_app->yellow_text_enabled)
|
|
ui_text_color->addItem("Yellow");
|
|
|
|
ui_music_slider = new QSlider(Qt::Horizontal, this);
|
|
ui_music_slider->setRange(0, 100);
|
|
ui_music_slider->setValue(50);
|
|
|
|
ui_sfx_slider = new QSlider(Qt::Horizontal, this);
|
|
ui_sfx_slider->setRange(0, 100);
|
|
ui_sfx_slider->setValue(50);
|
|
|
|
ui_blip_slider = new QSlider(Qt::Horizontal, this);
|
|
ui_blip_slider->setRange(0, 100);
|
|
ui_blip_slider->setValue(50);
|
|
|
|
ui_evidence_button = new AOButton(this, ao_app);
|
|
|
|
ui_evidence = new AOImage(this, ao_app);
|
|
ui_evidence->hide();
|
|
|
|
/////////////char select widgets under here///////////////
|
|
|
|
ui_char_select_background = new AOImage(this, ao_app);
|
|
|
|
//constructing character button grid
|
|
const int base_x_pos{25};
|
|
const int base_y_pos{36};
|
|
|
|
const int x_modifier{67};
|
|
int x_mod_count{0};
|
|
|
|
const int y_modifier{67};
|
|
int y_mod_count{0};
|
|
|
|
for (int n = 0 ; n < 90 ; ++n)
|
|
{
|
|
int x_pos = base_x_pos + (x_modifier * x_mod_count);
|
|
int y_pos = base_y_pos + (y_modifier * y_mod_count);
|
|
|
|
ui_char_button_list.append(new AOCharButton(ui_char_select_background, ao_app, x_pos, y_pos));
|
|
|
|
connect(ui_char_button_list.at(n), SIGNAL(clicked()), char_button_mapper, SLOT(map())) ;
|
|
char_button_mapper->setMapping (ui_char_button_list.at(n), n) ;
|
|
|
|
++x_mod_count;
|
|
|
|
//if char number is divisible by ten with rest 9 then the next charicon should start on a new line
|
|
if (n % 10 == 9 && n != 0)
|
|
{
|
|
++y_mod_count;
|
|
x_mod_count = 0;
|
|
}
|
|
}
|
|
|
|
connect (char_button_mapper, SIGNAL(mapped(int)), this, SLOT(char_clicked(int))) ;
|
|
|
|
ui_selector = new AOImage(ui_char_select_background, ao_app);
|
|
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
ui_selector->resize(62, 62);
|
|
|
|
ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app);
|
|
|
|
ui_char_password = new QLineEdit(ui_char_select_background);
|
|
|
|
ui_char_select_left = new AOButton(ui_char_select_background, ao_app);
|
|
ui_char_select_right = new AOButton(ui_char_select_background, ao_app);
|
|
|
|
ui_spectator = new AOButton(ui_char_select_background, ao_app);
|
|
|
|
connect(keepalive_timer, SIGNAL(timeout()), this, SLOT(ping_server()));
|
|
|
|
connect(ui_vp_objection, SIGNAL(done()), this, SLOT(objection_done()));
|
|
connect(ui_vp_player_char, SIGNAL(done()), this, SLOT(preanim_done()));
|
|
|
|
connect(text_delay_timer, SIGNAL(timeout()), this, SLOT(start_chat_ticking()));
|
|
connect(sfx_delay_timer, SIGNAL(timeout()), this, SLOT(play_sfx()));
|
|
|
|
connect(chat_tick_timer, SIGNAL(timeout()), this, SLOT(chat_tick()));
|
|
|
|
connect(realization_timer, SIGNAL(timeout()), this, SLOT(realization_done()));
|
|
|
|
connect(testimony_show_timer, SIGNAL(timeout()), this, SLOT(hide_testimony()));
|
|
connect(testimony_hide_timer, SIGNAL(timeout()), this, SLOT(show_testimony()));
|
|
//emote signals are set in emotes.cpp
|
|
|
|
connect(ui_mute_list, SIGNAL(clicked(QModelIndex)), this, SLOT(on_mute_list_clicked(QModelIndex)));
|
|
|
|
connect(ui_ic_chat_message, SIGNAL(returnPressed()), this, SLOT(on_chat_return_pressed()));
|
|
|
|
connect(ui_ooc_chat_message, SIGNAL(returnPressed()), this, SLOT(on_ooc_return_pressed()));
|
|
|
|
connect(ui_music_list, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_music_list_double_clicked(QModelIndex)));
|
|
|
|
connect(ui_hold_it, SIGNAL(clicked()), this, SLOT(on_hold_it_clicked()));
|
|
connect(ui_objection, SIGNAL(clicked()), this, SLOT(on_objection_clicked()));
|
|
connect(ui_take_that, SIGNAL(clicked()), this, SLOT(on_take_that_clicked()));
|
|
connect(ui_custom_objection, SIGNAL(clicked()), this, SLOT(on_custom_objection_clicked()));
|
|
|
|
connect(ui_realization, SIGNAL(clicked()), this, SLOT(on_realization_clicked()));
|
|
|
|
connect(ui_mute, SIGNAL(clicked()), this, SLOT(on_mute_clicked()));
|
|
|
|
connect(ui_defense_minus, SIGNAL(clicked()), this, SLOT(on_defense_minus_clicked()));
|
|
connect(ui_defense_plus, SIGNAL(clicked()), this, SLOT(on_defense_plus_clicked()));
|
|
connect(ui_prosecution_minus, SIGNAL(clicked()), this, SLOT(on_prosecution_minus_clicked()));
|
|
connect(ui_prosecution_plus, SIGNAL(clicked()), this, SLOT(on_prosecution_plus_clicked()));
|
|
|
|
connect(ui_text_color, SIGNAL(currentIndexChanged(int)), this, SLOT(on_text_color_changed(int)));
|
|
|
|
connect(ui_music_slider, SIGNAL(valueChanged(int)), this, SLOT(on_music_slider_moved(int)));
|
|
connect(ui_sfx_slider, SIGNAL(valueChanged(int)), this, SLOT(on_sfx_slider_moved(int)));
|
|
connect(ui_blip_slider, SIGNAL(valueChanged(int)), this, SLOT(on_blip_slider_moved(int)));
|
|
|
|
connect(ui_ooc_toggle, SIGNAL(clicked()), this, SLOT(on_ooc_toggle_clicked()));
|
|
|
|
connect(ui_music_search, SIGNAL(textChanged(QString)), this, SLOT(on_music_search_edited(QString)));
|
|
|
|
connect(ui_witness_testimony, SIGNAL(clicked()), this, SLOT(on_witness_testimony_clicked()));
|
|
connect(ui_cross_examination, SIGNAL(clicked()), this, SLOT(on_cross_examination_clicked()));
|
|
|
|
connect(ui_change_character, SIGNAL(clicked()), this, SLOT(on_change_character_clicked()));
|
|
connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked()));
|
|
connect(ui_call_mod, SIGNAL(clicked()), this, SLOT(on_call_mod_clicked()));
|
|
|
|
connect(ui_pre, SIGNAL(clicked()), this, SLOT(on_pre_clicked()));
|
|
connect(ui_flip, SIGNAL(clicked()), this, SLOT(on_flip_clicked()));
|
|
connect(ui_guard, SIGNAL(clicked()), this, SLOT(on_guard_clicked()));
|
|
|
|
connect(ui_evidence_button, SIGNAL(clicked()), this, SLOT(on_evidence_button_clicked()));
|
|
|
|
connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked()));
|
|
|
|
connect(ui_char_select_left, SIGNAL(clicked()), this, SLOT(on_char_select_left_clicked()));
|
|
connect(ui_char_select_right, SIGNAL(clicked()), this, SLOT(on_char_select_right_clicked()));
|
|
|
|
connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked()));
|
|
|
|
set_widgets();
|
|
|
|
//in evidence.cpp
|
|
construct_evidence();
|
|
|
|
//implementation in emotes.cpp
|
|
construct_emotes();
|
|
}
|
|
|
|
void Courtroom::set_mute_list()
|
|
{
|
|
mute_map.clear();
|
|
|
|
QStringList sorted_mute_list;
|
|
|
|
for (char_type i_char : char_list)
|
|
sorted_mute_list.append(i_char.name);
|
|
|
|
sorted_mute_list.sort();
|
|
|
|
for (QString i_name : sorted_mute_list)
|
|
{
|
|
mute_map.insert(i_name, false);
|
|
ui_mute_list->addItem(i_name);
|
|
}
|
|
}
|
|
|
|
void Courtroom::set_widgets()
|
|
{
|
|
QString design_ini_path = ao_app->get_theme_path() + "courtroom_design.ini";
|
|
QString default_ini_path = ao_app->get_base_path() + "themes/default/courtroom_design.ini";
|
|
|
|
pos_size_type f_courtroom = ao_app->get_pos_and_size("courtroom", design_ini_path);
|
|
|
|
if (f_courtroom.width < 0 || f_courtroom.height < 0)
|
|
{
|
|
f_courtroom = ao_app->get_pos_and_size("courtroom", default_ini_path);
|
|
if (f_courtroom.width < 0 || f_courtroom.height < 0)
|
|
{
|
|
qDebug() << "ERROR: did not find courtroom width or height in courtroom_design.ini!";
|
|
//T0D0: add error box then quit application, this is not recoverable
|
|
}
|
|
}
|
|
|
|
m_courtroom_width = f_courtroom.width;
|
|
m_courtroom_height = f_courtroom.height;
|
|
|
|
this->resize(m_courtroom_width, m_courtroom_height);
|
|
this->setFixedSize(m_courtroom_width, m_courtroom_height);
|
|
|
|
ui_background->set_image("courtroombackground.png");
|
|
ui_background->move(0, 0);
|
|
ui_background->resize(m_courtroom_width, m_courtroom_height);
|
|
|
|
set_size_and_pos(ui_viewport, "viewport");
|
|
|
|
ui_vp_background->move(0, 0);
|
|
ui_vp_background->resize(ui_viewport->width(), ui_viewport->height());
|
|
|
|
ui_vp_speedlines->move(0, 0);
|
|
ui_vp_speedlines->combo_resize(ui_viewport->width(), ui_viewport->height());
|
|
|
|
ui_vp_player_char->move(0, 0);
|
|
ui_vp_player_char->combo_resize(ui_viewport->width(), ui_viewport->height());
|
|
|
|
//the AO2 desk element
|
|
ui_vp_desk->move(0, 0);
|
|
ui_vp_desk->resize(ui_viewport->width(), ui_viewport->height());
|
|
|
|
//the size of the ui_vp_legacy_desk element relies on various factors and is set in set_scene()
|
|
|
|
double y_modifier = 147.0 / 192.0;
|
|
int final_y = y_modifier * ui_viewport->height();
|
|
ui_vp_legacy_desk->move(0, final_y);
|
|
ui_vp_legacy_desk->hide();
|
|
|
|
set_size_and_pos(ui_vp_chatbox, "chatbox");
|
|
ui_vp_chatbox->set_scaled_image("chatmed.png");
|
|
ui_vp_chatbox->hide();
|
|
|
|
set_size_and_pos(ui_vp_showname, "showname");
|
|
QFont pt_8 = ui_vp_showname->font();
|
|
QFont pt_9 = ui_vp_showname->font();
|
|
QFont pt_10 = ui_vp_showname->font();
|
|
pt_8.setPointSize(8);
|
|
pt_9.setPointSize(9);
|
|
pt_10.setPointSize(10);
|
|
ui_vp_showname->setFont(pt_8);
|
|
ui_vp_showname->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
|
"color: white;");
|
|
|
|
set_size_and_pos(ui_vp_message, "message");
|
|
ui_vp_message->setReadOnly(true);
|
|
#if (defined (_WIN32) || defined (_WIN64))
|
|
ui_vp_message->setFont(pt_10);
|
|
#else
|
|
ui_vp_message->setFont(pt_9);
|
|
#endif
|
|
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
|
"color: white");
|
|
|
|
ui_vp_testimony->move(0, 0);
|
|
ui_vp_testimony->resize(ui_viewport->width(), ui_viewport->height());
|
|
ui_vp_testimony->set_image("testimony.png");
|
|
ui_vp_testimony->hide();
|
|
|
|
ui_vp_realization->move(0, 0);
|
|
ui_vp_realization->resize(ui_viewport->width(), ui_viewport->height());
|
|
ui_vp_realization->set_scaled_image("realizationflash.png");
|
|
ui_vp_realization->hide();
|
|
|
|
ui_vp_wtce->move(0, 0);
|
|
ui_vp_wtce->combo_resize(ui_viewport->width(), ui_viewport->height());
|
|
|
|
ui_vp_objection->move(0, 0);
|
|
ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height());
|
|
|
|
set_size_and_pos(ui_ic_chatlog, "ic_chatlog");
|
|
#if (defined (_WIN32) || defined (_WIN64))
|
|
ui_ic_chatlog->setFont(pt_10);
|
|
#else
|
|
ui_ic_chatlog->setFont(pt_9);
|
|
#endif
|
|
ui_ic_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
|
"color: white;");
|
|
|
|
set_size_and_pos(ui_ms_chatlog, "ms_chatlog");
|
|
ui_ms_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
|
|
|
|
set_size_and_pos(ui_server_chatlog, "server_chatlog");
|
|
ui_server_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
|
|
|
|
set_size_and_pos(ui_mute_list, "mute_list");
|
|
ui_mute_list->hide();
|
|
|
|
//set_size_and_pos(ui_area_list, "area_list");
|
|
//ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
|
|
|
|
set_size_and_pos(ui_music_list, "music_list");
|
|
ui_music_list->setStyleSheet("QListWidget{background-color: rgba(0, 0, 0, 0);}");
|
|
ui_music_list->setFont(pt_8);
|
|
|
|
set_size_and_pos(ui_ic_chat_message, "ic_chat_message");
|
|
ui_ic_chat_message->setStyleSheet("background-color: rgba(100, 100, 100, 255);");
|
|
ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
|
|
ui_muted->set_image("muted.png");
|
|
|
|
set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message");
|
|
ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
|
|
|
|
set_size_and_pos(ui_ooc_chat_name, "ooc_chat_name");
|
|
ui_ooc_chat_name->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
|
|
|
|
//set_size_and_pos(ui_area_password, "area_password");
|
|
set_size_and_pos(ui_music_search, "music_search");
|
|
|
|
set_size_and_pos(ui_emotes, "emotes");
|
|
|
|
//emote buttons
|
|
|
|
set_size_and_pos(ui_defense_bar, "defense_bar");
|
|
ui_defense_bar->set_image("defensebar10.png");
|
|
|
|
set_size_and_pos(ui_prosecution_bar, "prosecution_bar");
|
|
ui_prosecution_bar->set_image("prosecutionbar10.png");
|
|
|
|
set_size_and_pos(ui_music_label, "music_label");
|
|
ui_music_label->setText("Music");
|
|
set_size_and_pos(ui_sfx_label, "sfx_label");
|
|
ui_sfx_label->setText("Sfx");
|
|
set_size_and_pos(ui_blip_label, "blip_label");
|
|
ui_blip_label->setText("Blips");
|
|
|
|
set_size_and_pos(ui_hold_it, "hold_it");
|
|
ui_hold_it->set_image("holdit.png");
|
|
set_size_and_pos(ui_objection, "objection");
|
|
ui_objection->set_image("objection.png");
|
|
set_size_and_pos(ui_take_that, "take_that");
|
|
ui_take_that->set_image("takethat.png");
|
|
|
|
set_size_and_pos(ui_ooc_toggle, "ooc_toggle");
|
|
ui_ooc_toggle->setText("Server");
|
|
|
|
set_size_and_pos(ui_witness_testimony, "witness_testimony");
|
|
ui_witness_testimony->set_image("witnesstestimony.png");
|
|
set_size_and_pos(ui_cross_examination, "cross_examination");
|
|
ui_cross_examination->set_image("crossexamination.png");
|
|
|
|
set_size_and_pos(ui_change_character, "change_character");
|
|
ui_change_character->setText("Change character");
|
|
|
|
set_size_and_pos(ui_reload_theme, "reload_theme");
|
|
ui_reload_theme->setText("Reload theme");
|
|
|
|
set_size_and_pos(ui_call_mod, "call_mod");
|
|
ui_call_mod->setText("Call mod");
|
|
|
|
set_size_and_pos(ui_pre, "pre");
|
|
ui_pre->setText("Pre");
|
|
|
|
set_size_and_pos(ui_flip, "flip");
|
|
|
|
set_size_and_pos(ui_guard, "guard");
|
|
|
|
set_size_and_pos(ui_custom_objection, "custom_objection");
|
|
ui_custom_objection->set_image("custom.png");
|
|
|
|
set_size_and_pos(ui_realization, "realization");
|
|
ui_realization->set_image("realization.png");
|
|
|
|
set_size_and_pos(ui_mute, "mute_button");
|
|
ui_mute->set_image("mute.png");
|
|
|
|
set_size_and_pos(ui_defense_plus, "defense_plus");
|
|
ui_defense_plus->set_image("defplus.png");
|
|
|
|
set_size_and_pos(ui_defense_minus, "defense_minus");
|
|
ui_defense_minus->set_image("defminus.png");
|
|
|
|
set_size_and_pos(ui_prosecution_plus, "prosecution_plus");
|
|
ui_prosecution_plus->set_image("proplus.png");
|
|
|
|
set_size_and_pos(ui_prosecution_minus, "prosecution_minus");
|
|
ui_prosecution_minus->set_image("prominus.png");
|
|
|
|
set_size_and_pos(ui_text_color, "text_color");
|
|
|
|
set_size_and_pos(ui_music_slider, "music_slider");
|
|
set_size_and_pos(ui_sfx_slider, "sfx_slider");
|
|
set_size_and_pos(ui_blip_slider, "blip_slider");
|
|
|
|
set_size_and_pos(ui_evidence_button, "evidence_button");
|
|
//ui_evidence_button->set_image("evidencebutton.png");
|
|
|
|
set_size_and_pos(ui_evidence, "evidence_background");
|
|
ui_evidence->set_image("evidencebackground.png");
|
|
|
|
//char select stuff under here
|
|
|
|
ui_char_select_background->set_image("charselect_background.png");
|
|
ui_char_select_background->move(0, 0);
|
|
ui_char_select_background->resize(m_courtroom_width, m_courtroom_height);
|
|
|
|
//buttons are in the constructor
|
|
|
|
ui_selector->set_image("char_selector.png");
|
|
ui_selector->hide();
|
|
|
|
ui_back_to_lobby->setText("Back to Lobby");
|
|
set_size_and_pos(ui_back_to_lobby, "back_to_lobby");
|
|
|
|
set_size_and_pos(ui_char_password, "char_password");
|
|
|
|
ui_char_select_left->set_image("arrow_left.png");
|
|
ui_char_select_left->move(2, 325);
|
|
ui_char_select_left->resize(20, 20);
|
|
|
|
ui_char_select_right->set_image("arrow_right.png");
|
|
ui_char_select_right->move(691, 325);
|
|
ui_char_select_right->resize(20, 20);
|
|
|
|
ui_spectator->setText("Spectator");
|
|
set_size_and_pos(ui_spectator, "spectator");
|
|
|
|
}
|
|
|
|
void Courtroom::set_window_title(QString p_title)
|
|
{
|
|
this->setWindowTitle(p_title);
|
|
}
|
|
|
|
void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier)
|
|
{
|
|
QString design_ini_path = ao_app->get_theme_path() + "courtroom_design.ini";
|
|
QString default_ini_path = ao_app->get_base_path() + "themes/default/courtroom_design.ini";
|
|
|
|
pos_size_type design_ini_result = ao_app->get_pos_and_size(p_identifier, design_ini_path);
|
|
|
|
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
|
{
|
|
design_ini_result = ao_app->get_pos_and_size(p_identifier, default_ini_path);
|
|
|
|
if (design_ini_result.width < 0 || design_ini_result.height < 0)
|
|
{
|
|
qDebug() << "W: could not find \"" << p_identifier << "\" in courtroom_design.ini";
|
|
}
|
|
}
|
|
|
|
p_widget->move(design_ini_result.x, design_ini_result.y);
|
|
p_widget->resize(design_ini_result.width, design_ini_result.height);
|
|
}
|
|
|
|
void Courtroom::set_taken(int n_char, bool p_taken)
|
|
{
|
|
if (n_char >= char_list.size())
|
|
{
|
|
qDebug() << "W: set_taken attempted to set an index bigger than char_list size";
|
|
return;
|
|
}
|
|
|
|
char_type f_char;
|
|
f_char.name = char_list.at(n_char).name;
|
|
f_char.description = char_list.at(n_char).description;
|
|
f_char.taken = p_taken;
|
|
|
|
char_list.replace(n_char, f_char);
|
|
}
|
|
|
|
void Courtroom::done_received()
|
|
{
|
|
m_cid = -1;
|
|
|
|
music_player->set_volume(0);
|
|
sfx_player->set_volume(0);
|
|
blip_player->set_volume(0);
|
|
|
|
set_char_select_page();
|
|
|
|
set_mute_list();
|
|
|
|
show();
|
|
}
|
|
|
|
void Courtroom::set_char_select_page()
|
|
{
|
|
ui_char_select_background->show();
|
|
|
|
ui_char_select_left->hide();
|
|
ui_char_select_right->hide();
|
|
|
|
for (AOCharButton *i_button : ui_char_button_list)
|
|
i_button->hide();
|
|
|
|
int total_pages = char_list.size() / 90;
|
|
int chars_on_page = 0;
|
|
|
|
if (char_list.size() % 90 != 0)
|
|
{
|
|
++total_pages;
|
|
//i. e. not on the last page
|
|
if (total_pages > current_char_page + 1)
|
|
chars_on_page = 90;
|
|
else
|
|
chars_on_page = char_list.size() % 90;
|
|
|
|
}
|
|
else
|
|
chars_on_page = 90;
|
|
|
|
if (total_pages > current_char_page + 1)
|
|
ui_char_select_right->show();
|
|
|
|
if (current_char_page > 0)
|
|
ui_char_select_left->show();
|
|
|
|
for (int n_button = 0 ; n_button < chars_on_page ; ++n_button)
|
|
{
|
|
int n_real_char = n_button + current_char_page * 90;
|
|
AOCharButton *f_button = ui_char_button_list.at(n_button);
|
|
|
|
f_button->reset();
|
|
f_button->set_image(char_list.at(n_real_char).name);
|
|
f_button->show();
|
|
|
|
if (char_list.at(n_real_char).taken)
|
|
f_button->set_taken();
|
|
}
|
|
|
|
}
|
|
|
|
void Courtroom::set_background(QString p_background)
|
|
{
|
|
current_background = p_background;
|
|
QString bg_path = get_background_path();
|
|
|
|
is_ao2_bg = file_exists(bg_path + "defensedesk.png") &&
|
|
file_exists(bg_path + "prosecutiondesk.png") &&
|
|
file_exists(bg_path + "stand.png");
|
|
|
|
if (is_ao2_bg)
|
|
{
|
|
set_size_and_pos(ui_vp_chatbox, "ao2_chatbox");
|
|
set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message");
|
|
}
|
|
else
|
|
{
|
|
set_size_and_pos(ui_vp_chatbox, "chatbox");
|
|
set_size_and_pos(ui_ic_chat_message, "ic_chat_message");
|
|
}
|
|
}
|
|
|
|
void Courtroom::enter_courtroom(int p_cid)
|
|
{
|
|
m_cid = p_cid;
|
|
QString f_char = ao_app->get_char_name(char_list.at(m_cid).name);
|
|
current_char = f_char;
|
|
|
|
current_emote_page = 0;
|
|
current_emote = 0;
|
|
|
|
ui_emotes->show();
|
|
|
|
set_emote_page();
|
|
|
|
QString side = ao_app->get_char_side(f_char);
|
|
|
|
if (side == "jud")
|
|
{
|
|
ui_witness_testimony->show();
|
|
ui_cross_examination->show();
|
|
ui_defense_minus->show();
|
|
ui_defense_plus->show();
|
|
ui_prosecution_minus->show();
|
|
ui_prosecution_plus->show();
|
|
}
|
|
else
|
|
{
|
|
ui_witness_testimony->hide();
|
|
ui_cross_examination->hide();
|
|
ui_defense_minus->hide();
|
|
ui_defense_plus->hide();
|
|
ui_prosecution_minus->hide();
|
|
ui_prosecution_plus->hide();
|
|
}
|
|
|
|
QString char_path = ao_app->get_character_path(current_char);
|
|
|
|
if (ao_app->custom_objection_enabled &&
|
|
file_exists(char_path + "custom.gif") &&
|
|
file_exists(char_path + "custom.wav"))
|
|
ui_custom_objection->show();
|
|
else
|
|
ui_custom_objection->hide();
|
|
|
|
if (ao_app->flipping_enabled)
|
|
ui_flip->show();
|
|
else
|
|
ui_flip->hide();
|
|
|
|
list_music();
|
|
|
|
music_player->set_volume(ui_music_slider->value());
|
|
sfx_player->set_volume(ui_sfx_slider->value());
|
|
blip_player->set_volume(ui_blip_slider->value());
|
|
|
|
testimony_in_progress = false;
|
|
|
|
ui_char_select_background->hide();
|
|
|
|
ui_ic_chat_message->setEnabled(true);
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::list_music()
|
|
{
|
|
ui_music_list->clear();
|
|
|
|
int n_listed_songs = 0;
|
|
|
|
for (int n_song = 0 ; n_song < music_list.size() ; ++n_song)
|
|
{
|
|
QString i_song = music_list.at(n_song);
|
|
|
|
if (i_song.toLower().contains(ui_music_search->text().toLower()))
|
|
{
|
|
ui_music_list->addItem(i_song);
|
|
|
|
QString song_path = ao_app->get_base_path() + "sounds/music/" + i_song.toLower();
|
|
|
|
if (file_exists(song_path))
|
|
ui_music_list->item(n_listed_songs)->setBackground(Qt::green);
|
|
else
|
|
ui_music_list->item(n_listed_songs)->setBackground(Qt::red);
|
|
|
|
++n_listed_songs;
|
|
}
|
|
}
|
|
}
|
|
|
|
void Courtroom::append_ms_chatmessage(QString f_message)
|
|
{
|
|
const QTextCursor old_cursor = ui_ms_chatlog->textCursor();
|
|
const int old_scrollbar_value = ui_ms_chatlog->verticalScrollBar()->value();
|
|
const bool is_scrolled_down = old_scrollbar_value == ui_ms_chatlog->verticalScrollBar()->maximum();
|
|
|
|
ui_ms_chatlog->moveCursor(QTextCursor::End);
|
|
|
|
ui_ms_chatlog->appendPlainText(f_message);
|
|
|
|
if (old_cursor.hasSelection() || !is_scrolled_down)
|
|
{
|
|
// The user has selected text or scrolled away from the bottom: maintain position.
|
|
ui_ms_chatlog->setTextCursor(old_cursor);
|
|
ui_ms_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
|
|
}
|
|
else
|
|
{
|
|
// The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom.
|
|
ui_ms_chatlog->moveCursor(QTextCursor::End);
|
|
ui_ms_chatlog->verticalScrollBar()->setValue(ui_ms_chatlog->verticalScrollBar()->maximum());
|
|
}
|
|
}
|
|
|
|
void Courtroom::append_server_chatmessage(QString f_message)
|
|
{
|
|
const QTextCursor old_cursor = ui_server_chatlog->textCursor();
|
|
const int old_scrollbar_value = ui_server_chatlog->verticalScrollBar()->value();
|
|
const bool is_scrolled_down = old_scrollbar_value == ui_server_chatlog->verticalScrollBar()->maximum();
|
|
|
|
ui_server_chatlog->moveCursor(QTextCursor::End);
|
|
|
|
ui_server_chatlog->appendPlainText(f_message);
|
|
|
|
if (old_cursor.hasSelection() || !is_scrolled_down)
|
|
{
|
|
// The user has selected text or scrolled away from the bottom: maintain position.
|
|
ui_server_chatlog->setTextCursor(old_cursor);
|
|
ui_server_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
|
|
}
|
|
else
|
|
{
|
|
// The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom.
|
|
ui_server_chatlog->moveCursor(QTextCursor::End);
|
|
ui_server_chatlog->verticalScrollBar()->setValue(ui_server_chatlog->verticalScrollBar()->maximum());
|
|
}
|
|
}
|
|
|
|
void Courtroom::on_chat_return_pressed()
|
|
{
|
|
if (ui_ic_chat_message->text() == "" || is_muted)
|
|
return;
|
|
|
|
if (anim_state < 3 || text_state < 2)
|
|
return;
|
|
|
|
//MS#chat#
|
|
//pre-emote#
|
|
//character#
|
|
//emote#
|
|
//message#
|
|
//side#
|
|
//sfx-name#
|
|
//emote_modifier#
|
|
//char_id#
|
|
//sfx_delay#
|
|
//objection_modifier#
|
|
//evidence#
|
|
//placeholder#
|
|
//realization#
|
|
//text_color#%
|
|
|
|
QStringList packet_contents;
|
|
|
|
packet_contents.append("chat");
|
|
|
|
packet_contents.append(ao_app->get_pre_emote(current_char, current_emote));
|
|
|
|
packet_contents.append(current_char);
|
|
|
|
packet_contents.append(ao_app->get_emote(current_char, current_emote));
|
|
|
|
packet_contents.append(ui_ic_chat_message->text());
|
|
|
|
packet_contents.append(ao_app->get_char_side(current_char));
|
|
|
|
packet_contents.append(ao_app->get_sfx_name(current_char, current_emote));
|
|
|
|
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 (f_emote_mod == 5)
|
|
f_emote_mod = 6;
|
|
else
|
|
f_emote_mod = 2;
|
|
}
|
|
else if (ui_pre->isChecked())
|
|
{
|
|
if (f_emote_mod == 0)
|
|
f_emote_mod = 1;
|
|
else if (f_emote_mod == 5 && ao_app->prezoom_enabled)
|
|
f_emote_mod = 4;
|
|
}
|
|
else
|
|
{
|
|
if (f_emote_mod == 1)
|
|
f_emote_mod = 0;
|
|
else if (f_emote_mod == 4)
|
|
f_emote_mod = 5;
|
|
}
|
|
|
|
packet_contents.append(QString::number(f_emote_mod));
|
|
packet_contents.append(QString::number(m_cid));
|
|
|
|
packet_contents.append(QString::number(ao_app->get_sfx_delay(current_char, current_emote)));
|
|
|
|
QString f_obj_state;
|
|
|
|
if ((objection_state == 4 && !ao_app->custom_objection_enabled) ||
|
|
(objection_state < 0))
|
|
f_obj_state = "0";
|
|
else
|
|
f_obj_state = QString::number(objection_state);
|
|
|
|
packet_contents.append(f_obj_state);
|
|
|
|
//evidence. 0 for now
|
|
packet_contents.append("0");
|
|
|
|
QString f_flip;
|
|
|
|
if (ao_app->flipping_enabled)
|
|
{
|
|
if (ui_flip->isChecked())
|
|
f_flip = "1";
|
|
else
|
|
f_flip = "0";
|
|
}
|
|
else
|
|
f_flip = QString::number(m_cid);
|
|
|
|
packet_contents.append(f_flip);
|
|
|
|
packet_contents.append(QString::number(realization_state));
|
|
|
|
QString f_text_color;
|
|
|
|
if (text_color < 0)
|
|
f_text_color = "0";
|
|
else if (text_color > 4 && !ao_app->yellow_text_enabled)
|
|
f_text_color = "0";
|
|
else
|
|
f_text_color = QString::number(text_color);
|
|
|
|
packet_contents.append(f_text_color);
|
|
|
|
ao_app->send_server_packet(new AOPacket("MS", packet_contents));
|
|
}
|
|
|
|
void Courtroom::handle_chatmessage(QStringList *p_contents)
|
|
{
|
|
for (int n_string = 0 ; n_string < chatmessage_size ; ++n_string)
|
|
{
|
|
m_chatmessage[n_string] = p_contents->at(n_string);
|
|
}
|
|
|
|
if (mute_map.value(m_chatmessage[CHAR_NAME]))
|
|
return;
|
|
|
|
QString f_showname = ao_app->get_showname(m_chatmessage[CHAR_NAME]);
|
|
|
|
QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n';
|
|
|
|
if (f_message == previous_ic_message)
|
|
return;
|
|
|
|
text_state = 0;
|
|
anim_state = 0;
|
|
|
|
chatmessage_is_empty = m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == "";
|
|
|
|
if (m_chatmessage[MESSAGE] == ui_ic_chat_message->text())
|
|
{
|
|
ui_ic_chat_message->clear();
|
|
objection_state = 0;
|
|
realization_state = 0;
|
|
ui_pre->setChecked(false);
|
|
ui_hold_it->set_image("holdit.png");
|
|
ui_objection->set_image("objection.png");
|
|
ui_take_that->set_image("takethat.png");
|
|
ui_custom_objection->set_image("custom.png");
|
|
ui_realization->set_image("realization.png");
|
|
}
|
|
|
|
append_ic_text(f_message);
|
|
|
|
previous_ic_message = f_message;
|
|
|
|
int objection_mod = m_chatmessage[OBJECTION_MOD].toInt();
|
|
|
|
//if an objection is used
|
|
if (objection_mod <= 4 && objection_mod >= 1)
|
|
{
|
|
switch (objection_mod)
|
|
{
|
|
case 1:
|
|
ui_vp_objection->play("holdit");
|
|
sfx_player->play("holdit.wav", m_chatmessage[CHAR_NAME]);
|
|
break;
|
|
case 2:
|
|
ui_vp_objection->play("objection");
|
|
sfx_player->play("objection.wav", m_chatmessage[CHAR_NAME]);
|
|
break;
|
|
case 3:
|
|
ui_vp_objection->play("takethat");
|
|
sfx_player->play("takethat.wav", m_chatmessage[CHAR_NAME]);
|
|
break;
|
|
//case 4 is AO2 only
|
|
case 4:
|
|
ui_vp_objection->play("custom", m_chatmessage[CHAR_NAME]);
|
|
sfx_player->play("custom.wav", m_chatmessage[CHAR_NAME]);
|
|
break;
|
|
default:
|
|
qDebug() << "W: Logic error in objection switch statement!";
|
|
}
|
|
|
|
int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
|
|
|
|
if (emote_mod == 0)
|
|
m_chatmessage[EMOTE_MOD] = 1;
|
|
}
|
|
else
|
|
handle_chatmessage_2();
|
|
}
|
|
|
|
void Courtroom::objection_done()
|
|
{
|
|
handle_chatmessage_2();
|
|
}
|
|
|
|
void Courtroom::handle_chatmessage_2()
|
|
{
|
|
ui_vp_speedlines->stop();
|
|
ui_vp_player_char->stop();
|
|
|
|
QString f_showname = ao_app->get_showname(m_chatmessage[CHAR_NAME]);
|
|
|
|
ui_vp_showname->setText(f_showname);
|
|
|
|
ui_vp_message->clear();
|
|
ui_vp_chatbox->hide();
|
|
|
|
QString chatbox = ao_app->get_chat(m_chatmessage[CHAR_NAME]);
|
|
|
|
if (chatbox == "")
|
|
ui_vp_chatbox->set_image("chatmed.png");
|
|
else
|
|
{
|
|
QString chatbox_path = ao_app->get_base_path() + "misc/" + chatbox + ".png";
|
|
ui_vp_chatbox->set_image_from_path(chatbox_path);
|
|
}
|
|
|
|
set_scene();
|
|
set_text_color();
|
|
|
|
int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
|
|
|
|
switch (emote_mod)
|
|
{
|
|
case 1: case 2: case 3: case 4: case 6:
|
|
play_preanim();
|
|
break;
|
|
default:
|
|
qDebug() << "W: invalid emote mod: " << QString::number(emote_mod);
|
|
//intentional fallthru
|
|
case 0: case 5:
|
|
start_chat_ticking();
|
|
handle_chatmessage_3();
|
|
}
|
|
}
|
|
|
|
void Courtroom::handle_chatmessage_3()
|
|
{
|
|
start_chat_ticking();
|
|
|
|
int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
|
|
|
|
if (emote_mod == 5 ||
|
|
emote_mod == 6)
|
|
{
|
|
QString side = m_chatmessage[SIDE];
|
|
ui_vp_desk->hide();
|
|
ui_vp_legacy_desk->hide();
|
|
|
|
if (side == "pro" ||
|
|
side == "hlp" ||
|
|
side == "wit")
|
|
ui_vp_speedlines->play("prosecution_speedlines", false);
|
|
else
|
|
ui_vp_speedlines->play("defense_speedlines", false);
|
|
|
|
}
|
|
|
|
int f_anim_state = 0;
|
|
//BLUE is from an enum in datatypes.h
|
|
bool text_is_blue = m_chatmessage[TEXT_COLOR].toInt() == BLUE;
|
|
|
|
if (!text_is_blue && text_state == 1)
|
|
//talking
|
|
f_anim_state = 2;
|
|
else
|
|
//idle
|
|
f_anim_state = 3;
|
|
|
|
if (f_anim_state <= anim_state)
|
|
return;
|
|
|
|
ui_vp_player_char->stop();
|
|
QString f_char = m_chatmessage[CHAR_NAME];
|
|
QString f_emote = m_chatmessage[EMOTE];
|
|
|
|
switch (f_anim_state)
|
|
{
|
|
case 2:
|
|
ui_vp_player_char->play_talking(f_char, f_emote);
|
|
anim_state = 2;
|
|
break;
|
|
default:
|
|
qDebug() << "W: invalid anim_state: " << f_anim_state;
|
|
case 3:
|
|
ui_vp_player_char->play_idle(f_char, f_emote);
|
|
anim_state = 3;
|
|
}
|
|
|
|
if (m_chatmessage[REALIZATION] == "1")
|
|
{
|
|
realization_timer->start(60);
|
|
ui_vp_realization->show();
|
|
sfx_player->play("sfx-realization.wav");
|
|
}
|
|
|
|
}
|
|
|
|
void Courtroom::append_ic_text(QString p_text)
|
|
{
|
|
const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
|
|
const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
|
|
const bool is_scrolled_up = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->minimum();
|
|
|
|
ui_ic_chatlog->moveCursor(QTextCursor::Start);
|
|
|
|
ui_ic_chatlog->textCursor().insertText(p_text);
|
|
|
|
if (old_cursor.hasSelection() || !is_scrolled_up)
|
|
{
|
|
// The user has selected text or scrolled away from the top: maintain position.
|
|
ui_ic_chatlog->setTextCursor(old_cursor);
|
|
ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
|
|
}
|
|
else
|
|
{
|
|
// The user hasn't selected any text and the scrollbar is at the top: scroll to the top.
|
|
ui_ic_chatlog->moveCursor(QTextCursor::Start);
|
|
ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->minimum());
|
|
}
|
|
}
|
|
|
|
void Courtroom::play_preanim()
|
|
{
|
|
QString f_char = m_chatmessage[CHAR_NAME];
|
|
QString f_preanim = m_chatmessage[PRE_EMOTE];
|
|
|
|
//all time values in char.inis are multiplied by a constant(time_mod) to get the actual time
|
|
int preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim) * time_mod;
|
|
int text_delay = ao_app->get_text_delay(f_char, f_preanim) * time_mod;
|
|
int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * time_mod;
|
|
|
|
ui_vp_player_char->play_pre(f_char, f_preanim, preanim_duration);
|
|
anim_state = 1;
|
|
if (text_delay >= 0)
|
|
text_delay_timer->start(text_delay);
|
|
sfx_delay_timer->start(sfx_delay);
|
|
}
|
|
|
|
void Courtroom::preanim_done()
|
|
{
|
|
handle_chatmessage_3();
|
|
}
|
|
|
|
void Courtroom::realization_done()
|
|
{
|
|
ui_vp_realization->hide();
|
|
qDebug() << "realization_done called";
|
|
}
|
|
|
|
void Courtroom::start_chat_ticking()
|
|
{
|
|
//we need to ensure that the text isn't already ticking because this function can be called by two logic paths
|
|
if (text_state != 0)
|
|
return;
|
|
|
|
if (chatmessage_is_empty)
|
|
{
|
|
//since the message is empty, it's technically done ticking
|
|
text_state = 2;
|
|
return;
|
|
}
|
|
|
|
ui_vp_chatbox->show();
|
|
|
|
tick_pos = 0;
|
|
chat_tick_timer->start(chat_tick_interval);
|
|
|
|
QString f_gender = ao_app->get_gender(m_chatmessage[CHAR_NAME]);
|
|
|
|
blip_player->set_blips("sfx-blip" + f_gender + ".wav");
|
|
|
|
//means text is currently ticking
|
|
text_state = 1;
|
|
}
|
|
|
|
void Courtroom::chat_tick()
|
|
{
|
|
//note: this is called fairly often(every 60 ms when char is talking)
|
|
//do not perform heavy operations here
|
|
|
|
QString f_message = m_chatmessage[MESSAGE];
|
|
|
|
if (tick_pos >= f_message.size())
|
|
{
|
|
text_state = 2;
|
|
chat_tick_timer->stop();
|
|
if (anim_state == 2)
|
|
{
|
|
ui_vp_player_char->play_idle(m_chatmessage[CHAR_NAME], m_chatmessage[EMOTE]);
|
|
anim_state = 3;
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
ui_vp_message->insertPlainText(f_message.at(tick_pos));
|
|
//ui_vp_message->app
|
|
|
|
QScrollBar *scroll = ui_vp_message->verticalScrollBar();
|
|
scroll->setValue(scroll->maximum());
|
|
scroll->hide();
|
|
|
|
if (f_message.at(tick_pos) != ' ')
|
|
blip_player->blip_tick();
|
|
|
|
++tick_pos;
|
|
}
|
|
}
|
|
|
|
void Courtroom::show_testimony()
|
|
{
|
|
if (!testimony_in_progress || m_chatmessage[SIDE] != "wit")
|
|
return;
|
|
|
|
ui_vp_testimony->show();
|
|
|
|
testimony_show_timer->start(testimony_show_time);
|
|
}
|
|
|
|
void Courtroom::hide_testimony()
|
|
{
|
|
ui_vp_testimony->hide();
|
|
|
|
if (!testimony_in_progress)
|
|
return;
|
|
|
|
testimony_hide_timer->start(testimony_hide_time);
|
|
}
|
|
|
|
void Courtroom::play_sfx()
|
|
{
|
|
QString sfx_name = m_chatmessage[SFX_NAME];
|
|
|
|
if (sfx_name == "1")
|
|
return;
|
|
|
|
sfx_player->play(sfx_name + ".wav");
|
|
|
|
//T0D0: add audio implementation
|
|
//QString sfx_name = m_chatmessage[SFX_NAME];
|
|
}
|
|
|
|
void Courtroom::set_scene()
|
|
{
|
|
if (testimony_in_progress)
|
|
show_testimony();
|
|
|
|
//witness is default if pos is invalid
|
|
QString f_image = "witnessempty.png";
|
|
|
|
QString f_side = m_chatmessage[SIDE];
|
|
|
|
if (f_side == "def")
|
|
f_image = "defenseempty.png";
|
|
else if (f_side == "pro")
|
|
f_image = "prosecutorempty.png";
|
|
else if (f_side == "jud")
|
|
f_image = "judgestand.png";
|
|
else if (f_side == "hld")
|
|
f_image = "helperstand.png";
|
|
else if (f_side == "hlp")
|
|
f_image = "prohelperstand.png";
|
|
|
|
ui_vp_background->set_image(f_image);
|
|
|
|
//no-desk-emotes have been temporarily reverted
|
|
//we're done if one of the non-desk positions is the current one(jud, hlp and hld)
|
|
if (f_side == "jud" ||
|
|
f_side == "hlp" ||
|
|
f_side == "hld")
|
|
{
|
|
ui_vp_desk->hide();
|
|
ui_vp_legacy_desk->hide();
|
|
return;
|
|
}
|
|
|
|
if (is_ao2_bg)
|
|
{
|
|
QString desk_image = "stand.png";
|
|
|
|
if (f_side == "def")
|
|
desk_image = "defensedesk.png";
|
|
else if (f_side == "pro")
|
|
desk_image = "prosecutiondesk.png";
|
|
|
|
ui_vp_desk->set_image(desk_image);
|
|
ui_vp_legacy_desk->hide();
|
|
ui_vp_desk->show();
|
|
}
|
|
else if (f_side == "def" || f_side == "pro")
|
|
{
|
|
QString desk_image;
|
|
|
|
if (f_side == "def")
|
|
desk_image = "bancodefensa.png";
|
|
else
|
|
desk_image = "bancoacusacion.png";
|
|
|
|
ui_vp_legacy_desk->set_legacy_desk(desk_image);
|
|
ui_vp_desk->hide();
|
|
ui_vp_legacy_desk->show();
|
|
}
|
|
//assume wit or invalid side
|
|
else
|
|
{
|
|
ui_vp_desk->set_image("estrado.png");
|
|
ui_vp_legacy_desk->hide();
|
|
ui_vp_desk->show();
|
|
}
|
|
}
|
|
|
|
void Courtroom::set_text_color()
|
|
{
|
|
switch (m_chatmessage[TEXT_COLOR].toInt())
|
|
{
|
|
case GREEN:
|
|
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
|
"color: rgb(0, 255, 0)");
|
|
break;
|
|
case RED:
|
|
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
|
"color: red");
|
|
break;
|
|
case ORANGE:
|
|
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
|
"color: orange");
|
|
break;
|
|
case BLUE:
|
|
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
|
"color: rgb(45, 150, 255)");
|
|
break;
|
|
case YELLOW:
|
|
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
|
"color: yellow");
|
|
break;
|
|
default:
|
|
qDebug() << "W: undefined text color: " << m_chatmessage[TEXT_COLOR];
|
|
case WHITE:
|
|
ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
|
"color: white");
|
|
|
|
}
|
|
}
|
|
|
|
void Courtroom::set_ip_list(QString p_list)
|
|
{
|
|
QString f_list = p_list.replace("|", ":").replace("*", "\n");
|
|
|
|
ui_server_chatlog->appendPlainText(f_list);
|
|
}
|
|
|
|
void Courtroom::set_mute(bool p_muted, int p_cid)
|
|
{
|
|
if (p_cid != m_cid && p_cid != -1)
|
|
return;
|
|
|
|
if (p_muted)
|
|
ui_muted->show();
|
|
else
|
|
{
|
|
ui_muted->hide();
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
|
|
ui_muted->set_image("muted.png");
|
|
|
|
is_muted = p_muted;
|
|
ui_ic_chat_message->setEnabled(!p_muted);
|
|
}
|
|
|
|
void Courtroom::set_ban(int p_cid)
|
|
{
|
|
if (p_cid != m_cid && p_cid != -1)
|
|
return;
|
|
|
|
call_notice("You have been banned.");
|
|
|
|
ao_app->construct_lobby();
|
|
ao_app->destruct_courtroom();
|
|
}
|
|
|
|
void Courtroom::handle_song(QStringList *p_contents)
|
|
{
|
|
QStringList f_contents = *p_contents;
|
|
|
|
if (f_contents.size() < 2)
|
|
return;
|
|
|
|
music_player->play(f_contents.at(0));
|
|
|
|
int n_char = f_contents.at(1).toInt();
|
|
|
|
if (n_char >= 0 && n_char < char_list.size())
|
|
append_ic_text(char_list.at(n_char).name + " has played a song: " + f_contents.at(0) + "\n");
|
|
}
|
|
|
|
void Courtroom::handle_wtce(QString p_wtce)
|
|
{
|
|
//witness testimony
|
|
if (p_wtce == "testimony1")
|
|
{
|
|
sfx_player->play("sfx-testimony2.wav");
|
|
ui_vp_wtce->play("witnesstestimony");
|
|
testimony_in_progress = true;
|
|
show_testimony();
|
|
}
|
|
//cross examination
|
|
else if (p_wtce == "testimony2")
|
|
{
|
|
sfx_player->play("sfx-testimony.wav");
|
|
ui_vp_wtce->play("crossexamination");
|
|
testimony_in_progress = false;
|
|
}
|
|
}
|
|
|
|
void Courtroom::set_hp_bar(int p_bar, int p_state)
|
|
{
|
|
if (p_state < 0 || p_state > 10)
|
|
return;
|
|
|
|
if (p_bar == 1)
|
|
{
|
|
ui_defense_bar->set_image("defensebar" + QString::number(p_state) + ".png");
|
|
defense_bar_state = p_state;
|
|
}
|
|
else if (p_bar == 2)
|
|
{
|
|
ui_prosecution_bar->set_image("prosecutionbar" + QString::number(p_state) + ".png");
|
|
prosecution_bar_state = p_state;
|
|
}
|
|
}
|
|
|
|
void Courtroom::mod_called(QString p_ip)
|
|
{
|
|
ui_server_chatlog->appendPlainText(p_ip);
|
|
if (ui_guard->isChecked())
|
|
modcall_player->play("sfx-gallery.wav");
|
|
}
|
|
|
|
void Courtroom::on_ooc_return_pressed()
|
|
{
|
|
if (ui_ooc_chat_message->text() == "" || ui_ooc_chat_name->text() == "")
|
|
return;
|
|
|
|
//cheap, but it works
|
|
if (ui_ooc_chat_message->text().startsWith("/login"))
|
|
ui_guard->show();
|
|
|
|
QStringList packet_contents;
|
|
packet_contents.append(ui_ooc_chat_name->text());
|
|
packet_contents.append(ui_ooc_chat_message->text());
|
|
|
|
AOPacket *f_packet = new AOPacket("CT", packet_contents);
|
|
|
|
if (server_ooc)
|
|
ao_app->send_server_packet(f_packet);
|
|
else
|
|
ao_app->send_ms_packet(f_packet);
|
|
|
|
ui_ooc_chat_message->clear();
|
|
|
|
ui_ooc_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_ooc_toggle_clicked()
|
|
{
|
|
if (server_ooc)
|
|
{
|
|
ui_ms_chatlog->show();
|
|
ui_server_chatlog->hide();
|
|
ui_ooc_toggle->setText("Master");
|
|
|
|
server_ooc = false;
|
|
}
|
|
else
|
|
{
|
|
ui_ms_chatlog->hide();
|
|
ui_server_chatlog->show();
|
|
ui_ooc_toggle->setText("Server");
|
|
|
|
server_ooc = true;
|
|
}
|
|
}
|
|
|
|
void Courtroom::on_music_search_edited(QString p_text)
|
|
{
|
|
//preventing compiler warnings
|
|
p_text += "a";
|
|
list_music();
|
|
}
|
|
|
|
void Courtroom::on_mute_list_clicked(QModelIndex p_index)
|
|
{
|
|
qDebug() << "mute_list_clicked";
|
|
QListWidgetItem *f_item = ui_mute_list->item(p_index.row());
|
|
qDebug() << "item text: " << f_item->text();
|
|
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]");
|
|
}
|
|
}
|
|
|
|
void Courtroom::on_music_list_double_clicked(QModelIndex p_model)
|
|
{
|
|
if (is_muted)
|
|
return;
|
|
|
|
QString p_song = ui_music_list->item(p_model.row())->text();
|
|
|
|
ao_app->send_server_packet(new AOPacket("MC#" + p_song + "#" + QString::number(m_cid) + "#%"), false);
|
|
}
|
|
|
|
void Courtroom::on_hold_it_clicked()
|
|
{
|
|
if (objection_state == 1)
|
|
{
|
|
ui_hold_it->set_image("holdit.png");
|
|
objection_state = 0;
|
|
}
|
|
else
|
|
{
|
|
ui_objection->set_image("objection.png");
|
|
ui_take_that->set_image("takethat.png");
|
|
ui_custom_objection->set_image("custom.png");
|
|
|
|
ui_hold_it->set_image("holdit_selected.png");
|
|
objection_state = 1;
|
|
}
|
|
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_objection_clicked()
|
|
{
|
|
if (objection_state == 2)
|
|
{
|
|
ui_objection->set_image("objection.png");
|
|
objection_state = 0;
|
|
}
|
|
else
|
|
{
|
|
ui_hold_it->set_image("holdit.png");
|
|
ui_take_that->set_image("takethat.png");
|
|
ui_custom_objection->set_image("custom.png");
|
|
|
|
ui_objection->set_image("objection_selected.png");
|
|
objection_state = 2;
|
|
}
|
|
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_take_that_clicked()
|
|
{
|
|
if (objection_state == 3)
|
|
{
|
|
ui_take_that->set_image("takethat.png");
|
|
objection_state = 0;
|
|
}
|
|
else
|
|
{
|
|
ui_objection->set_image("objection.png");
|
|
ui_hold_it->set_image("holdit.png");
|
|
ui_custom_objection->set_image("custom.png");
|
|
|
|
ui_take_that->set_image("takethat_selected.png");
|
|
objection_state = 3;
|
|
}
|
|
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_custom_objection_clicked()
|
|
{
|
|
if (objection_state == 4)
|
|
{
|
|
ui_custom_objection->set_image("custom.png");
|
|
objection_state = 0;
|
|
}
|
|
else
|
|
{
|
|
ui_objection->set_image("objection.png");
|
|
ui_take_that->set_image("takethat.png");
|
|
ui_hold_it->set_image("holdit.png");
|
|
|
|
ui_custom_objection->set_image("custom_selected.png");
|
|
objection_state = 4;
|
|
}
|
|
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_realization_clicked()
|
|
{
|
|
if (realization_state == 0)
|
|
{
|
|
realization_state = 1;
|
|
ui_realization->set_image("realization_pressed.png");
|
|
}
|
|
else
|
|
{
|
|
realization_state = 0;
|
|
ui_realization->set_image("realization.png");
|
|
}
|
|
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_mute_clicked()
|
|
{
|
|
if (ui_mute_list->isHidden())
|
|
{
|
|
ui_mute_list->show();
|
|
ui_mute->set_image("mute_pressed.png");
|
|
}
|
|
else
|
|
{
|
|
ui_mute_list->hide();
|
|
ui_mute->set_image("mute.png");
|
|
}
|
|
}
|
|
|
|
void Courtroom::on_defense_minus_clicked()
|
|
{
|
|
int f_state = defense_bar_state - 1;
|
|
|
|
if (f_state >= 0)
|
|
ao_app->send_server_packet(new AOPacket("HP#1#" + QString::number(f_state) + "#%"));
|
|
}
|
|
|
|
void Courtroom::on_defense_plus_clicked()
|
|
{
|
|
int f_state = defense_bar_state + 1;
|
|
|
|
if (f_state <= 10)
|
|
ao_app->send_server_packet(new AOPacket("HP#1#" + QString::number(f_state) + "#%"));
|
|
}
|
|
|
|
void Courtroom::on_prosecution_minus_clicked()
|
|
{
|
|
int f_state = prosecution_bar_state - 1;
|
|
|
|
if (f_state >= 0)
|
|
ao_app->send_server_packet(new AOPacket("HP#2#" + QString::number(f_state) + "#%"));
|
|
}
|
|
|
|
void Courtroom::on_prosecution_plus_clicked()
|
|
{
|
|
int f_state = prosecution_bar_state + 1;
|
|
|
|
if (f_state <= 10)
|
|
ao_app->send_server_packet(new AOPacket("HP#2#" + QString::number(f_state) + "#%"));
|
|
}
|
|
|
|
void Courtroom::on_text_color_changed(int p_color)
|
|
{
|
|
text_color = p_color;
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_music_slider_moved(int p_value)
|
|
{
|
|
music_player->set_volume(p_value);
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_sfx_slider_moved(int p_value)
|
|
{
|
|
sfx_player->set_volume(p_value);
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_blip_slider_moved(int p_value)
|
|
{
|
|
blip_player->set_volume(p_value);
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_witness_testimony_clicked()
|
|
{
|
|
if (is_muted)
|
|
return;
|
|
|
|
ao_app->send_server_packet(new AOPacket("RT#testimony1#%"));
|
|
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_cross_examination_clicked()
|
|
{
|
|
if (is_muted)
|
|
return;
|
|
|
|
ao_app->send_server_packet(new AOPacket("RT#testimony2#%"));
|
|
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_change_character_clicked()
|
|
{
|
|
music_player->set_volume(0);
|
|
sfx_player->set_volume(0);
|
|
blip_player->set_volume(0);
|
|
|
|
ui_char_select_background->show();
|
|
}
|
|
|
|
void Courtroom::on_reload_theme_clicked()
|
|
{
|
|
ao_app->set_user_theme();
|
|
|
|
set_widgets();
|
|
//to update status on the background
|
|
set_background(current_background);
|
|
enter_courtroom(m_cid);
|
|
|
|
|
|
}
|
|
|
|
void Courtroom::on_back_to_lobby_clicked()
|
|
{
|
|
ao_app->construct_lobby();
|
|
ao_app->w_lobby->list_servers();
|
|
ao_app->destruct_courtroom();
|
|
}
|
|
|
|
void Courtroom::on_char_select_left_clicked()
|
|
{
|
|
--current_char_page;
|
|
set_char_select_page();
|
|
}
|
|
|
|
void Courtroom::on_char_select_right_clicked()
|
|
{
|
|
++current_char_page;
|
|
set_char_select_page();
|
|
}
|
|
|
|
void Courtroom::on_spectator_clicked()
|
|
{
|
|
ui_emotes->hide();
|
|
|
|
ui_witness_testimony->hide();
|
|
ui_cross_examination->hide();
|
|
|
|
ui_ic_chat_message->setEnabled(false);
|
|
|
|
ui_char_select_background->hide();
|
|
}
|
|
|
|
void Courtroom::on_call_mod_clicked()
|
|
{
|
|
ao_app->send_server_packet(new AOPacket("ZZ#%"));
|
|
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_pre_clicked()
|
|
{
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_flip_clicked()
|
|
{
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_guard_clicked()
|
|
{
|
|
ui_ic_chat_message->setFocus();
|
|
}
|
|
|
|
void Courtroom::on_evidence_button_clicked()
|
|
{
|
|
if (ui_evidence->isHidden())
|
|
{
|
|
ui_evidence->show();
|
|
}
|
|
else
|
|
{
|
|
ui_evidence->hide();
|
|
}
|
|
}
|
|
|
|
void Courtroom::char_clicked(int n_char)
|
|
{
|
|
int n_real_char = n_char + current_char_page * 90;
|
|
|
|
QString char_ini_path = ao_app->get_character_path(char_list.at(n_real_char).name) + "char.ini";
|
|
|
|
if (!file_exists(char_ini_path))
|
|
{
|
|
qDebug() << "did not find " << char_ini_path;
|
|
call_notice("Could not find " + char_ini_path);
|
|
return;
|
|
}
|
|
|
|
if (n_real_char == m_cid)
|
|
enter_courtroom(m_cid);
|
|
else
|
|
ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_real_char) + "#" + get_hdid() + "#%"));
|
|
}
|
|
|
|
void Courtroom::ping_server()
|
|
{
|
|
ao_app->send_server_packet(new AOPacket("CH#" + QString::number(m_cid) + "#%"));
|
|
}
|
|
|
|
Courtroom::~Courtroom()
|
|
{
|
|
delete music_player;
|
|
delete sfx_player;
|
|
}
|