Skip to content

Commit

Permalink
[MIRROR] Hand label refactor / Adds hand label visuals (#1551)
Browse files Browse the repository at this point in the history
* Hand label refactor / Adds hand label visuals

* Update handlabeler.dm

---------

Co-authored-by: MrMelbert <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed Mar 22, 2024
1 parent 9aba8d1 commit dd22c1d
Show file tree
Hide file tree
Showing 9 changed files with 290 additions and 173 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
#define MAX_BROADCAST_LEN 512
#define MAX_CHARTER_LEN 80
#define MAX_PLAQUE_LEN 144
#define MAX_LABEL_LEN 64

// Audio/Visual Flags. Used to determine what sense are required to notice a message.
#define MSG_VISUAL (1<<0)
Expand Down
95 changes: 0 additions & 95 deletions code/datums/components/label.dm

This file was deleted.

47 changes: 27 additions & 20 deletions code/datums/components/sticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@
var/atom/movable/our_sticker
/// Reference to the created overlay, used during component deletion.
var/mutable_appearance/sticker_overlay
// Callback invoked when sticker is applied to the parent.
var/datum/callback/stick_callback
// Callback invoked when sticker is peeled (not removed) from the parent.
var/datum/callback/peel_callback

/datum/component/sticker/Initialize(atom/stickering_atom, mob/user, dir = NORTH, px = 0, py = 0)
/datum/component/sticker/Initialize(atom/stickering_atom, dir = NORTH, px = 0, py = 0, datum/callback/stick_callback, datum/callback/peel_callback)
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE

src.our_sticker = our_sticker

if(isliving(parent) && !isnull(user))
var/mob/living/victim = parent

if(!isnull(victim.client))
user.log_message("stuck [stickering_atom] to [key_name(victim)]", LOG_ATTACK)
victim.log_message("had [stickering_atom] stuck to them by [key_name(user)]", LOG_ATTACK)

src.stick_callback = stick_callback
src.peel_callback = peel_callback
stick(stickering_atom, px, py)
register_turf_signals(dir)

Expand All @@ -38,19 +36,18 @@

REMOVE_TRAIT(parent, TRAIT_STICKERED, REF(src))

QDEL_NULL(our_sticker)
QDEL_NULL(sticker_overlay)
our_sticker = null
sticker_overlay = null
stick_callback = null
peel_callback = null
return ..()

/datum/component/sticker/RegisterWithParent()
if(isliving(parent))
RegisterSignal(parent, COMSIG_LIVING_IGNITED, PROC_REF(on_ignite))
RegisterSignal(parent, COMSIG_LIVING_IGNITED, PROC_REF(on_ignite))
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, PROC_REF(on_clean))

/datum/component/sticker/UnregisterFromParent()
if(isliving(parent))
UnregisterSignal(parent, COMSIG_LIVING_IGNITED)
UnregisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT)
UnregisterSignal(parent, list(COMSIG_LIVING_IGNITED, COMSIG_COMPONENT_CLEAN_ACT))

/// Subscribes to `COMSIG_TURF_EXPOSE` if parent atom is a turf. If turf is closed - subscribes to signal
/datum/component/sticker/proc/register_turf_signals(dir)
Expand All @@ -67,10 +64,18 @@

UnregisterSignal(listening_turf, COMSIG_TURF_EXPOSE)

/datum/component/sticker/proc/sticker_gone(...)
SIGNAL_HANDLER

UnregisterSignal(our_sticker, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED))
our_sticker = null
qdel(src)

/// Handles overlay creation from supplied atom, adds created icon to the parent object, moves source atom to the nullspace.
/datum/component/sticker/proc/stick(atom/movable/stickering_atom, px, py)
our_sticker = stickering_atom
our_sticker.moveToNullspace()
RegisterSignals(our_sticker, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED), PROC_REF(sticker_gone))

var/atom/parent_atom = parent

Expand All @@ -79,23 +84,25 @@
sticker_overlay.pixel_z = py - world.icon_size / 2

parent_atom.add_overlay(sticker_overlay)

stick_callback?.Invoke(parent)
ADD_TRAIT(parent, TRAIT_STICKERED, REF(src))

/// Moves stickered atom from the nullspace, deletes component.
/datum/component/sticker/proc/peel()
var/atom/parent_atom = parent
var/turf/drop_location = isnull(listening_turf) ? parent_atom.drop_location() : listening_turf
var/turf/drop_location = listening_turf || parent_atom.drop_location()

UnregisterSignal(our_sticker, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED))
our_sticker.forceMove(drop_location)
our_sticker = null
peel_callback?.Invoke(parent)

qdel(src)

/datum/component/sticker/proc/on_ignite(datum/source)
SIGNAL_HANDLER

qdel(src)
qdel(our_sticker) // which qdels us

/datum/component/sticker/proc/on_clean(datum/source, clean_types)
SIGNAL_HANDLER
Expand All @@ -108,4 +115,4 @@
SIGNAL_HANDLER

if(exposed_temperature >= FIRE_MINIMUM_TEMPERATURE_TO_EXIST)
qdel(src)
qdel(our_sticker) // which qdels us
6 changes: 5 additions & 1 deletion code/game/objects/items/stickers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@
if(!isnull(user))
user.do_attack_animation(target, used_item = src)
target.balloon_alert(user, "sticker sticked")
var/mob/living/victim = target
if(istype(victim) && !isnull(victim.client))
user.log_message("stuck [src] to [key_name(victim)]", LOG_ATTACK)
victim.log_message("had [src] stuck to them by [key_name(user)]", LOG_ATTACK)

target.AddComponent(/datum/component/sticker, src, user, get_dir(target, src), px, py)
target.AddComponent(/datum/component/sticker, src, get_dir(target, src), px, py)
return TRUE

#undef MAX_STICKER_COUNT
Expand Down
11 changes: 11 additions & 0 deletions code/modules/hydroponics/fermenting_barrel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
soundloop = new(src, fermenting)
soundloop.volume = sound_volume

RegisterSignals(src, list(
SIGNAL_ADDTRAIT(TRAIT_WAS_RENAMED),
SIGNAL_ADDTRAIT(TRAIT_HAS_LABEL),
SIGNAL_REMOVETRAIT(TRAIT_WAS_RENAMED),
SIGNAL_REMOVETRAIT(TRAIT_HAS_LABEL),
), PROC_REF(update_overlay_on_sig))

/obj/structure/fermenting_barrel/Destroy()
QDEL_NULL(soundloop)
return ..()
Expand Down Expand Up @@ -82,6 +89,10 @@
icon_state = open ? "barrel_open" : "barrel"
return ..()

/obj/structure/fermenting_barrel/proc/update_overlay_on_sig()
SIGNAL_HANDLER
update_appearance(UPDATE_ICON)

/obj/structure/fermenting_barrel/update_overlays()
. = ..()
if(HAS_TRAIT(src, TRAIT_WAS_RENAMED) || HAS_TRAIT(src, TRAIT_HAS_LABEL))
Expand Down
Loading

0 comments on commit dd22c1d

Please sign in to comment.