Skip to content

Commit

Permalink
Breaking up the status UI element and moving fire onto the HUD datum.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 21, 2025
1 parent c5cea92 commit f18b3d8
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 105 deletions.
35 changes: 19 additions & 16 deletions code/__defines/hud.dm
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
// Keys used to set and retrieve icons from the UI decl system.
#define UI_ICON_INTERACTION "icon_interaction"
#define UI_ICON_ZONE_SELECT "icon_zone_sel"
#define UI_ICON_MOVEMENT "icon_movement"
#define UI_ICON_INVENTORY "icon_inventory"
#define UI_ICON_ATTACK "icon_attack"
#define UI_ICON_HANDS "icon_hands"
#define UI_ICON_INTERNALS "icon_internals"
#define UI_ICON_HEALTH "icon_health"
#define UI_ICON_CRIT_MARKER "icon_crit_marker"
#define UI_ICON_NUTRITION "icon_nutrition"
#define UI_ICON_HYDRATION "icon_hydration"
#define UI_ICON_FIRE_INTENT "icon_fire_intent"
#define UI_ICON_UP_HINT "icon_uphint"
#define UI_ICON_STATUS "icon_status"
#define UI_ICON_STATUS_FIRE "icon_status_fire"
#define UI_ICON_CHARGE "icon_charge"
#define UI_ICON_INTERACTION "icon_interaction"
#define UI_ICON_ZONE_SELECT "icon_zone_sel"
#define UI_ICON_MOVEMENT "icon_movement"
#define UI_ICON_INVENTORY "icon_inventory"
#define UI_ICON_ATTACK "icon_attack"
#define UI_ICON_HANDS "icon_hands"
#define UI_ICON_INTERNALS "icon_internals"
#define UI_ICON_HEALTH "icon_health"
#define UI_ICON_CRIT_MARKER "icon_crit_marker"
#define UI_ICON_NUTRITION "icon_nutrition"
#define UI_ICON_HYDRATION "icon_hydration"
#define UI_ICON_FIRE_INTENT "icon_fire_intent"
#define UI_ICON_UP_HINT "icon_uphint"
#define UI_ICON_STATUS_BODYTEMP "icon_status_bodytemp"
#define UI_ICON_STATUS_PRESSURE "icon_status_pressure"
#define UI_ICON_STATUS_TOX "icon_status_tox"
#define UI_ICON_STATUS_OXY "icon_status_oxy"
#define UI_ICON_STATUS_FIRE "icon_status_fire"
#define UI_ICON_CHARGE "icon_charge"

#define GET_HUD_ALERT(M, A) ((istype(M?.hud_used, /datum/hud) && (A in M.hud_used.alerts)) ? M.hud_used.alerts[A] : 0)

Expand Down
18 changes: 15 additions & 3 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
var/obj/screen/robot_module/select/hands
var/obj/screen/oxygen/oxygen
var/obj/screen/toxins/toxin
var/obj/screen/fire_warning/fire
var/obj/screen/bodytemp/bodytemp
var/obj/screen/throw_toggle/throw_icon
var/obj/screen/maneuver/maneuver_icon
Expand Down Expand Up @@ -69,6 +68,9 @@
var/charge_warning_type = /obj/screen/warning_cells
var/obj/screen/warning_cells/charge_warning

var/fire_warning_type = /obj/screen/fire_warning
var/obj/screen/fire_warning/fire_warning

var/list/adding = list()
var/list/other = list()
var/list/hud_elements = list()
Expand All @@ -84,10 +86,12 @@

/datum/hud/Destroy()
. = ..()

QDEL_NULL(action_intent)
QDEL_NULL(health_warning)
QDEL_NULL(internals_toggle)
QDEL_NULL(charge_warning)
QDEL_NULL(fire_warning)

stamina_bar = null
move_intent = null
Expand All @@ -110,8 +114,10 @@
internals_toggle?.update_icon()
if(UI_ICON_CHARGE)
charge_warning?.update_icon()
if(UI_ICON_STATUS)
if(UI_ICON_HEALTH)
health_warning?.update_icon()
if(UI_ICON_STATUS_FIRE)
fire_warning?.update_icon()
else
return FALSE
return TRUE
Expand Down Expand Up @@ -177,6 +183,7 @@
/datum/hud/proc/handle_life_hud_update()
health_warning?.update_icon()
charge_warning?.update_icon()
fire_warning?.update_icon()

