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

151 lines
6.0 KiB
Diff
Raw Permalink Normal View History

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(-)
2024-08-15 18:17:06 +02:00
Index: dsda-doom-0.28.0/prboom2/src/dsda/configuration.c
===================================================================
--- dsda-doom-0.28.0.orig/prboom2/src/dsda/configuration.c
+++ dsda-doom-0.28.0/prboom2/src/dsda/configuration.c
@@ -604,6 +604,10 @@ dsda_config_t dsda_config[dsda_config_co
"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
2024-08-15 18:17:06 +02:00
Index: dsda-doom-0.28.0/prboom2/src/dsda/configuration.h
===================================================================
--- dsda-doom-0.28.0.orig/prboom2/src/dsda/configuration.h
+++ dsda-doom-0.28.0/prboom2/src/dsda/configuration.h
@@ -121,6 +121,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,
2024-08-15 18:17:06 +02:00
Index: dsda-doom-0.28.0/prboom2/src/dsda/settings.c
===================================================================
--- dsda-doom-0.28.0.orig/prboom2/src/dsda/settings.c
+++ dsda-doom-0.28.0/prboom2/src/dsda/settings.c
@@ -251,6 +251,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);
}
2024-08-15 18:17:06 +02:00
Index: dsda-doom-0.28.0/prboom2/src/dsda/settings.h
===================================================================
--- dsda-doom-0.28.0.orig/prboom2/src/dsda/settings.h
+++ dsda-doom-0.28.0/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);
2024-08-15 18:17:06 +02:00
Index: dsda-doom-0.28.0/prboom2/src/gl_intern.h
===================================================================
--- dsda-doom-0.28.0.orig/prboom2/src/gl_intern.h
+++ dsda-doom-0.28.0/prboom2/src/gl_intern.h
@@ -216,6 +216,7 @@ typedef enum
health_bar_null,
health_bar_red,
health_bar_yellow,
+ health_bar_green,
} health_bar_color_t;
typedef struct
2024-08-15 18:17:06 +02:00
Index: dsda-doom-0.28.0/prboom2/src/gl_main.c
===================================================================
--- dsda-doom-0.28.0.orig/prboom2/src/gl_main.c
+++ dsda-doom-0.28.0/prboom2/src/gl_main.c
@@ -2031,12 +2031,18 @@ static void gld_DrawSprite(GLSprite *spr
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)
2024-08-15 18:17:06 +02:00
@@ -2063,10 +2069,11 @@ static void gld_AddHealthBar(mobj_t* thi
}
}
-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)
2024-08-15 18:17:06 +02:00
Index: dsda-doom-0.28.0/prboom2/src/m_menu.c
===================================================================
--- dsda-doom-0.28.0.orig/prboom2/src/m_menu.c
+++ dsda-doom-0.28.0/prboom2/src/m_menu.c
@@ -3155,6 +3155,7 @@ setup_menu_t demo_settings[] = {
{ "Coop Spawns", S_YESNO, m_conf, G_X, dsda_config_coop_spawns },
{ "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),
2024-08-15 18:17:06 +02:00
Index: dsda-doom-0.28.0/prboom2/src/m_misc.c
===================================================================
--- dsda-doom-0.28.0.orig/prboom2/src/m_misc.c
+++ dsda-doom-0.28.0/prboom2/src/m_misc.c
@@ -171,6 +171,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),