diff options
| author | Leifa♥ <26681464+TrickyLeifa@users.noreply.github.com> | 2022-06-24 01:58:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-23 18:58:17 -0500 |
| commit | 7b4b297a22e97046a3fca860ad3faf08438c6a8c (patch) | |
| tree | 9e8630a6b27ac82b0162163860ab87718f013f7a /src | |
| parent | 0be8d0f5aeb64ae9abae24c2669bb45d440d9ca6 (diff) | |
Added penalty effects (#786)
Themes can be configured to play an SFX and/or effect when the HP bar increases or decreases. Effects can be any defined effect, or a built-in effect such as "screenshake" or "flash".
Resolves AttorneyOnline/AO2-Client#743
Diffstat (limited to 'src')
| -rw-r--r-- | src/courtroom.cpp | 31 | ||||
| -rw-r--r-- | src/text_file_functions.cpp | 7 |
2 files changed, 38 insertions, 0 deletions
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); |
