Added support for the stenographer role in case alerts.

This commit is contained in:
Cerapter 2018-10-23 16:34:39 +02:00
parent de8badc9a6
commit 962289793d
11 changed files with 54 additions and 19 deletions

View File

@ -288,6 +288,9 @@ public:
// Same for juror.
bool get_casing_juror_enabled();
// Same for steno.
bool get_casing_steno_enabled();
// Same for CM.
bool get_casing_cm_enabled();

View File

@ -51,11 +51,14 @@ AOCaseAnnouncerDialog::AOCaseAnnouncerDialog(QWidget *parent, AOApplication *p_a
JudgeNeeded->setText("Judge needed");
JurorNeeded = new QCheckBox(this);
JurorNeeded->setText("Jurors needed");
StenographerNeeded = new QCheckBox(this);
StenographerNeeded->setText("Stenographer needed");
FormLayout->setWidget(1, QFormLayout::FieldRole, DefenceNeeded);
FormLayout->setWidget(2, QFormLayout::FieldRole, ProsecutorNeeded);
FormLayout->setWidget(3, QFormLayout::FieldRole, JudgeNeeded);
FormLayout->setWidget(4, QFormLayout::FieldRole, JurorNeeded);
FormLayout->setWidget(5, QFormLayout::FieldRole, StenographerNeeded);
setUpdatesEnabled(true);
}
@ -66,7 +69,8 @@ void AOCaseAnnouncerDialog::ok_pressed()
DefenceNeeded->isChecked(),
ProsecutorNeeded->isChecked(),
JudgeNeeded->isChecked(),
JurorNeeded->isChecked());
JurorNeeded->isChecked(),
StenographerNeeded->isChecked());
done(0);
}

View File

@ -35,6 +35,7 @@ private:
QCheckBox *ProsecutorNeeded;
QCheckBox *JudgeNeeded;
QCheckBox *JurorNeeded;
QCheckBox *StenographerNeeded;
public slots:
void ok_pressed();

View File

@ -388,18 +388,31 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
CasingForm->setWidget(5, QFormLayout::FieldRole, JurorCheckbox);
// -- STENO ANNOUNCEMENTS
StenographerLabel = new QLabel(formLayoutWidget_3);
StenographerLabel->setText("Stenographer:");
StenographerLabel->setToolTip("If checked, you will get alerts about case announcements if a stenographer spot is open.");
CasingForm->setWidget(6, QFormLayout::LabelRole, StenographerLabel);
StenographerCheckbox = new QCheckBox(formLayoutWidget_3);
StenographerCheckbox->setChecked(ao_app->get_casing_steno_enabled());
CasingForm->setWidget(6, QFormLayout::FieldRole, StenographerCheckbox);
// -- CM ANNOUNCEMENTS
CMLabel = new QLabel(formLayoutWidget_3);
CMLabel->setText("CM:");
CMLabel->setToolTip("If checked, you will appear amongst the potential CMs on the server.");
CasingForm->setWidget(6, QFormLayout::LabelRole, CMLabel);
CasingForm->setWidget(7, QFormLayout::LabelRole, CMLabel);
CMCheckbox = new QCheckBox(formLayoutWidget_3);
CMCheckbox->setChecked(ao_app->get_casing_cm_enabled());
CasingForm->setWidget(6, QFormLayout::FieldRole, CMCheckbox);
CasingForm->setWidget(7, QFormLayout::FieldRole, CMCheckbox);
// -- CM CASES ANNOUNCEMENTS
@ -407,12 +420,12 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
CMCasesLabel->setText("Hosting cases:");
CMCasesLabel->setToolTip("If you're a CM, enter what cases are you willing to host.");
CasingForm->setWidget(7, QFormLayout::LabelRole, CMCasesLabel);
CasingForm->setWidget(8, QFormLayout::LabelRole, CMCasesLabel);
CMCasesLineEdit = new QLineEdit(formLayoutWidget_3);
CMCasesLineEdit->setText(ao_app->get_casing_can_host_cases());
CasingForm->setWidget(7, QFormLayout::FieldRole, CMCasesLineEdit);
CasingForm->setWidget(8, QFormLayout::FieldRole, CMCasesLineEdit);
// When we're done, we should continue the updates!
setUpdatesEnabled(true);
@ -456,6 +469,7 @@ void AOOptionsDialog::save_pressed()
configini->setValue("casing_prosecution_enabled", ProsecutorCheckbox->isChecked());
configini->setValue("casing_judge_enabled", JudgeCheckbox->isChecked());
configini->setValue("casing_juror_enabled", JurorCheckbox->isChecked());
configini->setValue("casing_steno_enabled", StenographerCheckbox->isChecked());
configini->setValue("casing_cm_enabled", CMCheckbox->isChecked());
configini->setValue("casing_can_host_casees", CMCasesLineEdit->text());

View File

@ -96,6 +96,8 @@ private:
QCheckBox *JudgeCheckbox;
QLabel *JurorLabel;
QCheckBox *JurorCheckbox;
QLabel *StenographerLabel;
QCheckBox *StenographerCheckbox;
QLabel *CMLabel;
QCheckBox *CMCheckbox;
QLabel *CMCasesLabel;

View File

