New feature! /save_case . Takes two parameters, name and cr status.

E.g: /save_case case1 lfp . It takes court evidence but leaves the doc and cmdoc options blank to be entered manually(if anybody actually puts anything).
This commit is contained in:
cents02 2019-06-30 21:47:48 +00:00
parent ae85525780
commit f826ba390b

View File

@ -2864,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());
@ -3009,7 +3061,11 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index)
f_cid = n_char;
}
}
if (f_cid < -1 || f_cid >= char_list.size())
if (f_cid < -2 || f_cid >= char_list.size())
{
qDebug() << "W: " << real_char << " not present in char_list";
return;
@ -3030,9 +3086,10 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index)
}
if(other_charid != -1)
{
f_item->setText(real_char + " [x]");
f_item->setText(real_char + " [x]");
}
}
void Courtroom::on_music_list_double_clicked(QModelIndex p_model)
{
if (is_muted)