mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-01-03 14:03:25 +00: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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user