diff options
| author | Crystalwarrior <Varsash@Gmail.com> | 2020-07-04 00:34:09 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-03 16:34:09 -0500 |
| commit | 0a31a20266adcbd9afd6ef54abe4123f5f1708a3 (patch) | |
| tree | 279abf8f10cdaf12c587f5596e8b59a6e2cd5e6b /src/courtroom.cpp | |
| parent | 5cd9da37063bccab1d00931091df3f8b71225540 (diff) | |
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
Diffstat (limited to 'src/courtroom.cpp')
| -rw-r--r-- | src/courtroom.cpp | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index ba16f8cf..7326948f 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -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. |