/datum/hud/proc/finalize_instantiation()

Expand All @@ -192,7 +199,7 @@
hud_elements |= action_intent

if(!health_warning && health_warning_type)
health_warning = new health_warning_type(null, mymob, ui_style, null, null, UI_ICON_STATUS)
health_warning = new health_warning_type(null, mymob, ui_style, null, null, UI_ICON_HEALTH)
adding |= health_warning
hud_elements |= health_warning

Expand All @@ -206,6 +213,11 @@
adding |= charge_warning
hud_elements |= charge_warning

if(!fire_warning && fire_warning_type)
fire_warning = new fire_warning_type(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS_FIRE)
adding |= fire_warning
hud_elements |= fire_warning

build_inventory_ui()
build_hands_ui()

Expand Down
10 changes: 4 additions & 6 deletions code/_onclick/hud/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,19 @@
hud_elements |= mymob.throw_icon

if(hud_data.has_warnings)
mymob.oxygen = new(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS)
mymob.oxygen = new(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS_OXY)
hud_elements |= mymob.oxygen

mymob.toxin = new(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS)
mymob.toxin = new(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS_TOX)
hud_elements |= mymob.toxin

mymob.fire = new(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS_FIRE)
hud_elements |= mymob.fire

if(hud_data.has_pressure)
mymob.pressure = new(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS)
mymob.pressure = new(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS_PRESSURE)
hud_elements |= mymob.pressure

if(hud_data.has_bodytemp)
mymob.bodytemp = new(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS)
mymob.bodytemp = new(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS_BODYTEMP)
hud_elements |= mymob.bodytemp

if(!target.isSynthetic() && hud_data.has_nutrition)
Expand Down
3 changes: 1 addition & 2 deletions code/_onclick/hud/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
var/decl/ui_style/ui_style = get_ui_style_data()
var/ui_color = get_ui_color()
var/ui_alpha = get_ui_alpha()
mymob.fire = new /obj/screen/construct_fire(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS_FIRE)
mymob.zone_sel = new(null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_ZONE_SELECT)
adding += list(mymob.fire, mymob.zone_sel)
adding += list(mymob.zone_sel)
..()

/decl/ui_style/construct
Expand Down
7 changes: 3 additions & 4 deletions code/_onclick/hud/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,16 @@ var/global/obj/screen/robot_inventory

R.hands = new /obj/screen/robot_module/select(null, mymob)
robot_inventory = new /obj/screen/robot_inventory( null, mymob)
R.bodytemp = new /obj/screen/bodytemp( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS)
R.oxygen = new /obj/screen/robot_oxygen( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS)
R.fire = new /obj/screen/robot_fire( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS_FIRE)
R.bodytemp = new /obj/screen/bodytemp( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS_BODYTEMP)
R.oxygen = new /obj/screen/robot_oxygen( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_STATUS_OXY)
R.up_hint = new /obj/screen/up_hint( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_UP_HINT)
R.zone_sel = new( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_ZONE_SELECT)
R.gun_setting_icon = new /obj/screen/gun/mode( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_FIRE_INTENT)
R.item_use_icon = new /obj/screen/gun/item( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_FIRE_INTENT)
R.gun_move_icon = new /obj/screen/gun/move( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_FIRE_INTENT)
R.radio_use_icon = new /obj/screen/gun/radio( null, mymob, ui_style, ui_color, ui_alpha, UI_ICON_FIRE_INTENT)

hud_elements = list(R.zone_sel, R.oxygen, R.fire, R.up_hint, R.hands, robot_inventory, R.gun_setting_icon)
hud_elements = list(R.zone_sel, R.oxygen, R.up_hint, R.hands, robot_inventory, R.gun_setting_icon)
..()

/datum/hud/proc/toggle_show_robot_modules()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/obj/screen/fire_warning
name = "fire"
icon_state = "fire0"
screen_loc = ui_fire

