mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 12:41:09 +01:00
Merge pull request #9466 from Fayrik/TheNanoing
The Nanoing (Episode 2: The Fix Wars)
This commit is contained in:
@@ -39,5 +39,8 @@
|
||||
/atom/movable/proc/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
return
|
||||
|
||||
/atom/movable/proc/get_ui_data(mob/user)
|
||||
return list()
|
||||
|
||||
// Used by the Nano UI SubSystem (/datum/subsystem/nano) to track UIs opened by this mob
|
||||
/mob/var/list/open_uis = list()
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/**
|
||||
* Get an open /nanoui ui for the current user, or create a new one.
|
||||
*
|
||||
* @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 new or found ui
|
||||
*/
|
||||
/datum/subsystem/nano/proc/push_open_or_new_ui(var/mob/user, var/atom/movable/src_object, ui_key, var/datum/nanoui/ui, template, title, width, height, auto_update)
|
||||
var/list/data = src_object.get_ui_data(user)
|
||||
if (!data)
|
||||
data = list()
|
||||
|
||||
ui = try_update_ui(user, src_object, ui_key, ui, data)
|
||||
|
||||
if (isnull(ui))
|
||||
ui = new /datum/nanoui(user, src_object, ui_key, template, title, width, height)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(auto_update)
|
||||
|
||||
/**
|
||||
* Get an open /nanoui ui for the current user, src_object and ui_key and try to update it with data
|
||||
*
|
||||
@@ -11,9 +35,8 @@
|
||||
*/
|
||||
/datum/subsystem/nano/proc/try_update_ui(var/mob/user, src_object, ui_key, var/datum/nanoui/ui, data)
|
||||
if (isnull(ui)) // no ui has been passed, so we'll search for one
|
||||
{
|
||||
ui = get_open_ui(user, src_object, ui_key)
|
||||
}
|
||||
|
||||
if (!isnull(ui))
|
||||
// The UI is already open so push the data to it
|
||||
ui.push_data(data)
|
||||
@@ -186,4 +209,4 @@
|
||||
//Send all needed nano ui files to the client
|
||||
/datum/subsystem/nano/proc/send_resources(client)
|
||||
for(var/file in asset_files)
|
||||
client << browse_rsc(file)
|
||||
client << browse_rsc(file)
|
||||
@@ -131,8 +131,13 @@ nanoui is used to open and update nano browser uis
|
||||
set_status(STATUS_DISABLED, push_update) // no updates, completely disabled (red visibility)
|
||||
else
|
||||
var/dist = get_dist(src_object, user)
|
||||
var/isTK = 0
|
||||
|
||||
if (dist > 4)
|
||||
if(ishuman(user))
|
||||
var/mob/living/carbon/human/H = user
|
||||
isTK = H.dna.check_mutation(TK)
|
||||
|
||||
if (dist > 4 && !isTK)
|
||||
close()
|
||||
return
|
||||
|
||||
@@ -141,10 +146,10 @@ nanoui is used to open and update nano browser uis
|
||||
else if (user.restrained() || user.lying)
|
||||
set_status(STATUS_UPDATE, push_update) // update only (orange visibility)
|
||||
else if (!(src_object in view(4, user))) // If the src object is not in visable, set status to 0
|
||||
set_status(STATUS_DISABLED, push_update) // interactive (green visibility)
|
||||
set_status(STATUS_DISABLED, push_update) // no updates, completely disabled (red visibility)
|
||||
else if (dist <= 1)
|
||||
set_status(STATUS_INTERACTIVE, push_update) // interactive (green visibility)
|
||||
else if (dist <= 2)
|
||||
else if (dist <= 2 || isTK)
|
||||
set_status(STATUS_UPDATE, push_update) // update only (orange visibility)
|
||||
else if (dist <= 4)
|
||||
set_status(STATUS_DISABLED, push_update) // no updates, completely disabled (red visibility)
|
||||
|
||||
@@ -664,6 +664,9 @@
|
||||
if(!user)
|
||||
return
|
||||
|
||||
ui = SSnano.push_open_or_new_ui(user, src, ui_key, ui, "apc.tmpl", "[area.name] - APC", 520, user.has_unlimited_silicon_privilege ? 465 : 420, 1)
|
||||
|
||||
/obj/machinery/power/apc/get_ui_data(mob/user)
|
||||
var/list/data = list(
|
||||
"locked" = locked,
|
||||
"isOperating" = operating,
|
||||
@@ -709,19 +712,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = SSnano.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
// 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, "apc.tmpl", "[area.name] - APC", 520, data["siliconUser"] ? 465 : 420)
|
||||
// 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)
|
||||
return data
|
||||
|
||||
/obj/machinery/power/apc/proc/report()
|
||||
return "[area.name] : [equipment]/[lighting]/[environ] ([lastused_equip+lastused_light+lastused_environ]) : [cell? cell.percent() : "N/C"] ([charging])"
|
||||
|
||||
@@ -326,6 +326,10 @@
|
||||
if(!user)
|
||||
return
|
||||
|
||||
// update the ui if it exists, create a new one if it doesn't
|
||||
ui = SSnano.push_open_or_new_ui(user, src, ui_key, ui, "smes.tmpl", "SMES - [name]", 350, 560, 1)
|
||||
|
||||
/obj/machinery/power/smes/get_ui_data()
|
||||
var/list/data = list(
|
||||
"capacityPercent" = round(100.0*charge/capacity, 0.1),
|
||||
"capacity" = capacity,
|
||||
@@ -343,19 +347,7 @@
|
||||
"outputLevelMax" = output_level_max,
|
||||
"outputUsed" = output_used
|
||||
)
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = SSnano.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
// 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, "smes.tmpl", "SMES - [name]", 350, 560)
|
||||
// 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)
|
||||
return data
|
||||
|
||||
/obj/machinery/power/smes/Topic(href, href_list)
|
||||
// world << "[href] ; [href_list[href]]"
|
||||
|
||||
@@ -370,8 +370,10 @@
|
||||
if(!..())
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/solar_control/ui_interact(mob/user, ui_key = "main")
|
||||
/obj/machinery/power/solar_control/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
ui = SSnano.push_open_or_new_ui(user, src, ui_key, ui, "solar_control.tmpl", name, 490, 420, 1)
|
||||
|
||||
/obj/machinery/power/solar_control/get_ui_data()
|
||||
var/data = list()
|
||||
|
||||
data["generated"] = round(lastgen)
|
||||
@@ -384,16 +386,7 @@
|
||||
|
||||
data["connected_panels"] = connected_panels.len
|
||||
data["connected_tracker"] = (connected_tracker ? 1 : 0)
|
||||
|
||||
var/datum/nanoui/ui = SSnano.get_open_ui(user, src, ui_key)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "solar_control.tmpl", name, 490, 420)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
else
|
||||
ui.push_data(data)
|
||||
return
|
||||
return data
|
||||
|
||||
/obj/machinery/power/solar_control/attackby(I as obj, user as mob, params)
|
||||
if(istype(I, /obj/item/weapon/screwdriver))
|
||||
|
||||
@@ -75,8 +75,10 @@
|
||||
if(stat & (BROKEN)) return
|
||||
if(user.stat || user.restrained()) return
|
||||
|
||||
// this is the data which will be sent to the ui
|
||||
var/data[0]
|
||||
ui = SSnano.push_open_or_new_ui(user, src, ui_key, ui, "chem_dispenser.tmpl", "[uiname]", 490, 710, 0)
|
||||
|
||||
/obj/machinery/chem_dispenser/get_ui_data()
|
||||
var/data = list()
|
||||
data["amount"] = amount
|
||||
data["energy"] = energy
|
||||
data["maxEnergy"] = max_energy
|
||||
@@ -103,17 +105,7 @@
|
||||
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
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = SSnano.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
// 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", "[uiname]", 490, 710)
|
||||
// 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()
|
||||
return data
|
||||
|
||||
/obj/machinery/chem_dispenser/Topic(href, href_list)
|
||||
if(stat & (BROKEN))
|
||||
@@ -1510,7 +1502,10 @@
|
||||
/obj/machinery/chem_heater/ui_interact(var/mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
if(user.stat || user.restrained()) return
|
||||
|
||||
var/data[0]
|
||||
ui = SSnano.push_open_or_new_ui(user, src, ui_key, ui, "chem_heater.tmpl", "ChemHeater", 350, 270, 0)
|
||||
|
||||
/obj/machinery/chem_heater/get_ui_data()
|
||||
var/data = list()
|
||||
data["targetTemp"] = desired_temp
|
||||
data["isActive"] = on
|
||||
data["isBeakerLoaded"] = beaker ? 1 : 0
|
||||
@@ -1525,13 +1520,7 @@
|
||||
for(var/datum/reagent/R in beaker.reagents.reagent_list)
|
||||
beakerContents.Add(list(list("name" = R.name, "volume" = R.volume))) // list in a list because Byond merges the first list...
|
||||
data["beakerContents"] = beakerContents
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = SSnano.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "chem_heater.tmpl", "ChemHeater", 350, 270)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
return data
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user