aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/courtroom.cpp93
1 files changed, 81 insertions, 12 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index be7629b8..da05fe90 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -2024,6 +2024,7 @@ void Courtroom::chat_tick()
//do not perform heavy operations here
QString f_message = m_chatmessage[MESSAGE];
+ f_message.remove(0, tick_pos);
// Due to our new text speed system, we always need to stop the timer now.
chat_tick_timer->stop();
@@ -2038,7 +2039,7 @@ void Courtroom::chat_tick()
f_message.remove(0,2);
}
- if (tick_pos >= f_message.size())
+ if (f_message.size() == 0)
{
text_state = 2;
if (anim_state != 4)
@@ -2050,7 +2051,16 @@ void Courtroom::chat_tick()
else
{
- QString f_character = f_message.at(tick_pos);
+ QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_message);
+ QString f_character;
+
+ tbf.toNextBoundary();
+
+ if (tbf.position() == -1)
+ f_character = f_message;
+ else
+ f_character = f_message.left(tbf.position());
+
f_character = f_character.toHtmlEscaped();
if (f_character == " ")
@@ -2265,7 +2275,7 @@ void Courtroom::chat_tick()
if(blank_blip)
qDebug() << "blank_blip found true";
- if (f_message.at(tick_pos) != ' ' || blank_blip)
+ if (f_character != ' ' || blank_blip)
{
if (blip_pos % blip_rate == 0 && !formatting_char)
@@ -2277,7 +2287,7 @@ void Courtroom::chat_tick()
++blip_pos;
}
- ++tick_pos;
+ tick_pos += f_character.length();
// Restart the timer, but according to the newly set speeds, if there were any.
// Keep the speed at bay.
@@ -2304,6 +2314,7 @@ void Courtroom::chat_tick()
}
}
+
void Courtroom::show_testimony()
{
if (!testimony_in_progress || m_chatmessage[SIDE] != "wit")
@@ -2696,6 +2707,7 @@ void Courtroom::on_ooc_return_pressed()
}
else
{
+ other_charid = -1;
append_server_chatmessage("CLIENT", "You are no longer paired with anyone.", "1");
}
}
@@ -2852,6 +2864,58 @@ void Courtroom::on_ooc_return_pressed()
ui_ooc_chat_message->clear();
return;
}
+ else if(ooc_message.startsWith("/save_case"))
+ {
+ QStringList command = ooc_message.split(" ", QString::SkipEmptyParts);
+
+ QDir casefolder("base/cases");
+ if (!casefolder.exists())
+ {
+ QDir::current().mkdir("base/" + casefolder.dirName());
+ append_server_chatmessage("CLIENT", "You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely that you somehow deleted it.", "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+ QStringList caseslist = casefolder.entryList();
+ caseslist.removeOne(".");
+ caseslist.removeOne("..");
+ caseslist.replaceInStrings(".ini","");
+
+ if (command.size() < 2)
+ {
+ append_server_chatmessage("CLIENT", "You need to give a filename to save (extension not needed) and the courtroom status!" + caseslist.join(", "), "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+
+
+ if (command.size() > 3)
+ {
+ append_server_chatmessage("CLIENT", "Too many arguments to save a case! You only need a filename without extension and the courtroom status!", "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+ QSettings casefile("base/cases/" + command[1] + ".ini", QSettings::IniFormat);
+ casefile.setValue("author",ui_ooc_chat_name->text());
+ casefile.setValue("cmdoc","");
+ casefile.setValue("doc", "");
+ casefile.setValue("status",command[2]);
+ casefile.sync();
+ for(int i = local_evidence_list.size() - 1; i >= 0; i--)
+ {
+ casefile.beginGroup(QString::number(i));
+ casefile.sync();
+ casefile.setValue("name",local_evidence_list[i].name);
+ casefile.setValue("description",local_evidence_list[i].description);
+ casefile.setValue("image",local_evidence_list[i].image);
+ casefile.endGroup();
+ }
+ casefile.sync();
+ append_server_chatmessage("CLIENT", "Succesfully saved, edit doc and cmdoc link on the ini!", "1");
+ ui_ooc_chat_message->clear();
+ return;
+
+ }
QStringList packet_contents;
packet_contents.append(ui_ooc_chat_name->text());
@@ -2981,6 +3045,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index)
QListWidgetItem *f_item = ui_pair_list->item(p_index.row());
QString f_char = f_item->text();
QString real_char;
+ int f_cid = -1;
if (f_char.endsWith(" [x]"))
{
@@ -2988,17 +3053,19 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index)
f_item->setText(real_char);
}
else
- real_char = f_char;
-
- int f_cid = -1;
-
- for (int n_char = 0 ; n_char < char_list.size() ; n_char++)
{
+ real_char = f_char;
+ for (int n_char = 0 ; n_char < char_list.size() ; n_char++)
+ {
if (char_list.at(n_char).name == real_char)
f_cid = n_char;
+ }
}
- if (f_cid < 0 || f_cid >= char_list.size())
+
+
+
+ if (f_cid < -2 || f_cid >= char_list.size())
{
qDebug() << "W: " << real_char << " not present in char_list";
return;
@@ -3017,8 +3084,10 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index)
for (int i = 0; i < ui_pair_list->count(); i++) {
ui_pair_list->item(i)->setText(sorted_pair_list.at(i));
}
-
- f_item->setText(real_char + " [x]");
+ if(other_charid != -1)
+ {
+ f_item->setText(real_char + " [x]");
+ }
}
void Courtroom::on_music_list_double_clicked(QModelIndex p_model)