From 9d11a367a6f5b8ea5b347f9493331074f41c24f2 Mon Sep 17 00:00:00 2001 From: Zuhayr Date: Sun, 9 Aug 2015 16:22:19 +0930 Subject: [PATCH] Roll-down-jumpsuit now works properly with custom items, icon_override and (hopefully) species variants. --- code/modules/clothing/clothing.dm | 39 +++++++++++++++++------ code/modules/customitems/item_spawning.dm | 14 +++++--- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index e811c5a9aa..066ecee760 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -383,23 +383,41 @@ BLIND // can't see anything var/displays_id = 1 var/rolled_down = -1 //0 = unrolled, 1 = rolled, -1 = cannot be toggled sprite_sheets = list("Vox" = 'icons/mob/species/vox/uniform.dmi') - + //convenience var for defining the icon state for the overlay used when the clothing is worn. //Also used by rolling/unrolling. var/worn_state = null /obj/item/clothing/under/New() if(worn_state) - if(!item_state_slots) + if(!item_state_slots) item_state_slots = list() item_state_slots[slot_w_uniform_str] = worn_state else worn_state = icon_state - - //autodetect rollability - if(rolled_down < 0) - if((worn_state + "_d_s") in icon_states('icons/mob/uniform.dmi')) + +/obj/item/clothing/under/proc/update_rolldown_status() + + var/mob/living/carbon/human/H + if(istype(src.loc, /mob/living/carbon/human)) + H = src.loc + + var/icon/under_icon + if(icon_override) + under_icon = icon_override + else if(H && sprite_sheets && sprite_sheets[H.species.name]) + under_icon = sprite_sheets[H.species.name] + else if(item_icons && item_icons[slot_w_uniform_str]) + under_icon = item_icons[slot_w_uniform_str] + else + under_icon = INV_W_UNIFORM_DEF_ICON + + if((worn_state + "_d_s") in icon_states(under_icon)) + if(rolled_down != 1) rolled_down = 0 + else + rolled_down = -1 + if(H) update_clothing_icon() /obj/item/clothing/under/update_clothing_icon() if (ismob(src.loc)) @@ -459,10 +477,10 @@ BLIND // can't see anything if (( usr.restrained() ) || ( usr.stat )) return - + if (!usr.unEquip(src)) return - + switch(over_object.name) if("r_hand") usr.put_in_r_hand(src) @@ -542,10 +560,11 @@ BLIND // can't see anything if(!istype(usr, /mob/living)) return if(usr.stat) return - if(rolled_down < 0) + update_rolldown_status() + if(rolled_down == -1) usr << "You cannot roll down [src]!" return - + rolled_down = !rolled_down if(rolled_down) body_parts_covered &= LOWER_TORSO|LEGS|FEET diff --git a/code/modules/customitems/item_spawning.dm b/code/modules/customitems/item_spawning.dm index c99fe6936d..a573a4d7bc 100644 --- a/code/modules/customitems/item_spawning.dm +++ b/code/modules/customitems/item_spawning.dm @@ -49,18 +49,22 @@ item.icon = CUSTOM_ITEM_OBJ item.icon_state = item_icon return - else + else if(inherit_inhands) apply_inherit_inhands(item) else item.item_state_slots = null item.item_icons = null - + item.icon = CUSTOM_ITEM_OBJ item.icon_state = item_icon item.item_state = null item.icon_override = CUSTOM_ITEM_MOB + var/obj/item/clothing/under/U = item + if(istype(U)) + U.update_rolldown_status() + // Kits are dumb so this is going to have to be hardcoded/snowflake. if(istype(item, /obj/item/device/kit)) var/obj/item/device/kit/K = item @@ -81,9 +85,9 @@ /datum/custom_item/proc/apply_inherit_inhands(var/obj/item/item) var/list/new_item_icons = list() var/list/new_item_state_slots = list() - + var/list/available_states = icon_states(CUSTOM_ITEM_MOB) - + //If l_hand or r_hand are not present, preserve them using item_icons/item_state_slots //Then use icon_override to make every other slot use the custom sprites by default. //This has to be done before we touch any of item's vars @@ -93,7 +97,7 @@ if(!("[item_icon]_r" in available_states)) new_item_state_slots[slot_r_hand_str] = get_state(item, slot_r_hand_str, "_r") new_item_icons[slot_r_hand_str] = get_icon(item, slot_r_hand_str, 'icons/mob/items/righthand.dmi') - + item.item_state_slots = new_item_state_slots item.item_icons = new_item_icons