From 7b4b297a22e97046a3fca860ad3faf08438c6a8c Mon Sep 17 00:00:00 2001 From: Leifa♥ <26681464+TrickyLeifa@users.noreply.github.com> Date: Fri, 24 Jun 2022 01:58:17 +0200 Subject: 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 --- src/courtroom.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/courtroom.cpp') 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) -- cgit