1
0
forked from pool/dsda-doom
dsda-doom/prboom-hbar-all.diff

154 lines
5.6 KiB
Diff

From 882bcbe9f612b2bcc0daab095d73c7fb5e9723be Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Wed, 1 May 2013 09:53:49 +0200
Subject: [PATCH 1/2] Add option to show health bar for all destructible mobjs
Origin: https://github.com/jengelh/dsda-doom
The current health bar fails to show for Lost Souls. In addition,
showing it for other destructible objects (such as barrels - or DEH
modifications in that spirit) can be used to gauge the objects'
remaining life.
---
prboom2/src/dsda/configuration.c | 4 ++++
prboom2/src/dsda/configuration.h | 1 +
prboom2/src/dsda/settings.c | 5 +++++
prboom2/src/dsda/settings.h | 1 +
prboom2/src/gl_intern.h | 1 +
prboom2/src/gl_main.c | 13 ++++++++++---
prboom2/src/m_menu.c | 1 +
prboom2/src/m_misc.c | 1 +
8 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/prboom2/src/dsda/configuration.c b/prboom2/src/dsda/configuration.c
index e0fe40ecf..b1197ee17 100644
--- a/prboom2/src/dsda/configuration.c
+++ b/prboom2/src/dsda/configuration.c
@@ -597,6 +597,10 @@ dsda_config_t dsda_config[dsda_config_count] = {
"gl_health_bar", dsda_config_gl_health_bar,
CONF_BOOL(0), NULL, STRICT_INT(0)
},
+ [dsda_config_gl_health_bar_shootables] = {
+ "gl_health_bar_shootables", dsda_config_gl_health_bar_shootables,
+ CONF_BOOL(0), NULL, NOT_STRICT
+ },
[dsda_config_gl_usevbo] = {
"gl_usevbo", dsda_config_gl_usevbo,
CONF_BOOL(1), NULL, NOT_STRICT
diff --git a/prboom2/src/dsda/configuration.h b/prboom2/src/dsda/configuration.h
index 4bf8531b4..f32f4c6b2 100644
--- a/prboom2/src/dsda/configuration.h
+++ b/prboom2/src/dsda/configuration.h
@@ -119,6 +119,7 @@ typedef enum {
dsda_config_gl_render_multisampling,
dsda_config_gl_render_fov,
dsda_config_gl_health_bar,
+ dsda_config_gl_health_bar_shootables,
dsda_config_gl_usevbo,
dsda_config_gl_fade_mode,
dsda_config_use_mouse,
diff --git a/prboom2/src/dsda/settings.c b/prboom2/src/dsda/settings.c
index c417705bd..6019ed07d 100644
--- a/prboom2/src/dsda/settings.c
+++ b/prboom2/src/dsda/settings.c
@@ -248,6 +248,11 @@ dboolean dsda_ShowHealthBars(void) {
return dsda_IntConfig(dsda_config_gl_health_bar);
}
+dboolean dsda_ShowHealthBarsForShootables(void)
+{
+ return dsda_IntConfig(dsda_config_gl_health_bar_shootables);
+}
+
dboolean dsda_WipeAtFullSpeed(void) {
return dsda_IntConfig(dsda_config_wipe_at_full_speed);
}
diff --git a/prboom2/src/dsda/settings.h b/prboom2/src/dsda/settings.h
index a2fc9bf95..1988c5140 100644
--- a/prboom2/src/dsda/settings.h
+++ b/prboom2/src/dsda/settings.h
@@ -50,6 +50,7 @@ dboolean dsda_ShowMinimap(void);
dboolean dsda_ShowLevelSplits(void);
dboolean dsda_ShowDemoAttempts(void);
dboolean dsda_ShowHealthBars(void);
+dboolean dsda_ShowHealthBarsForShootables(void);
dboolean dsda_MapCoordinates(void);
dboolean dsda_MapTotals(void);
dboolean dsda_MapTime(void);
diff --git a/prboom2/src/gl_intern.h b/prboom2/src/gl_intern.h
index 0040edd1d..f55c66049 100644
--- a/prboom2/src/gl_intern.h
+++ b/prboom2/src/gl_intern.h
@@ -218,6 +218,7 @@ typedef enum
health_bar_null,
health_bar_red,
health_bar_yellow,
+ health_bar_green,
} health_bar_color_t;
typedef struct
diff --git a/prboom2/src/gl_main.c b/prboom2/src/gl_main.c
index e2458fd9f..92e5a7b38 100644
--- a/prboom2/src/gl_main.c
+++ b/prboom2/src/gl_main.c
@@ -2033,12 +2033,18 @@ static void gld_DrawSprite(GLSprite *sprite)
static void gld_AddHealthBar(mobj_t* thing, GLSprite *sprite)
{
- if (((thing->flags & (MF_COUNTKILL | MF_CORPSE)) == MF_COUNTKILL) && (thing->health > 0))
+ bool all_shoot = dsda_ShowHealthBarsForShootables();
+ int init_color = all_shoot ? health_bar_green : health_bar_null;
+ bool show_bar = all_shoot ?
+ thing->flags & MF_SHOOTABLE :
+ (thing->flags & (MF_COUNTKILL | MF_CORPSE)) == MF_COUNTKILL;
+
+ if (thing->health > 0 && show_bar)
{
GLHealthBar hbar;
int health_percent = thing->health * 100 / P_MobjSpawnHealth(thing);
- hbar.color = health_bar_null;
+ hbar.color = init_color;
if (health_percent <= 50)
hbar.color = health_bar_red;
else if (health_percent <= 99)
@@ -2065,10 +2071,11 @@ static void gld_AddHealthBar(mobj_t* thing, GLSprite *sprite)
}
}
-static GLfloat health_bar_rgb[3][3] = {
+static GLfloat health_bar_rgb[][3] = {
[health_bar_null] = { 0.0f, 0.0f, 0.0f },
[health_bar_red] = { 1.0f, 0.0f, 0.0f },
[health_bar_yellow] = { 1.0f, 1.0f, 0.0f },
+ [health_bar_green] = { 0.0f, 1.0f, 0.0f },
};
static void gld_DrawHealthBars(void)
diff --git a/prboom2/src/m_menu.c b/prboom2/src/m_menu.c
index fc3d22c82..7bc30508b 100644
--- a/prboom2/src/m_menu.c
+++ b/prboom2/src/m_menu.c
@@ -3052,6 +3052,7 @@ setup_menu_t demo_settings[] = {
{ "Casual Play Settings", S_SKIP | S_TITLE, m_null, G_X},
{ "Allow Jumping", S_YESNO, m_conf, G_X, dsda_config_allow_jumping },
{ "OpenGL Show Health Bars", S_YESNO, m_conf, G_X, dsda_config_gl_health_bar },
+ { "All Shootables have Health Bar", S_YESNO, m_conf, G_X, dsda_config_gl_health_bar_shootables },
PREV_PAGE(mapping_settings),
NEXT_PAGE(tas_settings),
diff --git a/prboom2/src/m_misc.c b/prboom2/src/m_misc.c
index 62b7160a1..b7cc44a72 100644
--- a/prboom2/src/m_misc.c
+++ b/prboom2/src/m_misc.c
@@ -169,6 +169,7 @@ cfg_def_t cfg_defs[] =
MIGRATED_SETTING(dsda_config_gl_render_fov),
MIGRATED_SETTING(dsda_config_gl_skymode),
MIGRATED_SETTING(dsda_config_gl_health_bar),
+ MIGRATED_SETTING(dsda_config_gl_health_bar_shootables),
MIGRATED_SETTING(dsda_config_gl_usevbo),
MIGRATED_SETTING(dsda_config_gl_fade_mode),
--
2.42.1