/obj/screen/warning_cells
name = "cell"
icon_state = "charge-empty"
Expand All @@ -15,8 +10,9 @@
. = ..()
var/mob/living/owner = owner_ref?.resolve()
if(!istype(owner) || !owner.isSynthetic())
icon_state = "blank"
invisibility = INVISIBILITY_ABSTRACT
return
invisibility = INVISIBILITY_NONE
var/obj/item/cell/cell = owner.get_cell()
if(cell)
var/chargeNum = clamp(ceil(cell.percent()/25), 0, 4) //0-100 maps to 0-4, but give it a paranoid clamp just in case.
Expand Down
10 changes: 10 additions & 0 deletions code/_onclick/hud/screen/screen_fire_warning.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/obj/screen/fire_warning
name = "fire"
icon_state = "fire0"
screen_loc = ui_fire

/obj/screen/fire_warning/on_update_icon()
. = ..()
var/mob/living/owner = owner_ref?.resolve()
if(istype(owner))
icon_state = "fire[GET_HUD_ALERT(owner, /decl/hud_element/condition/fire)]"
3 changes: 0 additions & 3 deletions code/_onclick/hud/screen/screen_health.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
else
icon_state = "health[round(owner.get_health_percent() * 6)]"

/obj/screen/health/organs
icon_state = "blank"

/obj/screen/health/organs/on_update_icon()

var/mob/living/human/owner = owner_ref?.resolve()
Expand Down
5 changes: 0 additions & 5 deletions code/_onclick/hud/screen/screen_robot_warnings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,3 @@
name = "oxygen"
icon_state = "oxy0"
screen_loc = ui_oxygen

