Fixes #26844 - Labeled condiment bottle loses its label when contents change (#26897)

* Fixes #26844

* removed some extra whitespace

* camel case'd everything that wasn't inherited and also switched seed lavelling to use the new update_name()

* ...and a little to the left...

* Alright, that's all set, hopefully!

* Update code/datums/components/label.dm

Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Signed-off-by: Pidgey <35320204+PidgeyThePirate@users.noreply.github.com>

* Picky, picky.

* Update code/datums/components/label.dm

Co-authored-by: warriorstar-orion <orion@snowfrost.garden>
Signed-off-by: Pidgey <35320204+PidgeyThePirate@users.noreply.github.com>

* Update code/datums/components/label.dm

Co-authored-by: warriorstar-orion <orion@snowfrost.garden>
Signed-off-by: Pidgey <35320204+PidgeyThePirate@users.noreply.github.com>

* Update code/datums/components/label.dm

Co-authored-by: warriorstar-orion <orion@snowfrost.garden>
Signed-off-by: Pidgey <35320204+PidgeyThePirate@users.noreply.github.com>

* One more tweak, hopefully.

---------

Signed-off-by: Pidgey <35320204+PidgeyThePirate@users.noreply.github.com>
Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Co-authored-by: warriorstar-orion <orion@snowfrost.garden>
This commit is contained in:
Pidgey
2024-11-21 02:57:01 +00:00
committed by GitHub
co-authored by DGamerL warriorstar-orion
parent 0f272d16b5
commit 9e6d40514a
3 changed files with 17 additions and 8 deletions
+15 -6
View File
@@ -22,11 +22,12 @@
apply_label()
/datum/component/label/RegisterWithParent()
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, PROC_REF(OnAttackby))
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(Examine))
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, PROC_REF(on_attack_by))
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
RegisterSignal(parent, COMSIG_ATOM_UPDATE_NAME, PROC_REF(on_update_name))
/datum/component/label/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_PARENT_ATTACKBY, COMSIG_PARENT_EXAMINE))
UnregisterSignal(parent, list(COMSIG_PARENT_ATTACKBY, COMSIG_PARENT_EXAMINE, COMSIG_ATOM_UPDATE_NAME))
/**
This proc will fire after the parent is hit by a hand labeler which is trying to apply another label.
@@ -51,7 +52,8 @@
* attacker: The object that is hitting the parent.
* user: The mob who is wielding the attacking object.
*/
/datum/component/label/proc/OnAttackby(datum/source, obj/item/attacker, mob/user)
/datum/component/label/proc/on_attack_by(datum/source, obj/item/attacker, mob/user)
SIGNAL_HANDLER // COMSIG_PARENT_ATTACKBY
// If the attacking object is not a hand labeler or it's not off (has a label ready to apply), return.
// The hand labeler should be off in order to remove a label.
var/obj/item/hand_labeler/labeler = attacker
@@ -72,7 +74,14 @@
* user: The mob exmaining the parent.
* examine_list: The current list of text getting passed from the parent's normal examine() proc.
*/
/datum/component/label/proc/Examine(datum/source, mob/user, list/examine_list)
///Reapplies label when update_name is called on the parent object. Attempts to remove it first just in case.
/datum/component/label/proc/on_update_name()
SIGNAL_HANDLER // COMSIG_ATOM_UPDATE_NAME
remove_label()
apply_label()
/datum/component/label/proc/on_examine(datum/source, mob/user, list/examine_list)
examine_list += "<span class='notice'>It has a label with some words written on it. Use a hand labeler to remove it.</span>"
/// Applies a label to the name of the parent in the format of: "parent_name (label)"
@@ -96,7 +105,7 @@
return ..()
/// Adds detailed information to the examine text.
/datum/component/label/goal/Examine(datum/source, mob/user, list/examine_list)
/datum/component/label/goal/on_examine(datum/source, mob/user, list/examine_list)
examine_list += "<span class='notice'>It has a label on it, marking it as part of a secondary goal for [label_name]. Use a hand labeler to remove it.</span>"
/// Applies a static label to the parent's name.