diff --git a/Tomb1Main.json b/Tomb1Main.json index b0a44f28b..1fb177a28 100644 --- a/Tomb1Main.json +++ b/Tomb1Main.json @@ -14,9 +14,6 @@ // Removes all shotgun and shotgun shells pickups. "disable_shotgun": false, - // Replaces the default golden healthbar with a red one. - "enable_red_healthbar": true, - // Enables showing healthbar for the active enemy. "enable_enemy_healthbar": true, @@ -64,12 +61,30 @@ // - bottom-right "healthbar_location": "top-left", + // Color of the healthbar. Possible values: + // - gold (game default) + // - red + // - grey + // - blue + // - silver + // - green + // - gold2 + // - blue2 + // - pink + "healthbar_color": "red", + // Location where the airbar is displayed. "airbar_location": "top-right", + // Color of the airbar. + "airbar_color": "blue", + // Location where the enemy healthbar is displayed. "enemy_healthbar_location": "bottom-left", + // Color of the enemy healthbar. + "enemy_healthbar_color": "grey", + // Fixes game freeze when ending the level with the Action key held. "fix_end_of_level_freeze": true, diff --git a/src/config.c b/src/config.c index 9ade64058..500cd8887 100644 --- a/src/config.c +++ b/src/config.c @@ -23,6 +23,34 @@ static int8_t ReadBarShowingMode(struct json_value_s* root, const char* name) return T1M_BSM_DEFAULT; } +static int8_t ReadBarColorConfig( + struct json_value_s* root, const char* name, int8_t default_value) +{ + const char* value_str = JSONGetStringValue(root, name); + if (!value_str) { + return default_value; + } else if (!strcmp(value_str, "gold")) { + return T1M_BC_GOLD; + } else if (!strcmp(value_str, "blue")) { + return T1M_BC_BLUE; + } else if (!strcmp(value_str, "grey")) { + return T1M_BC_GREY; + } else if (!strcmp(value_str, "red")) { + return T1M_BC_RED; + } else if (!strcmp(value_str, "silver")) { + return T1M_BC_SILVER; + } else if (!strcmp(value_str, "green")) { + return T1M_BC_GREEN; + } else if (!strcmp(value_str, "gold2")) { + return T1M_BC_GOLD2; + } else if (!strcmp(value_str, "blue2")) { + return T1M_BC_BLUE2; + } else if (!strcmp(value_str, "pink")) { + return T1M_BC_PINK; + } + return default_value; +} + static int8_t ReadBarLocationConfig( struct json_value_s* root, const char* name, int8_t default_value) { @@ -72,7 +100,6 @@ int T1MReadConfig() READ_BOOL(disable_magnums); READ_BOOL(disable_uzis); READ_BOOL(disable_shotgun); - READ_BOOL(enable_red_healthbar); READ_BOOL(enable_enemy_healthbar); READ_BOOL(enable_enhanced_look); READ_BOOL(enable_enhanced_ui); @@ -94,6 +121,13 @@ int T1MReadConfig() T1MConfig.enemy_healthbar_location = ReadBarLocationConfig( json, "enemy_healthbar_location", T1M_BL_BOTTOM_LEFT); + T1MConfig.healthbar_color = + ReadBarColorConfig(json, "healthbar_color", T1M_BC_RED); + T1MConfig.airbar_color = + ReadBarColorConfig(json, "airbar_color", T1M_BC_BLUE); + T1MConfig.enemy_healthbar_color = + ReadBarColorConfig(json, "enemy_healthbar_color", T1M_BC_GREY); + free(json); free(cfg_data); return 1; diff --git a/src/config.h b/src/config.h index addb4bf2a..668cd4799 100644 --- a/src/config.h +++ b/src/config.h @@ -12,6 +12,18 @@ typedef enum { T1M_BL_BOTTOM_RIGHT = 5, } T1M_BAR_LOCATION; +typedef enum { + T1M_BC_GOLD = 0, + T1M_BC_BLUE = 1, + T1M_BC_GREY = 2, + T1M_BC_RED = 3, + T1M_BC_SILVER = 4, + T1M_BC_GREEN = 5, + T1M_BC_GOLD2 = 6, + T1M_BC_BLUE2 = 7, + T1M_BC_PINK = 8, +} T1M_BAR_COLOR; + typedef enum { T1M_BSM_DEFAULT = 0, T1M_BSM_FLASHING = 1, @@ -24,7 +36,6 @@ struct { int8_t disable_magnums; int8_t disable_uzis; int8_t disable_shotgun; - int8_t enable_red_healthbar; int8_t enable_enemy_healthbar; int8_t enable_enhanced_look; int8_t enable_enhanced_ui; @@ -33,8 +44,11 @@ struct { int8_t enable_cheats; int8_t healthbar_showing_mode; int8_t healthbar_location; + int8_t healthbar_color; int8_t airbar_location; + int8_t airbar_color; int8_t enemy_healthbar_location; + int8_t enemy_healthbar_color; int8_t fix_end_of_level_freeze; int8_t fix_tihocan_secret_sound; int8_t fix_pyramid_secret_trigger; diff --git a/src/specific/output.c b/src/specific/output.c index 3d49314c1..d2bd1275f 100644 --- a/src/specific/output.c +++ b/src/specific/output.c @@ -7,10 +7,18 @@ #define COLOR_BAR_SIZE 5 -static int color_bar[][COLOR_BAR_SIZE] = { - { 8, 11, 8, 6, 24 }, - { 32, 41, 32, 19, 21 }, - { 18, 17, 18, 19, 21 }, +static int8_t color_bar_map[][COLOR_BAR_SIZE] = { + { 8, 11, 8, 6, 24 }, // gold + { 32, 41, 32, 19, 21 }, // blue +#ifdef T1M_FEAT_UI + { 18, 17, 18, 19, 21 }, // grey + { 29, 30, 29, 28, 26 }, // red + { 76, 77, 76, 75, 74 }, // silver + { 141, 143, 141, 139, 136 }, // green + { 119, 118, 119, 121, 123 }, // gold2 + { 113, 112, 113, 114, 115 }, // blue2 + { 193, 194, 192, 191, 189 }, // pink +#endif }; #ifdef T1M_FEAT_UI @@ -94,14 +102,6 @@ void RenderBar(int value, int value_max, int bar_type) } int percent = value * 100 / value_max; - if (T1MConfig.enable_red_healthbar) { - color_bar[BT_LARA_HEALTH][0] = 29; - color_bar[BT_LARA_HEALTH][1] = 30; - color_bar[BT_LARA_HEALTH][2] = 29; - color_bar[BT_LARA_HEALTH][3] = 28; - color_bar[BT_LARA_HEALTH][4] = 26; - } - const int color_border_1 = 19; const int color_border_2 = 17; const int color_bgnd = 0; @@ -109,17 +109,21 @@ void RenderBar(int value, int value_max, int bar_type) int32_t scale = GetRenderScaleGLRage(1); int32_t width = percent_max * scale; int32_t height = 5 * scale; + int16_t bar_color = bar_type; #ifdef T1M_FEAT_UI int x; int y; if (bar_type == BT_LARA_HEALTH) { BarLocation(T1MConfig.healthbar_location, scale, width, height, &x, &y); + bar_color = T1MConfig.healthbar_color; } else if (bar_type == BT_LARA_AIR) { BarLocation(T1MConfig.airbar_location, scale, width, height, &x, &y); + bar_color = T1MConfig.airbar_color; } else if (bar_type == BT_ENEMY_HEALTH) { BarLocation( T1MConfig.enemy_healthbar_location, scale, width, height, &x, &y); + bar_color = T1MConfig.enemy_healthbar_color; } #else int x = 8 * scale; @@ -170,7 +174,7 @@ void RenderBar(int value, int value_max, int bar_type) int color_index = i * COLOR_BAR_SIZE / height; Insert2DLine( left, top + i, right, top + i, p3, - color_bar[bar_type][color_index]); + color_bar_map[bar_color][color_index]); } } }