Client can now accept case alerts.

- Settings has a new tab with casing settings.
  - Can set when the game should alert of cases.
- In game tickbox to toggle if you should be alerted of cases.
This commit is contained in:
Cerapter 2018-10-23 14:54:36 +02:00
parent 3844827724
commit 660daf9922
7 changed files with 273 additions and 3 deletions

View File

@ -71,6 +71,7 @@ public:
bool evidence_enabled = false; bool evidence_enabled = false;
bool cccc_ic_support_enabled = false; bool cccc_ic_support_enabled = false;
bool arup_enabled = false; bool arup_enabled = false;
bool casing_alerts_enabled = false;
bool modcall_reason_enabled = false; bool modcall_reason_enabled = false;
///////////////loading info/////////////////// ///////////////loading info///////////////////
@ -267,6 +268,31 @@ public:
//Returns p_char's gender //Returns p_char's gender
QString get_gender(QString p_char); QString get_gender(QString p_char);
// ======
// These are all casing-related settings.
// ======
// Returns if the user has casing alerts enabled.
bool get_casing_enabled();
// Returns if the user wants to get alerts for the defence role.
bool get_casing_defence_enabled();
// Same for prosecution.
bool get_casing_prosecution_enabled();
// Same for judge.
bool get_casing_judge_enabled();
// Same for juror.
bool get_casing_juror_enabled();
// Same for CM.
bool get_casing_cm_enabled();
// Get the message for the CM for casing alerts.
QString get_casing_can_host_cases();
private: private:
const int RELEASE = 2; const int RELEASE = 2;
const int MAJOR_VERSION = 4; const int MAJOR_VERSION = 4;

View File

