mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-07-21 20:12:31 +01:00
NanoUI updates.
* Simplified the code used in ui_interact procs and updated all current uses. * Removed ununused jsviews JavaScript code (replaced it with vanilla jsrender). * Added a message to the UI which shows if JavaScript is disabled (people with JavaScript disabled previously got blank UIs).
This commit is contained in:
@@ -365,7 +365,7 @@
|
||||
/**
|
||||
* 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 /atom/movable
|
||||
* ui_interact is currently defined for /atom/movable (which is inherited by /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")
|
||||
@@ -451,23 +451,19 @@
|
||||
if (connected.beaker.reagents && connected.beaker.reagents.reagent_list.len)
|
||||
for(var/datum/reagent/R in connected.beaker.reagents.reagent_list)
|
||||
data["beakerVolume"] += R.volume
|
||||
|
||||
if (!ui) // no ui has been passed, so we'll search for one
|
||||
{
|
||||
ui = nanomanager.get_open_ui(user, src, ui_key)
|
||||
}
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
// the ui does not exist, so we'll create a new one
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "dna_modifier.tmpl", "DNA Modifier Console", 660, 700)
|
||||
// When the UI is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// when the ui is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
// Auto update every Master Controller tick
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(1)
|
||||
else
|
||||
// The UI is already open so push the new data to it
|
||||
ui.push_data(data)
|
||||
return
|
||||
|
||||
/obj/machinery/computer/scan_consolenew/Topic(href, href_list)
|
||||
if(..())
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
/**
|
||||
* 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 /atom/movable
|
||||
* ui_interact is currently defined for /atom/movable (which is inherited by /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")
|
||||
@@ -120,23 +120,18 @@
|
||||
for(var/datum/reagent/R in beaker.reagents.reagent_list)
|
||||
data["beakerVolume"] += R.volume
|
||||
|
||||
if (!ui) // no ui has been passed, so we'll search for one
|
||||
{
|
||||
ui = nanomanager.get_open_ui(user, src, ui_key)
|
||||
}
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
// the ui does not exist, so we'll create a new one
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
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)
|
||||
// when the ui is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
// Auto update every Master Controller tick
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(1)
|
||||
else
|
||||
// The UI is already open so push the new data to it
|
||||
ui.push_data(data)
|
||||
return
|
||||
//user.set_machine(src)
|
||||
|
||||
/obj/machinery/atmospherics/unary/cryo_cell/Topic(href, href_list)
|
||||
if(usr == occupant)
|
||||
|
||||
@@ -319,24 +319,9 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
return attack_self(M)
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
/* Notes for those wanting to modify this code or even understand it.
|
||||
There are two modes: New UI and a UI already existing.
|
||||
If the UI is new, you define your variables, if the ui already exists if it didn't have variables in data for what you want to add
|
||||
then it won't add it even if you make a data["blahblah"] for it. That's the reason for the = null all over the place, so that.
|
||||
ui.push_data(data) proc has to have the var structure already setup otherwise it can't push the update.
|
||||
|
||||
The exception to the "YOU HAVE TO DEFINE IT" rule is cartridges, we later force
|
||||
the ui to close if a cartridge is inserted so that never will be a problem.
|
||||
So there will never be a time a UI creation causes that to be a problem.
|
||||
*/
|
||||
|
||||
/obj/item/device/pda/ui_interact(mob/user, ui_key = "main")
|
||||
/obj/item/device/pda/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
var/title = "Personal Data Assistant"
|
||||
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key)
|
||||
|
||||
|
||||
var/data[0] // This is the data that will be sent to the PDA
|
||||
|
||||
|
||||
@@ -430,11 +415,11 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
data["convo_name"] = null
|
||||
data["convo_job"] = null
|
||||
|
||||
if(!ui || mode==41)
|
||||
if(mode==41)
|
||||
data["manifest"] = data_core.get_manifest_json()
|
||||
|
||||
|
||||
if(!ui || mode==3)
|
||||
if(mode==3)
|
||||
var/turf/T = get_turf_or_move(user.loc)
|
||||
if(!isnull(T) || mode!=3)
|
||||
var/datum/gas_mixture/environment = T.return_air()
|
||||
@@ -470,22 +455,18 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
"reading" = 0\
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
// the ui does not exist, so we'll create a new one
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "pda.tmpl", title, 630, 600)
|
||||
// When the UI is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// when the ui is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(1)
|
||||
else
|
||||
// The UI is already open so push the new data to it
|
||||
ui.push_data(data)
|
||||
return
|
||||
|
||||
|
||||
|
||||
//NOTE: graphic resources are loaded on client login
|
||||
/obj/item/device/pda/attack_self(mob/user as mob)
|
||||
|
||||
@@ -344,25 +344,24 @@ A list of items and costs is stored under the datum of every game mode, alongsid
|
||||
/*
|
||||
NANO UI FOR UPLINK WOOP WOOP
|
||||
*/
|
||||
/obj/item/device/uplink/hidden/ui_interact(mob/user, ui_key = "main")
|
||||
/obj/item/device/uplink/hidden/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
var/title = "Syndicate Uplink"
|
||||
var/data[0]
|
||||
|
||||
data["crystals"] = uses
|
||||
data["nano_items"] = nanoui_items
|
||||
data["welcome"] = welcome
|
||||
|
||||
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key)
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
// the ui does not exist, so we'll create a new one
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "uplink.tmpl", title, 450, 600)
|
||||
// When the UI is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// when the ui is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
else
|
||||
// The UI is already open so push the new data to it
|
||||
ui.push_data(data)
|
||||
return
|
||||
|
||||
// Interaction code. Gathers a list of items purchasable from the paren't uplink and displays it. It also adds a lock button.
|
||||
/obj/item/device/uplink/hidden/interact(mob/user)
|
||||
|
||||
@@ -14,6 +14,29 @@
|
||||
/datum/nanomanager/New()
|
||||
return
|
||||
|
||||
/**
|
||||
* Get an open /nanoui ui for the current user, src_object and ui_key and try to update it with data
|
||||
*
|
||||
* @param user /mob The mob who opened/owns the ui
|
||||
* @param src_object /obj|/mob The obj or mob which the ui belongs to
|
||||
* @param ui_key string A string key used for the ui
|
||||
* @param ui /datum/nanoui An existing instance of the ui (can be null)
|
||||
* @param data list The data to be passed to the ui, if it exists
|
||||
*
|
||||
* @return /nanoui Returns the found ui, for null if none exists
|
||||
*/
|
||||
/datum/nanomanager/proc/try_update_ui(var/mob/user, src_object, ui_key, var/datum/nanoui/ui, data)
|
||||
if (!ui) // no ui has been passed, so we'll search for one
|
||||
{
|
||||
ui = get_open_ui(user, src, ui_key)
|
||||
}
|
||||
if (ui)
|
||||
// The UI is already open so push the data to it
|
||||
ui.push_data(data)
|
||||
return ui
|
||||
|
||||
return null
|
||||
|
||||
/**
|
||||
* Get an open /nanoui ui for the current user, src_object and ui_key
|
||||
*
|
||||
@@ -21,7 +44,7 @@
|
||||
* @param src_object /obj|/mob The obj or mob which the ui belongs to
|
||||
* @param ui_key string A string key used for the ui
|
||||
*
|
||||
* @return /nanoui Returns the found ui, for null if none exists
|
||||
* @return /nanoui Returns the found ui, or null if none exists
|
||||
*/
|
||||
/datum/nanomanager/proc/get_open_ui(var/mob/user, src_object, ui_key)
|
||||
var/src_object_key = "\ref[src_object]"
|
||||
|
||||
@@ -308,6 +308,7 @@ nanoui is used to open and update nano browser uis
|
||||
<div id='uiWrapper'>
|
||||
[title ? "<div id='uiTitleWrapper'><div id='uiStatusIcon' class='icon24 uiStatusGood'></div><div id='uiTitle'>[title]</div><div id='uiTitleFluff'></div></div>" : ""]
|
||||
<div id='uiContent'>
|
||||
<noscript><div id='uiNoJavaScript'>Your browser does not have JavaScript enabled. Please enable JavaScript restart SS13.</div></noscript>
|
||||
"}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
icon_state = "dispenser"
|
||||
use_power = 0
|
||||
idle_power_usage = 40
|
||||
var/ui_name = "Chem Dispenser 5000"
|
||||
var/ui_title = "Chem Dispenser 5000"
|
||||
var/energy = 100
|
||||
var/max_energy = 100
|
||||
var/amount = 30
|
||||
@@ -104,7 +104,7 @@
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
/obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main")
|
||||
/obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
if(stat & (BROKEN|NOPOWER)) return
|
||||
if(user.stat || user.restrained()) return
|
||||
|
||||
@@ -140,18 +140,17 @@
|
||||
if(temp)
|
||||
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
|
||||
|
||||
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key)
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
// the ui does not exist, so we'll create a new one
|
||||
ui = new(user, src, ui_key, "chem_dispenser.tmpl", ui_name, 370, 605)
|
||||
// When the UI is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "chem_dispenser.tmpl", ui_title, 370, 605)
|
||||
// when the ui is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
else
|
||||
// The UI is already open so push the new data to it
|
||||
ui.push_data(data)
|
||||
return
|
||||
|
||||
/obj/machinery/chem_dispenser/Topic(href, href_list)
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
@@ -225,7 +224,7 @@
|
||||
icon_state = "soda_dispenser"
|
||||
name = "soda fountain"
|
||||
desc = "A drink fabricating machine, capable of producing many sugary drinks with just one touch."
|
||||
ui_name = "Soda Dispens-o-matic"
|
||||
ui_title = "Soda Dispens-o-matic"
|
||||
energy = 100
|
||||
accept_glass = 1
|
||||
max_energy = 100
|
||||
@@ -248,7 +247,7 @@
|
||||
/obj/machinery/chem_dispenser/beer
|
||||
icon_state = "booze_dispenser"
|
||||
name = "booze dispenser"
|
||||
ui_name = "Booze Portal 9001"
|
||||
ui_title = "Booze Portal 9001"
|
||||
energy = 100
|
||||
accept_glass = 1
|
||||
max_energy = 100
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
if(total_purity && fresh_coolant)
|
||||
coolant_purity = total_purity / fresh_coolant
|
||||
|
||||
/obj/machinery/radiocarbon_spectrometer/ui_interact(mob/user, ui_key = "radio_spectro")
|
||||
/obj/machinery/radiocarbon_spectrometer/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
|
||||
if(user.stat)
|
||||
return
|
||||
@@ -144,20 +144,19 @@
|
||||
data["radiation"] = round(radiation)
|
||||
data["t_left_radspike"] = round(t_left_radspike)
|
||||
data["rad_shield_on"] = rad_shield
|
||||
|
||||
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key)
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
// the ui does not exist, so we'll create a new one
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "geoscanner.tmpl", "High Res Radiocarbon Spectrometer", 900, 825)
|
||||
// When the UI is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// when the ui is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
// Auto update every Master Controller tick
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(1)
|
||||
else
|
||||
// The UI is already open so push the new data to it
|
||||
ui.push_data(data)
|
||||
return
|
||||
|
||||
/obj/machinery/radiocarbon_spectrometer/process()
|
||||
if(scanning)
|
||||
|
||||
Reference in New Issue
Block a user