This commit is contained in:
+134
-212
@@ -4,7 +4,11 @@
|
||||
*
|
||||
* lipstick wiping is in code/game/objects/items/weapons/cosmetics.dm!
|
||||
*/
|
||||
|
||||
/**
|
||||
** Paper is now using markdown (like in github pull notes) for ALL rendering
|
||||
** so we do loose a bit of functionality but we gain in easy of use of
|
||||
** paper and getting rid of that crashing bug
|
||||
**/
|
||||
/obj/item/paper
|
||||
name = "paper"
|
||||
gender = NEUTER
|
||||
@@ -21,19 +25,57 @@
|
||||
resistance_flags = FLAMMABLE
|
||||
max_integrity = 50
|
||||
dog_fashion = /datum/dog_fashion/head
|
||||
color = "white"
|
||||
/// What's actually written on the paper.
|
||||
var/info
|
||||
|
||||
var/info //What's actually written on the paper.
|
||||
var/info_links //A different version of the paper which includes html links at fields and EOF
|
||||
var/stamps //The (text for the) stamps on the paper.
|
||||
var/fields = 0 //Amount of user created fields
|
||||
/// The (text for the) stamps on the paper.
|
||||
var/stamps
|
||||
var/list/stamped
|
||||
|
||||
/// This REALLY should be a componenet. Basicly used during, april fools
|
||||
/// to honk at you
|
||||
var/rigged = 0
|
||||
var/spam_flag = 0
|
||||
///
|
||||
var/contact_poison // Reagent ID to transfer on contact
|
||||
var/contact_poison_volume = 0
|
||||
var/datum/oracle_ui/ui = null
|
||||
var/force_stars = FALSE // If we should force the text to get obfuscated with asterisks
|
||||
|
||||
var/ui_x = 600
|
||||
var/ui_y = 800
|
||||
/// When a piece of paper cannot be edited, this makes it mutable
|
||||
var/finalized = FALSE
|
||||
/// We MAY be edited, mabye we are just looking at it or something.
|
||||
var/readonly = FALSE
|
||||
/// Color of the pin that wrote on this paper
|
||||
var/pen_color = "black"
|
||||
|
||||
/**
|
||||
** This proc copies this sheet of paper to a new
|
||||
** sheet, Makes it nice and easy for carbon and
|
||||
** the copyer machine
|
||||
**/
|
||||
/obj/item/paper/proc/copy()
|
||||
var/obj/item/paper/N = new(arglist(args))
|
||||
N.info = info
|
||||
N.pen_color = pen_color
|
||||
N.color = color
|
||||
N.finalized = TRUE
|
||||
N.update_icon_state()
|
||||
N.stamps = stamps
|
||||
N.stamped = stamped.Copy()
|
||||
copy_overlays(N, TRUE)
|
||||
return N
|
||||
|
||||
/**
|
||||
** This proc sets the text of the paper and updates the
|
||||
** icons. You can modify the pen_color after if need
|
||||
** be.
|
||||
**/
|
||||
/obj/item/paper/proc/setText(text, read_only = TRUE)
|
||||
readonly = read_only
|
||||
info = text
|
||||
update_icon_state()
|
||||
|
||||
/obj/item/paper/pickup(user)
|
||||
if(contact_poison && ishuman(user))
|
||||
@@ -42,42 +84,16 @@
|
||||
if(!istype(G) || G.transfer_prints)
|
||||
H.reagents.add_reagent(contact_poison,contact_poison_volume)
|
||||
contact_poison = null
|
||||
//ui.check_view_all()
|
||||
..()
|
||||
|
||||
/obj/item/paper/dropped(mob/user)
|
||||
//ui.check_view(user)
|
||||
return ..()
|
||||
. = ..()
|
||||
|
||||
|
||||
/obj/item/paper/Initialize()
|
||||
. = ..()
|
||||
pixel_y = rand(-8, 8)
|
||||
pixel_x = rand(-9, 9)
|
||||
//ui = new /datum/oracle_ui(src, 420, 600, get_asset_datum(/datum/asset/spritesheet/simple/paper))
|
||||
//ui.can_resize = FALSE
|
||||
update_icon()
|
||||
updateinfolinks()
|
||||
/*
|
||||
/obj/item/paper/oui_getcontent(mob/target)
|
||||
if(!target.is_literate() || force_stars)
|
||||
force_stars = FALSE
|
||||
return "<HTML><HEAD><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><TITLE>[name]</TITLE></HEAD><BODY>[stars(info)]<HR>[stamps]</BODY></HTML>"
|
||||
else if(istype(target.get_active_held_item(), /obj/item/pen) | istype(target.get_active_held_item(), /obj/item/toy/crayon))
|
||||
return "<HTML><HEAD><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><TITLE>[name]</TITLE></HEAD><BODY>[info_links]<HR>[stamps]</BODY><div align='right'style='position:fixed;bottom:0;font-style:bold;'><A href='?src=[REF(src)];help=1'>\[?\]</A></div></HTML>"
|
||||
else
|
||||
return "<HTML><HEAD><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><TITLE>[name]</TITLE></HEAD><BODY>[info]<HR>[stamps]</BODY></HTML>"
|
||||
update_icon_state()
|
||||
|
||||
|
||||
/obj/item/paper/oui_canview(mob/target)
|
||||
if(check_rights_for(target.client, R_FUN)) //Allows admins to view faxes
|
||||
return TRUE
|
||||
if(isAI(target))
|
||||
force_stars = TRUE
|
||||
return TRUE
|
||||
if(iscyborg(target))
|
||||
return get_dist(src, target) < 2
|
||||
return ..()
|
||||
*/
|
||||
/obj/item/paper/update_icon_state()
|
||||
if(resistance_flags & ON_FIRE)
|
||||
icon_state = "paper_onfire"
|
||||
@@ -87,13 +103,10 @@
|
||||
return
|
||||
icon_state = "paper"
|
||||
|
||||
|
||||
/obj/item/paper/examine(mob/user)
|
||||
. = ..()
|
||||
. += "<span class='notice'>Alt-click to fold it.</span>"
|
||||
|
||||
/obj/item/paper/proc/show_content(mob/user)
|
||||
user.examinate(src)
|
||||
/obj/item/paper/ui_base_html(html)
|
||||
/// This might change in a future PR
|
||||
var/datum/asset/spritesheet/assets = get_asset_datum(/datum/asset/spritesheet/simple/paper)
|
||||
. = replacetext(html, "<!--customheadhtml-->", assets.css_tag())
|
||||
|
||||
/obj/item/paper/verb/rename()
|
||||
set name = "Rename paper"
|
||||
@@ -113,195 +126,62 @@
|
||||
if((loc == usr && usr.stat == CONSCIOUS))
|
||||
name = "paper[(n_name ? text("- '[n_name]'") : null)]"
|
||||
add_fingerprint(usr)
|
||||
//ui.render_all()
|
||||
|
||||
|
||||
/obj/item/paper/suicide_act(mob/user)
|
||||
user.visible_message("<span class='suicide'>[user] scratches a grid on [user.p_their()] wrist with the paper! It looks like [user.p_theyre()] trying to commit sudoku...</span>")
|
||||
return (BRUTELOSS)
|
||||
|
||||
/// ONLY USED FOR APRIL FOOLS
|
||||
|
||||
/obj/item/paper/proc/reset_spamflag()
|
||||
spam_flag = FALSE
|
||||
|
||||
/obj/item/paper/attack_self(mob/user)
|
||||
show_content(user)
|
||||
readonly = TRUE /// Assume we are just reading it
|
||||
if(rigged && (SSevents.holidays && SSevents.holidays[APRIL_FOOLS]))
|
||||
if(!spam_flag)
|
||||
spam_flag = TRUE
|
||||
playsound(loc, 'sound/items/bikehorn.ogg', 50, 1)
|
||||
playsound(loc, 'sound/items/bikehorn.ogg', 50, TRUE)
|
||||
addtimer(CALLBACK(src, .proc/reset_spamflag), 20)
|
||||
|
||||
/obj/item/paper/attack_ai(mob/living/silicon/ai/user)
|
||||
show_content(user)
|
||||
|
||||
/obj/item/paper/proc/addtofield(id, text, links = 0)
|
||||
var/locid = 0
|
||||
var/laststart = 1
|
||||
var/textindex = 1
|
||||
while(locid < 15) //hey whoever decided a while(1) was a good idea here, i hate you
|
||||
var/istart = 0
|
||||
if(links)
|
||||
istart = findtext(info_links, "<span class=\"paper_field\">", laststart)
|
||||
else
|
||||
istart = findtext(info, "<span class=\"paper_field\">", laststart)
|
||||
|
||||
if(istart == 0)
|
||||
return //No field found with matching id
|
||||
|
||||
if(links)
|
||||
laststart = istart + length(info_links[istart])
|
||||
else
|
||||
laststart = istart + length(info[istart])
|
||||
locid++
|
||||
if(locid == id)
|
||||
var/iend = 1
|
||||
if(links)
|
||||
iend = findtext(info_links, "</span>", istart)
|
||||
else
|
||||
iend = findtext(info, "</span>", istart)
|
||||
|
||||
//textindex = istart+26
|
||||
textindex = iend
|
||||
break
|
||||
|
||||
if(links)
|
||||
var/before = copytext(info_links, 1, textindex)
|
||||
var/after = copytext(info_links, textindex)
|
||||
info_links = before + text + after
|
||||
else
|
||||
var/before = copytext(info, 1, textindex)
|
||||
var/after = copytext(info, textindex)
|
||||
info = before + text + after
|
||||
updateinfolinks()
|
||||
|
||||
|
||||
/obj/item/paper/proc/updateinfolinks()
|
||||
info_links = info
|
||||
for(var/i in 1 to min(fields, 15))
|
||||
addtofield(i, "<font face=\"[PEN_FONT]\"><A href='?src=[REF(src)];write=[i]'>write</A></font>", 1)
|
||||
info_links = info_links + "<font face=\"[PEN_FONT]\"><A href='?src=[REF(src)];write=end'>write</A></font>"
|
||||
//ui.render_all()
|
||||
. = ..()
|
||||
|
||||
|
||||
/obj/item/paper/proc/clearpaper()
|
||||
finalized = FALSE
|
||||
info = null
|
||||
stamps = null
|
||||
LAZYCLEARLIST(stamped)
|
||||
cut_overlays()
|
||||
updateinfolinks()
|
||||
update_icon()
|
||||
update_icon_state()
|
||||
|
||||
|
||||
/obj/item/paper/proc/parsepencode(t, obj/item/pen/P, mob/user, iscrayon = 0)
|
||||
if(length(t) < 1) //No input means nothing needs to be parsed
|
||||
return
|
||||
|
||||
t = parsemarkdown(t, user, iscrayon)
|
||||
|
||||
if(!iscrayon)
|
||||
t = "<font face=\"[P.font]\" color=[P.colour]>[t]</font>"
|
||||
else
|
||||
var/obj/item/toy/crayon/C = P
|
||||
t = "<font face=\"[CRAYON_FONT]\" color=[C.paint_color]><b>[t]</b></font>"
|
||||
|
||||
// Count the fields
|
||||
var/laststart = 1
|
||||
while(fields < 15)
|
||||
var/i = findtext(t, "<span class=\"paper_field\">", laststart)
|
||||
if(i == 0)
|
||||
break
|
||||
laststart = i+1
|
||||
fields++
|
||||
|
||||
return t
|
||||
|
||||
/obj/item/paper/proc/reload_fields() // Useful if you made the paper programicly and want to include fields. Also runs updateinfolinks() for you.
|
||||
fields = 0
|
||||
var/laststart = 1
|
||||
while(fields < 15)
|
||||
var/i = findtext(info, "<span class=\"paper_field\">", laststart)
|
||||
if(i == 0)
|
||||
break
|
||||
laststart = i+1
|
||||
fields++
|
||||
updateinfolinks()
|
||||
|
||||
|
||||
/obj/item/paper/proc/openhelp(mob/user)
|
||||
user << browse({"<HTML><HEAD><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><TITLE>Paper Help</TITLE></HEAD>
|
||||
<BODY>
|
||||
You can use backslash (\\) to escape special characters.<br>
|
||||
<br>
|
||||
<b><center>Crayon&Pen commands</center></b><br>
|
||||
<br>
|
||||
# text : Defines a header.<br>
|
||||
|text| : Centers the text.<br>
|
||||
**text** : Makes the text <b>bold</b>.<br>
|
||||
*text* : Makes the text <i>italic</i>.<br>
|
||||
^text^ : Increases the <font size = \"4\">size</font> of the text.<br>
|
||||
%s : Inserts a signature of your name in a foolproof way.<br>
|
||||
%f : Inserts an invisible field which lets you start type from there. Useful for forms.<br>
|
||||
<br>
|
||||
<b><center>Pen exclusive commands</center></b><br>
|
||||
((text)) : Decreases the <font size = \"1\">size</font> of the text.<br>
|
||||
* item : An unordered list item.<br>
|
||||
* item: An unordered list child item.<br>
|
||||
--- : Adds a horizontal rule.
|
||||
</BODY></HTML>"}, "window=paper_help")
|
||||
|
||||
|
||||
/obj/item/paper/Topic(href, href_list)
|
||||
..()
|
||||
var/literate = usr.is_literate()
|
||||
if(!usr.canUseTopic(src, BE_CLOSE, literate))
|
||||
return
|
||||
|
||||
if(href_list["help"])
|
||||
openhelp(usr)
|
||||
return
|
||||
if(href_list["write"])
|
||||
var/id = href_list["write"]
|
||||
var/t = stripped_multiline_input("Enter what you want to write:", "Write", no_trim=TRUE)
|
||||
if(!t || !usr.canUseTopic(src, BE_CLOSE, literate))
|
||||
return
|
||||
var/obj/item/i = usr.get_active_held_item() //Check to see if he still got that darn pen, also check if he's using a crayon or pen.
|
||||
var/iscrayon = 0
|
||||
if(!istype(i, /obj/item/pen))
|
||||
if(!istype(i, /obj/item/toy/crayon))
|
||||
return
|
||||
iscrayon = 1
|
||||
|
||||
if(!in_range(src, usr) && loc != usr && !istype(loc, /obj/item/clipboard) && loc.loc != usr && usr.get_active_held_item() != i) //Some check to see if he's allowed to write
|
||||
return
|
||||
|
||||
t = parsepencode(t, i, usr, iscrayon) // Encode everything from pencode to html
|
||||
|
||||
if(t != null) //No input from the user means nothing needs to be added
|
||||
if(id!="end")
|
||||
addtofield(text2num(id), t) // He wants to edit a field, let him.
|
||||
else
|
||||
info += t // Oh, he wants to edit to the end of the file, let him.
|
||||
updateinfolinks()
|
||||
show_content(usr)
|
||||
update_icon()
|
||||
/obj/item/paper/can_interact(mob/user)
|
||||
if(!..())
|
||||
return FALSE
|
||||
if(resistance_flags & ON_FIRE) /// Are we on fire? Hard ot read if so
|
||||
return FALSE
|
||||
if(user.is_blind()) /// Even harder to read if your blind...braile? humm
|
||||
return FALSE
|
||||
return user.can_read(src) // checks if the user can read.
|
||||
|
||||
|
||||
/obj/item/paper/attackby(obj/item/P, mob/living/carbon/human/user, params)
|
||||
..()
|
||||
|
||||
if(resistance_flags & ON_FIRE)
|
||||
return
|
||||
|
||||
if(is_blind(user))
|
||||
return
|
||||
|
||||
readonly = TRUE /// Assume we are just reading it
|
||||
if(istype(P, /obj/item/pen) || istype(P, /obj/item/toy/crayon))
|
||||
if(user.is_literate())
|
||||
show_content(user)
|
||||
if(finalized)
|
||||
to_chat(user, "<span class='warning'>This sheet of paper has already been written too!</span>")
|
||||
return
|
||||
readonly = FALSE /// Nope we are going to write stuff
|
||||
/// should a crayon be in the same subtype as a pen? How about a brush or charcoal?
|
||||
if(istype(P, /obj/item/pen))
|
||||
var/obj/item/pen/PEN = P
|
||||
pen_color = PEN.colour
|
||||
else
|
||||
to_chat(user, "<span class='notice'>You don't know how to read or write.</span>")
|
||||
return
|
||||
|
||||
var/obj/item/toy/crayon/PEN = P
|
||||
pen_color = PEN.crayon_color
|
||||
ui_interact(user)
|
||||
return
|
||||
else if(istype(P, /obj/item/stamp))
|
||||
|
||||
if(!in_range(src, user))
|
||||
@@ -319,8 +199,8 @@
|
||||
add_overlay(stampoverlay)
|
||||
|
||||
to_chat(user, "<span class='notice'>You stamp the paper with your rubber stamp.</span>")
|
||||
//ui.render_all()
|
||||
|
||||
return /// Normaly you just stamp, you don't need to read the thing
|
||||
if(P.get_temperature())
|
||||
if(HAS_TRAIT(user, TRAIT_CLUMSY) && prob(10))
|
||||
user.visible_message("<span class='warning'>[user] accidentally ignites [user.p_them()]self!</span>", \
|
||||
@@ -337,19 +217,62 @@
|
||||
user.visible_message("<span class='danger'>[user] lights [src] ablaze with [P]!</span>", "<span class='danger'>You light [src] on fire!</span>")
|
||||
fire_act()
|
||||
|
||||
|
||||
add_fingerprint(user)
|
||||
. = ..()
|
||||
|
||||
/obj/item/paper/fire_act(exposed_temperature, exposed_volume)
|
||||
..()
|
||||
if(!(resistance_flags & FIRE_PROOF))
|
||||
icon_state = "paper_onfire"
|
||||
add_overlay("paper_onfire_overlay")
|
||||
info = "[stars(info)]"
|
||||
|
||||
|
||||
/obj/item/paper/extinguish()
|
||||
..()
|
||||
update_icon()
|
||||
cut_overlay("paper_onfire_overlay")
|
||||
|
||||
/obj/item/paper/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
var/datum/asset/assets = get_asset_datum(/datum/asset/spritesheet/simple/paper)
|
||||
assets.send(user)
|
||||
/// The x size is because we double the width for the editor
|
||||
ui = new(user, src, ui_key, "PaperSheet", name, 400, 600, master_ui, state)
|
||||
ui.set_autoupdate(FALSE)
|
||||
ui.open()
|
||||
|
||||
/obj/item/paper/proc/ui_update()
|
||||
var/datum/tgui/ui = SStgui.try_update_ui(usr, src, "main");
|
||||
if(ui)
|
||||
ui.update()
|
||||
|
||||
/obj/item/paper/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["text"] = info
|
||||
data["paper_state"] = icon_state /// TODO: show the sheet will bloodied or crinkling
|
||||
data["pen_color"] = pen_color
|
||||
data["paper_color"] = color || "white" // color might not be set
|
||||
data["edit_sheet"] = readonly || finalized ? FALSE : TRUE
|
||||
/// data["stamps_info"] = list(stamp_info)
|
||||
data["stamps"] = stamps
|
||||
return data
|
||||
|
||||
|
||||
/obj/item/paper/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
switch(action)
|
||||
if("save")
|
||||
var/in_paper = params["text"]
|
||||
if(length(in_paper) > 0 && length(in_paper) < 1000) // Sheet must have less than 1000 charaters
|
||||
info = in_paper
|
||||
finalized = TRUE // once you have writen to a sheet you cannot write again
|
||||
to_chat(usr, "You have finished your paper masterpiece!");
|
||||
ui_update()
|
||||
else
|
||||
to_chat(usr, pick("Writing block strikes again!", "You forgot to write anthing!"))
|
||||
ui_update()
|
||||
update_icon()
|
||||
. = TRUE
|
||||
|
||||
/*
|
||||
* Construction paper
|
||||
@@ -374,9 +297,8 @@
|
||||
icon_state = "scrap"
|
||||
slot_flags = null
|
||||
|
||||
/obj/item/paper/crumpled/ComponentInitialize()
|
||||
. = ..()
|
||||
AddElement(/datum/element/update_icon_blocker)
|
||||
/obj/item/paper/crumpled/update_icon_state()
|
||||
return
|
||||
|
||||
/obj/item/paper/crumpled/bloody
|
||||
icon_state = "scrap_bloodied"
|
||||
|
||||
Reference in New Issue
Block a user