/obj/screen/robot_fire
name = "fire"
icon_state = "fire0"
screen_loc = ui_fire
36 changes: 20 additions & 16 deletions code/modules/client/ui_styles/_ui_style.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@
var/name
/// Associative mapping of UI icon key to icon file.
var/list/icons = list(
UI_ICON_ATTACK = 'icons/mob/screen/styles/midnight/attack_selector.dmi',
UI_ICON_FIRE_INTENT = 'icons/mob/screen/styles/midnight/fire_intent.dmi',
UI_ICON_HANDS = 'icons/mob/screen/styles/midnight/hands.dmi',
UI_ICON_HEALTH = 'icons/mob/screen/styles/health.dmi',
UI_ICON_CRIT_MARKER = 'icons/mob/screen/styles/crit_markers.dmi',
UI_ICON_HYDRATION = 'icons/mob/screen/styles/hydration.dmi',
UI_ICON_INTERACTION = 'icons/mob/screen/styles/midnight/interaction.dmi',
UI_ICON_INTERNALS = 'icons/mob/screen/styles/internals.dmi',
UI_ICON_INVENTORY = 'icons/mob/screen/styles/midnight/inventory.dmi',
UI_ICON_MOVEMENT = 'icons/mob/screen/styles/midnight/movement.dmi',
UI_ICON_NUTRITION = 'icons/mob/screen/styles/nutrition.dmi',
UI_ICON_STATUS_FIRE = 'icons/mob/screen/styles/status_fire.dmi',
UI_ICON_STATUS = 'icons/mob/screen/styles/status.dmi',
UI_ICON_UP_HINT = 'icons/mob/screen/styles/midnight/uphint.dmi',
UI_ICON_ZONE_SELECT = 'icons/mob/screen/styles/midnight/zone_selector.dmi',
UI_ICON_CHARGE = 'icons/mob/screen/styles/charge.dmi'
(UI_ICON_ATTACK) = 'icons/mob/screen/styles/midnight/attack_selector.dmi',
(UI_ICON_FIRE_INTENT) = 'icons/mob/screen/styles/midnight/fire_intent.dmi',
(UI_ICON_HANDS) = 'icons/mob/screen/styles/midnight/hands.dmi',
(UI_ICON_HEALTH) = 'icons/mob/screen/styles/health.dmi',
(UI_ICON_CRIT_MARKER) = 'icons/mob/screen/styles/crit_markers.dmi',
(UI_ICON_HYDRATION) = 'icons/mob/screen/styles/hydration.dmi',
(UI_ICON_INTERACTION) = 'icons/mob/screen/styles/midnight/interaction.dmi',
(UI_ICON_INTERNALS) = 'icons/mob/screen/styles/internals.dmi',
(UI_ICON_INVENTORY) = 'icons/mob/screen/styles/midnight/inventory.dmi',
(UI_ICON_MOVEMENT) = 'icons/mob/screen/styles/midnight/movement.dmi',
(UI_ICON_NUTRITION) = 'icons/mob/screen/styles/nutrition.dmi',
(UI_ICON_STATUS_FIRE) = 'icons/mob/screen/styles/status_fire.dmi',
(UI_ICON_STATUS_PRESSURE) = 'icons/mob/screen/styles/status.dmi',
(UI_ICON_STATUS_BODYTEMP) = 'icons/mob/screen/styles/status.dmi',
(UI_ICON_STATUS_FIRE) = 'icons/mob/screen/styles/status.dmi',
(UI_ICON_STATUS_TOX) = 'icons/mob/screen/styles/status.dmi',
(UI_ICON_STATUS_OXY) = 'icons/mob/screen/styles/status.dmi',
(UI_ICON_UP_HINT) = 'icons/mob/screen/styles/midnight/uphint.dmi',
(UI_ICON_ZONE_SELECT) = 'icons/mob/screen/styles/midnight/zone_selector.dmi',
(UI_ICON_CHARGE) = 'icons/mob/screen/styles/charge.dmi'
)
/// A subset of UI keys to icon files used to override the above.
var/list/override_icons
Expand Down
54 changes: 32 additions & 22 deletions code/modules/client/ui_styles/_ui_style_states.dm
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
var/global/list/_ui_all_keys = list(
UI_ICON_INTERACTION,
UI_ICON_ZONE_SELECT,
UI_ICON_MOVEMENT,
UI_ICON_INVENTORY,
UI_ICON_ATTACK,
UI_ICON_HANDS,
UI_ICON_INTERNALS,
UI_ICON_HEALTH,
UI_ICON_NUTRITION,
UI_ICON_HYDRATION,
UI_ICON_FIRE_INTENT,
UI_ICON_UP_HINT,
UI_ICON_STATUS,
UI_ICON_STATUS_FIRE,
UI_ICON_CHARGE
(UI_ICON_INTERACTION),
(UI_ICON_ZONE_SELECT),
(UI_ICON_MOVEMENT),
(UI_ICON_INVENTORY),
(UI_ICON_ATTACK),
(UI_ICON_HANDS),
(UI_ICON_INTERNALS),
(UI_ICON_HEALTH),
(UI_ICON_NUTRITION),
(UI_ICON_HYDRATION),
(UI_ICON_FIRE_INTENT),
(UI_ICON_UP_HINT),
(UI_ICON_STATUS_PRESSURE),
(UI_ICON_STATUS_BODYTEMP),
(UI_ICON_STATUS_FIRE),
(UI_ICON_STATUS_TOX),
(UI_ICON_STATUS_OXY),
(UI_ICON_STATUS_FIRE),
(UI_ICON_CHARGE)
)

