aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2017-01-27 17:45:02 +0100
committerDavid Skoland <davidskoland@gmail.com>2017-01-27 17:45:02 +0100
commitd197d1f50112ee658d3112d1c980b8e4228b5357 (patch)
tree295bfc818e864a21aa55f5f9fb74e94d10c1e1ec
parent9682087667e2de26e14406efde960b8c7f0c3c98 (diff)
added some functionality to handle_chatmessage function
-rw-r--r--courtroom.cpp22
-rw-r--r--courtroom.h2
-rw-r--r--packet_distribution.cpp16
3 files changed, 33 insertions, 7 deletions
diff --git a/courtroom.cpp b/courtroom.cpp
index f408b148..0233fe7c 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -177,7 +177,8 @@ void Courtroom::set_widgets()
//viewport elements like background, desk, etc. go here
set_size_and_pos(ui_ic_chatlog, "ic_chatlog");
- ui_ic_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
+ 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);");
@@ -396,9 +397,14 @@ void Courtroom::set_char_select_page()
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);
- ui_char_button_list.at(n_button)->set_image(char_list.at(n_real_char).name);
- ui_char_button_list.at(n_button)->show();
+ 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();
}
}
@@ -444,6 +450,16 @@ void Courtroom::append_server_chatmessage(QString f_message)
ui_server_chatlog->appendPlainText(f_message);
}
+void Courtroom::handle_chatmessage(QStringList *p_contents)
+{
+ QString f_message = p_contents->at(2) + ": " + p_contents->at(4) + '\n';
+
+ ui_ic_chatlog->moveCursor(QTextCursor::Start);
+ ui_ic_chatlog->insertPlainText(f_message);
+
+ //T0D0: play objection gif->preanimation if there is any
+}
+
void Courtroom::on_ooc_return_pressed()
{
if (ui_ooc_chat_message->text() == "" || ui_ooc_chat_name->text() == "")
diff --git a/courtroom.h b/courtroom.h
index 9f25387e..7660ad8c 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -40,6 +40,8 @@ public:
void append_ms_chatmessage(QString f_message);
void append_server_chatmessage(QString f_message);
+ void handle_chatmessage(QStringList *p_contents);
+
~Courtroom();
private:
diff --git a/packet_distribution.cpp b/packet_distribution.cpp
index 163c744d..1b25cef8 100644
--- a/packet_distribution.cpp
+++ b/packet_distribution.cpp
@@ -115,7 +115,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
QString message_line = f_contents.at(0) + ": " + f_contents.at(1);
- w_courtroom->append_server_chatmessage(message_line);
+ if (courtroom_constructed)
+ w_courtroom->append_server_chatmessage(message_line);
}
else if (header == "PN")
{
@@ -262,7 +263,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
send_server_packet(new AOPacket("AM#" + next_packet_number + "#%"));
//}
}
- if (header == "CharsCheck")
+ else if (header == "CharsCheck")
{
for (int n_char = 0 ; n_char < f_contents.size() ; ++n_char)
{
@@ -272,7 +273,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
w_courtroom->set_taken(n_char, false);
}
}
- if (header == "DONE")
+ else if (header == "DONE")
{
if (!courtroom_constructed)
return;
@@ -286,13 +287,20 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
destruct_lobby();
}
//server accepting char request(CC) packet
- if (header == "PV")
+ else if (header == "PV")
{
if (f_contents.size() < 3)
return;
w_courtroom->enter_courtroom(f_contents.at(2).toInt());
}
+ else if (header == "MS")
+ {
+ if (courtroom_constructed)
+ w_courtroom->handle_chatmessage(&p_packet->get_contents());
+ }
+
+ delete p_packet;
}
void AOApplication::send_ms_packet(AOPacket *p_packet)