mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 12:35:33 +01:00
Fix NanoUI runtimes when data is null; touch up code
This commit is contained in:
@@ -194,13 +194,14 @@
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/alarm/get_ui_data(mob/user)
|
||||
var/data = list()
|
||||
data["locked"] = locked
|
||||
data["siliconUser"] = user.has_unlimited_silicon_privilege
|
||||
data["screen"] = screen
|
||||
data["dangerous"] = emagged
|
||||
var/data = list(
|
||||
"locked" = locked,
|
||||
"siliconUser" = user.has_unlimited_silicon_privilege,
|
||||
"screen" = screen,
|
||||
"emagged" = emagged
|
||||
)
|
||||
populate_status(data)
|
||||
if (!locked || user.has_unlimited_silicon_privilege)
|
||||
if(!locked || user.has_unlimited_silicon_privilege)
|
||||
populate_controls(data)
|
||||
return data
|
||||
|
||||
|
||||
@@ -22,23 +22,23 @@
|
||||
/client/Topic(href, href_list, hsrc)
|
||||
if(!usr || usr != mob) //stops us calling Topic for somebody else's client. Also helps prevent usr=null
|
||||
return
|
||||
// NanoUI
|
||||
if(href_list["nano_error"])
|
||||
src << href_list["nano_error"]
|
||||
throw EXCEPTION("NanoUI: [href_list["nano_error"]]")
|
||||
// asset_cache
|
||||
if(href_list["asset_cache_confirm_arrival"])
|
||||
//src << "ASSET JOB [href_list["asset_cache_confirm_arrival"]] ARRIVED."
|
||||
var/job = text2num(href_list["asset_cache_confirm_arrival"])
|
||||
completed_asset_jobs += job
|
||||
return
|
||||
//Admin PM
|
||||
// Admin PM
|
||||
if(href_list["priv_msg"])
|
||||
if (href_list["ahelp_reply"])
|
||||
cmd_ahelp_reply(href_list["priv_msg"])
|
||||
return
|
||||
cmd_admin_pm(href_list["priv_msg"],null)
|
||||
return
|
||||
// NanoUI
|
||||
if(href_list["nano_error"])
|
||||
src << href_list["nano_error"]
|
||||
throw EXCEPTION("NanoUI: [href_list["nano_error"]]")
|
||||
|
||||
//Logs all hrefs
|
||||
if(config && config.log_hrefs && href_logfile)
|
||||
|
||||
@@ -226,12 +226,8 @@
|
||||
"title" = title,
|
||||
"status" = status,
|
||||
"layout" = layout,
|
||||
"window" = window_id,
|
||||
"ref" = "\ref[src]",
|
||||
"window" = list(
|
||||
"width" = width,
|
||||
"height" = height,
|
||||
"ref" = window_id
|
||||
),
|
||||
"user" = list(
|
||||
"name" = user.name,
|
||||
"fancy" = user.client.prefs.nanoui_fancy,
|
||||
@@ -269,8 +265,8 @@
|
||||
* private
|
||||
*
|
||||
* Handle clicks from the NanoUI.
|
||||
* Call the src_object's Topic() if status is NANO_INTERACTIVE.
|
||||
* If the src_object's Topic() returns 1, update all UIs attacked to it.
|
||||
* Call the src_object's ui_act() if status is NANO_INTERACTIVE.
|
||||
* If the src_object's ui_act() returns 1, update all UIs attacked to it.
|
||||
**/
|
||||
/datum/nanoui/Topic(href, href_list)
|
||||
update_status(push = 0) // Update the window state.
|
||||
@@ -280,10 +276,9 @@
|
||||
var/action = href_list["nano"] // Pull the action out.
|
||||
href_list -= "nano"
|
||||
|
||||
var/update = src_object.ui_act(action, href_list, state) // Call Topic() on the src_object.
|
||||
|
||||
var/update = src_object.ui_act(action, href_list, state) // Call ui_act() on the src_object.
|
||||
if(src_object && update)
|
||||
SSnano.update_uis(src_object) // If we have a src_object and its Topic() told us to update.
|
||||
SSnano.update_uis(src_object) // If we have a src_object and its ui_act() told us to update.
|
||||
|
||||
/**
|
||||
* private
|
||||
@@ -313,7 +308,7 @@
|
||||
**/
|
||||
/datum/nanoui/proc/push_data(data, force = 0)
|
||||
update_status(push = 0) // Update the window state.
|
||||
if(status == NANO_DISABLED && !force)
|
||||
if(status <= NANO_DISABLED && !force)
|
||||
return // Cannot update UI, we have no visibility.
|
||||
|
||||
var/list/send_data = get_send_data(data) // Get the data to send.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2,3 +2,4 @@
|
||||
INTERACTIVE: 2
|
||||
UPDATE: 1
|
||||
DISABLED: 0
|
||||
CLOSE: -1
|
||||
|
||||
@@ -22,7 +22,15 @@ class NanoUI
|
||||
|
||||
update: (dataString) =>
|
||||
try
|
||||
@data = JSON.parse dataString
|
||||
data = JSON.parse dataString
|
||||
|
||||
if not data.data?
|
||||
if @data.data?
|
||||
data.data = @data.data
|
||||
else
|
||||
data.data = {}
|
||||
|
||||
@data = data
|
||||
catch error
|
||||
@error error
|
||||
@render @data
|
||||
@@ -59,7 +67,7 @@ class NanoUI
|
||||
location.href = @href {nano_error: error}, null
|
||||
|
||||
winset: (key, value, window) =>
|
||||
window = @data.config.window.ref unless window?
|
||||
window = @data.config.window unless window?
|
||||
location.href = @href {"#{window}.#{key}": value}, "winset"
|
||||
setPos: (x, y) =>
|
||||
@winset "pos", "#{x},#{y}"
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<span class="bad bold">Warning: Cannot obtain air sample for analysis.</span>
|
||||
</section>
|
||||
{{?}}
|
||||
{{? data.dangerous}}
|
||||
{{? data.emagged}}
|
||||
<hr />
|
||||
<section>
|
||||
<span class="bad bold">Warning: Safety measures offline. Device may exhibit abnormal behavior.</span>
|
||||
|
||||
Reference in New Issue
Block a user