diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index bd70bf2f475..2a7c64bb510 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -268,9 +268,7 @@ if(LAZYLEN(embedding)) updateEmbedding() - if(unique_reskin) - RegisterSignal(src, COMSIG_CLICK_ALT, PROC_REF(on_click_alt_reskin)) - register_context() + setup_reskinning() /obj/item/Destroy(force) diff --git a/code/game/objects/items_reskin.dm b/code/game/objects/items_reskin.dm index 1a7c27e098d..9fa3b91d0e1 100644 --- a/code/game/objects/items_reskin.dm +++ b/code/game/objects/items_reskin.dm @@ -11,12 +11,41 @@ INVOKE_ASYNC(src, PROC_REF(reskin_obj), user) return CLICK_ACTION_SUCCESS +/** + * Checks if we should set up reskinning, + * by default if unique_reskin is set. + * + * Called on setup_reskinning(). + * Inheritors should override this to add their own checks. + */ +/obj/item/proc/check_setup_reskinning() + SHOULD_CALL_PARENT(TRUE) + if(unique_reskin) + return TRUE + + return FALSE + +/** + * Registers signals and context for reskinning, + * if check_setup_reskinning() passes. + * + * Called on Initialize(...). + * Inheritors should override this to add their own setup steps, + * or to avoid double calling register_context(). + */ +/obj/item/proc/setup_reskinning() + SHOULD_CALL_PARENT(FALSE) + if(!check_setup_reskinning()) + return + + RegisterSignal(src, COMSIG_CLICK_ALT, PROC_REF(on_click_alt_reskin)) + register_context() /** * Reskins object based on a user's choice * * Arguments: - * * M The mob choosing a reskin option + * * user The mob choosing a reskin option */ /obj/item/proc/reskin_obj(mob/user) if(!LAZYLEN(unique_reskin)) diff --git a/code/modules/clothing/under/_under.dm b/code/modules/clothing/under/_under.dm index 7194046b196..4a881582d33 100644 --- a/code/modules/clothing/under/_under.dm +++ b/code/modules/clothing/under/_under.dm @@ -51,10 +51,15 @@ if(random_sensor) //make the sensor mode favor higher levels, except coords. sensor_mode = pick(SENSOR_VITALS, SENSOR_VITALS, SENSOR_VITALS, SENSOR_LIVING, SENSOR_LIVING, SENSOR_COORDS, SENSOR_COORDS, SENSOR_OFF) - if(!unique_reskin) // Already registered via unique reskin - register_context() + register_context() AddElement(/datum/element/update_icon_updates_onmob, flags = ITEM_SLOT_ICLOTHING|ITEM_SLOT_OCLOTHING, body = TRUE) +/obj/item/clothing/under/setup_reskinning() + if(!check_setup_reskinning()) + return + + // We already register context in Initialize. + RegisterSignal(src, COMSIG_CLICK_ALT, PROC_REF(on_click_alt_reskin)) /obj/item/clothing/under/add_context(atom/source, list/context, obj/item/held_item, mob/living/user) . = ..() diff --git a/code/modules/clothing/under/accessories/_accessories.dm b/code/modules/clothing/under/accessories/_accessories.dm index 67c2768ad23..fdaf666638d 100644 --- a/code/modules/clothing/under/accessories/_accessories.dm +++ b/code/modules/clothing/under/accessories/_accessories.dm @@ -30,6 +30,13 @@ . = ..() register_context() +/obj/item/clothing/accessory/setup_reskinning() + if(!check_setup_reskinning()) + return + + // We already register context regardless in Initialize. + RegisterSignal(src, COMSIG_CLICK_ALT, PROC_REF(on_click_alt_reskin)) + /** * Can we be attached to the passed clothing article? */ diff --git a/code/modules/clothing/under/accessories/badges.dm b/code/modules/clothing/under/accessories/badges.dm index 21afd8aab79..5b2bda98416 100644 --- a/code/modules/clothing/under/accessories/badges.dm +++ b/code/modules/clothing/under/accessories/badges.dm @@ -195,9 +195,13 @@ GLOBAL_LIST_INIT(pride_pin_reskins, list( icon_state = "pride" obj_flags = UNIQUE_RENAME | INFINITE_RESKIN -/obj/item/clothing/accessory/pride/Initialize(mapload) - . = ..() +/obj/item/clothing/accessory/pride/setup_reskinning() unique_reskin = GLOB.pride_pin_reskins + if(!check_setup_reskinning()) + return + + // We already register context regardless in Initialize. + RegisterSignal(src, COMSIG_CLICK_ALT, PROC_REF(on_click_alt_reskin)) /obj/item/clothing/accessory/deaf_pin name = "deaf personnel pin"