mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 16:44:43 +01:00
[MIRROR] Adds screentips to rolling beds and body bags. [MDB IGNORE] (#15140)
* Adds screentips to rolling beds and body bags. (#68331) Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> * Adds screentips to rolling beds and body bags. Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/// Apply basic contextual screentips when the user hovers over this item with an item of the given tool behavior.
|
||||
/// A "Type B" interaction.
|
||||
/// This stacks with other contextual screentip elements, though you may want to register the signal/flag manually at that point for performance.
|
||||
/datum/element/contextual_screentip_sharpness
|
||||
element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH
|
||||
id_arg_index = 2
|
||||
|
||||
/// If set, the text to show for LMB
|
||||
var/lmb_text
|
||||
|
||||
/// If set, the text to show for RMB
|
||||
var/rmb_text
|
||||
|
||||
/datum/element/contextual_screentip_sharpness/Attach(datum/target, lmb_text, rmb_text)
|
||||
. = ..()
|
||||
if (!isatom(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
|
||||
src.lmb_text = lmb_text
|
||||
src.rmb_text = rmb_text
|
||||
|
||||
var/atom/atom_target = target
|
||||
atom_target.flags_1 |= HAS_CONTEXTUAL_SCREENTIPS_1
|
||||
RegisterSignal(atom_target, COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, .proc/on_requesting_context_from_item)
|
||||
|
||||
/datum/element/contextual_screentip_sharpness/Detach(datum/source, ...)
|
||||
UnregisterSignal(source, COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM)
|
||||
|
||||
// We don't remove HAS_CONTEXTUAL_SCREENTIPS_1, since there could be other stuff still hooked to it,
|
||||
// and being set without signals is not dangerous, just less performant.
|
||||
// A lot of things don't do this, perhaps make a proc that checks if any signals are still set, and if not,
|
||||
// remove the flag.
|
||||
|
||||
return ..()
|
||||
|
||||
/datum/element/contextual_screentip_sharpness/proc/on_requesting_context_from_item(
|
||||
datum/source,
|
||||
list/context,
|
||||
obj/item/held_item,
|
||||
)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if (isnull(held_item))
|
||||
return NONE
|
||||
|
||||
var/sharpness = held_item.get_sharpness()
|
||||
if (!sharpness)
|
||||
return NONE
|
||||
|
||||
if (!isnull(lmb_text))
|
||||
context[SCREENTIP_CONTEXT_LMB] = lmb_text
|
||||
|
||||
if (!isnull(rmb_text))
|
||||
context[SCREENTIP_CONTEXT_RMB] = rmb_text
|
||||
|
||||
return CONTEXTUAL_SCREENTIP_SET
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
icon = 'icons/obj/bodybag.dmi'
|
||||
icon_state = "bodybag_folded"
|
||||
w_class = WEIGHT_CLASS_SMALL
|
||||
///Stored path we use for spawning a new body bag entity when unfolded.
|
||||
var/unfoldedbag_path = /obj/structure/closet/body_bag
|
||||
|
||||
/obj/item/bodybag/attack_self(mob/user)
|
||||
@@ -19,6 +20,11 @@
|
||||
if(isopenturf(target))
|
||||
deploy_bodybag(user, target)
|
||||
|
||||
/**
|
||||
* Creates a new body bag item when unfolded, at the provided location, replacing the body bag item.
|
||||
* * mob/user: User opening the body bag.
|
||||
* * atom/location: the place/entity/mob where the body bag is being deployed from.
|
||||
*/
|
||||
/obj/item/bodybag/proc/deploy_bodybag(mob/user, atom/location)
|
||||
var/obj/structure/closet/body_bag/item_bag = new unfoldedbag_path(location)
|
||||
item_bag.open(user)
|
||||
|
||||
@@ -57,8 +57,15 @@
|
||||
icon_state = "down"
|
||||
anchored = FALSE
|
||||
resistance_flags = NONE
|
||||
///The item it spawns when it's folded up.
|
||||
var/foldabletype = /obj/item/roller
|
||||
|
||||
/obj/structure/bed/roller/Initialize(mapload)
|
||||
. = ..()
|
||||
AddElement( \
|
||||
/datum/element/contextual_screentip_bare_hands, \
|
||||
rmb_text = "Fold up", \
|
||||
)
|
||||
|
||||
/obj/structure/bed/roller/examine(mob/user)
|
||||
. = ..()
|
||||
|
||||
@@ -22,6 +22,20 @@
|
||||
var/tagged = FALSE // so closet code knows to put the tag overlay back
|
||||
can_install_electronics = FALSE
|
||||
|
||||
/obj/structure/closet/body_bag/Initialize(mapload)
|
||||
. = ..()
|
||||
var/static/list/tool_behaviors = list(
|
||||
TOOL_WIRECUTTER = list(
|
||||
SCREENTIP_CONTEXT_RMB = "Remove Tag",
|
||||
),
|
||||
)
|
||||
AddElement(/datum/element/contextual_screentip_tools, tool_behaviors)
|
||||
AddElement( \
|
||||
/datum/element/contextual_screentip_bare_hands, \
|
||||
rmb_text = "Fold up", \
|
||||
)
|
||||
AddElement(/datum/element/contextual_screentip_sharpness, lmb_text = "Remove Tag")
|
||||
|
||||
/obj/structure/closet/body_bag/Destroy()
|
||||
// If we have a stored bag, and it's in nullspace (not in someone's hand), delete it.
|
||||
if (foldedbag_instance && !foldedbag_instance.loc)
|
||||
|
||||
@@ -1111,6 +1111,7 @@
|
||||
#include "code\datums\elements\food\venue_price.dm"
|
||||
#include "code\datums\elements\screentips\contextual_screentip_bare_hands.dm"
|
||||
#include "code\datums\elements\screentips\contextual_screentip_item_typechecks.dm"
|
||||
#include "code\datums\elements\screentips\contextual_screentip_sharpness.dm"
|
||||
#include "code\datums\elements\screentips\contextual_screentip_tools.dm"
|
||||
#include "code\datums\greyscale\_greyscale_config.dm"
|
||||
#include "code\datums\greyscale\json_reader.dm"
|
||||
|
||||
Reference in New Issue
Block a user