Add a setting to turn on/off custom character-defined chatboxes (#166)
* Add a new "Custom Chatboxes" settings option to enable/disable char.ini setting custom chat box designs per-character * Fix chat_arrow being incorrectly updated between character messages if the custom chatbox modified the chat arrow positioning/size in any way * brackets matter
This commit is contained in:
parent
5cd9da3706
commit
0a31a20266
@ -200,6 +200,11 @@ public:
|
||||
// from the config.ini.
|
||||
bool is_stickypres_enabled();
|
||||
|
||||
// Returns the value of whether custom chatboxes should be a thing.
|
||||
// from the config.ini.
|
||||
// I am increasingly maddened by the lack of dynamic auto-generation system for settings.
|
||||
bool is_customchat_enabled();
|
||||
|
||||
// Returns the value of the maximum amount of lines the IC chatlog
|
||||
// may contain, from config.ini.
|
||||
int get_max_log_size();
|
||||
|
@ -78,6 +78,9 @@ private:
|
||||
QLabel *ui_stickypres_lbl;
|
||||
QCheckBox *ui_stickypres_cb;
|
||||
|
||||
QLabel *ui_customchat_lbl;
|
||||
QCheckBox *ui_customchat_cb;
|
||||
|
||||
QWidget *ui_callwords_tab;
|
||||
QWidget *ui_callwords_widget;
|
||||
QVBoxLayout *ui_callwords_layout;
|
||||
|
@ -313,6 +313,20 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
|
||||
|
||||
ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_stickypres_cb);
|
||||
|
||||
row += 1;
|
||||
ui_customchat_lbl = new QLabel(ui_form_layout_widget);
|
||||
ui_customchat_lbl->setText(tr("Custom Chatboxes:"));
|
||||
ui_customchat_lbl->setToolTip(
|
||||
tr("Turn this on to allow characters to define their own "
|
||||
"custom chat box designs."));
|
||||
|
||||
ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_customchat_lbl);
|
||||
|
||||
ui_customchat_cb = new QCheckBox(ui_form_layout_widget);
|
||||
ui_customchat_cb->setChecked(ao_app->is_customchat_enabled());
|
||||
|
||||
ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_customchat_cb);
|
||||
|
||||
QScrollArea *scroll = new QScrollArea;
|
||||
scroll->setWidget(ui_form_layout_widget);
|
||||
ui_gameplay_tab->setLayout(new QVBoxLayout);
|
||||
@ -708,6 +722,7 @@ void AOOptionsDialog::save_pressed()
|
||||
configini->setValue("stickysounds", ui_stickysounds_cb->isChecked());
|
||||
configini->setValue("stickyeffects", ui_stickyeffects_cb->isChecked());
|
||||
configini->setValue("stickypres", ui_stickypres_cb->isChecked());
|
||||
configini->setValue("customchat", ui_customchat_cb->isChecked());
|
||||
|
||||
QFile *callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini");
|
||||
|
||||
|
@ -1883,30 +1883,35 @@ void Courtroom::handle_chatmessage_2()
|
||||
|
||||
QString chatbox_path = ao_app->get_theme_path("chat");
|
||||
QString chatbox = ao_app->get_chat(m_chatmessage[CHAR_NAME]);
|
||||
if (chatbox != "") {
|
||||
QString customchar;
|
||||
if (ao_app->is_customchat_enabled())
|
||||
customchar = m_chatmessage[CHAR_NAME];
|
||||
|
||||
if (chatbox != "" && ao_app->is_customchat_enabled()) {
|
||||
chatbox_path = ao_app->get_base_path() + "misc/" + chatbox + "/chat";
|
||||
if (!ui_vp_chatbox->set_chatbox(chatbox_path))
|
||||
ui_vp_chatbox->set_chatbox(chatbox_path + "box");
|
||||
}
|
||||
|
||||
pos_size_type design_ini_result = ao_app->get_element_dimensions(
|
||||
"chat_arrow", "courtroom_design.ini", m_chatmessage[CHAR_NAME]);
|
||||
if (design_ini_result.width < 0 || design_ini_result.height < 0) {
|
||||
qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini";
|
||||
ui_vp_chat_arrow->hide();
|
||||
}
|
||||
else {
|
||||
ui_vp_chat_arrow->move(design_ini_result.x, design_ini_result.y);
|
||||
ui_vp_chat_arrow->combo_resize(design_ini_result.width,
|
||||
design_ini_result.height);
|
||||
}
|
||||
//This should probably be called only if any change from the last chat arrow was actually detected.
|
||||
pos_size_type design_ini_result = ao_app->get_element_dimensions(
|
||||
"chat_arrow", "courtroom_design.ini", customchar);
|
||||
if (design_ini_result.width < 0 || design_ini_result.height < 0) {
|
||||
qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini";
|
||||
ui_vp_chat_arrow->hide();
|
||||
}
|
||||
else {
|
||||
ui_vp_chat_arrow->move(design_ini_result.x, design_ini_result.y);
|
||||
ui_vp_chat_arrow->combo_resize(design_ini_result.width,
|
||||
design_ini_result.height);
|
||||
}
|
||||
|
||||
pos_size_type default_width = ao_app->get_element_dimensions(
|
||||
"showname", "courtroom_design.ini", m_chatmessage[CHAR_NAME]);
|
||||
"showname", "courtroom_design.ini", customchar);
|
||||
int extra_width =
|
||||
ao_app
|
||||
->get_design_element("showname_extra_width", "courtroom_design.ini",
|
||||
m_chatmessage[CHAR_NAME])
|
||||
customchar)
|
||||
.toInt();
|
||||
|
||||
if (extra_width > 0) {
|
||||
@ -2692,8 +2697,13 @@ void Courtroom::chat_tick()
|
||||
ui_vp_player_char->play_idle(m_chatmessage[CHAR_NAME],
|
||||
m_chatmessage[EMOTE]);
|
||||
}
|
||||
QString f_char = m_chatmessage[CHAR_NAME];
|
||||
QString f_custom_theme = ao_app->get_chat(f_char);
|
||||
QString f_char;
|
||||
QString f_custom_theme;
|
||||
if (ao_app->is_customchat_enabled())
|
||||
{
|
||||
f_char = m_chatmessage[CHAR_NAME];
|
||||
f_custom_theme = ao_app->get_chat(f_char);
|
||||
}
|
||||
ui_vp_chat_arrow->play(
|
||||
"chat_arrow", f_char,
|
||||
f_custom_theme); // Chat stopped being processed, indicate that.
|
||||
|
@ -988,6 +988,12 @@ bool AOApplication::is_stickypres_enabled()
|
||||
return result.startsWith("true");
|
||||
}
|
||||
|
||||
bool AOApplication::is_customchat_enabled()
|
||||
{
|
||||
QString result = configini->value("customchat", "true").value<QString>();
|
||||
return result.startsWith("true");
|
||||
}
|
||||
|
||||
bool AOApplication::get_casing_enabled()
|
||||
{
|
||||
QString result = configini->value("casing_enabled", "false").value<QString>();
|
||||
|
Loading…
Reference in New Issue
Block a user