From 01a41bef0d28aa92f518815aa6d779dab8918108 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 14 Oct 2021 22:20:22 +0200 Subject: [PATCH] [MIRROR] Printer Circuit Component [MDB IGNORE] (#8825) * Printer Circuit Component (#62012) I'm adding a circuit component that can print text string on a paper object in a variety of colors and font typefaces (currently only web-safe ones are available, maybe i'll add some fancy ones in the future but they'd need to be imported either through @ import of @ font-face in a separate CSS not imported by every tgui UI). It's important to note that because the UI sanitizes new text inputed by users and not what's already written on the paper (so the pen_color and pen_font don't be purged in the process), we can't safely have these strings "printed" into the info variable directly, because of that these values will be stored in two new list variables, one for the text and one for font color, face and the signature. When the paper sheet UI is opened, these will be sanitized and then parsed into the text, so the next time the paper is edited we can clear these two lists. Obviously better than a hacky byond proc - parsemarkdown() is outdated af -, albeit a bit messy... like the rest of paper code. Requires #62033. * Printer Circuit Component Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/__DEFINES/text.dm | 8 + code/__DEFINES/traits.dm | 2 + code/game/objects/items/devices/PDA/PDA.dm | 10 +- code/game/objects/items/inspector.dm | 4 +- code/game/objects/structures/votingbox.dm | 2 +- .../modular_computers/hardware/printer.dm | 2 +- code/modules/paperwork/carbonpaper.dm | 2 +- code/modules/paperwork/paper.dm | 74 +++++++-- code/modules/paperwork/photocopier.dm | 7 +- code/modules/religion/rites.dm | 4 +- .../research/designs/wiremod_designs.dm | 5 + code/modules/research/techweb/all_nodes.dm | 1 + .../wiremod/components/action/printer.dm | 138 ++++++++++++++++ code/modules/wiremod/core/component.dm | 2 + sound/machines/dotprinter.ogg | Bin 0 -> 52339 bytes tgstation.dme | 1 + tgui/packages/tgui/interfaces/PaperSheet.js | 147 +++++++++++------- 17 files changed, 334 insertions(+), 75 deletions(-) create mode 100644 code/modules/wiremod/components/action/printer.dm create mode 100644 sound/machines/dotprinter.ogg diff --git a/code/__DEFINES/text.dm b/code/__DEFINES/text.dm index 58ab98b132b..48487531d0f 100644 --- a/code/__DEFINES/text.dm +++ b/code/__DEFINES/text.dm @@ -9,3 +9,11 @@ /// Simply removes the < and > characters, and limits the length of the message. #define STRIP_HTML_SIMPLE(text, limit) (GLOB.angular_brackets.Replace(copytext(text, 1, limit), "")) + +///Index access defines for paper/var/add_info_style +#define ADD_INFO_COLOR 1 +#define ADD_INFO_FONT 2 +#define ADD_INFO_SIGN 3 + +///Adds a html style to a text string. Hacky, but that's how inputted text appear on paper sheets after going through the UI. +#define PAPER_MARK_TEXT(text, color, font) "[text]\n \n" diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index 5c5d667bf85..c1bb2815720 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -526,6 +526,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai /// Trait applied when the MMI component is added to an [/obj/item/integrated_circuit] #define TRAIT_COMPONENT_MMI "component_mmi" +/// Trait applied when the MMI component is added to an [/obj/item/integrated_circuit] +#define TRAIT_COMPONENT_PRINTER "component_printer" /// If present on a [/mob/living/carbon], will make them appear to have a medium level disease on health HUDs. #define TRAIT_DISEASELIKE_SEVERITY_MEDIUM "diseaselike_severity_medium" diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index ff5563b1d8c..6b028aa5745 100644 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -1131,11 +1131,15 @@ GLOBAL_LIST_EMPTY(PDAs) A.analyzer_act(user, src) if (!scanmode && istype(A, /obj/item/paper) && owner) - var/obj/item/paper/PP = A - if (!PP.info) + var/obj/item/paper/paper = A + if (!paper.get_info_length()) to_chat(user, span_warning("Unable to scan! Paper is blank.")) return - notehtml = PP.info + notehtml = paper.info + if(paper.add_info) + for(var/index in 1 to length(paper.add_info)) + var/list/style = paper.add_info_style[index] + notehtml += PAPER_MARK_TEXT(paper.add_info[index], style[ADD_INFO_COLOR], style[ADD_INFO_FONT]) note = replacetext(notehtml, "
", "\[br\]") note = replacetext(note, "
  • ", "\[*\]") note = replacetext(note, "