Printing Fixes (#1476)

Refactors machines to use /obj/machinery/proc/print() to print things to reduce redundant code.
Fixes #1433.
Fixes #1454.
This commit is contained in:
Lohikar
2017-01-09 00:44:42 +02:00
committed by skull132
parent b96f954762
commit 465b982eeb
29 changed files with 299 additions and 253 deletions
+7 -6
View File
@@ -149,16 +149,17 @@
break
if(M)
var/obj/item/weapon/paper/P = new /obj/item/weapon/paper(src)
P.info = "<CENTER><B>Medical Record</B></CENTER><BR>"
P.info += "Name: [G.fields["name"]] ID: [G.fields["id"]]<BR>\nSex: [G.fields["sex"]]<BR>\nAge: [G.fields["age"]]<BR>\nFingerprint: [G.fields["fingerprint"]]<BR>\nPhysical Status: [G.fields["p_stat"]]<BR>\nMental Status: [G.fields["m_stat"]]<BR>"
var/info = "<CENTER><B>Medical Record</B></CENTER><BR>"
info += "Name: [G.fields["name"]] ID: [G.fields["id"]]<BR>\nSex: [G.fields["sex"]]<BR>\nAge: [G.fields["age"]]<BR>\nFingerprint: [G.fields["fingerprint"]]<BR>\nPhysical Status: [G.fields["p_stat"]]<BR>\nMental Status: [G.fields["m_stat"]]<BR>"
P.info += "<BR>\n<CENTER><B>Medical Data</B></CENTER><BR>\nBlood Type: [M.fields["b_type"]]<BR>\nDNA: [M.fields["b_dna"]]<BR>\n<BR>\nMinor Disabilities: [M.fields["mi_dis"]]<BR>\nDetails: [M.fields["mi_dis_d"]]<BR>\n<BR>\nMajor Disabilities: [M.fields["ma_dis"]]<BR>\nDetails: [M.fields["ma_dis_d"]]<BR>\n<BR>\nAllergies: [M.fields["alg"]]<BR>\nDetails: [M.fields["alg_d"]]<BR>\n<BR>\nCurrent Diseases: [M.fields["cdi"]] (per disease info placed in log/comment section)<BR>\nDetails: [M.fields["cdi_d"]]<BR>\n<BR>\nImportant Notes:<BR>\n\t[M.fields["notes"]]<BR>\n<BR>\n<CENTER><B>Comments/Log</B></CENTER><BR>"
info += "<BR>\n<CENTER><B>Medical Data</B></CENTER><BR>\nBlood Type: [M.fields["b_type"]]<BR>\nDNA: [M.fields["b_dna"]]<BR>\n<BR>\nMinor Disabilities: [M.fields["mi_dis"]]<BR>\nDetails: [M.fields["mi_dis_d"]]<BR>\n<BR>\nMajor Disabilities: [M.fields["ma_dis"]]<BR>\nDetails: [M.fields["ma_dis_d"]]<BR>\n<BR>\nAllergies: [M.fields["alg"]]<BR>\nDetails: [M.fields["alg_d"]]<BR>\n<BR>\nCurrent Diseases: [M.fields["cdi"]] (per disease info placed in log/comment section)<BR>\nDetails: [M.fields["cdi_d"]]<BR>\n<BR>\nImportant Notes:<BR>\n\t[M.fields["notes"]]<BR>\n<BR>\n<CENTER><B>Comments/Log</B></CENTER><BR>"
var/counter = 1
while(M.fields["com_[counter]"])
P.info += "[M.fields["com_[counter]"]]<BR>"
info += "[M.fields["com_[counter]"]]<BR>"
counter++
P.info += "</TT>"
P.name = "Medical Record ([G.fields["name"]])"
info += "</TT>"
var/pname = "Medical Record ([G.fields["name"]])"
P.set_content_unsafe(pname, info)
virgin = 0 //tabbing here is correct- it's possible for people to try and use it
//before the records have been generated, so we do this inside the loop.
..()
+20 -2
View File
@@ -37,9 +37,14 @@
/obj/item/weapon/paper/New(loc, text,title)
..(loc)
set_content(text ? text : info, title)
set_content(title, text ? text : info)
/obj/item/weapon/paper/proc/set_content(text,title)
// needed for subtyped papers with pre-defined content
/obj/item/weapon/paper/New()
..()
update_icon()
/obj/item/weapon/paper/proc/set_content(title, text)
if(title)
name = title
if (text && length(text))
@@ -52,6 +57,19 @@
update_space(info)
updateinfolinks()
// DO NOT USE THIS FOR UNTRUSTED PLAYER INPUT. IT DOES NOT SANITIZE.
/obj/item/weapon/paper/proc/set_content_unsafe(title, text)
if (title)
name = title
if (text && length(text))
info = text
else
info = ""
update_icon()
update_space()
updateinfolinks()
/obj/item/weapon/paper/update_icon()
if(icon_state == "paper_talisman")
return
+14 -9
View File
@@ -147,17 +147,19 @@
return
/obj/machinery/photocopier/proc/copy(var/obj/item/weapon/paper/copy)
var/obj/item/weapon/paper/c = new /obj/item/weapon/paper (loc)
if(toner > 10) //lots of toner, make it dark
c.info = "<font color = #101010>"
var/obj/item/weapon/paper/c = new /obj/item/weapon/paper()
var/info
var/pname
if (toner > 10) //lots of toner, make it dark
info = "<font color = #101010>"
else //no toner? shitty copies for you!
c.info = "<font color = #808080>"
info = "<font color = #808080>"
var/copied = html_decode(copy.info)
copied = replacetext(copied, "<font face=\"[c.deffont]\" color=", "<font face=\"[c.deffont]\" nocolor=") //state of the art techniques in action
copied = replacetext(copied, "<font face=\"[c.crayonfont]\" color=", "<font face=\"[c.crayonfont]\" nocolor=") //This basically just breaks the existing color tag, which we need to do because the innermost tag takes priority.
c.info += copied
c.info += "</font>"//</font>
c.name = copy.name // -- Doohl
info += copied
info += "</font>"//</font>
pname = copy.name // -- Doohl
c.fields = copy.fields
c.stamps = copy.stamps
c.stamped = copy.stamped
@@ -176,11 +178,14 @@
img.pixel_x = copy.offset_x[j]
img.pixel_y = copy.offset_y[j]
c.overlays += img
c.updateinfolinks()
toner--
if(toner == 0)
visible_message("<span class='notice'>A red light on \the [src] flashes, indicating that it is out of toner.</span>")
return c
return
c.set_content_unsafe(pname, info)
print(c, 1, 'sound/items/poster_being_created.ogg', 20)
/obj/machinery/photocopier/proc/photocopy(var/obj/item/weapon/photo/photocopy)