aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmniTroid <davidskoland@gmail.com>2017-03-28 02:54:07 +0200
committerOmniTroid <davidskoland@gmail.com>2017-03-28 02:54:07 +0200
commit3495dfae3aee770c1026ff9e7095dee83c745a5b (patch)
tree3d7d2190def0e60008f4f5af2a3649a5ba7817c1
parent2f4e6881e09359a4aa7498f828f82fe395124bc6 (diff)
started adding the desk/nodesk feature
-rw-r--r--aoapplication.h1
-rw-r--r--aotextarea.cpp8
-rw-r--r--courtroom.cpp20
-rw-r--r--datatypes.h2
-rw-r--r--packet_distribution.cpp3
-rw-r--r--text_file_functions.cpp9
6 files changed, 26 insertions, 17 deletions
diff --git a/aoapplication.h b/aoapplication.h
index 0dc15e92..6d9fe03a 100644
--- a/aoapplication.h
+++ b/aoapplication.h
@@ -49,6 +49,7 @@ public:
bool flipping_enabled = false;
bool custom_objection_enabled = false;
bool improved_loading_enabled = false;
+ bool desk_mod_enabled = false;
///////////////loading info///////////////////
diff --git a/aotextarea.cpp b/aotextarea.cpp
index 18551c1b..a61a2486 100644
--- a/aotextarea.cpp
+++ b/aotextarea.cpp
@@ -17,24 +17,20 @@ void AOTextArea::append_chatmessage(QString p_name, QString p_message)
this->moveCursor(QTextCursor::End);
- this->insertPlainText(p_name + ": ");
+ this->append(p_name + ": ");
- QRegExp split_rx("(\\ |\\n)");
- QStringList word_list = p_message.split(split_rx);
+ QStringList word_list = p_message.split(" ");
for (QString i_word : word_list)
{
if (i_word.startsWith("http"))
{
- i_word.replace("\r", "");
this->insertHtml("<a href=\"" + i_word + "\">" + i_word + "</a> ");
}
else
this->insertPlainText(i_word + " ");
}
- this->insertPlainText("\n");
-
if (old_cursor.hasSelection() || !is_scrolled_down)
{
// The user has selected text or scrolled away from the bottom: maintain position.
diff --git a/courtroom.cpp b/courtroom.cpp
index fef7d51e..3abe83ce 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -793,7 +793,14 @@ void Courtroom::on_chat_return_pressed()
QStringList packet_contents;
- packet_contents.append("chat");
+ QString f_side = ao_app->get_char_side(current_char);
+
+ QString f_desk_mod = QString::number(ao_app->get_desk_mod(current_char, current_emote));
+ qDebug() << "f_desk_mod: " << f_desk_mod;
+ if (f_desk_mod == "-1")
+ f_desk_mod = "chat";
+
+ packet_contents.append(f_desk_mod);
packet_contents.append(ao_app->get_pre_emote(current_char, current_emote));
@@ -803,7 +810,7 @@ void Courtroom::on_chat_return_pressed()
packet_contents.append(ui_ic_chat_message->text());
- packet_contents.append(ao_app->get_char_side(current_char));
+ packet_contents.append(f_side);
packet_contents.append(ao_app->get_sfx_name(current_char, current_emote));
@@ -1295,6 +1302,7 @@ void Courtroom::set_scene()
QString f_image = "witnessempty.png";
QString f_side = m_chatmessage[SIDE];
+ QString f_desk_mod = m_chatmessage[DESK_MOD];
if (f_side == "def")
f_image = "defenseempty.png";
@@ -1309,11 +1317,9 @@ void Courtroom::set_scene()
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")
+ //we're done if deskmod is 0 or the deskmod is chat and it's a nondesk side
+ if (f_desk_mod == "0" ||
+ (f_desk_mod == "chat" && (f_side == "hlp" || f_side == "hld" || f_side == "jud")))
{
ui_vp_desk->hide();
ui_vp_legacy_desk->hide();
diff --git a/datatypes.h b/datatypes.h
index 5cb60824..37d3e99a 100644
--- a/datatypes.h
+++ b/datatypes.h
@@ -78,7 +78,7 @@ struct pos_size_type
enum CHAT_MESSAGE
{
- CHAT = 0,
+ DESK_MOD = 0,
PRE_EMOTE,
CHAR_NAME,
EMOTE,
diff --git a/packet_distribution.cpp b/packet_distribution.cpp
index 6cd89b2e..857e730b 100644
--- a/packet_distribution.cpp
+++ b/packet_distribution.cpp
@@ -136,6 +136,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
flipping_enabled = false;
custom_objection_enabled = false;
improved_loading_enabled = false;
+ desk_mod_enabled = false;
AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%");
send_server_packet(hi_packet);
@@ -176,6 +177,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
improved_loading_enabled = true;
if (f_packet.contains("noencryption",Qt::CaseInsensitive))
encryption_needed = false;
+ if (f_packet.contains("deskmod",Qt::CaseInsensitive))
+ desk_mod_enabled = true;
}
else if (header == "PN")
{
diff --git a/text_file_functions.cpp b/text_file_functions.cpp
index 5d809c30..8f6fa617 100644
--- a/text_file_functions.cpp
+++ b/text_file_functions.cpp
@@ -459,10 +459,13 @@ int AOApplication::get_desk_mod(QString p_char, int p_emote)
QStringList result_contents = f_result.split("#");
if (result_contents.size() < 5)
- {
return -1;
- }
- else return result_contents.at(4).toInt();
+
+ QString string_result = result_contents.at(4);
+ if (string_result == "")
+ return -1;
+
+ else return string_result.toInt();
}
QString AOApplication::get_sfx_name(QString p_char, int p_emote)