Merge pull request #8661 from ShadowLarkens/med_pass_2

TGUI Medical: Second Pass
This commit is contained in:
Novacat
2020-08-12 20:01:12 -04:00
committed by GitHub
46 changed files with 2418 additions and 1509 deletions

View File

@@ -243,7 +243,6 @@
user.visible_message("[user] [panel_open ? "opens" : "closes"] the maintenance panel of \the [src].", "You [panel_open ? "open" : "close"] the maintenance panel of \the [src].")
playsound(src, O.usesound, 50, 1)
update_icon()
SSnanoui.update_uis(src)
return
if(wrenchable && default_unfasten_wrench(user, O, 20))
@@ -263,7 +262,6 @@
stock(O)
user.visible_message("<span class='notice'>[user] has added \the [O] to \the [src].</span>", "<span class='notice'>You add \the [O] to \the [src].</span>")
else if(istype(O, /obj/item/weapon/storage/bag))
var/obj/item/weapon/storage/bag/P = O
var/plants_loaded = 0
@@ -309,11 +307,11 @@
var/datum/stored_item/item = new/datum/stored_item(src, O.type, O.name)
item.add_product(O)
item_records.Add(item)
SSnanoui.update_uis(src)
SStgui.update_uis(src)
/obj/machinery/smartfridge/proc/vend(datum/stored_item/I)
I.get_product(get_turf(src))
SSnanoui.update_uis(src)
SStgui.update_uis(src)
/obj/machinery/smartfridge/attack_ai(mob/user as mob)
attack_hand(user)
@@ -322,66 +320,59 @@
if(stat & (NOPOWER|BROKEN))
return
wires.Interact(user)
ui_interact(user)
tgui_interact(user)
/*******************
* SmartFridge Menu
********************/
/obj/machinery/smartfridge/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "SmartVend", name)
ui.set_autoupdate(FALSE)
ui.open()
/obj/machinery/smartfridge/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
user.set_machine(src)
/obj/machinery/smartfridge/tgui_data(mob/user)
. = list()
var/data[0]
data["contents"] = null
data["electrified"] = seconds_electrified > 0
data["shoot_inventory"] = shoot_inventory
data["locked"] = locked
data["secure"] = is_secure
var/list/items[0]
for (var/i=1 to length(item_records))
var/list/items = list()
for(var/i=1 to length(item_records))
var/datum/stored_item/I = item_records[i]
var/count = I.get_amount()
if(count > 0)
items.Add(list(list("display_name" = html_encode(capitalize(I.item_name)), "vend" = i, "quantity" = count)))
items.Add(list(list("name" = html_encode(capitalize(I.item_name)), "index" = i, "amount" = count)))
if(items.len > 0)
data["contents"] = items
.["contents"] = items
.["name"] = name
.["locked"] = locked
.["secure"] = is_secure
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, ui_key, "smartfridge.tmpl", src.name, 400, 500)
ui.set_initial_data(data)
ui.open()
/obj/machinery/smartfridge/tgui_act(action, params)
if(..())
return TRUE
/obj/machinery/smartfridge/Topic(href, href_list)
if(..()) return 0
add_fingerprint(usr)
switch(action)
if("Release")
var/amount = 0
if(params["amount"])
amount = params["amount"]
else
amount = input("How many items?", "How many items would you like to take out?", 1) as num|null
if(QDELETED(src) || QDELETED(usr) || !usr.Adjacent(src))
return FALSE
var/index = text2num(params["index"])
var/datum/stored_item/I = item_records[index]
var/count = I.get_amount()
var/mob/user = usr
var/datum/nanoui/ui = SSnanoui.get_open_ui(user, src, "main")
// Sanity check, there are probably ways to press the button when it shouldn't be possible.
if(count > 0)
if((count - amount) < 0)
amount = count
for(var/i = 1 to amount)
vend(I)
src.add_fingerprint(user)
if(href_list["close"])
user.unset_machine()
ui.close()
return 0
if(href_list["vend"])
var/index = text2num(href_list["vend"])
var/amount = text2num(href_list["amount"])
var/datum/stored_item/I = item_records[index]
var/count = I.get_amount()
// Sanity check, there are probably ways to press the button when it shouldn't be possible.
if(count > 0)
if((count - amount) < 0)
amount = count
for(var/i = 1 to amount)
vend(I)
return 1
return 0
return TRUE
return FALSE
/obj/machinery/smartfridge/proc/throw_item()
var/obj/throw_item = null
@@ -400,17 +391,18 @@
spawn(0)
throw_item.throw_at(target,16,3,src)
src.visible_message("<span class='warning'>[src] launches [throw_item.name] at [target.name]!</span>")
SStgui.update_uis(src)
return 1
/************************
* Secure SmartFridges
*************************/
/obj/machinery/smartfridge/secure/Topic(href, href_list)
/obj/machinery/smartfridge/secure/tgui_act(action, params)
if(stat & (NOPOWER|BROKEN))
return 0
return TRUE
if(usr.contents.Find(src) || (in_range(src, usr) && istype(loc, /turf)))
if(!allowed(usr) && !emagged && locked != -1 && href_list["vend"])
if(!allowed(usr) && !emagged && locked != -1 && action == "Release")
to_chat(usr, "<span class='warning'>Access denied.</span>")
return 0
return TRUE
return ..()