Better documentation for the ui_interact proc.

This commit is contained in:
Mark Aherne (Faerdan)
2013-09-11 21:46:59 +01:00
parent 8a6094685a
commit 762baa490f
2 changed files with 28 additions and 12 deletions

View File

@@ -62,14 +62,24 @@
/obj/machinery/atmospherics/unary/cryo_cell/attack_hand(mob/user)
ui_interact(user)
/**
* The ui_interact proc is used to open and update Nano UIs
* If ui_interact is not used then the UI will not update correctly
* ui_interact is currently defined for /obj and /mob
*
* @param user /mob The mob who is interacting with this ui
* @param ui_key string A string key to use for this ui. Allows for multiple unique uis on one obj/mob (defaut value "main")
*
* @return nothing
*/
/obj/machinery/atmospherics/unary/cryo_cell/ui_interact(mob/user, ui_key = "main")
if(user == occupant || user.stat)
return
var/data[0]
// this is the data which will be sent to the ui
var/data[0]
data["isOperating"] = on
data["hasOccupant"] = occupant ? 1 : 0
var/occupantData[0]
@@ -111,10 +121,9 @@
beakerContents.Add(list(list("name" = R.name, "volume" = R.volume))) // list in a list because Byond merges the first list...
data["beakerContents"] = beakerContents
//user << list2json(data)
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key)
if (!ui)
if (!ui)
// the ui does not exist, so we'll create a new one
ui = new(user, src, ui_key, "cryo.tmpl", "Cryo Cell Control System", 520, 410)
// When the UI is first opened this is the data it will use
ui.set_initial_data(data)

View File

@@ -67,19 +67,27 @@
del(src)
return
/obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main")
/**
* The ui_interact proc is used to open and update Nano UIs
* If ui_interact is not used then the UI will not update correctly
* ui_interact is currently defined for /obj and /mob
*
* @param user /mob The mob who is interacting with this ui
* @param ui_key string A string key to use for this ui. Allows for multiple unique uis on one obj/mob (defaut value "main")
*
* @return nothing
*/
/obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main")
if(stat & (BROKEN|NOPOWER)) return
if(user.stat || user.restrained()) return
// this is the data which will be sent to the ui
var/data[0]
data["amount"] = amount
data["energy"] = energy
data["maxEnergy"] = max_energy
data["isBeakerLoaded"] = beaker ? 1 : 0
var beakerContents[0]
var beakerCurrentVolume = 0
if(beaker && beaker:reagents && beaker:reagents.reagent_list.len)
@@ -102,10 +110,9 @@
chemicals.Add(list(list("title" = temp.name, "id" = temp.id, "commands" = list("dispense" = temp.id)))) // list in a list because Byond merges the first list...
data["chemicals"] = chemicals
//user << list2json(data)
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key)
if (!ui)
if (!ui)
// the ui does not exist, so we'll create a new one
ui = new(user, src, ui_key, "chem_dispenser.tmpl", "Chem Dispenser 5000", 370, 605)
// When the UI is first opened this is the data it will use
ui.set_initial_data(data)