@ -186,7 +186,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
CallwordsLayout->addWidget(CallwordsExplainLabel); CallwordsLayout->addWidget(CallwordsExplainLabel);
// And finally, the Audio tab. // The audio tab.
AudioTab = new QWidget(); AudioTab = new QWidget();
SettingsTabs->addTab(AudioTab, "Audio"); SettingsTabs->addTab(AudioTab, "Audio");
@ -299,6 +299,121 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
AudioForm->setWidget(7, QFormLayout::FieldRole, BlankBlipsCheckbox); AudioForm->setWidget(7, QFormLayout::FieldRole, BlankBlipsCheckbox);
// The casing tab!
CasingTab = new QWidget();
SettingsTabs->addTab(CasingTab, "Casing");
formLayoutWidget_3 = new QWidget(CasingTab);
formLayoutWidget_3->setGeometry(QRect(10,10, 361, 211));
CasingForm = new QFormLayout(formLayoutWidget_3);
CasingForm->setObjectName(QStringLiteral("CasingForm"));
CasingForm->setLabelAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
CasingForm->setFormAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
CasingForm->setContentsMargins(0, 0, 0, 0);
// -- SERVER SUPPORTS CASING
ServerSupportsCasing = new QLabel(formLayoutWidget_3);
if (ao_app->casing_alerts_enabled)
ServerSupportsCasing->setText("This server supports case alerts.");
else
ServerSupportsCasing->setText("This server does not support case alerts.");
ServerSupportsCasing->setToolTip("Pretty self-explanatory.");
CasingForm->setWidget(0, QFormLayout::FieldRole, ServerSupportsCasing);
// -- CASE ANNOUNCEMENTS
CasingEnabledLabel = new QLabel(formLayoutWidget_3);
CasingEnabledLabel->setText("Casing:");
CasingEnabledLabel->setToolTip("If checked, you will get alerts about case announcements.");
CasingForm->setWidget(1, QFormLayout::LabelRole, CasingEnabledLabel);
CasingEnabledCheckbox = new QCheckBox(formLayoutWidget_3);
CasingEnabledCheckbox->setChecked(ao_app->get_casing_enabled());
CasingForm->setWidget(1, QFormLayout::FieldRole, CasingEnabledCheckbox);
// -- DEFENCE ANNOUNCEMENTS
DefenceLabel = new QLabel(formLayoutWidget_3);
DefenceLabel->setText("Defence:");
DefenceLabel->setToolTip("If checked, you will get alerts about case announcements if a defence spot is open.");
CasingForm->setWidget(2, QFormLayout::LabelRole, DefenceLabel);
DefenceCheckbox = new QCheckBox(formLayoutWidget_3);
DefenceCheckbox->setChecked(ao_app->get_casing_defence_enabled());
CasingForm->setWidget(2, QFormLayout::FieldRole, DefenceCheckbox);
// -- PROSECUTOR ANNOUNCEMENTS
ProsecutorLabel = new QLabel(formLayoutWidget_3);
ProsecutorLabel->setText("Prosecution:");
ProsecutorLabel->setToolTip("If checked, you will get alerts about case announcements if a prosecutor spot is open.");
CasingForm->setWidget(3, QFormLayout::LabelRole, ProsecutorLabel);
ProsecutorCheckbox = new QCheckBox(formLayoutWidget_3);
ProsecutorCheckbox->setChecked(ao_app->get_casing_prosecution_enabled());
CasingForm->setWidget(3, QFormLayout::FieldRole, ProsecutorCheckbox);
// -- JUDGE ANNOUNCEMENTS
JudgeLabel = new QLabel(formLayoutWidget_3);
JudgeLabel->setText("Judge:");
JudgeLabel->setToolTip("If checked, you will get alerts about case announcements if the judge spot is open.");
CasingForm->setWidget(4, QFormLayout::LabelRole, JudgeLabel);
JudgeCheckbox = new QCheckBox(formLayoutWidget_3);
JudgeCheckbox->setChecked(ao_app->get_casing_judge_enabled());
CasingForm->setWidget(4, QFormLayout::FieldRole, JudgeCheckbox);
// -- JUROR ANNOUNCEMENTS
JurorLabel = new QLabel(formLayoutWidget_3);
JurorLabel->setText("Juror:");
JurorLabel->setToolTip("If checked, you will get alerts about case announcements if a juror spot is open.");
CasingForm->setWidget(5, QFormLayout::LabelRole, JurorLabel);
JurorCheckbox = new QCheckBox(formLayoutWidget_3);
JurorCheckbox->setChecked(ao_app->get_casing_juror_enabled());
CasingForm->setWidget(5, QFormLayout::FieldRole, JurorCheckbox);
// -- 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);
CMCheckbox = new QCheckBox(formLayoutWidget_3);
CMCheckbox->setChecked(ao_app->get_casing_cm_enabled());
CasingForm->setWidget(6, QFormLayout::FieldRole, CMCheckbox);
// -- CM CASES ANNOUNCEMENTS
CMCasesLabel = new QLabel(formLayoutWidget_3);
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);
CMCasesLineEdit = new QLineEdit(formLayoutWidget_3);
CMCasesLineEdit->setText(ao_app->get_casing_can_host_cases());
CasingForm->setWidget(7, QFormLayout::FieldRole, CMCasesLineEdit);
// When we're done, we should continue the updates! // When we're done, we should continue the updates!
setUpdatesEnabled(true); setUpdatesEnabled(true);
} }
@ -336,6 +451,14 @@ void AOOptionsDialog::save_pressed()
configini->setValue("blip_rate", BlipRateSpinbox->value()); configini->setValue("blip_rate", BlipRateSpinbox->value());
configini->setValue("blank_blip", BlankBlipsCheckbox->isChecked()); configini->setValue("blank_blip", BlankBlipsCheckbox->isChecked());
configini->setValue("casing_enabled", CasingEnabledCheckbox->isChecked());
configini->setValue("casing_defence_enabled", DefenceCheckbox->isChecked());
configini->setValue("casing_prosecution_enabled", ProsecutorCheckbox->isChecked());
configini->setValue("casing_judge_enabled", JudgeCheckbox->isChecked());
configini->setValue("casing_juror_enabled", JurorCheckbox->isChecked());
configini->setValue("casing_cm_enabled", CMCheckbox->isChecked());
configini->setValue("casing_can_host_casees", CMCasesLineEdit->text());
callwordsini->close(); callwordsini->close();
done(0); done(0);
} }

View File