@ -2722,7 +2722,7 @@ void Courtroom::mod_called(QString p_ip)
}
}
void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur)
void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur, bool steno)
{
if (ui_casing->isChecked())
{
@ -2730,7 +2730,8 @@ void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur)
if ((ao_app->get_casing_defence_enabled() && def) ||
(ao_app->get_casing_prosecution_enabled() && pro) ||
(ao_app->get_casing_judge_enabled() && jud) ||
(ao_app->get_casing_juror_enabled() && jur))
(ao_app->get_casing_juror_enabled() && jur) ||
(ao_app->get_casing_steno_enabled() && steno))
{
modcall_player->play(ao_app->get_sfx("case_call"));
ao_app->alert(this);
@ -3564,13 +3565,14 @@ void Courtroom::on_casing_clicked()
+ " " + QString::number(ao_app->get_casing_prosecution_enabled())
+ " " + QString::number(ao_app->get_casing_judge_enabled())
+ " " + QString::number(ao_app->get_casing_juror_enabled())
+ " " + QString::number(ao_app->get_casing_steno_enabled())
+ "#%"));
else
ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/setcase \"\" 0 0 0 0 0#%"));
ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/setcase \"\" 0 0 0 0 0 0#%"));
}
}
void Courtroom::announce_case(QString title, bool def, bool pro, bool jud, bool jur)
void Courtroom::announce_case(QString title, bool def, bool pro, bool jud, bool jur, bool steno)
{
if (ao_app->casing_alerts_enabled)
ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/anncase \""
@ -3578,7 +3580,8 @@ void Courtroom::announce_case(QString title, bool def, bool pro, bool jud, bool
+ QString::number(def) + " "
+ QString::number(pro) + " "
+ QString::number(jud) + " "
+ QString::number(jur)
+ QString::number(jur) + " "
+ QString::number(steno)
+ "#%"));
}

View File

@ -198,7 +198,7 @@ public:
//state is an number between 0 and 10 inclusive
void set_hp_bar(int p_bar, int p_state);
void announce_case(QString title, bool def, bool pro, bool jud, bool jur);
void announce_case(QString title, bool def, bool pro, bool jud, bool jur, bool steno);
void check_connection_received();
@ -551,7 +551,7 @@ public slots:
void mod_called(QString p_ip);
void case_called(QString msg, bool def, bool pro, bool jud, bool jur);
void case_called(QString msg, bool def, bool pro, bool jud, bool jur, bool steno);
private slots:
void start_chat_ticking();

View File

@ -662,10 +662,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
}
else if (header == "CASEA")
{
if (courtroom_constructed && f_contents.size() > 0)
w_courtroom->case_called(f_contents.at(0), f_contents.at(1) == "1", f_contents.at(2) == "1", f_contents.at(3) == "1", f_contents.at(4) == "1");
qDebug() << f_contents;
qDebug() << (f_contents.at(1) == "1");
if (courtroom_constructed && f_contents.size() > 6)
w_courtroom->case_called(f_contents.at(0), f_contents.at(1) == "1", f_contents.at(2) == "1", f_contents.at(3) == "1", f_contents.at(4) == "1", f_contents.at(5) == "1");
}
end:

View File

@ -72,6 +72,7 @@ class ClientManager:
self.casing_pro = False
self.casing_jud = False
self.casing_jur = False
self.casing_steno = False
self.case_call_time = 0
#flood-guard stuff

View File

@ -780,6 +780,7 @@ def ooc_cmd_setcase(client, arg):
client.casing_pro = args[3] == "1"
client.casing_jud = args[4] == "1"
client.casing_jur = args[5] == "1"
client.casing_steno = args[6] == "1"
def ooc_cmd_anncase(client, arg):
if client in client.area.owners:
@ -791,7 +792,7 @@ def ooc_cmd_anncase(client, arg):
elif len(args) == 1:
raise ArgumentError('You should probably announce the case to at least one person.')
else:
if not args[1] == "1" and not args[2] == "1" and not args[3] == "1" and not args[4] == "1":
if not args[1] == "1" and not args[2] == "1" and not args[3] == "1" and not args[4] == "1" and not args[5] == "1":
raise ArgumentError('You should probably announce the case to at least one person.')
msg = '=== Case Announcement ===\r\n{} [{}] is hosting {}, looking for '.format(client.get_char_name(), client.id, args[0])
@ -805,14 +806,16 @@ def ooc_cmd_anncase(client, arg):
lookingfor.append("judge")
if args[4] == "1":
lookingfor.append("juror")
if args[5] == "1":
lookingfor.append("stenographer")
msg = msg + ', '.join(lookingfor) + '.\r\n=================='
client.server.send_all_cmd_pred('CASEA', msg, args[1], args[2], args[3], args[4], '1')
client.server.send_all_cmd_pred('CASEA', msg, args[1], args[2], args[3], args[4], args[5], '1')
client.set_case_call_delay()
logger.log_server('[{}][{}][CASE_ANNOUNCEMENT]{}, DEF: {}, PRO: {}, JUD: {}, JUR: {}.'.format(client.area.abbreviation, client.get_char_name(), args[0], args[1], args[2], args[3], args[4]), client)
logger.log_server('[{}][{}][CASE_ANNOUNCEMENT]{}, DEF: {}, PRO: {}, JUD: {}, JUR: {}, STENO: {}.'.format(client.area.abbreviation, client.get_char_name(), args[0], args[1], args[2], args[3], args[4], args[5]), client)
else:
raise ClientError('You cannot announce a case in an area where you are not a CM!')

View File

@ -548,6 +548,12 @@ bool AOApplication::get_casing_juror_enabled()
return result.startsWith("true");
}
bool AOApplication::get_casing_steno_enabled()
{
QString result = configini->value("casing_steno_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_cm_enabled()
{
QString result = configini->value("casing_cm_enabled", "false").value<QString>();