From 8aa0bcb2893529cc832b5afe1fa40f25163744be Mon Sep 17 00:00:00 2001 From: Rykka Date: Wed, 13 May 2020 07:11:55 -0400 Subject: [PATCH] Photocopier improvements and NanoUI fixes! Upstream port of https://github.com/VOREStation/VOREStation/pull/7825 with all the butts + butt-copying removed. --- code/modules/paperwork/photocopier.dm | 63 ++++++++++++------- nano/templates/photocopier.tmpl | 90 +++++++++++++-------------- 2 files changed, 84 insertions(+), 69 deletions(-) diff --git a/code/modules/paperwork/photocopier.dm b/code/modules/paperwork/photocopier.dm index 71a110b4bd..6b4d96ff31 100644 --- a/code/modules/paperwork/photocopier.dm +++ b/code/modules/paperwork/photocopier.dm @@ -15,6 +15,7 @@ var/copies = 1 //how many copies to print! var/toner = 30 //how much toner is left! woooooo~ var/maxcopies = 10 //how many copies can be copied at once- idea shamelessly stolen from bs12's copier! + var/copying = FALSE // Is the printer busy with something? Sanity check variable. /obj/machinery/photocopier/Initialize() . = ..() @@ -58,33 +59,47 @@ ui.open() ui.set_auto_update(10) +/obj/machinery/photocopier/proc/copy_operation(var/mob/user) + if(copying) + return FALSE + copying = TRUE + for(var/i = 0, i < copies, i++) + if(toner <= 0) + break + + if (istype(copyitem, /obj/item/weapon/paper)) + playsound(loc, "sound/machines/copier.ogg", 100, 1) + sleep(11) + copy(copyitem) + audible_message("You can hear [src] whirring as it finishes printing.") + playsound(loc, "sound/machines/buzzbeep.ogg", 30) + else if (istype(copyitem, /obj/item/weapon/photo)) + playsound(loc, "sound/machines/copier.ogg", 100, 1) + sleep(11) + photocopy(copyitem) + audible_message("You can hear [src] whirring as it finishes printing.") + playsound(loc, "sound/machines/buzzbeep.ogg", 30) + else if (istype(copyitem, /obj/item/weapon/paper_bundle)) + sleep(11) + playsound(loc, "sound/machines/copier.ogg", 100, 1) + var/obj/item/weapon/paper_bundle/B = bundlecopy(copyitem) + sleep(11*B.pages.len) + audible_message("You can hear [src] whirring as it finishes printing.") + playsound(loc, "sound/machines/buzzbeep.ogg", 30) + else + to_chat(user, "\The [copyitem] can't be copied by [src].") + playsound(loc, "sound/machines/buzz-two.ogg", 100) + break + + use_power(active_power_usage) + copying = FALSE + /obj/machinery/photocopier/Topic(href, href_list) if(href_list["copy"]) if(stat & (BROKEN|NOPOWER)) return + addtimer(CALLBACK(src, .proc/copy_operation, usr), 0) - for(var/i = 0, i < copies, i++) - if(toner <= 0) - break - - if (istype(copyitem, /obj/item/weapon/paper)) - playsound(loc, "sound/machines/copier.ogg", 100, 1) - sleep(11) - copy(copyitem) - else if (istype(copyitem, /obj/item/weapon/photo)) - playsound(loc, "sound/machines/copier.ogg", 100, 1) - sleep(11) - photocopy(copyitem) - else if (istype(copyitem, /obj/item/weapon/paper_bundle)) - sleep(11) - playsound(loc, "sound/machines/copier.ogg", 100, 1) - var/obj/item/weapon/paper_bundle/B = bundlecopy(copyitem) - sleep(11*B.pages.len) - else - to_chat(usr, "\The [copyitem] can't be copied by \the [src].") - break - - use_power(active_power_usage) else if(href_list["remove"]) if(copyitem) copyitem.loc = usr.loc @@ -145,7 +160,6 @@ playsound(loc, O.usesound, 50, 1) anchored = !anchored to_chat(user, "You [anchored ? "wrench" : "unwrench"] \the [src].") - else if(default_deconstruction_screwdriver(user, O)) return else if(default_deconstruction_crowbar(user, O)) @@ -205,6 +219,7 @@ if(need_toner) toner-- if(toner == 0) + playsound(loc, "sound/machines/buzz-sigh.ogg", 100) visible_message("A red light on \the [src] flashes, indicating that it is out of toner.") return c @@ -227,6 +242,7 @@ toner -= 5 //photos use a lot of ink! if(toner < 0) toner = 0 + playsound(loc, "sound/machines/buzz-sigh.ogg", 100) visible_message("A red light on \the [src] flashes, indicating that it is out of toner.") return p @@ -237,6 +253,7 @@ for(var/obj/item/weapon/W in bundle.pages) if(toner <= 0 && need_toner) toner = 0 + playsound(loc, "sound/machines/buzz-sigh.ogg", 100) visible_message("A red light on \the [src] flashes, indicating that it is out of toner.") break diff --git a/nano/templates/photocopier.tmpl b/nano/templates/photocopier.tmpl index 9c9910e969..695f5677ad 100644 --- a/nano/templates/photocopier.tmpl +++ b/nano/templates/photocopier.tmpl @@ -1,47 +1,45 @@ - - -{{if data.copyItem}} -
- {{:helper.link('Remove Item', 'eject', {'remove' : 1})}} - {{if data.toner}} - {{:helper.link('Copy', 'copy', {'copy' : 1})}}
-
-
-
- Printing: -
-
-
- {{:helper.link('-', null, {'min' : 1}, data.copies == 1 ? 'linkOff' : null)}} -
{{:data.copies}}
- {{:helper.link('+', null, {'add' : 1}, data.copies == data.maxCopies ? 'linkOff' : null)}} -
-
-
-
-
-
Current toner level:
-
{{:data.toner}}u
-
- {{else}} -
- Please insert a new toner cartridge! -
- {{/if}} -{{else data.toner}} -

Please insert something to copy.

- {{if data.isSilicon}} - {{:helper.link('Print photo from database', 'image', {'aipic' : 1})}} - {{/if}} -
-
Current toner level:
-
{{:data.toner}}u
-
-{{else}} -
- Please insert a new toner cartridge! -
+ + +{{if data.copyItem}} +
+ {{:helper.link('Remove Item', 'eject', {'remove' : 1})}} + {{if data.toner}} + {{:helper.link('Copy', 'copy', {'copy' : 1})}} +
+
+ Printing: +
+
+
+ {{:helper.link('-', null, {'min' : 1}, data.copies == 1 ? 'linkOff' : null)}} +
{{:data.copies}}
+ {{:helper.link('+', null, {'add' : 1}, data.copies == data.maxCopies ? 'linkOff' : null)}} +
+
+
+
+
+
Current toner level:
+
{{:data.toner}}u
+
+ {{else}} + Please insert a new toner cartridge! + {{/if}} +
+{{else data.toner}} +

Please insert something to copy.

+ {{if data.isSilicon}} + {{:helper.link('Print photo from database', 'image', {'aipic' : 1})}} + {{/if}} +
+
Current toner level:
+
{{:data.toner}}u
+
+{{else}} +
+ Please insert a new toner cartridge! +
{{/if}} \ No newline at end of file