Fix handcuff hud icons appearing on the left and right hand inventory hud slots when handcuffed.

We define the inventory screen objects for hands to be special in that apply overlays to themselves for handcuffed.  By putting that logic on the screen object itself, we allow it to be expanded to other cases besides handcuffs in the future without conflict.
This commit is contained in:
Leshana
2017-03-10 21:33:20 -05:00
parent 7130d56b80
commit baf8e2d143
4 changed files with 29 additions and 2 deletions

View File

@@ -158,7 +158,8 @@
using.alpha = ui_alpha
src.adding += using
inv_box = new /obj/screen/inventory()
inv_box = new /obj/screen/inventory/hand()
inv_box.hud = src
inv_box.name = "r_hand"
inv_box.icon = ui_style
inv_box.icon_state = "r_hand_inactive"
@@ -173,7 +174,8 @@
src.r_hand_hud_object = inv_box
src.adding += inv_box
inv_box = new /obj/screen/inventory()
inv_box = new /obj/screen/inventory/hand()
inv_box.hud = src
inv_box.name = "l_hand"
inv_box.icon = ui_style
inv_box.icon_state = "l_hand_inactive"

View File

@@ -12,6 +12,7 @@
layer = 20.0
unacidable = 1
var/obj/master = null //A reference to the object in the slot. Grabs or items, generally.
var/datum/hud/hud = null // A reference to the owner HUD, if any.
/obj/screen/Destroy()
master = null
@@ -507,3 +508,20 @@
usr.update_inv_l_hand(0)
usr.update_inv_r_hand(0)
return 1
// Hand slots are special to handle the handcuffs overlay
/obj/screen/inventory/hand
var/image/handcuff_overlay
/obj/screen/inventory/hand/update_icon()
..()
if(!hud)
return
if(!handcuff_overlay)
var/state = (hud.l_hand_hud_object == src) ? "l_hand_hud_handcuffs" : "r_hand_hud_handcuffs"
handcuff_overlay = image("icon"='icons/mob/screen_gen.dmi', "icon_state"=state)
overlays.Cut()
if(hud.mymob && iscarbon(hud.mymob))
var/mob/living/carbon/C = hud.mymob
if(C.handcuffed)
overlays |= handcuff_overlay

View File

@@ -895,6 +895,11 @@ var/global/list/damage_icon_parts = list()
if(hud_used)
hud_used.hidden_inventory_update() //Updates the screenloc of the items on the 'other' inventory bar
//update whether handcuffs appears on our hud.
/mob/living/carbon/proc/update_hud_handcuffed()
if(hud_used && hud_used.l_hand_hud_object && hud_used.r_hand_hud_object)
hud_used.l_hand_hud_object.update_icon()
hud_used.r_hand_hud_object.update_icon()
/mob/living/carbon/human/update_inv_handcuffed(var/update_icons=1)
if(handcuffed)
@@ -913,6 +918,8 @@ var/global/list/damage_icon_parts = list()
else
overlays_standing[HANDCUFF_LAYER] = null
update_hud_handcuffed()
if(update_icons) update_icons()
/mob/living/carbon/human/update_inv_legcuffed(var/update_icons=1)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 B

After

Width:  |  Height:  |  Size: 466 B