From 9bc76b4776da207e2425f736d46aedf5c3c1b64c7968056f5f6dcc79dbeca7fa Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 14 Nov 2023 21:30:46 +0000 Subject: [PATCH] update hbar patches for 0.27 OBS-URL: https://build.opensuse.org/package/show/games/dsda-doom?expand=0&rev=9 --- cmake-path-suffix.diff | 4 +- dsda-doom.spec | 4 +- prboom-hbar-all.diff | 193 ++++++++++++++++++++++++++------------ prboom-hbar-gradient.diff | 151 ++++++++++++++++++----------- 4 files changed, 237 insertions(+), 115 deletions(-) diff --git a/cmake-path-suffix.diff b/cmake-path-suffix.diff index 696b7b6..cd9a4cd 100644 --- a/cmake-path-suffix.diff +++ b/cmake-path-suffix.diff @@ -17,17 +17,19 @@ Index: dsda-doom-0.27.2/prboom2/cmake/FindLibMad.cmake =================================================================== --- dsda-doom-0.27.2.orig/prboom2/cmake/FindLibMad.cmake +++ dsda-doom-0.27.2/prboom2/cmake/FindLibMad.cmake -@@ -59,13 +59,11 @@ select_dll_configurations(LibMad) +@@ -59,13 +59,13 @@ select_dll_configurations(LibMad) find_library( LibMad_LIBRARY_RELEASE NAMES mad - PATH_SUFFIXES ../../lib ++ PATH_SUFFIXES ${CMAKE_CURRENT_BINARY_DIR}/../../lib ) find_library( LibMad_LIBRARY_DEBUG NAMES mad - PATH_SUFFIXES ../debug/lib ++ PATH_SUFFIXES ${CMAKE_CURRENT_BINARY_DIR}/../debug/lib ) include(SelectLibraryConfigurations) diff --git a/dsda-doom.spec b/dsda-doom.spec index d135c93..cb20911 100644 --- a/dsda-doom.spec +++ b/dsda-doom.spec @@ -28,8 +28,8 @@ URL: https://github.com/kraflab/dsda-doom #Announce: https://www.doomworld.com/forum/topic/118074-dsda-doom-source-port-v0243/ Source: https://github.com/kraflab/dsda-doom/archive/refs/tags/v%version.tar.gz Patch1: cmake-path-suffix.diff -#Patch2: prboom-hbar-all.diff -#Patch3: prboom-hbar-gradient.diff +Patch2: prboom-hbar-all.diff +Patch3: prboom-hbar-gradient.diff BuildRequires: Mesa-devel BuildRequires: c++_compiler BuildRequires: cmake diff --git a/prboom-hbar-all.diff b/prboom-hbar-all.diff index d0e0db3..983b67f 100644 --- a/prboom-hbar-all.diff +++ b/prboom-hbar-all.diff @@ -1,76 +1,153 @@ -From f8dc397539f27c601aa6f1f3ea0f6c1f177efd97 Mon Sep 17 00:00:00 2001 +From 882bcbe9f612b2bcc0daab095d73c7fb5e9723be Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 1 May 2013 09:53:49 +0200 Subject: [PATCH 1/2] Add option to show health bar for all destructible mobjs -References: https://github.com/coelckers/prboom-plus/pull/274 +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. +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/gl_main.c | 10 +++++++++- - prboom2/src/m_misc.c | 1 + - prboom2/src/r_things.c | 1 + - prboom2/src/r_things.h | 1 + - 4 files changed, 12 insertions(+), 1 deletion(-) + 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(-) -Index: prboom2/src/gl_main.c -=================================================================== ---- prboom2/src/gl_main.c.orig -+++ prboom2/src/gl_main.c -@@ -2467,9 +2467,17 @@ static void gld_DrawSprite(GLSprite *spr - } +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); } -+static int gld_EvaluateShowBar(mobj_t* thing) ++dboolean dsda_ShowHealthBarsForShootables(void) +{ -+ if (health_bar_shootables) -+ return thing->flags & MF_SHOOTABLE; -+ return (thing->flags & (MF_COUNTKILL | MF_CORPSE)) == MF_COUNTKILL; ++ 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)) -+ if (thing->info->spawnhealth > 0 && thing->health > 0 && -+ gld_EvaluateShowBar(thing)) ++ 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 / thing->info->spawnhealth; -Index: prboom2/src/m_misc.c -=================================================================== ---- prboom2/src/m_misc.c.orig -+++ prboom2/src/m_misc.c -@@ -997,6 +997,7 @@ default_t defaults[] = - { "screenshot_dir", { NULL, &screenshot_dir }, { 0, "" }, UL, UL, def_str, ss_none }, - { "health_bar", { &health_bar }, { 0 }, 0, 1, def_bool, ss_stat }, - { "health_bar_full_length", { &health_bar_full_length }, { 1 }, 0, 1, def_bool, ss_stat }, -+ { "health_bar_shootables", { &health_bar_shootables }, { 0 }, 0, 1, def_bool, ss_stat }, - { "health_bar_red", { &health_bar_red }, { 50 }, 0, 100, def_int, ss_stat }, - { "health_bar_yellow", { &health_bar_yellow }, { 99 }, 0, 100, def_int, ss_stat }, - { "health_bar_green", { &health_bar_green }, { 0 }, 0, 100, def_int, ss_stat }, -Index: prboom2/src/r_things.c -=================================================================== ---- prboom2/src/r_things.c.orig -+++ prboom2/src/r_things.c -@@ -75,6 +75,7 @@ int sprites_doom_order; + int health_percent = thing->health * 100 / P_MobjSpawnHealth(thing); - int health_bar; - int health_bar_full_length; -+int health_bar_shootables; - int health_bar_red; - int health_bar_yellow; - int health_bar_green; -Index: prboom2/src/r_things.h -=================================================================== ---- prboom2/src/r_things.h.orig -+++ prboom2/src/r_things.h -@@ -75,6 +75,7 @@ extern int sprites_doom_order; +- 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) + } + } - extern int health_bar; - extern int health_bar_full_length; -+extern int health_bar_shootables; - extern int health_bar_red; - extern int health_bar_yellow; - extern int health_bar_green; +-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 + diff --git a/prboom-hbar-gradient.diff b/prboom-hbar-gradient.diff index 0ef45d5..624966a 100644 --- a/prboom-hbar-gradient.diff +++ b/prboom-hbar-gradient.diff @@ -1,85 +1,128 @@ -From be1128c66a342ca381532ac3c6bcd286d871fdc3 Mon Sep 17 00:00:00 2001 +From bef62d87d8de7236d2a6b306c588440b885f579b Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 1 May 2013 09:53:49 +0200 -Subject: [PATCH 2/2] Implement color gradient for health bar -References: https://github.com/coelckers/prboom-plus/pull/274 +Subject: [PATCH] Implement color gradient for health bar +I drew inspiration from the gradient bars from Fire Fight. --- - prboom2/src/gl_intern.h | 2 +- - prboom2/src/gl_main.c | 31 +++++++++++++++++-------------- - 2 files changed, 18 insertions(+), 15 deletions(-) + prboom2/src/gl_intern.h | 11 +-------- + prboom2/src/gl_main.c | 52 ++++++++++++++++++++++++----------------- + 2 files changed, 31 insertions(+), 32 deletions(-) -diff --git prboom2/src/gl_intern.h prboom2/src/gl_intern.h -index b4be8d56..8c44d9a7 100644 ---- prboom2/src/gl_intern.h -+++ prboom2/src/gl_intern.h -@@ -219,7 +219,7 @@ typedef struct +diff --git a/prboom2/src/gl_intern.h b/prboom2/src/gl_intern.h +index f55c66049..b5a0d7f83 100644 +--- a/prboom2/src/gl_intern.h ++++ b/prboom2/src/gl_intern.h +@@ -213,18 +213,9 @@ typedef struct + float light; + } GLShadow; +-typedef enum +-{ +- health_bar_null, +- health_bar_red, +- health_bar_yellow, +- health_bar_green, +-} health_bar_color_t; +- typedef struct { -- int cm; -+ float r,g; - +- health_bar_color_t color; +- ++ float cr, cg; float x1, x2, x3; float z1, z2, z3; -diff --git prboom2/src/gl_main.c prboom2/src/gl_main.c -index 763bcbae..8dcb03fd 100644 ---- prboom2/src/gl_main.c -+++ prboom2/src/gl_main.c -@@ -2340,16 +2340,24 @@ static void gld_AddHealthBar(mobj_t* thing, GLSprite *sprite) + float y; +diff --git a/prboom2/src/gl_main.c b/prboom2/src/gl_main.c +index 92e5a7b38..b5f023c60 100644 +--- a/prboom2/src/gl_main.c ++++ b/prboom2/src/gl_main.c +@@ -2034,24 +2034,41 @@ static void gld_DrawSprite(GLSprite *sprite) + static void gld_AddHealthBar(mobj_t* thing, GLSprite *sprite) + { + 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; ++ /* ++ * These were called "health_bar_red", "health_bar_yellow" and ++ * "health_bar_green", respectively, in prboom-plus. I have given ++ * them some better names. —j.eng ++ */ ++ static const int orange_ramp_end = 50; ++ static const int chartreuse_ramp_end = 99; ++ static const int green_end = 100; + + if (thing->health > 0 && show_bar) { GLHealthBar hbar; - int health_percent = thing->health * 100 / thing->info->spawnhealth; -+ int yr = health_bar_yellow - health_bar_red; + int health_percent = thing->health * 100 / P_MobjSpawnHealth(thing); ++ int yr = chartreuse_ramp_end - orange_ramp_end; -- hbar.cm = -1; -- if (health_percent <= health_bar_red) -- hbar.cm = CR_RED; -- else if (health_percent <= health_bar_yellow) -- hbar.cm = CR_YELLOW; -- else if (health_percent <= health_bar_green) -- hbar.cm = CR_GREEN; -+ hbar.r = hbar.g = -1.0f; -+ if (health_percent <= 0) { -+ hbar.r = 1.0f; -+ hbar.g = 0.0f; -+ } else if (health_percent <= health_bar_red) { -+ hbar.r = 1.0f; -+ hbar.g = yr == 0 ? 0 : (float)health_percent / yr; -+ } else if (health_percent <= health_bar_yellow) { -+ hbar.r = yr == 0 ? 1 : (float)(health_bar_yellow - health_percent) / yr; -+ hbar.g = 1.0f; -+ } else if (health_percent <= health_bar_green) { -+ hbar.r = 0.0f; -+ hbar.g = 1.0f; +- hbar.color = init_color; +- if (health_percent <= 50) +- hbar.color = health_bar_red; +- else if (health_percent <= 99) +- hbar.color = health_bar_yellow; ++ hbar.cr = -1; ++ if (!all_shoot && health_percent == 100) { ++ } else if (health_percent <= 0) { ++ hbar.cr = 1; ++ hbar.cg = 0; ++ } else if (health_percent <= orange_ramp_end) { ++ hbar.cr = 1; ++ hbar.cg = yr == 0 ? 0 : (float)health_percent / yr; ++ } else if (health_percent <= chartreuse_ramp_end) { ++ hbar.cr = yr == 0 ? 1 : (float)(chartreuse_ramp_end - health_percent) / yr; ++ hbar.cg = 1; ++ } else if (health_percent <= green_end) { ++ hbar.cr = 0; ++ hbar.cg = 1; + } -- if (hbar.cm >= 0) -+ if (hbar.r >= 0 && hbar.g >= 0) - { +- if (hbar.color != health_bar_null) +- { ++ if (hbar.cr >= 0) { float sx2 = (float)thing->radius / 2.0f / MAP_SCALE; float sx1 = sx2 - (float)health_percent * (float)thing->radius / 100.0f / MAP_SCALE; -@@ -2373,7 +2381,6 @@ static void gld_AddHealthBar(mobj_t* thing, GLSprite *sprite) + float sx3 = -sx2; +@@ -2071,17 +2088,10 @@ static void gld_AddHealthBar(mobj_t* thing, GLSprite *sprite) + } + } + +-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) { int i, count; -- int cm = -1; +- int color = health_bar_null; ++ float cr = -1, cg = -1; count = gld_drawinfo.num_items[GLDIT_HBAR]; if (count > 0) -@@ -2384,11 +2391,7 @@ static void gld_DrawHealthBars(void) +@@ -2092,12 +2102,10 @@ static void gld_DrawHealthBars(void) for (i = count - 1; i >= 0; i--) { GLHealthBar *hbar = gld_drawinfo.items[GLDIT_HBAR][i].item.hbar; -- if (hbar->cm != cm) +- if (hbar->color != color) - { -- cm = hbar->cm; -- glColor4f(cm2RGB[cm][0], cm2RGB[cm][1], cm2RGB[cm][2], 1.0f); -- } -+ glColor4f(hbar->r, hbar->g, 0.0f, 1.0f); +- color = hbar->color; +- glColor4f(health_bar_rgb[color][0], +- health_bar_rgb[color][1], +- health_bar_rgb[color][2], 1.0f); ++ if (hbar->cr != cr || hbar->cg != cg) { ++ cr = hbar->cr; ++ cg = hbar->cg; ++ glColor4f(cr, cg, 0, 1); + } glVertex3f(hbar->x1, hbar->y, hbar->z1); - glVertex3f(hbar->x2, hbar->y, hbar->z2); -- -2.31.1 +2.42.1