@ -34,6 +34,7 @@ private:
QVBoxLayout *verticalLayout; QVBoxLayout *verticalLayout;
QTabWidget *SettingsTabs; QTabWidget *SettingsTabs;
QWidget *GameplayTab; QWidget *GameplayTab;
QWidget *formLayoutWidget; QWidget *formLayoutWidget;
QFormLayout *GameplayForm; QFormLayout *GameplayForm;
@ -54,12 +55,14 @@ private:
QLineEdit *MasterServerLineEdit; QLineEdit *MasterServerLineEdit;
QLabel *DiscordLabel; QLabel *DiscordLabel;
QCheckBox *DiscordCheckBox; QCheckBox *DiscordCheckBox;
QWidget *CallwordsTab; QWidget *CallwordsTab;
QWidget *verticalLayoutWidget; QWidget *verticalLayoutWidget;
QVBoxLayout *CallwordsLayout; QVBoxLayout *CallwordsLayout;
QPlainTextEdit *CallwordsTextEdit; QPlainTextEdit *CallwordsTextEdit;
QLabel *CallwordsExplainLabel; QLabel *CallwordsExplainLabel;
QCheckBox *CharacterCallwordsCheckbox; QCheckBox *CharacterCallwordsCheckbox;
QWidget *AudioTab; QWidget *AudioTab;
QWidget *formLayoutWidget_2; QWidget *formLayoutWidget_2;
QFormLayout *AudioForm; QFormLayout *AudioForm;
@ -79,6 +82,25 @@ private:
QLabel *BlankBlipsLabel; QLabel *BlankBlipsLabel;
QDialogButtonBox *SettingsButtons; QDialogButtonBox *SettingsButtons;
QWidget *CasingTab;
QWidget *formLayoutWidget_3;
QFormLayout *CasingForm;
QLabel *ServerSupportsCasing;
QLabel *CasingEnabledLabel;
QCheckBox *CasingEnabledCheckbox;
QLabel *DefenceLabel;
QCheckBox *DefenceCheckbox;
QLabel *ProsecutorLabel;
QCheckBox *ProsecutorCheckbox;
QLabel *JudgeLabel;
QCheckBox *JudgeCheckbox;
QLabel *JurorLabel;
QCheckBox *JurorCheckbox;
QLabel *CMLabel;
QCheckBox *CMCheckbox;
QLabel *CMCasesLabel;
QLineEdit *CMCasesLineEdit;
bool needs_default_audiodev(); bool needs_default_audiodev();
signals: signals:

View File

