added some functionality to handle_chatmessage function

This commit is contained in:
David Skoland 2017-01-27 17:45:02 +01:00
parent 9682087667
commit d197d1f501
3 changed files with 33 additions and 7 deletions

View File

@ -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() == "")

View File

@ -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:

View File

@ -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)