Skip to content

Commit

Permalink
photocopiers (custom forms not included)
Browse files Browse the repository at this point in the history
  • Loading branch information
meemofcourse committed Jul 30, 2023
1 parent f4d81a3 commit 435a457
Show file tree
Hide file tree
Showing 7 changed files with 960 additions and 14 deletions.
5 changes: 5 additions & 0 deletions code/modules/asset_cache/asset_list_items.dm
Expand Up @@ -99,6 +99,7 @@
"stamp-clown" = 'icons/stamp_icons/large_stamp-clown.png',
"stamp-deny" = 'icons/stamp_icons/large_stamp-deny.png',
"stamp-ok" = 'icons/stamp_icons/large_stamp-ok.png',
"stamp-void" = 'icons/stamp_icons/large_stamp-void.png',
"stamp-hop" = 'icons/stamp_icons/large_stamp-hop.png',
"stamp-cmo" = 'icons/stamp_icons/large_stamp-cmo.png',
"stamp-ce" = 'icons/stamp_icons/large_stamp-ce.png',
Expand All @@ -107,6 +108,10 @@
"stamp-cap" = 'icons/stamp_icons/large_stamp-cap.png',
"stamp-qm" = 'icons/stamp_icons/large_stamp-qm.png',
"stamp-law" = 'icons/stamp_icons/large_stamp-law.png',
"stamp-chap" = 'icons/stamp_icons/large_stamp-chap.png',
"stamp-mime" = 'icons/stamp_icons/large_stamp-mime.png',
"stamp-centcom" = 'icons/stamp_icons/large_stamp-centcom.png',
"stamp-syndicate" = 'icons/stamp_icons/large_stamp-syndicate.png',
"stamp-solgov" = 'icons/stamp_icons/large_stamp-solgov.png'
)

Expand Down
61 changes: 61 additions & 0 deletions code/modules/paperwork/photocopier.dm
Expand Up @@ -45,11 +45,33 @@
var/color_mode = PHOTO_COLOR
/// Indicates whether the printer is currently busy copying or not.
var/busy = FALSE
/// Variable needed to determine the selected category of forms on Photocopier.js
var/category

/obj/machinery/photocopier/Initialize()
. = ..()
toner_cartridge = new(src)

/obj/machinery/photocopier/handle_atom_del(atom/deleting_atom)
if(deleting_atom == paper_copy)
paper_copy = null
if(deleting_atom == photo_copy)
photo_copy = null
if(deleting_atom == document_copy)
document_copy = null
if(deleting_atom == ass)
ass = null
if(deleting_atom == toner_cartridge)
toner_cartridge = null
return ..()

/obj/machinery/photocopier/Destroy()
QDEL_NULL(paper_copy)
QDEL_NULL(photo_copy)
QDEL_NULL(toner_cartridge)
ass = null //the mob isn't actually contained and just referenced, no need to delete it.
return ..()

/obj/machinery/photocopier/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
Expand All @@ -61,6 +83,18 @@
data["has_item"] = !copier_empty()
data["num_copies"] = num_copies

try
var/list/blanks = json_decode(file2text("config/blanks.json"))
if (blanks != null)
data["blanks"] = blanks
data["category"] = category
data["forms_exist"] = TRUE
else
data["forms_exist"] = FALSE
catch()
data["forms_exist"] = FALSE


if(photo_copy)
data["is_photo"] = TRUE
data["color_mode"] = color_mode
Expand Down Expand Up @@ -165,6 +199,27 @@
if("set_copies")
num_copies = clamp(text2num(params["num_copies"]), 1, MAX_COPIES_AT_ONCE)
return TRUE
// Changes the forms displayed on Photocopier.js when you switch categories
if("choose_category")
category = params["category"]
return TRUE
// Called when you press print blank
if("print_blank")
if(busy)
to_chat(usr, span_warning("[src] is currently busy copying something. Please wait until it is finished."))
return FALSE
if (toner_cartridge.charges - PAPER_TONER_USE < 0)
to_chat(usr, span_warning("There is not enough toner in [src] to print the form, please replace the cartridge."))
return FALSE
do_copy_loop(CALLBACK(src, .proc/make_blank_print), usr)
var/obj/item/paper/printblank = new /obj/item/paper (loc)
var/printname = params["name"]
var/list/printinfo
for(var/infoline as anything in params["info"])
printinfo += infoline
printblank.name = printname
printblank.add_raw_text(printinfo)
return printblank

/**
* Determines if the photocopier has enough toner to create `num_copies` amount of copies of the currently inserted item.
Expand Down Expand Up @@ -278,6 +333,12 @@

return copied_doc

/**
* The procedure is called when printing a blank to write off toner consumption.
*/
/obj/machinery/photocopier/proc/make_blank_print()
toner_cartridge.charges -= PAPER_TONER_USE

/**
* Handles the copying of an ass photo.
*
Expand Down

0 comments on commit 435a457

Please sign in to comment.