Files
CHOMPStation2/code/modules/paperwork/paper.dm
Cael_Aislinn aae42d928a Merge branch 'incremental_tg' r5200 into bs12_with_tgport
Conflicts:
	baystation12.dme
	code/__HELPERS/global_lists.dm
	code/__HELPERS/type2type.dm
	code/__HELPERS/unsorted.dm
	code/datums/datumvars.dm
	code/datums/disease.dm
	code/datums/organs/organ_external.dm
	code/datums/supplypacks.dm
	code/defines/obj.dm
	code/game/area/areas.dm
	code/game/atoms.dm
	code/game/gamemodes/cult/cult_structures.dm
	code/game/gamemodes/cult/runes.dm
	code/game/gamemodes/events.dm
	code/game/gamemodes/events/ninja_equipment.dm
	code/game/gamemodes/events/space_ninja.dm
	code/game/gamemodes/game_mode.dm
	code/game/gamemodes/gameticker.dm
	code/game/hud.dm
	code/game/jobs/access.dm
	code/game/jobs/job/civilian.dm
	code/game/machinery/alarm.dm
	code/game/machinery/cloning.dm
	code/game/machinery/computer/cloning.dm
	code/game/machinery/computer/medical.dm
	code/game/machinery/computer/syndicate_shuttle.dm
	code/game/machinery/telecomms/broadcaster.dm
	code/game/machinery/telecomms/machine_interactions.dm
	code/game/objects/effects/decals/contraband.dm
	code/game/objects/effects/signs.dm
	code/game/objects/items/devices/PDA/PDA.dm
	code/game/objects/items/devices/PDA/cart.dm
	code/game/objects/items/weapons/photography.dm
	code/game/objects/structures/door_assembly.dm
	code/game/objects/structures/window.dm
	code/game/sound.dm
	code/game/verbs/ooc.dm
	code/global.dm
	code/modules/DetectiveWork/detective_work.dm
	code/modules/DetectiveWork/evidence.dm
	code/modules/DetectiveWork/footprints_and_rag.dm
	code/modules/DetectiveWork/scanner.dm
	code/modules/admin/player_panel.dm
	code/modules/admin/verbs/adminhelp.dm
	code/modules/admin/verbs/adminpm.dm
	code/modules/awaymissions/gateway.dm
	code/modules/client/client defines.dm
	code/modules/client/client procs.dm
	code/modules/client/preferences.dm
	code/modules/clothing/spacesuits/rig.dm
	code/modules/mining/machine_processing.dm
	code/modules/mining/machine_stacking.dm
	code/modules/mining/mint.dm
	code/modules/mining/ores_coins.dm
	code/modules/mining/satchel_ore_boxdm.dm
	code/modules/mob/living/carbon/alien/alien.dm
	code/modules/mob/living/carbon/carbon.dm
	code/modules/mob/living/carbon/carbon_defines.dm
	code/modules/mob/living/carbon/human/human_damage.dm
	code/modules/mob/living/carbon/human/life.dm
	code/modules/mob/living/carbon/human/update_icons.dm
	code/modules/mob/living/living.dm
	code/modules/mob/living/say.dm
	code/modules/mob/mob.dm
	code/modules/mob/mob_cleanup.dm
	code/modules/mob/mob_defines.dm
	code/modules/mob/mob_transformation_simple.dm
	code/modules/mob/new_player/login.dm
	code/modules/mob/new_player/new_player.dm
	code/modules/mob/new_player/preferences_setup.dm
	code/modules/mob/new_player/savefile.dm
	code/modules/mob/new_player/sprite_accessories.dm
	code/modules/paperwork/folders.dm
	code/modules/paperwork/paper.dm
	code/modules/paperwork/photocopier.dm
	code/modules/projectiles/guns/energy/special.dm
	code/modules/projectiles/guns/projectile/automatic.dm
	code/setup.dm
	code/unused/mining/datum_processing_recipe.dm
	code/unused/powerarmor/powerarmor.dm
	code/world.dm
	html/changelog.html
	icons/effects/96x96.dmi
	icons/mob/head.dmi
	icons/mob/items_lefthand.dmi
	icons/mob/items_righthand.dmi
	icons/mob/suit.dmi
	icons/obj/clothing/hats.dmi
	icons/obj/clothing/suits.dmi
	icons/obj/hydroponics.dmi
	icons/obj/items.dmi
	icons/turf/areas.dmi
	icons/turf/walls.dmi
	maps/RandomZLevels/fileList.txt
	maps/RandomZLevels/spacebattle.dmm

Signed-off-by: Cael_Aislinn <cael_aislinn@yahoo.com.au>
2013-01-07 00:23:22 +10:00

297 lines
9.7 KiB
Plaintext

