mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-19 03:55:11 +01:00
Adds pen clicking, changes most pen typechecks into writing implement checks (#84186)
## About The Pull Request Fixes #84170 Adds pen clicking and changes some of edagger and pendriver code to use it instead. Also replaces most pen typechecks to writing implement checks where it makes sense, so now you can rename things with everything you can write with (crayons)  Twisting pen caps (for traitor uplinks) has been moved to ctrl + click instead.
This commit is contained in:
@@ -77,7 +77,7 @@
|
||||
return
|
||||
to_chat(user, span_notice("You put [weapon] into [src]."))
|
||||
update_appearance()
|
||||
else if(istype(weapon, /obj/item/pen))
|
||||
else if(IS_WRITING_UTENSIL(weapon))
|
||||
rename(user, weapon)
|
||||
|
||||
/obj/item/folder/attack_self(mob/user)
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
/obj/item/paperplane/attackby(obj/item/attacking_item, mob/user, params)
|
||||
if(burn_paper_product_attackby_check(attacking_item, user))
|
||||
return
|
||||
if(istype(attacking_item, /obj/item/pen) || istype(attacking_item, /obj/item/toy/crayon))
|
||||
if(IS_WRITING_UTENSIL(attacking_item))
|
||||
to_chat(user, span_warning("You should unfold [src] before changing it!"))
|
||||
return
|
||||
else if(istype(attacking_item, /obj/item/stamp)) //we don't randomize stamps on a paperplane
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
var/dart_insert_icon = 'icons/obj/weapons/guns/toy.dmi'
|
||||
var/dart_insert_casing_icon_state = "overlay_pen"
|
||||
var/dart_insert_projectile_icon_state = "overlay_pen_proj"
|
||||
/// If this pen can be clicked in order to retract it
|
||||
var/can_click = TRUE
|
||||
|
||||
/obj/item/pen/Initialize(mapload)
|
||||
. = ..()
|
||||
@@ -47,6 +49,34 @@
|
||||
AddElement(/datum/element/tool_renaming)
|
||||
RegisterSignal(src, COMSIG_DART_INSERT_ADDED, PROC_REF(on_inserted_into_dart))
|
||||
RegisterSignal(src, COMSIG_DART_INSERT_REMOVED, PROC_REF(on_removed_from_dart))
|
||||
if (!can_click)
|
||||
return
|
||||
create_transform_component()
|
||||
RegisterSignal(src, COMSIG_TRANSFORMING_ON_TRANSFORM, PROC_REF(on_transform))
|
||||
|
||||
/// Proc that child classes can override to have custom transforms, like edaggers or pendrivers
|
||||
/obj/item/pen/proc/create_transform_component()
|
||||
AddComponent( \
|
||||
/datum/component/transforming, \
|
||||
sharpness_on = NONE, \
|
||||
inhand_icon_change = FALSE, \
|
||||
)
|
||||
|
||||
/*
|
||||
* Signal proc for [COMSIG_TRANSFORMING_ON_TRANSFORM].
|
||||
*
|
||||
* Clicks the pen to make an annoying sound. Clickity clickery click!
|
||||
*/
|
||||
/obj/item/pen/proc/on_transform(obj/item/source, mob/user, active)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(user)
|
||||
balloon_alert(user, "clicked")
|
||||
playsound(src, 'sound/machines/click.ogg', 30, TRUE, -3)
|
||||
icon_state = initial(icon_state) + (active ? "_retracted" : "")
|
||||
update_appearance(UPDATE_ICON)
|
||||
|
||||
return COMPONENT_NO_DEFAULT_MESSAGE
|
||||
|
||||
/obj/item/pen/proc/on_inserted_into_dart(datum/source, obj/projectile/dart, mob/user, embedded = FALSE)
|
||||
SIGNAL_HANDLER
|
||||
@@ -90,6 +120,7 @@
|
||||
name = "four-color pen"
|
||||
icon_state = "pen_4color"
|
||||
colour = COLOR_BLACK
|
||||
can_click = FALSE
|
||||
|
||||
/obj/item/pen/fourcolor/attack_self(mob/living/carbon/user)
|
||||
. = ..()
|
||||
@@ -110,6 +141,8 @@
|
||||
colour = COLOR_BLACK
|
||||
to_chat(user, span_notice("\The [src] will now write in [chosen_color]."))
|
||||
desc = "It's a fancy four-color ink pen, set to [chosen_color]."
|
||||
balloon_alert(user, "clicked")
|
||||
playsound(src, 'sound/machines/click.ogg', 30, TRUE, -3)
|
||||
|
||||
/obj/item/pen/fountain
|
||||
name = "fountain pen"
|
||||
@@ -119,6 +152,7 @@
|
||||
requires_gravity = FALSE // fancy spess pens
|
||||
dart_insert_casing_icon_state = "overlay_fountainpen"
|
||||
dart_insert_projectile_icon_state = "overlay_fountainpen_proj"
|
||||
can_click = FALSE
|
||||
|
||||
/obj/item/pen/charcoal
|
||||
name = "charcoal stylus"
|
||||
@@ -129,6 +163,7 @@
|
||||
custom_materials = null
|
||||
grind_results = list(/datum/reagent/ash = 5, /datum/reagent/cellulose = 10)
|
||||
requires_gravity = FALSE // this is technically a pencil
|
||||
can_click = FALSE
|
||||
|
||||
/datum/crafting_recipe/charcoal_stylus
|
||||
name = "Charcoal Stylus"
|
||||
@@ -187,19 +222,17 @@
|
||||
insert_comp.casing_overlay_icon_state = overlay_reskin[current_skin]
|
||||
insert_comp.projectile_overlay_icon_state = "[overlay_reskin[current_skin]]_proj"
|
||||
|
||||
/obj/item/pen/attack_self(mob/living/carbon/user)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
/obj/item/pen/item_ctrl_click(mob/living/carbon/user)
|
||||
if(loc != user)
|
||||
to_chat(user, span_warning("You must be holding the pen to continue!"))
|
||||
return
|
||||
return CLICK_ACTION_BLOCKING
|
||||
var/deg = tgui_input_number(user, "What angle would you like to rotate the pen head to? (0-360)", "Rotate Pen Head", max_value = 360)
|
||||
if(isnull(deg) || QDELETED(user) || QDELETED(src) || !user.can_perform_action(src, FORBID_TELEKINESIS_REACH) || loc != user)
|
||||
return
|
||||
return CLICK_ACTION_BLOCKING
|
||||
degrees = deg
|
||||
to_chat(user, span_notice("You rotate the top of the pen to [deg] degrees."))
|
||||
SEND_SIGNAL(src, COMSIG_PEN_ROTATED, deg, user)
|
||||
return CLICK_ACTION_SUCCESS
|
||||
|
||||
/obj/item/pen/attack(mob/living/M, mob/user, params)
|
||||
if(force) // If the pen has a force value, call the normal attack procs. Used for e-daggers and captain's pen mostly.
|
||||
@@ -212,6 +245,8 @@
|
||||
return TRUE
|
||||
|
||||
/obj/item/pen/get_writing_implement_details()
|
||||
if (HAS_TRAIT(src, TRAIT_TRANSFORM_ACTIVE))
|
||||
return null
|
||||
return list(
|
||||
interaction_mode = MODE_WRITING,
|
||||
font = font,
|
||||
@@ -287,6 +322,9 @@
|
||||
speed = 6 SECONDS, \
|
||||
butcher_sound = 'sound/weapons/blade1.ogg', \
|
||||
)
|
||||
RegisterSignal(src, COMSIG_DETECTIVE_SCANNED, PROC_REF(on_scan))
|
||||
|
||||
/obj/item/pen/edagger/create_transform_component()
|
||||
AddComponent( \
|
||||
/datum/component/transforming, \
|
||||
force_on = 18, \
|
||||
@@ -296,8 +334,6 @@
|
||||
w_class_on = WEIGHT_CLASS_NORMAL, \
|
||||
inhand_icon_change = FALSE, \
|
||||
)
|
||||
RegisterSignal(src, COMSIG_TRANSFORMING_ON_TRANSFORM, PROC_REF(on_transform))
|
||||
RegisterSignal(src, COMSIG_DETECTIVE_SCANNED, PROC_REF(on_scan))
|
||||
|
||||
/obj/item/pen/edagger/on_inserted_into_dart(datum/source, obj/item/ammo_casing/dart, mob/user)
|
||||
. = ..()
|
||||
@@ -369,9 +405,7 @@
|
||||
* Handles swapping their icon files to edagger related icon files -
|
||||
* as they're supposed to look like a normal pen.
|
||||
*/
|
||||
/obj/item/pen/edagger/proc/on_transform(obj/item/source, mob/user, active)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
/obj/item/pen/edagger/on_transform(obj/item/source, mob/user, active)
|
||||
if(active)
|
||||
name = hidden_name
|
||||
desc = hidden_desc
|
||||
@@ -418,6 +452,7 @@
|
||||
colour = COLOR_BLUE
|
||||
dart_insert_casing_icon_state = "overlay_survivalpen"
|
||||
dart_insert_projectile_icon_state = "overlay_survivalpen_proj"
|
||||
can_click = FALSE
|
||||
|
||||
/obj/item/pen/survival/on_inserted_into_dart(datum/source, obj/item/ammo_casing/dart, mob/user)
|
||||
. = ..()
|
||||
@@ -456,6 +491,9 @@
|
||||
|
||||
/obj/item/pen/screwdriver/Initialize(mapload)
|
||||
. = ..()
|
||||
AddElement(/datum/element/update_icon_updates_onmob)
|
||||
|
||||
/obj/item/pen/screwdriver/create_transform_component()
|
||||
AddComponent( \
|
||||
/datum/component/transforming, \
|
||||
throwforce_on = 5, \
|
||||
@@ -464,12 +502,7 @@
|
||||
inhand_icon_change = FALSE, \
|
||||
)
|
||||
|
||||
RegisterSignal(src, COMSIG_TRANSFORMING_ON_TRANSFORM, PROC_REF(toggle_screwdriver))
|
||||
AddElement(/datum/element/update_icon_updates_onmob)
|
||||
|
||||
/obj/item/pen/screwdriver/proc/toggle_screwdriver(obj/item/source, mob/user, active)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
/obj/item/pen/screwdriver/on_transform(obj/item/source, mob/user, active)
|
||||
if(user)
|
||||
balloon_alert(user, active ? "extended" : "retracted")
|
||||
playsound(src, 'sound/weapons/batonextend.ogg', 50, TRUE)
|
||||
|
||||
Reference in New Issue
Block a user