@ -201,10 +201,14 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_guard = new QCheckBox(this); ui_guard = new QCheckBox(this);
ui_guard->setText("Guard"); ui_guard->setText("Guard");
ui_guard->hide(); ui_guard->hide();
ui_casing = new QCheckBox(this);
ui_showname_enable->setChecked(ao_app->get_casing_enabled());
ui_casing->setText("Casing");
ui_casing->hide();
ui_showname_enable = new QCheckBox(this); ui_showname_enable = new QCheckBox(this);
ui_showname_enable->setChecked(ao_app->get_showname_enabled_by_default()); ui_showname_enable->setChecked(ao_app->get_showname_enabled_by_default());
ui_showname_enable->setText("Custom shownames"); ui_showname_enable->setText("Shownames");
ui_pre_non_interrupt = new QCheckBox(this); ui_pre_non_interrupt = new QCheckBox(this);
ui_pre_non_interrupt->setText("No Intrpt"); ui_pre_non_interrupt->setText("No Intrpt");
@ -323,6 +327,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(ui_pre, SIGNAL(clicked()), this, SLOT(on_pre_clicked())); connect(ui_pre, SIGNAL(clicked()), this, SLOT(on_pre_clicked()));
connect(ui_flip, SIGNAL(clicked()), this, SLOT(on_flip_clicked())); connect(ui_flip, SIGNAL(clicked()), this, SLOT(on_flip_clicked()));
connect(ui_guard, SIGNAL(clicked()), this, SLOT(on_guard_clicked())); connect(ui_guard, SIGNAL(clicked()), this, SLOT(on_guard_clicked()));
connect(ui_casing, SIGNAL(clicked()), this, SLOT(on_casing_clicked()));
connect(ui_showname_enable, SIGNAL(clicked()), this, SLOT(on_showname_enable_clicked())); connect(ui_showname_enable, SIGNAL(clicked()), this, SLOT(on_showname_enable_clicked()));
@ -599,11 +604,12 @@ void Courtroom::set_widgets()
ui_pre->setText("Pre"); ui_pre->setText("Pre");
set_size_and_pos(ui_pre_non_interrupt, "pre_no_interrupt"); set_size_and_pos(ui_pre_non_interrupt, "pre_no_interrupt");
set_size_and_pos(ui_flip, "flip"); set_size_and_pos(ui_flip, "flip");
set_size_and_pos(ui_guard, "guard"); set_size_and_pos(ui_guard, "guard");
set_size_and_pos(ui_casing, "casing");
set_size_and_pos(ui_showname_enable, "showname_enable"); set_size_and_pos(ui_showname_enable, "showname_enable");
set_size_and_pos(ui_custom_objection, "custom_objection"); set_size_and_pos(ui_custom_objection, "custom_objection");
@ -879,6 +885,11 @@ void Courtroom::enter_courtroom(int p_cid)
else else
ui_flip->hide(); ui_flip->hide();
if (ao_app->casing_alerts_enabled)
ui_casing->show();
else
ui_casing->hide();
list_music(); list_music();
list_areas(); list_areas();
@ -2697,6 +2708,22 @@ void Courtroom::mod_called(QString p_ip)
} }
} }
void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur)
{
if (ui_casing->isChecked())
{
ui_server_chatlog->append(msg);
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))
{
modcall_player->play(ao_app->get_sfx("case_call"));
ao_app->alert(this);
}
}
}
void Courtroom::on_ooc_return_pressed() void Courtroom::on_ooc_return_pressed()
{ {
QString ooc_message = ui_ooc_chat_message->text(); QString ooc_message = ui_ooc_chat_message->text();
@ -3506,6 +3533,24 @@ void Courtroom::ping_server()
ao_app->send_server_packet(new AOPacket("CH#" + QString::number(m_cid) + "#%")); ao_app->send_server_packet(new AOPacket("CH#" + QString::number(m_cid) + "#%"));
} }
void Courtroom::on_casing_clicked()
{
if (ao_app->casing_alerts_enabled)
{
if (ui_casing->isChecked())
ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/setcase"
+ " \"" + ao_app->get_casing_can_host_cases() + "\""
+ " " + QString::number(ao_app->get_casing_cm_enabled())
+ " " + QString::number(ao_app->get_casing_defence_enabled())
+ " " + QString::number(ao_app->get_casing_prosecution_enabled())
+ " " + QString::number(ao_app->get_casing_judge_enabled())
+ " " + QString::number(ao_app->get_casing_juror_enabled())
+ "#%"));
else
ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/setcase \"\" 0 0 0 0 0#%"));
}
}
Courtroom::~Courtroom() Courtroom::~Courtroom()
{ {
delete music_player; delete music_player;

View File

@ -460,6 +460,7 @@ private:
QCheckBox *ui_pre; QCheckBox *ui_pre;
QCheckBox *ui_flip; QCheckBox *ui_flip;
QCheckBox *ui_guard; QCheckBox *ui_guard;
QCheckBox *ui_casing;
QCheckBox *ui_pre_non_interrupt; QCheckBox *ui_pre_non_interrupt;
QCheckBox *ui_showname_enable; QCheckBox *ui_showname_enable;
@ -548,6 +549,8 @@ public slots:
void mod_called(QString p_ip); void mod_called(QString p_ip);
void case_called(QString msg, bool def, bool pro, bool jud, bool jur);
private slots: private slots:
void start_chat_ticking(); void start_chat_ticking();
void play_sfx(); void play_sfx();
@ -648,6 +651,8 @@ private slots:
void on_switch_area_music_clicked(); void on_switch_area_music_clicked();
void on_casing_clicked();
void ping_server(); void ping_server();
void load_bass_opus_plugin(); void load_bass_opus_plugin();

View File

@ -149,6 +149,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
evidence_enabled = false; evidence_enabled = false;
cccc_ic_support_enabled = false; cccc_ic_support_enabled = false;
arup_enabled = false; arup_enabled = false;
casing_alerts_enabled = false;
modcall_reason_enabled = false; modcall_reason_enabled = false;
//workaround for tsuserver4 //workaround for tsuserver4
@ -204,6 +205,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
cccc_ic_support_enabled = true; cccc_ic_support_enabled = true;
if (f_packet.contains("arup",Qt::CaseInsensitive)) if (f_packet.contains("arup",Qt::CaseInsensitive))
arup_enabled = true; arup_enabled = true;
if (f_packet.contains("casing_alerts",Qt::CaseInsensitive))
casing_alerts_enabled = true;
if (f_packet.contains("modcall_reason",Qt::CaseInsensitive)) if (f_packet.contains("modcall_reason",Qt::CaseInsensitive))
modcall_reason_enabled = true; modcall_reason_enabled = true;
@ -657,6 +660,13 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (courtroom_constructed && f_contents.size() > 0) if (courtroom_constructed && f_contents.size() > 0)
w_courtroom->mod_called(f_contents.at(0)); w_courtroom->mod_called(f_contents.at(0));
} }
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");
}
end: end:

View File

@ -518,5 +518,44 @@ bool AOApplication::is_discord_enabled()
return result.startsWith("true"); return result.startsWith("true");
} }
bool AOApplication::get_casing_enabled()
{
QString result = configini->value("casing_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_defence_enabled()
{
QString result = configini->value("casing_defence_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_prosecution_enabled()
{
QString result = configini->value("casing_prosecution_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_judge_enabled()
{
QString result = configini->value("casing_judge_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_juror_enabled()
{
QString result = configini->value("casing_juror_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_casing_cm_enabled()
{
QString result = configini->value("casing_cm_enabled", "false").value<QString>();
return result.startsWith("true");
}
QString AOApplication::get_casing_can_host_cases()
{
QString result = configini->value("casing_can_host_casees", "Turnabout Check Your Settings").value<QString>();
return result;
}