diff options
| -rw-r--r-- | include/aoapplication.h | 4 | ||||
| -rw-r--r-- | src/courtroom.cpp | 31 | ||||
| -rw-r--r-- | src/text_file_functions.cpp | 7 |
3 files changed, 42 insertions, 0 deletions
diff --git a/include/aoapplication.h b/include/aoapplication.h index 4c3a83f3..cf9eb2b2 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -361,6 +361,10 @@ public: // Returns the color from the misc folder. QColor get_chat_color(QString p_identifier, QString p_chat); + // Returns the value with p_identifier from penalty/penalty.ini in the current + // theme path + QString get_penalty_value(QString p_identifier); + // Returns the sfx with p_identifier from courtroom_sounds.ini in the current theme path QString get_court_sfx(QString p_identifier, QString p_misc=""); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 516d3fc2..55fc35fe 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3994,14 +3994,45 @@ void Courtroom::set_hp_bar(int p_bar, int p_state) if (p_state < 0 || p_state > 10) return; + int prev_state = p_state; if (p_bar == 1) { ui_defense_bar->set_image("defensebar" + QString::number(p_state)); + prev_state = defense_bar_state; defense_bar_state = p_state; } else if (p_bar == 2) { ui_prosecution_bar->set_image("prosecutionbar" + QString::number(p_state)); + prev_state = prosecution_bar_state; prosecution_bar_state = p_state; } + + QString sfx_name; + QString effect_name; + if (p_state > prev_state) { + sfx_name = ao_app->get_penalty_value("hp_increased_sfx"); + effect_name = ao_app->get_penalty_value("hp_increased_effect").toLower(); + } + else if (p_state < prev_state) { + sfx_name = ao_app->get_penalty_value("hp_decreased_sfx"); + effect_name = ao_app->get_penalty_value("hp_decreased_effect").toLower(); + } + else { + return; + } + + if (effect_name == "screenshake") { + do_screenshake(); + } + else if (effect_name == "flash") { + do_flash(); + } + else { + do_effect(effect_name, "", "", ""); + } + + if (!sfx_name.isEmpty()) { + sfx_player->play(sfx_name); + } } void Courtroom::show_judge_controls(bool visible) diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 4073c054..5f3de175 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -521,6 +521,13 @@ QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat) return return_color; } +QString AOApplication::get_penalty_value(QString p_identifier) +{ + return get_config_value(p_identifier, "penalty/penalty.ini", current_theme, + get_subtheme(), default_theme, ""); +} + + QString AOApplication::get_court_sfx(QString p_identifier, QString p_misc) { QString value = get_config_value(p_identifier, "courtroom_sounds.ini", current_theme, get_subtheme(), default_theme, p_misc); |
