Skip to content

Commit

Permalink
bugfix: HUD Zone Select Fixes (#4325)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottfrei authored Feb 1, 2024
1 parent 8f8eed1 commit 7deb9ec
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 63 deletions.
2 changes: 1 addition & 1 deletion code/_onclick/hud/alien.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
icon_state = "leap_off"

/obj/screen/alien/leap/Click()
if(istype(usr, /mob/living/carbon/alien/humanoid))
if(istype(usr, /mob/living/carbon/alien/humanoid/hunter))
var/mob/living/carbon/alien/humanoid/hunter/AH = usr
AH.toggle_leap()

Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/devil.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
using.screen_loc = ui_swaphand2
static_inventory += using

zone_select = new /obj/screen/zone_sel/human(null, src, ui_style)
zone_select = new /obj/screen/zone_sel(null, src, ui_style)

lingchemdisplay = new /obj/screen/ling/chems()
devilsouldisplay = new /obj/screen/devil/soul_counter
Expand Down
9 changes: 9 additions & 0 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,12 @@

/datum/hud/proc/update_locked_slots()
return


/mob/proc/remake_hud() //used for preference changes mid-round; can't change hud icons without remaking the hud.
QDEL_NULL(hud_used)
create_mob_hud()
update_action_buttons_icon()
if(hud_used)
hud_used.show_hud(hud_used.hud_version)

9 changes: 1 addition & 8 deletions code/_onclick/hud/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@
invisibility = INVISIBILITY_ABSTRACT


/mob/living/carbon/human/proc/remake_hud() //used for preference changes mid-round; can't change hud icons without remaking the hud.
QDEL_NULL(hud_used)
create_mob_hud()
update_action_buttons_icon()
if(hud_used)
hud_used.show_hud(hud_used.hud_version)

/mob/living/carbon/human/create_mob_hud()
if(client && !hud_used)
hud_used = new /datum/hud/human(src, ui_style2icon(client.prefs.UI_style), client.prefs.UI_style_color, client.prefs.UI_style_alpha)
Expand Down Expand Up @@ -393,7 +386,7 @@
devilsouldisplay = new /obj/screen/devil/soul_counter
infodisplay += devilsouldisplay

zone_select = new /obj/screen/zone_sel/human(null, src, ui_style, ui_alpha, ui_color)
zone_select = new /obj/screen/zone_sel(null, src, ui_style, ui_alpha, ui_color)
static_inventory += zone_select

inventory_shown = FALSE
Expand Down
119 changes: 66 additions & 53 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -242,21 +242,32 @@
screen_loc = ui_zonesel
var/overlay_file = 'icons/mob/zone_sel.dmi'
var/selecting = BODY_ZONE_CHEST
var/static/list/hover_overlays_cache = list()
var/list/hover_overlays_cache
var/list/selecting_overlays_cache
var/hovering

/obj/screen/zone_sel/Initialize(mapload, _hud, _icon, _alpha, _color)

/obj/screen/zone_sel/Initialize(mapload, hud, icon, alpha, color)
. = ..()
hud = _hud // Don't forget to always put here the created HUD '/datum/hud/'.
if(_icon)
icon = _icon
if(_alpha)
alpha = _alpha
if(_color)
color = _color
hud.mymob.zone_selected = selecting
src.hud = hud // Don't forget to always put here the created HUD '/datum/hud/'.
hover_overlays_cache = list()
selecting_overlays_cache = list()
if(icon)
src.icon = icon
if(alpha)
src.alpha = alpha
if(color)
src.color = color
src.hud.mymob.zone_selected = selecting
update_icon(UPDATE_OVERLAYS)


/obj/screen/zone_sel/Destroy()
QDEL_LIST_ASSOC_VAL(hover_overlays_cache)
QDEL_LIST_ASSOC_VAL(selecting_overlays_cache)
return ..()


/obj/screen/zone_sel/Click(location, control, params)
if(isobserver(usr))
return FALSE
Expand All @@ -270,44 +281,43 @@

return set_selected_zone(choice)


/obj/screen/zone_sel/MouseEntered(location, control, params)
MouseMove(location, control, params)


/obj/screen/zone_sel/MouseMove(location, control, params)
if(isobserver(usr))
return

var/list/PL = params2list(params)
var/icon_x = text2num(PL["icon-x"])
var/icon_y = text2num(PL["icon-y"])
var/choice = get_zone_at(icon_x, icon_y)
var/choice = get_zone_at(text2num(PL["icon-x"]), text2num(PL["icon-y"]))

if(!choice)
cut_overlay(hover_overlays_cache[hovering])
hovering = null
return

if(hovering == choice)
if(choice == hovering)
return

cut_overlay(hover_overlays_cache[hovering])
hovering = choice

var/obj/effect/overlay/zone_sel/overlay_object = hover_overlays_cache[choice]
if(!overlay_object)
overlay_object = new
overlay_object.icon_state = "[choice]"
hover_overlays_cache[choice] = overlay_object
add_overlay(overlay_object)
var/mutable_appearance/hovering_olay = hover_overlays_cache[hovering]
if(!hovering_olay)
hovering_olay = mutable_appearance(overlay_file, "[hovering]", alpha = 128, appearance_flags = RESET_COLOR)
hover_overlays_cache[hovering] = hovering_olay

add_overlay(hovering_olay)

/obj/effect/overlay/zone_sel
icon = 'icons/mob/zone_sel.dmi'
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
alpha = 128
anchored = TRUE
layer = ABOVE_HUD_LAYER
plane = ABOVE_HUD_PLANE

/obj/screen/zone_sel/MouseExited(location, control, params)
if(!isobserver(usr) && hovering)
cut_overlay(hover_overlays_cache[hovering])
hovering = null


/obj/screen/zone_sel/proc/get_zone_at(icon_x, icon_y)
switch(icon_y)
if(1 to 3) //Feet
Expand All @@ -322,7 +332,7 @@
return BODY_ZONE_R_LEG
if(17 to 22)
return BODY_ZONE_L_LEG
if(24 to 29)
if(23 to 29)
return BODY_ZONE_TAIL
if(10 to 13) //Hands,groin and wings
switch(icon_x)
Expand All @@ -338,29 +348,34 @@
return BODY_ZONE_WING
if(14 to 22) //Chest and arms to shoulders and wings
switch(icon_x)
if (3 to 7)
if(3 to 7)
return BODY_ZONE_WING
if(8 to 11)
return BODY_ZONE_R_ARM
if(12 to 20)
return BODY_ZONE_CHEST
if(21 to 24)
return BODY_ZONE_L_ARM
if(24 to 28)
if(25 to 28)
return BODY_ZONE_WING
if(23 to 30)
switch(icon_x)
if(4 to 10)
return BODY_ZONE_WING
if(12 to 20) //Head, but we need to check for eye or mouth
switch(icon_y)
if(23 to 24)
if(icon_x in 15 to 17)
return BODY_ZONE_PRECISE_MOUTH
if(26) //Eyeline, eyes are on 15 and 17
if(icon_x in 14 to 18)
return BODY_ZONE_PRECISE_EYES
if(25 to 27)
if(icon_x in 15 to 17)
return BODY_ZONE_PRECISE_EYES
return BODY_ZONE_HEAD
if(22 to 28)
return BODY_ZONE_WING
if(23 to 30) //Head, but we need to check for eye or mouth
if(icon_x in 12 to 20)
switch(icon_y)
if(23 to 24)
if(icon_x in 15 to 17)
return BODY_ZONE_PRECISE_MOUTH
if(26) //Eyeline, eyes are on 15 and 17
if(icon_x in 14 to 18)
return BODY_ZONE_PRECISE_EYES
if(25 to 27)
if(icon_x in 15 to 17)
return BODY_ZONE_PRECISE_EYES
return BODY_ZONE_HEAD


/obj/screen/zone_sel/proc/set_selected_zone(choice)
Expand All @@ -379,15 +394,12 @@

/obj/screen/zone_sel/update_overlays()
. = ..()
var/image/sel = image(overlay_file, "[selecting]")
sel.appearance_flags = RESET_COLOR
. += sel
var/mutable_appearance/selecting_olay = selecting_overlays_cache[selecting]
if(!selecting_olay)
selecting_olay = mutable_appearance(overlay_file, "[selecting]", appearance_flags = RESET_COLOR)
selecting_overlays_cache[selecting] = selecting_olay
. += selecting_olay

/obj/screen/zone_sel/human/update_overlays()
var/image/human = image('icons/mob/zone_sel.dmi', "human")
human.appearance_flags = RESET_COLOR
. = list(human)
. += ..()

/obj/screen/zone_sel/alien
icon = 'icons/mob/screen_alien.dmi'
Expand All @@ -397,6 +409,7 @@
/obj/screen/zone_sel/robot
icon = 'icons/mob/screen_robot.dmi'


/obj/screen/craft
name = "crafting menu"
icon = 'icons/mob/screen_midnight.dmi'
Expand Down Expand Up @@ -542,11 +555,11 @@


/obj/screen/inventory/hand/update_overlays()
. = ..()

if(!hud || !hud.mymob)
return

. = ..()

if(!active_overlay)
active_overlay = image("icon" = icon, "icon_state" = "hand_active")

Expand Down
Binary file modified icons/mob/screen_alien.dmi
Binary file not shown.
Binary file modified icons/mob/screen_white.dmi
Binary file not shown.

0 comments on commit 7deb9ec

Please sign in to comment.