var/global/list/_ui_expected_states
Expand Down Expand Up @@ -100,7 +104,16 @@ var/global/list/_ui_expected_states
"fire1",
"fire2"
),
UI_ICON_STATUS = list(
UI_ICON_STATUS_OXY = list(
"oxy0",
"oxy1",
"oxy2"
),
UI_ICON_STATUS_TOX = list(
"tox0",
"tox1"
),
UI_ICON_STATUS_BODYTEMP = list(
"temp-4",
"temp-3",
"temp-2",
Expand All @@ -109,12 +122,9 @@ var/global/list/_ui_expected_states
"temp1",
"temp2",
"temp3",
"temp4",
"tox0",
"tox1",
"oxy0",
"oxy1",
"oxy2",
"temp4"
),
UI_ICON_STATUS_PRESSURE = list(
"pressure-2",
"pressure-1",
"pressure0",
Expand Down
12 changes: 2 additions & 10 deletions code/modules/client/ui_styles/ui_style_subtypes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,15 @@
name = "Underworld"
uid = "ui_style_underworld"
restricted = FALSE
icons = list(
override_icons = list(
(UI_ICON_ATTACK) = 'icons/mob/screen/styles/underworld/attack_selector.dmi',
(UI_ICON_FIRE_INTENT) = 'icons/mob/screen/styles/underworld/fire_intent.dmi',
(UI_ICON_HANDS) = 'icons/mob/screen/styles/underworld/hands.dmi',
(UI_ICON_HEALTH) = 'icons/mob/screen/styles/health.dmi',
(UI_ICON_CRIT_MARKER) = 'icons/mob/screen/styles/crit_markers.dmi',
(UI_ICON_HYDRATION) = 'icons/mob/screen/styles/hydration.dmi',
(UI_ICON_INTERACTION) = 'icons/mob/screen/styles/underworld/interaction.dmi',
(UI_ICON_INTERNALS) = 'icons/mob/screen/styles/internals.dmi',
(UI_ICON_INVENTORY) = 'icons/mob/screen/styles/underworld/inventory.dmi',
(UI_ICON_MOVEMENT) = 'icons/mob/screen/styles/underworld/movement.dmi',
(UI_ICON_NUTRITION) = 'icons/mob/screen/styles/nutrition.dmi',
(UI_ICON_STATUS_FIRE) = 'icons/mob/screen/styles/status_fire.dmi',
(UI_ICON_STATUS) = 'icons/mob/screen/styles/status.dmi',
(UI_ICON_UP_HINT) = 'icons/mob/screen/styles/underworld/uphint.dmi',
(UI_ICON_ZONE_SELECT) = 'icons/mob/screen/styles/underworld/zone_selector.dmi',
(UI_ICON_CHARGE) = 'icons/mob/screen/styles/charge.dmi'
(UI_ICON_ZONE_SELECT) = 'icons/mob/screen/styles/underworld/zone_selector.dmi'
)
use_overlay_color = TRUE
use_ui_color = TRUE
2 changes: 0 additions & 2 deletions code/modules/mob/living/human/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,6 @@
toxin.icon_state = "tox[GET_HUD_ALERT(src, /decl/hud_element/condition/toxins)]"
if(oxygen)
oxygen.icon_state = "oxy[GET_HUD_ALERT(src, /decl/hud_element/condition/oxygen)]"
if(fire)
fire.icon_state = "fire[GET_HUD_ALERT(src, /decl/hud_element/condition/fire)]"

if(bodytemp)
if (!species)
Expand Down
6 changes: 0 additions & 6 deletions code/modules/mob/living/silicon/robot/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@
src.bodytemp.icon_state = "temp-2"

var/datum/gas_mixture/environment = loc?.return_air()
if(fire && environment)
switch(environment.temperature)
if(-INFINITY to T100C)
src.fire.icon_state = "fire0"
else
src.fire.icon_state = "fire1"
if(oxygen && environment)
var/decl/species/species = all_species[global.using_map.default_species]
if(!species.breath_type || environment.gas[species.breath_type] >= species.breath_pressure)
Expand Down
1 change: 0 additions & 1 deletion code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
/mob/proc/remove_screen_obj_references()
QDEL_NULL_SCREEN(oxygen)
QDEL_NULL_SCREEN(toxin)
QDEL_NULL_SCREEN(fire)
QDEL_NULL_SCREEN(bodytemp)
QDEL_NULL_SCREEN(throw_icon)
QDEL_NULL_SCREEN(maneuver_icon)
Expand Down
2 changes: 0 additions & 2 deletions mods/gamemodes/cult/mobs/constructs/constructs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,4 @@
/mob/living/simple_animal/construct/handle_regular_hud_updates()
. = ..()
if(.)
if(fire)
fire.icon_state = "fire[!!GET_HUD_ALERT(src, /decl/hud_element/condition/fire)]"
disable_abilities(purge)
Loading

0 comments on commit f18b3d8

Please sign in to comment.