added mod functions and optimized emotes

This commit is contained in:
David Skoland 2017-02-09 02:01:25 +01:00
parent 1243662c9c
commit 49579cdb9c
7 changed files with 169 additions and 14 deletions

View File

@ -2,6 +2,8 @@
#include "aoimage.h" #include "aoimage.h"
#include <QDebug>
AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent) AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)
{ {
m_parent = parent; m_parent = parent;

View File

@ -25,6 +25,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
sfx_delay_timer = new QTimer(this); sfx_delay_timer = new QTimer(this);
sfx_delay_timer->setSingleShot(true); sfx_delay_timer->setSingleShot(true);
realization_timer = new QTimer(this);
realization_timer->setSingleShot(true);
char_button_mapper = new QSignalMapper(this); char_button_mapper = new QSignalMapper(this);
sfx_player = new QSoundEffect(this); sfx_player = new QSoundEffect(this);
@ -41,7 +44,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_showname = new QLabel(ui_vp_chatbox); ui_vp_showname = new QLabel(ui_vp_chatbox);
ui_vp_message = new QPlainTextEdit(ui_vp_chatbox); ui_vp_message = new QPlainTextEdit(ui_vp_chatbox);
ui_vp_testimony = new AOImage(ui_viewport, ao_app); ui_vp_testimony = new AOImage(ui_viewport, ao_app);
ui_vp_realization = 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_wtce = new AOMovie(ui_viewport, ao_app);
ui_vp_objection = new AOMovie(ui_viewport, ao_app); ui_vp_objection = new AOMovie(ui_viewport, ao_app);
@ -56,12 +59,15 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_server_chatlog->setReadOnly(true); ui_server_chatlog->setReadOnly(true);
ui_mute_list = new QListWidget(this); ui_mute_list = new QListWidget(this);
ui_area_list = new QListWidget(this); //ui_area_list = new QListWidget(this);
ui_music_list = new QListWidget(this); ui_music_list = new QListWidget(this);
ui_ic_chat_message = new QLineEdit(this); ui_ic_chat_message = new QLineEdit(this);
ui_ic_chat_message->setFrame(false); 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 = new QLineEdit(this);
ui_ooc_chat_message->setFrame(false); ui_ooc_chat_message->setFrame(false);
@ -140,8 +146,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_blip_slider->setRange(0, 100); ui_blip_slider->setRange(0, 100);
ui_blip_slider->setValue(50); ui_blip_slider->setValue(50);
ui_muted = new AOImage(this, ao_app);
/////////////char select widgets under here/////////////// /////////////char select widgets under here///////////////
ui_char_select_background = new AOImage(this, ao_app); ui_char_select_background = new AOImage(this, ao_app);
@ -201,6 +205,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(chat_tick_timer, SIGNAL(timeout()), this, SLOT(chat_tick())); connect(chat_tick_timer, SIGNAL(timeout()), this, SLOT(chat_tick()));
connect(realization_timer, SIGNAL(timeout()), this, SLOT(realization_done()));
//emote signals are set in emotes.cpp //emote signals are set in emotes.cpp
connect(ui_ic_chat_message, SIGNAL(returnPressed()), this, SLOT(on_chat_return_pressed())); connect(ui_ic_chat_message, SIGNAL(returnPressed()), this, SLOT(on_chat_return_pressed()));
@ -315,7 +321,9 @@ void Courtroom::set_widgets()
ui_vp_testimony->resize(ui_viewport->width(), ui_viewport->height()); ui_vp_testimony->resize(ui_viewport->width(), ui_viewport->height());
ui_vp_realization->move(0, 0); ui_vp_realization->move(0, 0);
ui_vp_realization->resize(ui_viewport->x(), ui_viewport->y()); 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->move(0, 0);
ui_vp_wtce->combo_resize(ui_viewport->width(), ui_viewport->height()); ui_vp_wtce->combo_resize(ui_viewport->width(), ui_viewport->height());
@ -336,14 +344,17 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_mute_list, "mute_list"); set_size_and_pos(ui_mute_list, "mute_list");
ui_mute_list->hide(); ui_mute_list->hide();
set_size_and_pos(ui_area_list, "area_list"); //set_size_and_pos(ui_area_list, "area_list");
ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); //ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
set_size_and_pos(ui_music_list, "music_list"); set_size_and_pos(ui_music_list, "music_list");
ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); ui_music_list->setStyleSheet("QListWidget{background-color: rgba(0, 0, 0, 0);}");
ui_music_list->setFont(f);
set_size_and_pos(ui_ic_chat_message, "ic_chat_message"); set_size_and_pos(ui_ic_chat_message, "ic_chat_message");
ui_ic_chat_message->setStyleSheet("background-color: rgba(89, 89, 89, 255);"); ui_ic_chat_message->setStyleSheet("background-color: rgba(89, 89, 89, 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"); set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message");
ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
@ -439,9 +450,6 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_sfx_slider, "sfx_slider"); set_size_and_pos(ui_sfx_slider, "sfx_slider");
set_size_and_pos(ui_blip_slider, "blip_slider"); set_size_and_pos(ui_blip_slider, "blip_slider");
//T0D0: scale this according to ui_ic_chat_message
//set_size_and_pos(ui_muted, "muted");
//char select stuff under here //char select stuff under here
ui_char_select_background->set_image("charselect_background.png"); ui_char_select_background->set_image("charselect_background.png");
@ -706,7 +714,7 @@ void Courtroom::append_server_chatmessage(QString f_message)
void Courtroom::on_chat_return_pressed() void Courtroom::on_chat_return_pressed()
{ {
if (ui_ic_chat_message->text() == "") if (ui_ic_chat_message->text() == "" || is_muted)
return; return;
//MS#chat# //MS#chat#
@ -817,6 +825,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
ui_objection->set_image("objection.png"); ui_objection->set_image("objection.png");
ui_take_that->set_image("takethat.png"); ui_take_that->set_image("takethat.png");
ui_custom_objection->set_image("custom.png"); ui_custom_objection->set_image("custom.png");
ui_realization->set_image("realization.png");
} }
append_ic_text(f_message); append_ic_text(f_message);
@ -880,6 +889,8 @@ void Courtroom::handle_chatmessage_2()
QString remote_name = m_chatmessage[CHAR_NAME]; QString remote_name = m_chatmessage[CHAR_NAME];
QString local_showname = ao_app->get_showname(remote_name); QString local_showname = ao_app->get_showname(remote_name);
qDebug() << "local_showname: " << local_showname;
//empty string means we couldnt find showname in char ini //empty string means we couldnt find showname in char ini
if (local_showname == "") if (local_showname == "")
ui_vp_showname->setText(remote_name); ui_vp_showname->setText(remote_name);
@ -971,6 +982,13 @@ void Courtroom::handle_chatmessage_3()
anim_state = 3; anim_state = 3;
} }
if (m_chatmessage[REALIZATION] == "1")
{
realization_timer->start(60);
ui_vp_realization->show();
//T0D0: add realization sfx
}
} }
void Courtroom::append_ic_text(QString p_text) void Courtroom::append_ic_text(QString p_text)
@ -1019,6 +1037,12 @@ void Courtroom::preanim_done()
handle_chatmessage_3(); handle_chatmessage_3();
} }
void Courtroom::realization_done()
{
ui_vp_realization->hide();
qDebug() << "realization_done called";
}
void Courtroom::start_chat_ticking() 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 //we need to ensure that the text isn't already ticking because this function can be called by two logic paths
@ -1182,6 +1206,44 @@ void Courtroom::set_text_color()
} }
} }
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) void Courtroom::handle_song(QStringList *p_contents)
{ {
QStringList f_contents = *p_contents; QStringList f_contents = *p_contents;
@ -1247,6 +1309,10 @@ void Courtroom::on_ooc_return_pressed()
if (ui_ooc_chat_message->text() == "" || ui_ooc_chat_name->text() == "") if (ui_ooc_chat_message->text() == "" || ui_ooc_chat_name->text() == "")
return; return;
//cheap, but it works
if (ui_ooc_chat_message->text().startsWith("/login"))
ui_guard->show();
QStringList packet_contents; QStringList packet_contents;
packet_contents.append(ui_ooc_chat_name->text()); packet_contents.append(ui_ooc_chat_name->text());
packet_contents.append(ui_ooc_chat_message->text()); packet_contents.append(ui_ooc_chat_message->text());
@ -1293,6 +1359,9 @@ void Courtroom::on_music_search_edited(QString p_text)
void Courtroom::on_music_list_double_clicked(QModelIndex p_model) 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(); 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) + "#%")); ao_app->send_server_packet(new AOPacket("MC#" + p_song + "#" + QString::number(m_cid) + "#%"));
@ -1390,6 +1459,8 @@ void Courtroom::on_realization_clicked()
realization_state = 0; realization_state = 0;
ui_realization->set_image("realization.png"); ui_realization->set_image("realization.png");
} }
ui_ic_chat_message->setFocus();
} }
void Courtroom::on_defense_minus_clicked() void Courtroom::on_defense_minus_clicked()
@ -1427,10 +1498,14 @@ void Courtroom::on_prosecution_plus_clicked()
void Courtroom::on_text_color_changed(int p_color) void Courtroom::on_text_color_changed(int p_color)
{ {
text_color = p_color; text_color = p_color;
ui_ic_chat_message->setFocus();
} }
void Courtroom::on_witness_testimony_clicked() void Courtroom::on_witness_testimony_clicked()
{ {
if (is_muted)
return;
ao_app->send_server_packet(new AOPacket("RT#testimony1#%")); ao_app->send_server_packet(new AOPacket("RT#testimony1#%"));
ui_ic_chat_message->setFocus(); ui_ic_chat_message->setFocus();
@ -1438,6 +1513,9 @@ void Courtroom::on_witness_testimony_clicked()
void Courtroom::on_cross_examination_clicked() void Courtroom::on_cross_examination_clicked()
{ {
if (is_muted)
return;
ao_app->send_server_packet(new AOPacket("RT#testimony2#%")); ao_app->send_server_packet(new AOPacket("RT#testimony2#%"));
ui_ic_chat_message->setFocus(); ui_ic_chat_message->setFocus();

View File

@ -48,6 +48,11 @@ public:
//sets text color based on text color in chatmessage //sets text color based on text color in chatmessage
void set_text_color(); void set_text_color();
void set_ip_list(QString p_list);
void set_mute(bool p_muted, int p_cid);
void set_ban(int p_cid);
//implementations in path_functions.cpp //implementations in path_functions.cpp
QString get_background_path(); QString get_background_path();
QString get_default_background_path(); QString get_default_background_path();
@ -109,6 +114,8 @@ private:
//delay before sfx plays //delay before sfx plays
QTimer *sfx_delay_timer; QTimer *sfx_delay_timer;
QTimer *realization_timer;
//every time point in char.inis times this equals the final time //every time point in char.inis times this equals the final time
const int time_mod = 35; const int time_mod = 35;
@ -118,6 +125,8 @@ private:
QString previous_ic_message = ""; QString previous_ic_message = "";
bool is_muted = false;
//state of animation, 0 = objecting, 1 = preanim, 2 = talking, 3 = idle //state of animation, 0 = objecting, 1 = preanim, 2 = talking, 3 = idle
int anim_state = 0; int anim_state = 0;
@ -255,6 +264,8 @@ public slots:
void objection_done(); void objection_done();
void preanim_done(); void preanim_done();
void realization_done();
private slots: private slots:
void start_chat_ticking(); void start_chat_ticking();
void play_sfx(); void play_sfx();

View File

@ -10,6 +10,18 @@ void call_error(QString p_message)
msgBox->setWindowTitle("Error"); msgBox->setWindowTitle("Error");
//msgBox->setWindowModality(Qt::NonModal);
msgBox->show();
}
void call_notice(QString p_message)
{
QMessageBox *msgBox = new QMessageBox;
msgBox->setText(p_message);
msgBox->setWindowTitle("Notice");
//msgBox->setWindowModality(Qt::NonModal); //msgBox->setWindowModality(Qt::NonModal);
msgBox->show(); msgBox->show();
} }

View File

@ -4,5 +4,6 @@
#include <QString> #include <QString>
void call_error(QString message); void call_error(QString message);
void call_notice(QString message);
#endif // DEBUG_FUNCTIONS_H #endif // DEBUG_FUNCTIONS_H

View File

@ -91,8 +91,17 @@ void Courtroom::set_emote_page()
void Courtroom::on_emote_clicked(int p_id) void Courtroom::on_emote_clicked(int p_id)
{ {
int min = current_emote_page * max_emotes_on_page;
int max = 9 + current_emote_page * max_emotes_on_page;
if (current_emote >= min && current_emote <= max)
ui_emote_list.at(current_emote % max_emotes_on_page)->set_off(current_char, current_emote);
current_emote = p_id + 10 * current_emote_page; current_emote = p_id + 10 * current_emote_page;
ui_emote_list.at(current_emote % max_emotes_on_page)->set_on(current_char, current_emote);
/*
for (int n_emote = 0 ; n_emote < 10 ; ++n_emote) for (int n_emote = 0 ; n_emote < 10 ; ++n_emote)
{ {
int n_real_emote = n_emote + current_emote_page * 10; int n_real_emote = n_emote + current_emote_page * 10;
@ -100,9 +109,10 @@ void Courtroom::on_emote_clicked(int p_id)
if (n_real_emote == current_emote) if (n_real_emote == current_emote)
f_emote->set_on(current_char, n_real_emote); f_emote->set_on(current_char, n_real_emote);
else //else
f_emote->set_off(current_char, n_real_emote); // f_emote->set_off(current_char, n_real_emote);
} }
*/
int emote_mod = ao_app->get_emote_mod(current_char, current_emote); int emote_mod = ao_app->get_emote_mod(current_char, current_emote);

View File

@ -5,6 +5,7 @@
#include "networkmanager.h" #include "networkmanager.h"
#include "encryption_functions.h" #include "encryption_functions.h"
#include "hardware_functions.h" #include "hardware_functions.h"
#include "debug_functions.h"
#include <QDebug> #include <QDebug>
@ -326,6 +327,46 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (courtroom_constructed && f_contents.size() > 1) if (courtroom_constructed && f_contents.size() > 1)
w_courtroom->set_hp_bar(f_contents.at(0).toInt(), f_contents.at(1).toInt()); w_courtroom->set_hp_bar(f_contents.at(0).toInt(), f_contents.at(1).toInt());
} }
else if (header == "IL")
{
if (courtroom_constructed && f_contents.size() > 0)
w_courtroom->set_ip_list(f_contents.at(0));
}
else if (header == "MU")
{
if (courtroom_constructed && f_contents.size() > 0)
w_courtroom->set_mute(true, f_contents.at(0).toInt());
}
else if (header == "UM")
{
if (courtroom_constructed && f_contents.size() > 0)
w_courtroom->set_mute(false, f_contents.at(0).toInt());
}
else if (header == "KK")
{
if (courtroom_constructed && f_contents.size() > 0)
{
int f_cid = w_courtroom->get_cid();
int remote_cid = f_contents.at(0).toInt();
if (f_cid != remote_cid && remote_cid != -1)
return;
call_notice("You have been kicked.");
construct_lobby();
destruct_courtroom();
}
}
else if (header == "KB")
{
if (courtroom_constructed && f_contents.size() > 0)
w_courtroom->set_ban(f_contents.at(0).toInt());
}
else if (header == "BD")
{
call_notice("You are banned on this server.");
}
else if (header == "checkconnection") else if (header == "checkconnection")
{ {
send_server_packet(new AOPacket("CH#" + QString::number(w_courtroom->get_cid()) + "#%")); send_server_packet(new AOPacket("CH#" + QString::number(w_courtroom->get_cid()) + "#%"));