/obj/item/weapon/paper
name = "paper"
gender = PLURAL
icon = 'icons/obj/bureaucracy.dmi'
icon_state = "paper"
throwforce = 0
w_class = 1.0
throw_range = 1
throw_speed = 1
layer = 4
pressure_resistance = 1
slot_flags = SLOT_HEAD
body_parts_covered = HEAD
attack_verb = list("")
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 //Amount of user created fields
var/list/stamped
var/rigged = 0
var/spam_flag = 0
var/const/deffont = "Verdana"
var/const/signfont = "Times New Roman"
var/const/crayonfont = "Comic Sans MS"
//lipstick wiping is in code/game/objects/items/weapons/cosmetics.dm!
/obj/item/weapon/paper/New()
..()
pixel_y = rand(-8, 8)
pixel_x = rand(-9, 9)
spawn(2)
update_icon()
updateinfolinks()
return
/obj/item/weapon/paper/update_icon()
if(info)
icon_state = "paper_words"
return
icon_state = "paper"
/obj/item/weapon/paper/examine()
set src in oview(1)
// ..() //We don't want them to see the dumb "this is a paper" thing every time.
// I didn't like the idea that people can read tiny pieces of paper from across the room.
// Now you need to be next to the paper in order to read it.
if(in_range(usr, src))
if(!(istype(usr, /mob/living/carbon/human) || istype(usr, /mob/dead/observer) || istype(usr, /mob/living/silicon)))
usr << browse("<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[stars(info)][stamps]</BODY></HTML>", "window=[name]")
onclose(usr, "[name]")
else
usr << browse("<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[info][stamps]</BODY></HTML>", "window=[name]")
onclose(usr, "[name]")
else
usr << "<span class='notice'>It is too far away.</span>"
return
/obj/item/weapon/paper/verb/rename()
set name = "Rename paper"
set category = "Object"
set src in usr
if((CLUMSY in usr.mutations) && prob(50))
usr << "<span class='warning'>You cut yourself on the paper.</span>"
return
var/n_name = copytext(sanitize(input(usr, "What would you like to label the paper?", "Paper Labelling", null) as text), 1, MAX_NAME_LEN)
if((loc == usr && usr.stat == 0))
name = "paper[(n_name ? text("- '[n_name]'") : null)]"
add_fingerprint(usr)
return
/obj/item/weapon/paper/attack_self(mob/living/user as mob)
examine()
if(rigged && (Holiday == "April Fool's Day"))
if(spam_flag == 0)
spam_flag = 1
playsound(loc, 'sound/items/bikehorn.ogg', 50, 1)
spawn(20)
spam_flag = 0
return
/obj/item/weapon/paper/attack_ai(var/mob/living/silicon/ai/user as mob)
var/dist
if(istype(user) && user.current) //is AI
dist = get_dist(src, user.current)
else //cyborg or AI not seeing through a camera
dist = get_dist(src, user)
if(dist < 2)
usr << browse("<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[info][stamps]</BODY></HTML>", "window=[name]")
onclose(usr, "[name]")
else
usr << browse("<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[stars(info)][stamps]</BODY></HTML>", "window=[name]")
onclose(usr, "[name]")
return
/obj/item/weapon/paper/proc/addtofield(var/id, var/text, var/links = 0)
var/locid = 0
var/laststart = 1
var/textindex = 1
while(1) // I know this can cause infinite loops and fuck up the whole server, but the if(istart==0) should be safe as fuck
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
laststart = istart+1
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/weapon/paper/proc/updateinfolinks()
info_links = info
var/i = 0
for(i=1,i<=fields,i++)
addtofield(i, "<font face=\"[deffont]\"><A href='?src=\ref[src];write=[i]'>write</A></font>", 1)
info_links = info_links + "<font face=\"[deffont]\"><A href='?src=\ref[src];write=end'>write</A></font>"
/obj/item/weapon/paper/proc/clearpaper()
info = null
stamps = null
stamped = list()
overlays = null
updateinfolinks()
update_icon()
/obj/item/weapon/paper/proc/parsepencode(var/t, var/obj/item/weapon/pen/P, mob/user as mob, var/iscrayon = 0)
// t = copytext(sanitize(t),1,MAX_MESSAGE_LEN)
t = replacetext(t, "\[center\]", "<center>")
t = replacetext(t, "\[/center\]", "</center>")
t = replacetext(t, "\[br\]", "<BR>")
t = replacetext(t, "\[b\]", "<B>")
t = replacetext(t, "\[/b\]", "</B>")
t = replacetext(t, "\[i\]", "<I>")
t = replacetext(t, "\[/i\]", "</I>")
t = replacetext(t, "\[u\]", "<U>")
t = replacetext(t, "\[/u\]", "</U>")
t = replacetext(t, "\[large\]", "<font size=\"4\">")
t = replacetext(t, "\[/large\]", "</font>")
t = replacetext(t, "\[sign\]", "<font face=\"[signfont]\"><i>[user.real_name]</i></font>")
t = replacetext(t, "\[field\]", "<span class=\"paper_field\"></span>")
if(!iscrayon)
t = replacetext(t, "\[*\]", "<li>")
t = replacetext(t, "\[hr\]", "<HR>")
t = replacetext(t, "\[small\]", "<font size = \"1\">")
t = replacetext(t, "\[/small\]", "</font>")
t = replacetext(t, "\[list\]", "<ul>")
t = replacetext(t, "\[/list\]", "</ul>")
t = "<font face=\"[deffont]\" color=[P.colour]>[t]</font>"
else // If it is a crayon, and he still tries to use these, make them empty!
t = replacetext(t, "\[*\]", "")
t = replacetext(t, "\[hr\]", "")
t = replacetext(t, "\[small\]", "")
t = replacetext(t, "\[/small\]", "")
t = replacetext(t, "\[list\]", "")
t = replacetext(t, "\[/list\]", "")
t = "<font face=\"[crayonfont]\" color=[P.colour]><b>[t]</b></font>"
// t = replacetext(t, "#", "") // Junk converted to nothing!
//Count the fields
var/laststart = 1
while(1)
var/i = findtext(t, "<span class=\"paper_field\">", laststart)
if(i==0)
break
laststart = i+1
fields++
return t
/obj/item/weapon/paper/proc/openhelp(mob/user as mob)
user << browse({"<HTML><HEAD><TITLE>Pen Help</TITLE></HEAD>
<BODY>
<b><center>Crayon&Pen commands</center></b><br>
<br>
\[br\] : Creates a linebreak.<br>
\[center\] - \[/center\] : Centers the text.<br>
\[b\] - \[/b\] : Makes the text <b>bold</b>.<br>
\[i\] - \[/i\] : Makes the text <i>italic</i>.<br>
\[u\] - \[/u\] : Makes the text <u>underlined</u>.<br>
\[large\] - \[/large\] : Increases the <font size = \"4\">size</font> of the text.<br>
\[sign\] : Inserts a signature of your name in a foolproof way.<br>
\[field\] : Inserts an invisible field which lets you start type from there. Useful for forms.<br>
<br>
<b><center>Pen exclusive commands</center></b><br>
\[small\] - \[/small\] : Decreases the <font size = \"1\">size</font> of the text.<br>
\[list\] - \[/list\] : A list.<br>
\[*\] : A dot used for lists.<br>
\[hr\] : Adds a horizontal rule.
</BODY></HTML>"}, "window=paper_help")
/obj/item/weapon/paper/Topic(href, href_list)
..()
if(!usr || (usr.stat || usr.restrained()))
return
if(href_list["write"])
var/id = href_list["write"]
//var/t = strip_html_simple(input(usr, "What text do you wish to add to " + (id=="end" ? "the end of the paper" : "field "+id) + "?", "[name]", null),8192) as message
var/t = strip_html_simple(input("Enter what you want to write:", "Write", null, null) as message, MAX_MESSAGE_LEN)
var/obj/item/i = usr.get_active_hand() // 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/weapon/pen))
if(!istype(i, /obj/item/toy/crayon))
return
iscrayon = 1
if((!in_range(src, usr) && loc != usr && !( istype(loc, /obj/item/weapon/clipboard) ) && loc.loc != usr && usr.get_active_hand() != 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(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()
usr << browse("<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[info_links][stamps]</BODY></HTML>", "window=[name]") // Update the window
update_icon()
/obj/item/weapon/paper/attackby(obj/item/weapon/P as obj, mob/user as mob)
..()
var/clown = 0
if(user.mind && (user.mind.assigned_role == "Clown"))
clown = 1
if(istype(P, /obj/item/weapon/pen) || istype(P, /obj/item/toy/crayon))
if ( istype(P, /obj/item/weapon/pen/robopen) && P:mode == 2 )
P:RenamePaper(user,src)
else
user << browse("<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[info_links][stamps]</BODY></HTML>", "window=[name]")
//openhelp(user)
return
else if(istype(P, /obj/item/weapon/stamp))
if((!in_range(src, usr) && loc != user && !( istype(loc, /obj/item/weapon/clipboard) ) && loc.loc != user && user.get_active_hand() != P))
return
stamps += (stamps=="" ? "<HR>" : "<BR>") + "<i>This paper has been stamped with the [P.name].</i>"
var/image/stampoverlay = image('icons/obj/bureaucracy.dmi')
stampoverlay.pixel_x = rand(-2, 2)
stampoverlay.pixel_y = rand(-3, 2)
if(istype(P, /obj/item/weapon/stamp/clown))
if(!clown)
user << "<span class='notice'>You are totally unable to use the stamp. HONK!</span>"
return
stampoverlay.icon_state = "paper_[P.icon_state]"
if(!stamped)
stamped = new
stamped += P.type
overlays += stampoverlay
user << "<span class='notice'>You stamp the paper with your rubber stamp.</span>"
add_fingerprint(user)
return