Files
CHOMPStation2/code/modules/paperwork/clipboard.dm
CHOMPStation2StaffMirrorBot a245b8687f [MIRROR] usr to user part two (#10015)
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
2025-01-31 22:27:34 +01:00

180 lines
5.3 KiB
Plaintext

/obj/item/clipboard
name = "clipboard"
desc = "Used to clip paper to, for an on-the-go writing board."
icon = 'icons/obj/bureaucracy.dmi'
icon_state = "clipboard"
item_state = "clipboard"
throwforce = 0
w_class = ITEMSIZE_SMALL
throw_speed = 3
throw_range = 10
var/obj/item/pen/haspen //The stored pen.
var/obj/item/toppaper //The topmost piece of paper.
slot_flags = SLOT_BELT
/obj/item/clipboard/Initialize() //ChompEDIT New --> Initialize
update_icon()
/obj/item/clipboard/MouseDrop(obj/over_object as obj) //Quick clipboard fix. -Agouri
if(ishuman(usr))
var/mob/M = usr
if(!(istype(over_object, /obj/screen) ))
return ..()
if(!M.restrained() && !M.stat)
switch(over_object.name)
if("r_hand")
M.unEquip(src)
M.put_in_r_hand(src)
if("l_hand")
M.unEquip(src)
M.put_in_l_hand(src)
add_fingerprint(usr)
return
/obj/item/clipboard/update_icon()
cut_overlays()
if(toppaper)
add_overlay(toppaper.icon_state)
add_overlay(toppaper.overlays)
if(haspen)
add_overlay("clipboard_pen")
add_overlay("clipboard_over")
return
/obj/item/clipboard/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/paper) || istype(W, /obj/item/photo))
user.drop_item()
W.loc = src
if(istype(W, /obj/item/paper))
toppaper = W
to_chat(user, span_notice("You clip the [W] onto \the [src]."))
update_icon()
else if(istype(toppaper) && istype(W, /obj/item/pen))
toppaper.attackby(W, user)
update_icon()
return
/obj/item/clipboard/afterattack(turf/T as turf, mob/user)
for(var/obj/item/paper/P in T)
P.loc = src
toppaper = P
update_icon()
to_chat(user, span_notice("You clip the [P] onto \the [src]."))
/obj/item/clipboard/attack_self(mob/user)
var/dat = "<title>Clipboard</title>"
if(haspen)
dat += "<A href='byond://?src=\ref[src];pen=1'>Remove Pen</A><BR><HR>"
else
dat += "<A href='byond://?src=\ref[src];addpen=1'>Add Pen</A><BR><HR>"
//The topmost paper. I don't think there's any way to organise contents in byond, so this is what we're stuck with. -Pete
if(toppaper)
var/obj/item/paper/P = toppaper
dat += "<A href='byond://?src=\ref[src];write=\ref[P]'>Write</A> <A href='byond://?src=\ref[src];remove=\ref[P]'>Remove</A> <A href='byond://?src=\ref[src];rename=\ref[P]'>Rename</A> - <A href='byond://?src=\ref[src];read=\ref[P]'>[P.name]</A><BR><HR>"
for(var/obj/item/paper/P in src)
if(P==toppaper)
continue
dat += "<A href='byond://?src=\ref[src];remove=\ref[P]'>Remove</A> <A href='byond://?src=\ref[src];rename=\ref[P]'>Rename</A> - <A href='byond://?src=\ref[src];read=\ref[P]'>[P.name]</A><BR>"
for(var/obj/item/photo/Ph in src)
dat += "<A href='byond://?src=\ref[src];remove=\ref[Ph]'>Remove</A> <A href='byond://?src=\ref[src];rename=\ref[Ph]'>Rename</A> - <A href='byond://?src=\ref[src];look=\ref[Ph]'>[Ph.name]</A><BR>"
user << browse("<html>[dat]</html>", "window=clipboard")
onclose(user, "clipboard")
add_fingerprint(user)
return
/obj/item/clipboard/Topic(href, href_list)
..()
if((usr.stat || usr.restrained()))
return
if(src.loc == usr)
if(href_list["pen"])
if(istype(haspen) && (haspen.loc == src))
haspen.loc = usr.loc
usr.put_in_hands(haspen)
haspen = null
else if(href_list["addpen"])
if(!haspen)
var/obj/item/pen/W = usr.get_active_hand()
if(istype(W, /obj/item/pen))
usr.drop_item()
W.loc = src
haspen = W
to_chat(usr, span_notice("You slot the pen into \the [src]."))
else if(href_list["write"])
var/obj/item/P = locate(href_list["write"])
if(P && (P.loc == src) && istype(P, /obj/item/paper) && (P == toppaper) )
var/obj/item/I = usr.get_active_hand()
if(istype(I, /obj/item/pen))
P.attackby(I, usr)
else if(href_list["remove"])
var/obj/item/P = locate(href_list["remove"])
if(P && (P.loc == src) && (istype(P, /obj/item/paper) || istype(P, /obj/item/photo)) )
P.loc = usr.loc
usr.put_in_hands(P)
if(P == toppaper)
toppaper = null
var/obj/item/paper/newtop = locate(/obj/item/paper) in src
if(newtop && (newtop != P))
toppaper = newtop
else
toppaper = null
else if(href_list["rename"])
var/obj/item/O = locate(href_list["rename"])
if(O && (O.loc == src))
if(istype(O, /obj/item/paper))
var/obj/item/paper/to_rename = O
to_rename.rename()
else if(istype(O, /obj/item/photo))
var/obj/item/photo/to_rename = O
to_rename.rename()
else if(href_list["read"])
var/obj/item/paper/P = locate(href_list["read"])
if(P && (P.loc == src) && istype(P, /obj/item/paper) )
if(!(ishuman(usr) || isobserver(usr) || issilicon(usr)))
usr << browse("<HTML><HEAD><TITLE>[P.name]</TITLE></HEAD><BODY>[stars(P.info)][P.stamps]</BODY></HTML>", "window=[P.name]")
onclose(usr, "[P.name]")
else
usr << browse("<HTML><HEAD><TITLE>[P.name]</TITLE></HEAD><BODY>[P.info][P.stamps]</BODY></HTML>", "window=[P.name]")
onclose(usr, "[P.name]")
else if(href_list["look"])
var/obj/item/photo/P = locate(href_list["look"])
if(P && (P.loc == src) && istype(P, /obj/item/photo) )
P.show(usr)
else if(href_list["top"]) // currently unused
var/obj/item/P = locate(href_list["top"])
if(P && (P.loc == src) && istype(P, /obj/item/paper) )
toppaper = P
to_chat(usr, span_notice("You move [P.name] to the top."))
//Update everything
attack_self(usr)
update_icon()
return