From 09e52541054122c9dce26eb2e9816369c807f377 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Fri, 7 Jan 2022 12:58:16 +0100 Subject: [PATCH] additional widget colors options (#405) * additional widget colors options * backpack changes thresholds (fixes #399) * color of armor depends on type * consistent wording --- Source/hu_stuff.c | 18 ++++++++++++++++++ Source/m_menu.c | 24 ++++++++++++++++++++++-- Source/m_misc.c | 16 ++++++++++++++++ Source/st_stuff.c | 25 +++++++++++++++++++++++-- Source/st_stuff.h | 3 +++ 5 files changed, 82 insertions(+), 4 deletions(-) diff --git a/Source/hu_stuff.c b/Source/hu_stuff.c index ec274ef3..d54329f3 100644 --- a/Source/hu_stuff.c +++ b/Source/hu_stuff.c @@ -984,6 +984,10 @@ void HU_Drawer(void) hud_ammostr[i] = '\0'; strcat(hud_ammostr,ammostr); + // backpack changes thresholds (ammo widget) + if (plr->backpack && !hud_backpack_thresholds && fullammo) + ammopct = (100*ammo)/(fullammo/2); + // set the display color from the percentage of total ammo held if (ammopctarmortype) ? colrngs[CR_RED] : + (plr->armortype == 1) ? colrngs[CR_GREEN] : colrngs[CR_BLUE]; + } + else + { // set the display color from the amount of armor posessed w_armor.cr = armorbackpack && !hud_backpack_thresholds && fullammo) + ammopct = (100*ammo)/(fullammo/2); + // display each weapon number in a color related to the ammo for it hud_weapstr[i++] = '\x1b'; //jff 3/26/98 use ESC not '\' for paths if (weaponinfo[w].ammo==am_noammo) //jff 3/14/98 show berserk on HUD diff --git a/Source/m_menu.c b/Source/m_menu.c index b6f78aea..4f322270 100644 --- a/Source/m_menu.c +++ b/Source/m_menu.c @@ -3076,10 +3076,12 @@ void M_DrawWeapons(void) // Screen table definitions setup_menu_t stat_settings1[]; +setup_menu_t stat_settings2[]; setup_menu_t* stat_settings[] = { stat_settings1, + stat_settings2, NULL }; @@ -3102,12 +3104,30 @@ setup_menu_t stat_settings1[] = // Status Bar and HUD Settings screen {"ARMOR GOOD/EXTRA" ,S_NUM ,m_null,ST_X,ST_Y+13*8, {"armor_green"}}, {"AMMO LOW/OK" ,S_NUM ,m_null,ST_X,ST_Y+14*8, {"ammo_red"}}, {"AMMO OK/GOOD" ,S_NUM ,m_null,ST_X,ST_Y+15*8, {"ammo_yellow"}}, - {"\"A SECRET IS REVEALED!\" MESSAGE",S_YESNO,m_null,ST_X,ST_Y+17*8, {"hud_secret_message"}}, - {"SHOW TIME/STS ABOVE STATUS BAR",S_YESNO,m_null,ST_X,ST_Y+18*8, {"hud_timests"}}, // Button for resetting to defaults {0,S_RESET,m_null,X_BUTTON,Y_BUTTON}, + {"NEXT ->",S_SKIP|S_NEXT,m_null,KB_NEXT,KB_Y+17*8, {stat_settings2}}, + + // Final entry + {0,S_SKIP|S_END,m_null} +}; + +setup_menu_t stat_settings2[] = +{ + {"WIDGET COLORS",S_SKIP|S_TITLE,m_null,ST_X,ST_Y+ 1*8 }, + + {"BACKPACK CHANGES THRESHOLDS",S_YESNO,m_null,ST_X,ST_Y+2*8, {"hud_backpack_thresholds"}}, + {"COLOR OF ARMOR DEPENDS ON TYPE",S_YESNO,m_null,ST_X,ST_Y+3*8, {"hud_armor_type"}}, + + {"EXTENDED HUD",S_SKIP|S_TITLE,m_null,ST_X,ST_Y+ 5*8 }, + + {"\"A SECRET IS REVEALED!\" MESSAGE",S_YESNO,m_null,ST_X,ST_Y+6*8, {"hud_secret_message"}}, + {"SHOW TIME/STS ABOVE STATUS BAR",S_YESNO,m_null,ST_X,ST_Y+7*8, {"hud_timests"}}, + + {"<- PREV" ,S_SKIP|S_PREV,m_null,KB_PREV,KB_Y+17*8, {stat_settings1}}, + // Final entry {0,S_SKIP|S_END,m_null} }; diff --git a/Source/m_misc.c b/Source/m_misc.c index 83a4575c..a2e825b7 100644 --- a/Source/m_misc.c +++ b/Source/m_misc.c @@ -1768,6 +1768,22 @@ default_t defaults[] = { "1 to disable display of kills/items/secrets on HUD" }, + // backpack changes thresholds + { + "hud_backpack_thresholds", + (config_t *) &hud_backpack_thresholds, NULL, + {1}, {0,1}, number, ss_none, wad_no, + "backpack changes thresholds" + }, + + // color of armor depends on type + { + "hud_armor_type", + (config_t *) &hud_armor_type, NULL, + {0}, {0,1}, number, ss_none, wad_no, + "color of armor depends on type" + }, + // "A secret is revealed!" message { "hud_secret_message", diff --git a/Source/st_stuff.c b/Source/st_stuff.c index 8a3af281..2a515365 100644 --- a/Source/st_stuff.c +++ b/Source/st_stuff.c @@ -271,6 +271,9 @@ int armor_red; // armor amount less than which status is red int armor_yellow; // armor amount less than which status is yellow int armor_green; // armor amount above is blue, below is green +int hud_backpack_thresholds; // backpack changes thresholds +int hud_armor_type; // color of armor depends on type + // in deathmatch only, summary of frags stats static st_number_t w_frags; @@ -774,6 +777,7 @@ void ST_doPaletteStuff(void) void ST_drawWidgets(boolean refresh) { int i; + int maxammo = plyr->maxammo[weaponinfo[w_ready.data].ammo]; // used by w_arms[] widgets st_armson = st_statusbaron && !deathmatch; @@ -781,12 +785,16 @@ void ST_drawWidgets(boolean refresh) // used by w_frags widget st_fragson = deathmatch && st_statusbaron; + // backpack changes thresholds + if (plyr->backpack && !hud_backpack_thresholds) + maxammo /= 2; + //jff 2/16/98 make color of ammo depend on amount - if (*w_ready.num*100 < ammo_red*plyr->maxammo[weaponinfo[w_ready.data].ammo]) + if (*w_ready.num*100 < ammo_red*maxammo) STlib_updateNum(&w_ready, cr_red, refresh); else if (*w_ready.num*100 < - ammo_yellow*plyr->maxammo[weaponinfo[w_ready.data].ammo]) + ammo_yellow*maxammo) STlib_updateNum(&w_ready, cr_gold, refresh); else STlib_updateNum(&w_ready, cr_green, refresh); @@ -807,6 +815,18 @@ void ST_drawWidgets(boolean refresh) else STlib_updatePercent(&w_health, cr_blue2, refresh); //killough 2/28/98 + // color of armor depends on type + if (hud_armor_type) + { + if (!plyr->armortype) + STlib_updatePercent(&w_armor, cr_red, refresh); + else if (plyr->armortype == 1) + STlib_updatePercent(&w_armor, cr_green, refresh); + else + STlib_updatePercent(&w_armor, cr_blue2, refresh); + } + else + { //jff 2/16/98 make color of armor depend on amount if (*w_armor.n.num