Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pride pin reskinning #82920

Merged
merged 9 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,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)
Expand Down
31 changes: 30 additions & 1 deletion code/game/objects/items_reskin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 7 additions & 2 deletions code/modules/clothing/under/_under.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down
7 changes: 7 additions & 0 deletions code/modules/clothing/under/accessories/_accessories.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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?
*/
Expand Down
8 changes: 6 additions & 2 deletions code/modules/clothing/under/accessories/badges.dm
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,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"
Expand Down