From 2fb20841082be54b660dee9a1e3f3eeebba1e026 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:03:16 +0300 Subject: [PATCH] Converts Nutrition alert to hud element (#25616) * hud * convert nutrition from alert to hud * return alert5 and remove some unused ui defines * reorganize top-to-bottom --- code/__DEFINES/hud_locations.dm | 25 +++--------------- code/_onclick/hud/hud_datum.dm | 1 + code/_onclick/hud/human_hud.dm | 3 +++ code/_onclick/hud/screen_objects.dm | 6 +++++ .../modules/antagonists/vampire/vamp_datum.dm | 2 -- .../mob/living/carbon/human/human_life.dm | 26 +++++++++---------- .../living/carbon/human/species/_species.dm | 2 -- .../living/carbon/human/species/machine.dm | 1 - code/modules/mob/mob_vars.dm | 1 + 9 files changed, 26 insertions(+), 41 deletions(-) diff --git a/code/__DEFINES/hud_locations.dm b/code/__DEFINES/hud_locations.dm index c475b4d7a4d..7bfe1c0e3ae 100644 --- a/code/__DEFINES/hud_locations.dm +++ b/code/__DEFINES/hud_locations.dm @@ -83,30 +83,11 @@ #define ui_alert4 "EAST-1:28,CENTER+2:21" #define ui_alert5 "EAST-1:28,CENTER+1:19" - -//Gun buttons -#define ui_gun1 "EAST-2:26,SOUTH+2:7" -#define ui_gun2 "EAST-1:28,SOUTH+3:7" -#define ui_gun3 "EAST-2:26,SOUTH+3:7" -#define ui_gun_select "EAST-1:28,SOUTH+2:7" - -//Upper-middle right (damage indicators) -#define ui_toxin "EAST-1:28,CENTER+5:27" -#define ui_fire "EAST-1:28,CENTER+4:25" -#define ui_oxygen "EAST-1:28,CENTER+3:23" -#define ui_pressure "EAST-1:28,CENTER+2:21" - -#define ui_alien_toxin "EAST-1:28,CENTER+5:25" -#define ui_alien_fire "EAST-1:28,CENTER+4:25" -#define ui_alien_oxygen "EAST-1:28,CENTER+3:25" -#define ui_alien_nightvision "EAST-1:28,CENTER+2:25" - //Middle right (status indicators) -#define ui_nutrition "EAST-1:28,CENTER-3:11" -#define ui_temp "EAST-1:28,CENTER-2:13" -#define ui_healthdoll "EAST-1:28,CENTER-1:15" -#define ui_health "EAST-1:28,CENTER:17" #define ui_internal "EAST-1:28,CENTER+1:19" +#define ui_health "EAST-1:28,CENTER:17" +#define ui_healthdoll "EAST-1:28,CENTER-1:15" +#define ui_nutrition "EAST-2:32,CENTER-1:13" #define ui_stamina "EAST-1:28,CENTER-2:15" //borgs diff --git a/code/_onclick/hud/hud_datum.dm b/code/_onclick/hud/hud_datum.dm index 4f11604ade2..be2bb5aaea1 100644 --- a/code/_onclick/hud/hud_datum.dm +++ b/code/_onclick/hud/hud_datum.dm @@ -131,6 +131,7 @@ mymob.healths = null mymob.healthdoll = null mymob.pullin = null + mymob.nutrition_display = null //clear the rest of our reload_fullscreen lingchemdisplay = null diff --git a/code/_onclick/hud/human_hud.dm b/code/_onclick/hud/human_hud.dm index 94c08989d00..1f37d8bea0e 100644 --- a/code/_onclick/hud/human_hud.dm +++ b/code/_onclick/hud/human_hud.dm @@ -345,6 +345,9 @@ mymob.healthdoll = new() infodisplay += mymob.healthdoll + mymob.nutrition_display = new() + infodisplay += mymob.nutrition_display + mymob.pullin = new /atom/movable/screen/pull() mymob.pullin.icon = ui_style mymob.pullin.hud = src diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 9216a62bbf3..1a47699ea2b 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -556,6 +556,12 @@ var/mob/living/carbon/H = usr H.check_self_for_injuries() +/atom/movable/screen/nutrition + name = "nutrition" + icon = 'icons/mob/screen_hunger.dmi' + icon_state = null + screen_loc = ui_nutrition + /atom/movable/screen/component_button var/atom/movable/screen/parent diff --git a/code/modules/antagonists/vampire/vamp_datum.dm b/code/modules/antagonists/vampire/vamp_datum.dm index dea34b67cad..45625ed3121 100644 --- a/code/modules/antagonists/vampire/vamp_datum.dm +++ b/code/modules/antagonists/vampire/vamp_datum.dm @@ -84,7 +84,6 @@ RESTRICT_TYPE(/datum/antagonist/vampire) var/datum/hud/hud = mob_override.hud_used if(hud?.vampire_blood_display) hud.remove_vampire_hud() - mob_override.dna?.species.hunger_type = initial(mob_override.dna.species.hunger_type) mob_override.dna?.species.hunger_icon = initial(mob_override.dna.species.hunger_icon) owner.current.alpha = 255 REMOVE_TRAITS_IN(owner.current, "vampire") @@ -354,7 +353,6 @@ RESTRICT_TYPE(/datum/antagonist/vampire) owner.som = new() owner.som.masters += owner - mob_override.dna?.species.hunger_type = "vampire" mob_override.dna?.species.hunger_icon = 'icons/mob/screen_hunger_vampire.dmi' check_vampire_upgrade(FALSE) diff --git a/code/modules/mob/living/carbon/human/human_life.dm b/code/modules/mob/living/carbon/human/human_life.dm index 0289d9c3365..ac2757f49b6 100644 --- a/code/modules/mob/living/carbon/human/human_life.dm +++ b/code/modules/mob/living/carbon/human/human_life.dm @@ -668,28 +668,26 @@ #undef BODYPART_PAIN_REDUCTION -/mob/living/carbon/human/proc/handle_nutrition_alerts() //This is a terrible abuse of the alert system; something like this should be a HUD element - if(HAS_TRAIT(src, TRAIT_NOHUNGER)) +/mob/living/carbon/human/proc/handle_nutrition_alerts() + if(!nutrition_display) return - var/new_hunger + if(HAS_TRAIT(src, TRAIT_NOHUNGER)) + nutrition_display.icon_state = null + return + nutrition_display.icon = dna.species.hunger_icon switch(nutrition) if(NUTRITION_LEVEL_FULL to INFINITY) - new_hunger = "fat" + nutrition_display.icon_state = "fat" if(NUTRITION_LEVEL_WELL_FED to NUTRITION_LEVEL_FULL) - new_hunger = "full" + nutrition_display.icon_state = "full" if(NUTRITION_LEVEL_FED to NUTRITION_LEVEL_WELL_FED) - new_hunger = "well_fed" + nutrition_display.icon_state = "well_fed" if(NUTRITION_LEVEL_HUNGRY to NUTRITION_LEVEL_FED) - new_hunger = "fed" + nutrition_display.icon_state = "fed" if(NUTRITION_LEVEL_STARVING to NUTRITION_LEVEL_HUNGRY) - new_hunger = "hungry" + nutrition_display.icon_state = "hungry" else - new_hunger = "starving" - if(dna.species.hunger_type) - new_hunger += "/[dna.species.hunger_type]" - if(dna.species.hunger_level != new_hunger) - dna.species.hunger_level = new_hunger - throw_alert("nutrition", "/atom/movable/screen/alert/hunger/[new_hunger]", icon_override = dna.species.hunger_icon) + nutrition_display.icon_state = "starving" /mob/living/carbon/human/handle_random_events() // Puke if toxloss is too high diff --git a/code/modules/mob/living/carbon/human/species/_species.dm b/code/modules/mob/living/carbon/human/species/_species.dm index 1153580bae1..56fdac5bc74 100644 --- a/code/modules/mob/living/carbon/human/species/_species.dm +++ b/code/modules/mob/living/carbon/human/species/_species.dm @@ -48,8 +48,6 @@ var/hunger_drain = HUNGER_FACTOR var/taste_sensitivity = TASTE_SENSITIVITY_NORMAL //the most widely used factor; humans use a different one var/hunger_icon = 'icons/mob/screen_hunger.dmi' - var/hunger_type - var/hunger_level var/siemens_coeff = 1 //base electrocution coefficient diff --git a/code/modules/mob/living/carbon/human/species/machine.dm b/code/modules/mob/living/carbon/human/species/machine.dm index fadcdf582df..ceb23d954fc 100644 --- a/code/modules/mob/living/carbon/human/species/machine.dm +++ b/code/modules/mob/living/carbon/human/species/machine.dm @@ -44,7 +44,6 @@ butt_sprite = "machine" hunger_icon = 'icons/mob/screen_hunger_machine.dmi' - hunger_type = "machine" has_organ = list( "brain" = /obj/item/organ/internal/brain/mmi_holder/posibrain, diff --git a/code/modules/mob/mob_vars.dm b/code/modules/mob/mob_vars.dm index 79c7b588320..0330a6b82ed 100644 --- a/code/modules/mob/mob_vars.dm +++ b/code/modules/mob/mob_vars.dm @@ -27,6 +27,7 @@ */ var/atom/movable/screen/leap_icon = null var/atom/movable/screen/healthdoll/healthdoll = null + var/atom/movable/screen/nutrition/nutrition_display = null var/use_me = TRUE //Allows all mobs to use the me verb by default, will have to manually specify they cannot var/damageoverlaytemp = 0