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).

Conflicts:
	code/game/objects/items/devices/PDA/PDA.dm
	code/game/objects/items/devices/uplinks.dm
	code/modules/reagents/Chemistry-Machinery.dm
	nano/css/shared.css
This commit is contained in:
Mark Aherne (Faerdan)
2014-01-05 23:28:52 -05:00
committed by ZomgPonies
parent d5f5a7f60d
commit 5d04a41151
13 changed files with 1756 additions and 4830 deletions
+24 -1
View File
@@ -13,6 +13,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
*
@@ -20,7 +43,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]"
+1
View File
@@ -313,6 +313,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>
"}
/**
+12 -9
View File
@@ -10,6 +10,7 @@
icon_state = "dispenser"
use_power = 0
idle_power_usage = 40
var/ui_title = "Chem Dispenser 5000"
var/energy = 100
var/max_energy = 100
var/amount = 30
@@ -107,7 +108,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
@@ -145,17 +146,17 @@
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", "Chem Dispenser 5000", 374, 640)
// When the UI is first opened this is the data it will use
// 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))
@@ -245,6 +246,7 @@
icon_state = "soda_dispenser"
name = "soda fountain"
desc = "A drink fabricating machine, capable of producing many sugary drinks with just one touch."
ui_title = "Soda Dispens-o-matic"
energy = 100
max_energy = 100
dispensable_reagents = list("water","ice","coffee","tea","icetea","cola","spacemountainwind","dr_gibb","space_up","tonic","sodawater","lemon_lime","sugar","orangejuice","limejuice","tomatojuice" ,"watermelonjuice","berryjuice")
@@ -255,6 +257,7 @@
/obj/machinery/chem_dispenser/beer
icon_state = "booze_dispenser"
name = "booze dispenser"
ui_title = "Booze Portal 9001"
energy = 100
max_energy = 100
desc = "A technological marvel, supposedly able to mix just the mixture you'd like to drink the moment you ask for one."
@@ -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)