From baf8e2d1434146a00c3db82cabdd555d16f27f88 Mon Sep 17 00:00:00 2001 From: Leshana Date: Fri, 10 Mar 2017 21:33:20 -0500 Subject: [PATCH] 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. --- code/_onclick/hud/human.dm | 6 ++++-- code/_onclick/hud/screen_objects.dm | 18 ++++++++++++++++++ .../mob/living/carbon/human/update_icons.dm | 7 +++++++ icons/mob/screen_gen.dmi | Bin 182 -> 466 bytes 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/code/_onclick/hud/human.dm b/code/_onclick/hud/human.dm index 709117de8c5..57e1e4bb6ad 100644 --- a/code/_onclick/hud/human.dm +++ b/code/_onclick/hud/human.dm @@ -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" diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index d899f620499..3f6758c6ad2 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -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 diff --git a/code/modules/mob/living/carbon/human/update_icons.dm b/code/modules/mob/living/carbon/human/update_icons.dm index 6f586d764e0..2a29d2d1d97 100644 --- a/code/modules/mob/living/carbon/human/update_icons.dm +++ b/code/modules/mob/living/carbon/human/update_icons.dm @@ -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) diff --git a/icons/mob/screen_gen.dmi b/icons/mob/screen_gen.dmi index cf74d73796c8c6121c0818fdac74e4a7f0ab9a5f..2071c634d1327ea703d95f89ab82c0c31e0a2aa8 100644 GIT binary patch delta 427 zcmV;c0aX6B0n!71iBL{Q4GJ0x0000DNk~Le0000$0000$2m=5B0G+pi>;M1&Gf+%a zMF0Q*G&D3=SXeJFFF`>;E-o${92`nYN=;2oPft&1XlO%2LsnK+Zfjj$Z(w8ic$+`hyY`+nP=d$P#W93qW^#hW9UyN31LIR^ R|8+nXgQu&X%Q~loCICDTAFlua