Skip to content

Commit

Permalink
add option to always show the healthbar
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Feb 15, 2021
1 parent 3b4b373 commit 8b09221
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ Currently the following configuration options are supported:
- <kbd>4</kbd>: draw UZI
- <kbd>8</kbd>: use small medpack
- <kbd>9</kbd>: use large medpack
- `healthbar_showing_mode`: change when the healthbar is displayed. Possible values:
- `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
getting hit or while having weapons equipped (as in OG)
- `fix_end_of_level_freeze`: fix game freeze when ending the level with the
Action key held.
- `fix_tihocan_secret_sound`: disable the secret sound incorrectly playing
Expand Down
1 change: 1 addition & 0 deletions TR1Main.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"enable_enhanced_look": true,
"enable_enhanced_ui": true,
"enable_numeric_keys": true,
"healthbar_showing_mode": "flashing",
"fix_end_of_level_freeze": true,
"fix_tihocan_secret_sound": true
}
7 changes: 7 additions & 0 deletions src/game/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ int32_t __cdecl ControlPhase(int32_t nframes, int demo_mode)
LaraItem ? LaraItem->hit_points : LARA_HITPOINTS;
}
}

if (TR1MConfig.healthbar_showing_mode == TR1M_BSM_ALWAYS
|| (TR1MConfig.healthbar_showing_mode == TR1M_BSM_FLASHING
&& LaraItem
&& LaraItem->hit_points < (LARA_HITPOINTS * 20) / 100)) {
HealthBarTimer = 1;
}
}
return 0;
}
Expand Down
6 changes: 6 additions & 0 deletions src/json_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ int tr1m_json_get_boolean_value(json_value* root, const char* name)
json_value* field = tr1m_json_get_field(root, json_boolean, name, NULL);
return field ? field->u.boolean : 0;
}

const char* tr1m_json_get_string_value(json_value* root, const char* name)
{
json_value* field = tr1m_json_get_field(root, json_string, name, NULL);
return field ? field->u.string.ptr : NULL;
}
1 change: 1 addition & 0 deletions src/json_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ json_value* tr1m_json_get_field(
json_value* root, json_type field_type, const char* name, int* pIndex);

int tr1m_json_get_boolean_value(json_value* root, const char* name);
const char* tr1m_json_get_string_value(json_value* root, const char* name);

#endif
12 changes: 12 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ static int TR1MReadConfig()
tr1m_json_get_boolean_value(json, "enable_enhanced_look");
TR1MConfig.enable_enhanced_ui =
tr1m_json_get_boolean_value(json, "enable_enhanced_ui");

const char* healthbar_showing_mode =
tr1m_json_get_string_value(json, "healthbar_showing_mode");
TR1MConfig.healthbar_showing_mode = TR1M_BSM_DEFAULT;
if (healthbar_showing_mode) {
if (!strcmp(healthbar_showing_mode, "flashing")) {
TR1MConfig.healthbar_showing_mode = TR1M_BSM_FLASHING;
} else if (!strcmp(healthbar_showing_mode, "always")) {
TR1MConfig.healthbar_showing_mode = TR1M_BSM_ALWAYS;
}
}

TR1MConfig.enable_numeric_keys =
tr1m_json_get_boolean_value(json, "enable_numeric_keys");
TR1MConfig.fix_end_of_level_freeze =
Expand Down
7 changes: 7 additions & 0 deletions src/mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ typedef enum {
TR1M_BAR_NUMBER = 3,
} TR1M_BAR;

typedef enum {
TR1M_BSM_DEFAULT = 0,
TR1M_BSM_FLASHING = 1,
TR1M_BSM_ALWAYS = 2,
} TR1M_BAR_SHOW_MODE;

struct {
int disable_healing_between_levels;
int disable_medpacks;
Expand All @@ -21,6 +27,7 @@ struct {
int enable_enhanced_look;
int enable_enhanced_ui;
int enable_numeric_keys;
int healthbar_showing_mode;
int fix_end_of_level_freeze;
int fix_tihocan_secret_sound;
} TR1MConfig;
Expand Down

0 comments on commit 8b09221

Please sign in to comment.