Refactors renaming things with a pen. (#14960)

* Refactors renaming things with a pen.

* Farie review (thanks!!)

* Derp.

* Farie take 2
This commit is contained in:
moxian
2020-12-16 14:43:15 -05:00
committed by GitHub
parent b797f85a49
commit 1683c4271a
27 changed files with 186 additions and 268 deletions
+6 -12
View File
@@ -27,23 +27,17 @@
/obj/structure/closet/body_bag/attackby(W as obj, mob/user as mob, params)
if(istype(W, /obj/item/pen))
var/t = input(user, "What would you like the label to be?", text("[]", src.name), null) as text
if(user.get_active_hand() != W)
var/t = rename_interactive(user, W)
if(isnull(t))
return
if(!in_range(src, user) && src.loc != user)
return
t = sanitize(copytext(t,1,MAX_MESSAGE_LEN))
cut_overlays()
if(t)
src.name = "body bag - "
src.name += t
src.overlays += image(src.icon, "bodybag_label")
else
src.name = "body bag"
add_overlay(image(icon, "bodybag_label"))
return
if(istype(W, /obj/item/wirecutters))
to_chat(user, "You cut the tag off the bodybag")
src.name = "body bag"
src.overlays.Cut()
name = "body bag"
cut_overlays()
return
return ..()
@@ -309,12 +309,7 @@
to_chat(user, "<span class='notice'>You wound the tape back in!</span>")
fix()
else if(istype(I, /obj/item/pen))
var/title = stripped_input(usr,"What do you want to name the tape?", "Tape Renaming", name, MAX_NAME_LEN)
if(!title || !length(title))
name = initial(name)
return
name = "tape - [title]"
rename_interactive(user, I)
//Random colour tapes
/obj/item/tape/random/New()
@@ -29,15 +29,7 @@
/obj/item/implantcase/attackby(obj/item/W, mob/user, params)
..()
if(istype(W, /obj/item/pen))
var/t = stripped_input(user, "What would you like the label to be?", name, null)
if(user.get_active_hand() != W)
return
if(!in_range(src, user) && loc != user)
return
if(t)
name = "implant case - '[t]'"
else
name = "implant case"
rename_interactive(user, W)
else if(istype(W, /obj/item/implanter))
var/obj/item/implanter/I = W
if(I.imp)
@@ -43,15 +43,7 @@
/obj/item/implanter/attackby(obj/item/W, mob/user, params)
..()
if(istype(W, /obj/item/pen))
var/t = stripped_input(user, "What would you like the label to be?", name, null)
if(user.get_active_hand() != W)
return
if(!in_range(src, user) && loc != user)
return
if(t)
name = "implanter ([t])"
else
name = "implanter"
rename_interactive(user, W)
/obj/item/implanter/New()
..()
@@ -317,22 +317,10 @@
/obj/item/storage/pill_bottle/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/pen) || istype(I, /obj/item/flashlight/pen))
var/tmp_label = sanitize(input(user, "Enter a label for [name]","Label",label_text))
if(length(tmp_label) > MAX_NAME_LEN)
to_chat(user, "<span class='warning'>The label can be at most [MAX_NAME_LEN] characters long.</span>")
else
to_chat(user, "<span class='notice'>You set the label to \"[tmp_label]\".</span>")
label_text = tmp_label
update_name_label()
rename_interactive(user, I)
else
return ..()
/obj/item/storage/pill_bottle/proc/update_name_label()
if(label_text == "")
name = base_name
else
name = "[base_name] ([label_text])"
/obj/item/storage/pill_bottle/patch_pack
name = "Patch Pack"
desc = "It's a container for storing medical patches."
@@ -55,12 +55,11 @@
/obj/structure/door_assembly/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the door.", name, created_name),1,MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
created_name = t
// The door assembly gets renamed to "Assembly - Foobar",
// but the `t` returned from the proc is just "Foobar" without the prefix.
var/t = rename_interactive(user, W)
if(!isnull(t))
created_name = t
return
else if(iscoil(W) && state == AIRLOCK_ASSEMBLY_NEEDS_WIRES && anchored)
+5 -20
View File
@@ -125,18 +125,12 @@
/obj/structure/morgue/attackby(P as obj, mob/user as mob, params)
if(istype(P, /obj/item/pen))
var/t = input(user, "What would you like the label to be?", text("[]", name), null) as text
if(user.get_active_hand() != P)
var/t = rename_interactive(user, P)
if(isnull(t))
return
if((!in_range(src, usr) && loc != user))
return
t = sanitize(copytext(t,1,MAX_MESSAGE_LEN))
cut_overlays()
if(t)
name = text("Morgue- '[]'", t)
overlays += image(icon, "morgue_label")
else
name = "Morgue"
overlays.Cut()
add_overlay(image(icon, "morgue_label"))
add_fingerprint(user)
return
return ..()
@@ -325,16 +319,7 @@
/obj/structure/crematorium/attackby(P as obj, mob/user as mob, params)
if(istype(P, /obj/item/pen))
var/t = input(user, "What would you like the label to be?", text("[]", name), null) as text
if(user.get_active_hand() != P)
return
if((!in_range(src, usr) > 1 && loc != user))
return
t = sanitize(copytext(t,1,MAX_MESSAGE_LEN))
if(t)
name = text("Crematorium- '[]'", t)
else
name = "Crematorium"
rename_interactive(user, P)
add_fingerprint(user)
return
return ..()
@@ -148,12 +148,9 @@
W.forceMove(loc)
else if(istype(W, /obj/item/pen))
var/t = stripped_input(user, "Enter the name for the door.", name, created_name,MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
created_name = t
var/t = rename_interactive(user, W)
if(!isnull(t))
created_name = t
return
else
return ..()