streamline bar flashing modes (closes #35)

This commit is contained in:
rr- 2021-02-28 09:28:25 +01:00
parent 7c8cdb3ba0
commit d830dba34b
4 changed files with 32 additions and 18 deletions

View file

@ -54,11 +54,14 @@
// Changes how the healthbar is displayed. Possible values: // Changes how the healthbar is displayed. Possible values:
// - always: always show the healthbar // - always: always show the healthbar
// - flashing: show the healthbar only when Lara's health is 20% or below
// - default: show the healthbar at the beginning of a level, after // - default: show the healthbar at the beginning of a level, after
// getting hit or while having weapons equipped (as in OG) // getting hit or while having weapons equipped (as in OG)
// - flashing-or-default: show the healthbar when Lara's health is 20% or
// below, or under default circumstances
// - flashing-only: show the healthbar *only* when Lara's health is 20% or
// below (useful for challenge runs)
// - never: never display the healthbar (for challenge runs) // - never: never display the healthbar (for challenge runs)
"healthbar_showing_mode": "flashing", "healthbar_showing_mode": "flashing-or-default",
// Location where the healthbar is displayed. Possible values: // Location where the healthbar is displayed. Possible values:
// - top-left // - top-left
@ -83,9 +86,15 @@
// Changes how the airbar is displayed. Possible values: // Changes how the airbar is displayed. Possible values:
// - always: always show the airbar // - always: always show the airbar
// - flashing: show the airbar only when Lara's oxygen is 20% or below
// - default: show the airbar only in the water // - default: show the airbar only in the water
// - flashing-or-default: show the airbar when Lara's oxygen is 20% or
/ below or under normal circumstances
// - flashing-only: show the airbar *only* when Lara's oxygen is 20% or /
// below (useful for challenge runs)
// - never: never display the airbar (for challenge runs) // - never: never display the airbar (for challenge runs)
// In case of airbar, the flashing-or-default mode is there mostly for
// consistency and the only practical difference is that it's shown when
// Lara dies. When using the fly cheat, the airbar is never shown.
"airbar_showing_mode": "default", "airbar_showing_mode": "default",
// Location where the airbar is displayed. // Location where the airbar is displayed.

View file

@ -15,8 +15,10 @@ static int8_t ReadBarShowingMode(struct json_value_s* root, const char* name)
const char* value_str = JSONGetStringValue(root, name); const char* value_str = JSONGetStringValue(root, name);
if (!value_str) { if (!value_str) {
return T1M_BSM_DEFAULT; return T1M_BSM_DEFAULT;
} else if (!strcmp(value_str, "flashing")) { } else if (!strcmp(value_str, "flashing-or-default")) {
return T1M_BSM_FLASHING; return T1M_BSM_FLASHING_OR_DEFAULT;
} else if (!strcmp(value_str, "flashing-only")) {
return T1M_BSM_FLASHING_ONLY;
} else if (!strcmp(value_str, "always")) { } else if (!strcmp(value_str, "always")) {
return T1M_BSM_ALWAYS; return T1M_BSM_ALWAYS;
} else if (!strcmp(value_str, "never")) { } else if (!strcmp(value_str, "never")) {

View file

@ -26,9 +26,10 @@ typedef enum {
typedef enum { typedef enum {
T1M_BSM_DEFAULT = 0, T1M_BSM_DEFAULT = 0,
T1M_BSM_FLASHING = 1, T1M_BSM_FLASHING_OR_DEFAULT = 1,
T1M_BSM_ALWAYS = 2, T1M_BSM_FLASHING_ONLY = 2,
T1M_BSM_NEVER = 3, T1M_BSM_ALWAYS = 3,
T1M_BSM_NEVER = 4,
} T1M_BAR_SHOW_MODE; } T1M_BAR_SHOW_MODE;
struct { struct {

View file

@ -58,11 +58,12 @@ void DrawHealthBar()
break; break;
case T1M_BSM_NEVER: case T1M_BSM_NEVER:
show = 0; show = 0;
return; break;
case T1M_BSM_FLASHING: case T1M_BSM_FLASHING_OR_DEFAULT:
if (hit_points <= (LARA_HITPOINTS * 20) / 100) { show |= hit_points <= (LARA_HITPOINTS * 20) / 100;
show = 1; break;
} case T1M_BSM_FLASHING_ONLY:
show = hit_points <= (LARA_HITPOINTS * 20) / 100;
break; break;
} }
if (!show) { if (!show) {
@ -88,11 +89,12 @@ void DrawAirBar()
break; break;
case T1M_BSM_NEVER: case T1M_BSM_NEVER:
show = 0; show = 0;
return; break;
case T1M_BSM_FLASHING: case T1M_BSM_FLASHING_OR_DEFAULT:
if (Lara.air > (LARA_AIR * 20) / 100) { show |= Lara.air <= (LARA_AIR * 20) / 100;
show = 0; break;
} case T1M_BSM_FLASHING_ONLY:
show = Lara.air <= (LARA_AIR * 20) / 100;
break; break;
} }
if (!show) { if (!show) {