aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aoapplication.h2
-rw-r--r--courtroom.cpp130
-rw-r--r--courtroom.h13
-rw-r--r--packet_distribution.cpp5
-rw-r--r--path_functions.cpp4
5 files changed, 119 insertions, 35 deletions
diff --git a/aoapplication.h b/aoapplication.h
index 87dcc149..cb9c102c 100644
--- a/aoapplication.h
+++ b/aoapplication.h
@@ -83,7 +83,7 @@ public:
QString get_character_path(QString p_character);
QString get_demothings_path();
QString get_sounds_path();
- QString get_music_path();
+ QString get_music_path(QString p_song);
QString get_background_path();
QString get_default_background_path();
diff --git a/courtroom.cpp b/courtroom.cpp
index 88571afe..def07417 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -69,8 +69,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ooc_chat_name->setFrame(false);
ui_ooc_chat_name->setPlaceholderText("Name");
- ui_area_password = new QLineEdit(this);
- ui_area_password->setFrame(false);
+ //ui_area_password = new QLineEdit(this);
+ //ui_area_password->setFrame(false);
ui_music_search = new QLineEdit(this);
ui_music_search->setFrame(false);
@@ -84,6 +84,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_emote_left = new AOButton(ui_emotes, ao_app);
ui_emote_right = new AOButton(ui_emotes, ao_app);
+ ///////////////////////////////////////
+
ui_defense_bar = new AOImage(this, ao_app);
ui_prosecution_bar = new AOImage(this, ao_app);
@@ -198,13 +200,19 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
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_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_emote_left, SIGNAL(clicked()), this, SLOT(on_emote_left_clicked()));
connect(ui_emote_right, SIGNAL(clicked()), this, SLOT(on_emote_right_clicked()));
@@ -329,7 +337,7 @@ void Courtroom::set_widgets()
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_area_password, "area_password");
set_size_and_pos(ui_music_search, "music_search");
set_size_and_pos(ui_emotes, "emotes");
@@ -612,6 +620,8 @@ 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);
@@ -623,9 +633,11 @@ void Courtroom::list_music()
QString song_path = ao_app->get_base_path() + "sounds/music/" + i_song.toLower();
if (file_exists(song_path))
- ui_music_list->item(n_song)->setBackground(Qt::green);
+ ui_music_list->item(n_listed_songs)->setBackground(Qt::green);
else
- ui_music_list->item(n_song)->setBackground(Qt::red);
+ ui_music_list->item(n_listed_songs)->setBackground(Qt::red);
+
+ ++n_listed_songs;
}
}
}
@@ -766,48 +778,36 @@ void Courtroom::on_chat_return_pressed()
void Courtroom::handle_chatmessage(QStringList *p_contents)
{
- text_state = 0;
- anim_state = 0;
-
for (int n_string = 0 ; n_string < chatmessage_size ; ++n_string)
{
m_chatmessage[n_string] = p_contents->at(n_string);
}
+ QString f_message = m_chatmessage[CHAR_NAME] + ": " + 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");
}
- chatmessage_is_empty = m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == "";
-
- QString f_message = m_chatmessage[CHAR_NAME] + ": " + m_chatmessage[MESSAGE] + '\n';
-
- 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(f_message);
+ append_ic_text(f_message);
- 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());
- }
+ previous_ic_message = f_message;
int objection_mod = m_chatmessage[OBJECTION_MOD].toInt();
@@ -959,6 +959,30 @@ void Courtroom::handle_chatmessage_3()
}
+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];
@@ -1144,6 +1168,21 @@ void Courtroom::set_text_color()
}
}
+void Courtroom::handle_song(QStringList *p_contents)
+{
+ QStringList f_contents = *p_contents;
+
+ if (f_contents.size() < 2)
+ return;
+
+ //T0D0: add audio implementation
+
+ 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
@@ -1213,6 +1252,21 @@ void Courtroom::on_ooc_toggle_clicked()
}
}
+void Courtroom::on_music_search_edited(QString p_text)
+{
+ //preventing compiler warnings
+ p_text += "a";
+ qDebug() << "music search edited";
+ list_music();
+}
+
+void Courtroom::on_music_list_double_clicked(QModelIndex p_model)
+{
+ 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) + "#%"));
+}
+
void Courtroom::on_hold_it_clicked()
{
if (objection_state == 1)
@@ -1293,6 +1347,20 @@ void Courtroom::on_custom_objection_clicked()
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");
+ }
+}
+
void Courtroom::on_witness_testimony_clicked()
{
ao_app->send_server_packet(new AOPacket("RT#testimony1#%"));
diff --git a/courtroom.h b/courtroom.h
index b1d32d70..4c4ba12b 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -65,6 +65,10 @@ public:
void handle_chatmessage_2();
void handle_chatmessage_3();
+ void append_ic_text(QString p_text);
+
+ void handle_song(QStringList *p_contents);
+
void play_preanim();
void handle_wtce(QString p_wtce);
@@ -111,6 +115,8 @@ private:
QString m_chatmessage[chatmessage_size];
bool chatmessage_is_empty = false;
+ QString previous_ic_message = "";
+
//state of animation, 0 = objecting, 1 = preanim, 2 = talking, 3 = idle
int anim_state = 0;
@@ -172,7 +178,7 @@ private:
QLineEdit *ui_ooc_chat_message;
QLineEdit *ui_ooc_chat_name;
- QLineEdit *ui_area_password;
+ //QLineEdit *ui_area_password;
QLineEdit *ui_music_search;
QWidget *ui_emotes;
@@ -255,6 +261,9 @@ private slots:
void on_ooc_return_pressed();
+ void on_music_search_edited(QString p_text);
+ void on_music_list_double_clicked(QModelIndex p_model);
+
void on_emote_clicked(int p_id);
void on_emote_left_clicked();
@@ -265,6 +274,8 @@ private slots:
void on_take_that_clicked();
void on_custom_objection_clicked();
+ void on_realization_clicked();
+
void on_ooc_toggle_clicked();
void on_witness_testimony_clicked();
diff --git a/packet_distribution.cpp b/packet_distribution.cpp
index 0b7853e0..d8517f3a 100644
--- a/packet_distribution.cpp
+++ b/packet_distribution.cpp
@@ -305,6 +305,11 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (courtroom_constructed)
w_courtroom->handle_chatmessage(&p_packet->get_contents());
}
+ else if (header == "MC")
+ {
+ if (courtroom_constructed)
+ w_courtroom->handle_song(&p_packet->get_contents());
+ }
else if (header == "RT")
{
if (f_contents.size() < 1)
diff --git a/path_functions.cpp b/path_functions.cpp
index 7e81e646..0630e0f0 100644
--- a/path_functions.cpp
+++ b/path_functions.cpp
@@ -37,9 +37,9 @@ QString AOApplication::get_sounds_path()
{
return get_base_path() + "sounds/general/";
}
-QString AOApplication::get_music_path()
+QString AOApplication::get_music_path(QString p_song)
{
- return get_base_path() + "sounds/music/";
+ return get_base_path() + "sounds/music/" + p_song.toLower();
}
QString AOApplication::get_background_path()