aboutsummaryrefslogtreecommitdiff
path: root/src/courtroom.cpp
diff options
context:
space:
mode:
authorLeifa♥ <26681464+TrickyLeifa@users.noreply.github.com>2022-06-24 01:58:17 +0200
committerGitHub <noreply@github.com>2022-06-23 18:58:17 -0500
commit7b4b297a22e97046a3fca860ad3faf08438c6a8c (patch)
tree9e8630a6b27ac82b0162163860ab87718f013f7a /src/courtroom.cpp
parent0be8d0f5aeb64ae9abae24c2669bb45d440d9ca6 (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/courtroom.cpp')
-rw-r--r--src/courtroom.cpp31
1 files changed, 31 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)