mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 19:44:58 +01:00
Refactor NanoUI API
Also update NanoUI-using code to the new API.
This commit is contained in:
@@ -779,8 +779,8 @@ var/global/list/g_fancy_list_of_types = null
|
||||
|
||||
/client/proc/reload_nanoui_templates()
|
||||
set category = "Debug"
|
||||
set name = "Reload NanoUI Templates"
|
||||
set desc = "Forces the client to redownload NanoUI Templates"
|
||||
set name = "Reload NanoUI Resources"
|
||||
set desc = "Force the client to redownload NanoUI Resources"
|
||||
|
||||
var/list/resources = SSnano.populate_resources()
|
||||
|
||||
|
||||
@@ -1,54 +1,59 @@
|
||||
// This file contains all Nano procs/definitions for external classes/objects
|
||||
|
||||
/**
|
||||
* Called when a Nano UI window is closed
|
||||
* This is how Nano handles closed windows
|
||||
* It must be a verb so that it can be called using winset
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
/client/verb/nanoclose(var/uiref as text)
|
||||
set hidden = 1 // hide this verb from the user's panel
|
||||
set name = "nanoclose"
|
||||
|
||||
var/datum/nanoui/ui = locate(uiref)
|
||||
|
||||
if (istype(ui))
|
||||
ui.close()
|
||||
|
||||
if(ui.ref)
|
||||
var/href = "close=1"
|
||||
src.Topic(href, params2list(href), ui.ref) // this will direct to the atom's Topic() proc via client.Topic()
|
||||
else if (ui.on_close_logic)
|
||||
// no atomref specified (or not found)
|
||||
// so just reset the user mob's machine var
|
||||
if(src && src.mob)
|
||||
src.mob.unset_machine()
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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")
|
||||
* @param ui /datum/nanoui This parameter is passed by the nanoui process() proc when updating an open ui
|
||||
* @param force_open boolean Force the UI to (re)open, even if it's already open
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
/atom/movable/proc/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/nano_ui/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
return
|
||||
|
||||
/**
|
||||
* Used to get data to send to the Nano UI.
|
||||
*
|
||||
* @param user /mob The mob who is interacting with this ui
|
||||
*
|
||||
* @return list
|
||||
*/
|
||||
/atom/movable/proc/get_ui_data(mob/user)
|
||||
return list()
|
||||
|
||||
// Used by the Nano UI Manager (/datum/nanomanager) to track UIs opened by this mob
|
||||
/mob/var/list/open_uis = list()
|
||||
// This file contains all Nano procs/definitions for external classes/objects
|
||||
|
||||
/**
|
||||
* Called when a Nano UI window is closed
|
||||
* This is how Nano handles closed windows
|
||||
* It must be a verb so that it can be called using winset
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
/client/verb/nanoclose(var/uiref as text)
|
||||
set hidden = 1 // hide this verb from the user's panel
|
||||
set name = "nanoclose"
|
||||
|
||||
var/datum/nanoui/ui = locate(uiref)
|
||||
|
||||
if (istype(ui))
|
||||
ui.close()
|
||||
|
||||
if(ui.ref)
|
||||
var/href = "close=1"
|
||||
src.Topic(href, params2list(href), ui.ref) // this will direct to the atom's Topic() proc via client.Topic()
|
||||
else if (ui.on_close_logic)
|
||||
// no atomref specified (or not found)
|
||||
// so just reset the user mob's machine var
|
||||
if(src && src.mob)
|
||||
src.mob.unset_machine()
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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")
|
||||
* @param ui /datum/nanoui This parameter is passed by the nanoui process() proc when updating an open ui
|
||||
* @param force_open boolean Force the UI to (re)open, even if it's already open
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
/atom/movable/proc/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, \
|
||||
var/force_open = 1, var/datum/nano_ui/master_ui = null, \
|
||||
var/datum/topic_state/state = default_state)
|
||||
return
|
||||
|
||||
// Used by the Nano UI Manager (/datum/nanomanager) to track UIs opened by this mob
|
||||
/mob/var/list/open_uis = list()
|
||||
|
||||
/**
|
||||
* Used to get data to send to the Nano UI.
|
||||
*
|
||||
* @param user /mob The mob who is interacting with this ui
|
||||
*
|
||||
* @return list
|
||||
*/
|
||||
/atom/movable/proc/get_ui_data(mob/user)
|
||||
return list()
|
||||
|
||||
/atom/proc/nano_host()
|
||||
return src
|
||||
@@ -1,32 +1,43 @@
|
||||
/atom/proc/nano_host()
|
||||
return src
|
||||
|
||||
/atom/proc/CanUseTopic(var/mob/user, var/datum/topic_state/state)
|
||||
var/src_object = nano_host()
|
||||
return state.can_use_topic(src_object, user)
|
||||
return state.can_use_topic(src_object, user) // Check if the state allows interaction.
|
||||
|
||||
/datum/topic_state/proc/href_list(var/mob/user)
|
||||
return list()
|
||||
|
||||
/datum/topic_state/proc/can_use_topic(var/src_object, var/mob/user)
|
||||
return NANO_CLOSE
|
||||
return NANO_CLOSE // Don't allow interaction by default.
|
||||
|
||||
|
||||
/mob/proc/shared_nano_interaction()
|
||||
if (src.stat || !client)
|
||||
return NANO_CLOSE // no updates, close the interface
|
||||
else if (restrained() || lying || stat || stunned || weakened) // TODO: Change to incapaciated() on merge
|
||||
return NANO_UPDATE // update only (orange visibility)
|
||||
if (!client || src.stat) // Close NanoUIs if mindless or dead/unconcious.
|
||||
return NANO_CLOSE
|
||||
else if (restrained() || lying || stat || stunned || weakened) // Update NanoUIs if incapicitated but concious.
|
||||
return NANO_UPDATE
|
||||
return NANO_INTERACTIVE
|
||||
|
||||
/mob/living/silicon/ai/shared_nano_interaction()
|
||||
if (lacks_power())
|
||||
if (lacks_power()) // Close NanoUIs if the AI is unpowered.
|
||||
return NANO_CLOSE
|
||||
return ..()
|
||||
|
||||
/mob/living/silicon/robot/shared_nano_interaction()
|
||||
. = NANO_INTERACTIVE
|
||||
if (cell.charge <= 0)
|
||||
if (cell.charge <= 0) // Close NanoUIs if the Borg is unpowered.
|
||||
return NANO_CLOSE
|
||||
if (lockcharge)
|
||||
. = NANO_DISABLED
|
||||
return min(., ..())
|
||||
if (lockcharge) // Disable NanoUIs if the Borg is locked.
|
||||
return NANO_DISABLED
|
||||
return ..()
|
||||
|
||||
/atom/proc/contents_nano_distance(var/src_object, var/mob/living/user)
|
||||
return user.shared_living_nano_distance(src_object)
|
||||
|
||||
/mob/living/proc/shared_living_nano_distance(var/atom/movable/src_object)
|
||||
if (!(src_object in view(4, src))) // If the src object is not in visable, disable updates
|
||||
return NANO_CLOSE
|
||||
|
||||
var/dist = get_dist(src_object, src)
|
||||
if (dist <= 1)
|
||||
return NANO_INTERACTIVE // interactive (green visibility)
|
||||
else if (dist <= 2)
|
||||
return NANO_UPDATE // update only (orange visibility)
|
||||
else if (dist <= 4)
|
||||
return NANO_DISABLED // no updates, completely disabled (red visibility)
|
||||
return NANO_CLOSE
|
||||
@@ -1,11 +1,10 @@
|
||||
/var/global/datum/topic_state/default/default_state = new()
|
||||
|
||||
/datum/topic_state/default/href_list(var/mob/user)
|
||||
return list()
|
||||
|
||||
/datum/topic_state/default/can_use_topic(var/src_object, var/mob/user)
|
||||
return user.default_can_use_topic(src_object)
|
||||
|
||||
|
||||
/mob/proc/default_can_use_topic(var/src_object)
|
||||
return NANO_CLOSE // By default no mob can do anything with NanoUI
|
||||
|
||||
@@ -14,12 +13,6 @@
|
||||
return NANO_INTERACTIVE // Admins are more equal
|
||||
return NANO_UPDATE // Ghosts can view updates
|
||||
|
||||
/mob/living/silicon/pai/default_can_use_topic(var/src_object)
|
||||
if((src_object == src || src_object == radio) && !stat)
|
||||
return NANO_INTERACTIVE
|
||||
else
|
||||
return ..()
|
||||
|
||||
/mob/living/silicon/robot/default_can_use_topic(var/src_object)
|
||||
. = shared_nano_interaction()
|
||||
if(. <= NANO_DISABLED)
|
||||
@@ -45,37 +38,20 @@
|
||||
|
||||
/mob/living/silicon/ai/default_can_use_topic(var/src_object)
|
||||
. = shared_nano_interaction()
|
||||
if(. != NANO_INTERACTIVE)
|
||||
if (. != NANO_INTERACTIVE)
|
||||
return
|
||||
|
||||
// Prevents the AI from using Topic on admin levels (by for example viewing through the court/thunderdome cameras)
|
||||
// unless it's on the same level as the object it's interacting with.
|
||||
var/turf/T = get_turf(src_object)
|
||||
if(!T || !(z == T.z))
|
||||
return NANO_CLOSE
|
||||
|
||||
// If an object is in view then we can interact with it
|
||||
if(src_object in view(client.view, src))
|
||||
// If an object is in view of the client and a camera then we can interact with it
|
||||
if ((src_object in view(eyeobj)) && cameranet.checkTurfVis(get_turf(src_object)))
|
||||
return NANO_INTERACTIVE
|
||||
|
||||
return NANO_CLOSE
|
||||
|
||||
//Some atoms such as vehicles might have special rules for how mobs inside them interact with NanoUI.
|
||||
/atom/proc/contents_nano_distance(var/src_object, var/mob/living/user)
|
||||
return user.shared_living_nano_distance(src_object)
|
||||
|
||||
/mob/living/proc/shared_living_nano_distance(var/atom/movable/src_object)
|
||||
if (!(src_object in view(4, src))) // If the src object is not in visable, disable updates
|
||||
return NANO_CLOSE
|
||||
|
||||
var/dist = get_dist(src_object, src)
|
||||
if (dist <= 1)
|
||||
return NANO_INTERACTIVE // interactive (green visibility)
|
||||
else if (dist <= 2)
|
||||
return NANO_UPDATE // update only (orange visibility)
|
||||
else if (dist <= 4)
|
||||
return NANO_DISABLED // no updates, completely disabled (red visibility)
|
||||
return NANO_CLOSE
|
||||
/mob/living/silicon/pai/default_can_use_topic(var/src_object)
|
||||
if((src_object == src || src_object == radio) && !stat)
|
||||
return NANO_INTERACTIVE
|
||||
else
|
||||
return ..()
|
||||
|
||||
/mob/living/default_can_use_topic(var/src_object)
|
||||
. = shared_nano_interaction(src_object)
|
||||
|
||||
+24
-19
@@ -1,10 +1,12 @@
|
||||
/**********************************************************
|
||||
NANO UI FRAMEWORK
|
||||
/**
|
||||
* NanoUI
|
||||
*
|
||||
* /tg/station user interface library
|
||||
* thanks to baystation12
|
||||
*
|
||||
* modified by neersighted
|
||||
**/
|
||||
|
||||
nanoui class (or whatever Byond calls classes)
|
||||
|
||||
nanoui is used to open and update nano browser uis
|
||||
**********************************************************/
|
||||
|
||||
/datum/nanoui
|
||||
// the user who opened this ui
|
||||
@@ -46,9 +48,9 @@ nanoui is used to open and update nano browser uis
|
||||
// the map z level to display
|
||||
var/map_z_level = 1
|
||||
// initial data, containing the full data structure, must be sent to the ui (the data structure cannot be extended later on)
|
||||
var/list/initial_data[0]
|
||||
var/list/initial_data
|
||||
// set to 1 to update the ui automatically every master_controller tick
|
||||
var/is_auto_updating = 0
|
||||
var/auto_update = 0
|
||||
// the current status/visibility of the ui
|
||||
var/status = NANO_INTERACTIVE
|
||||
|
||||
@@ -156,7 +158,7 @@ nanoui is used to open and update nano browser uis
|
||||
* @return nothing
|
||||
*/
|
||||
/datum/nanoui/proc/set_auto_update(nstate = 1)
|
||||
is_auto_updating = nstate
|
||||
auto_update = nstate
|
||||
|
||||
/**
|
||||
* Set the initial data for the ui. This is vital as the data structure set here cannot be changed when pushing new updates.
|
||||
@@ -194,11 +196,10 @@ nanoui is used to open and update nano browser uis
|
||||
*
|
||||
* @return /list data to send to the ui
|
||||
*/
|
||||
/datum/nanoui/proc/get_send_data(var/list/data)
|
||||
var/list/config_data = get_config_data()
|
||||
|
||||
var/list/send_data = list("config" = config_data)
|
||||
/datum/nanoui/proc/get_send_data(list/data)
|
||||
var/list/send_data = list()
|
||||
|
||||
send_data["config"] = get_config_data()
|
||||
if (!isnull(data))
|
||||
send_data["data"] = data
|
||||
|
||||
@@ -329,7 +330,6 @@ nanoui is used to open and update nano browser uis
|
||||
* @return string HTML for the UI
|
||||
*/
|
||||
/datum/nanoui/proc/get_html()
|
||||
|
||||
// before the UI opens, add the layout files based on the layout key
|
||||
add_stylesheet("layout_[layout_key].css")
|
||||
add_template("layout", "layout_[layout_key].tmpl")
|
||||
@@ -337,10 +337,10 @@ nanoui is used to open and update nano browser uis
|
||||
var/head_content = ""
|
||||
|
||||
for (var/filename in scripts)
|
||||
head_content += "<script type='text/javascript' src='[filename]'></script> "
|
||||
head_content += "<script type='text/javascript' src='[filename]' /></script>"
|
||||
|
||||
for (var/filename in stylesheets)
|
||||
head_content += "<link rel='stylesheet' type='text/css' href='[filename]'> "
|
||||
head_content += "<link rel='stylesheet' type='text/css' href='[filename]' /> "
|
||||
|
||||
var/template_data_json = "{}" // An empty JSON object
|
||||
if (templates.len > 0)
|
||||
@@ -388,10 +388,15 @@ nanoui is used to open and update nano browser uis
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
/datum/nanoui/proc/open()
|
||||
/datum/nanoui/proc/open(list/data = null)
|
||||
if(!user.client)
|
||||
return
|
||||
|
||||
if (!initial_data)
|
||||
if (!data)
|
||||
data = src_object.get_ui_data()
|
||||
set_initial_data(data)
|
||||
|
||||
var/window_size = ""
|
||||
if (width && height)
|
||||
window_size = "size=[width]x[height];"
|
||||
@@ -423,7 +428,7 @@ nanoui is used to open and update nano browser uis
|
||||
* @return nothing
|
||||
*/
|
||||
/datum/nanoui/proc/close()
|
||||
is_auto_updating = 0
|
||||
auto_update = 0
|
||||
SSnano.ui_closed(src)
|
||||
user << browse(null, "window=[window_id]")
|
||||
for(var/datum/nanoui/child in children)
|
||||
@@ -495,7 +500,7 @@ nanoui is used to open and update nano browser uis
|
||||
close()
|
||||
return
|
||||
|
||||
if (status && (update || is_auto_updating))
|
||||
if (status && (update || auto_update))
|
||||
update() // Update the UI (update_status() is called whenever a UI is updated)
|
||||
else
|
||||
update_status(1) // Not updating UI, so lets check here if status has changed
|
||||
|
||||
@@ -1,27 +1,3 @@
|
||||
/**
|
||||
* 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(mob/user, atom/movable/src_object, ui_key, datum/nanoui/ui, template, title, width, height, auto_update, var/atom/ref = null, var/datum/nanoui/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
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, ref, master_ui, state)
|
||||
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
|
||||
*
|
||||
@@ -34,21 +10,22 @@
|
||||
*
|
||||
* @return /nanoui Returns the found ui, for null if none exists
|
||||
*/
|
||||
/datum/subsystem/nano/proc/try_update_ui(var/mob/user, src_object, ui_key, var/datum/nanoui/ui, data, var/force_open = 0)
|
||||
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
|
||||
if (!force_open)
|
||||
ui.push_data(data)
|
||||
return ui
|
||||
else
|
||||
ui.reinitialise(new_initial_data=data)
|
||||
return ui
|
||||
/datum/subsystem/nano/proc/try_update_ui(mob/user, atom/movable/src_object, ui_key, datum/nanoui/ui, \
|
||||
list/data = null, force_open = 0)
|
||||
if (!data)
|
||||
data = src_object.get_ui_data(user)
|
||||
|
||||
return null
|
||||
if (isnull(ui)) // No NanoUI was passed, so look for one.
|
||||
ui = get_open_ui(user, src_object, ui_key)
|
||||
|
||||
if (!isnull(ui))
|
||||
if (!force_open) // UI is already open; update it.
|
||||
ui.push_data(data)
|
||||
else // Re-open it anyways.
|
||||
ui.reinitialise(new_initial_data=data)
|
||||
return ui // We found the UI, return it.
|
||||
|
||||
return null // We couldn't find a UI.
|
||||
|
||||
/**
|
||||
* Get an open /nanoui ui for the current user, src_object and ui_key
|
||||
@@ -278,6 +255,7 @@
|
||||
* @param resources /list The resources to be sent.
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
*/
|
||||
|
||||
/datum/subsystem/nano/proc/send_resources(client, var/list/resources = resource_files)
|
||||
getFilesSlow(client, resources)
|
||||
getFilesSlow(client, resources)
|
||||
+29
-44
@@ -586,11 +586,8 @@
|
||||
// attack with hand - remove cell (if cover open) or interact with the APC
|
||||
|
||||
/obj/machinery/power/apc/attack_hand(mob/user)
|
||||
// if (!can_use(user)) This already gets called in interact() and in topic()
|
||||
// return
|
||||
if(!user)
|
||||
return
|
||||
src.add_fingerprint(user)
|
||||
if (!user) return
|
||||
add_fingerprint(user)
|
||||
if(usr == user && opened && (!issilicon(user)))
|
||||
if(cell)
|
||||
user.put_in_hands(cell)
|
||||
@@ -604,14 +601,10 @@
|
||||
charging = 0
|
||||
src.update_icon()
|
||||
return
|
||||
if(stat & (BROKEN|MAINT))
|
||||
return
|
||||
// do APC interaction
|
||||
src.interact(user)
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/apc/attack_alien(mob/living/carbon/alien/humanoid/user)
|
||||
if(!user)
|
||||
return
|
||||
if(!user) return
|
||||
user.do_attack_animation(src)
|
||||
user.visible_message("<span class='danger'>[user.name] slashes at the [src.name]!</span>", "<span class='notice'>You slash at the [src.name]!</span>")
|
||||
playsound(src.loc, 'sound/weapons/slash.ogg', 100, 1)
|
||||
@@ -633,35 +626,15 @@
|
||||
|
||||
|
||||
/obj/machinery/power/apc/interact(mob/user)
|
||||
if(!user)
|
||||
return
|
||||
if(stat & (BROKEN|MAINT)) return
|
||||
if(wiresexposed && !istype(user, /mob/living/silicon/ai)) wires.Interact(user)
|
||||
else ui_interact(user)
|
||||
|
||||
if(wiresexposed /*&& (!istype(user, /mob/living/silicon))*/) //Commented out the typecheck to allow engiborgs to repair damaged apcs.
|
||||
wires.Interact(user)
|
||||
|
||||
return ui_interact(user)
|
||||
|
||||
|
||||
/obj/machinery/power/apc/proc/get_malf_status(mob/user)
|
||||
if (ticker && ticker.mode && (user.mind in ticker.mode.malf_ai) && istype(user, /mob/living/silicon/ai))
|
||||
if (src.malfai == (user:parent ? user:parent : user))
|
||||
if (src.occupier == user)
|
||||
return 3 // 3 = User is shunted in this APC
|
||||
else if (istype(user.loc, /obj/machinery/power/apc))
|
||||
return 4 // 4 = User is shunted in another APC
|
||||
else
|
||||
return 2 // 2 = APC hacked by user, and user is in its core.
|
||||
else
|
||||
return 1 // 1 = APC not hacked.
|
||||
else
|
||||
return 0 // 0 = User is not a Malf AI
|
||||
|
||||
|
||||
/obj/machinery/power/apc/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null)
|
||||
if(!user)
|
||||
return
|
||||
|
||||
ui = SSnano.push_open_or_new_ui(user, src, ui_key, ui, "apc.tmpl", "[area.name] - APC", 540, user.has_unlimited_silicon_privilege ? 550 : 470, 1)
|
||||
/obj/machinery/power/apc/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, force_open = 1)
|
||||
SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "apc.tmpl", name, 515, 550)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/power/apc/get_ui_data(mob/user)
|
||||
var/list/data = list(
|
||||
@@ -711,6 +684,21 @@
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
/obj/machinery/power/apc/proc/get_malf_status(mob/user)
|
||||
if (ticker && ticker.mode && (user.mind in ticker.mode.malf_ai) && istype(user, /mob/living/silicon/ai))
|
||||
if (src.malfai == (user:parent ? user:parent : user))
|
||||
if (src.occupier == user)
|
||||
return 3 // 3 = User is shunted in this APC
|
||||
else if (istype(user.loc, /obj/machinery/power/apc))
|
||||
return 4 // 4 = User is shunted in another APC
|
||||
else
|
||||
return 2 // 2 = APC hacked by user, and user is in its core.
|
||||
else
|
||||
return 1 // 1 = APC not hacked.
|
||||
else
|
||||
return 0 // 0 = User is not a Malf AI
|
||||
|
||||
/obj/machinery/power/apc/proc/report()
|
||||
return "[area.name] : [equipment]/[lighting]/[environ] ([lastused_equip+lastused_light+lastused_environ]) : [cell? cell.percent() : "N/C"] ([charging])"
|
||||
|
||||
@@ -778,11 +766,8 @@
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/apc/Topic(href, href_list)
|
||||
if(..())
|
||||
return 0
|
||||
|
||||
if(!can_use(usr, 1))
|
||||
return 0
|
||||
if(..()) return
|
||||
if(!can_use(usr, 1)) return
|
||||
|
||||
if (href_list["lock"])
|
||||
coverlocked = !coverlocked
|
||||
|
||||
+11
-19
@@ -313,24 +313,20 @@
|
||||
if(terminal && terminal.powernet)
|
||||
terminal.powernet.load += amount
|
||||
|
||||
|
||||
/obj/machinery/power/smes/attack_ai(mob/user)
|
||||
if(stat & BROKEN) return
|
||||
ui_interact(user)
|
||||
|
||||
|
||||
/obj/machinery/power/smes/attack_hand(mob/user)
|
||||
if (!user) return
|
||||
add_fingerprint(user)
|
||||
if(stat & BROKEN) return
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/smes/interact(mob/user)
|
||||
if (stat & BROKEN) return
|
||||
ui_interact(user)
|
||||
|
||||
|
||||
/obj/machinery/power/smes/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null)
|
||||
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/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
|
||||
SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "smes.tmpl", name, 350, 560)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/power/smes/get_ui_data()
|
||||
var/list/data = list(
|
||||
@@ -353,11 +349,7 @@
|
||||
return data
|
||||
|
||||
/obj/machinery/power/smes/Topic(href, href_list)
|
||||
// world << "[href] ; [href_list[href]]"
|
||||
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(..()) return
|
||||
|
||||
else if( href_list["input_attempt"] )
|
||||
input_attempt = text2num(href_list["input_attempt"])
|
||||
|
||||
@@ -357,11 +357,19 @@
|
||||
overlays += image('icons/obj/computer.dmi', "solcon-o", FLY_LAYER, angle2dir(cdir))
|
||||
|
||||
/obj/machinery/power/solar_control/attack_hand(mob/user)
|
||||
if(!..())
|
||||
ui_interact(user)
|
||||
if (..() || !user) return
|
||||
add_fingerprint(user)
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/solar_control/ui_interact(mob/user, ui_key = "main", 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/interact(mob/user)
|
||||
if (stat & BROKEN) return
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/solar_control/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
|
||||
SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "solar_control.tmpl", name, 490, 420)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/power/solar_control/get_ui_data()
|
||||
var/data = list()
|
||||
|
||||
@@ -61,21 +61,15 @@
|
||||
if(prob(50))
|
||||
qdel(src)
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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")
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
/obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null)
|
||||
if(stat & (BROKEN)) return
|
||||
if(user.incapacitated()) return
|
||||
/obj/machinery/chem_dispenser/interact(mob/user)
|
||||
if(stat & BROKEN) return
|
||||
ui_interact(user)
|
||||
|
||||
ui = SSnano.push_open_or_new_ui(user, src, ui_key, ui, "chem_dispenser.tmpl", "[uiname]", 490, 710, 0)
|
||||
/obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
|
||||
SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "chem_dispenser.tmpl", uiname, 490, 710)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/chem_dispenser/get_ui_data()
|
||||
var/data = list()
|
||||
@@ -108,8 +102,7 @@
|
||||
return data
|
||||
|
||||
/obj/machinery/chem_dispenser/Topic(href, href_list)
|
||||
if(stat & (BROKEN))
|
||||
return 0 // don't update UIs attached to this object
|
||||
if(stat & (BROKEN)) return
|
||||
|
||||
if(href_list["amount"])
|
||||
amount = round(text2num(href_list["amount"]), 5) // round to nearest 5
|
||||
@@ -135,7 +128,6 @@
|
||||
overlays.Cut()
|
||||
|
||||
add_fingerprint(usr)
|
||||
return 1 // update UIs attached to this object
|
||||
|
||||
/obj/machinery/chem_dispenser/attackby(obj/item/weapon/reagent_containers/glass/B, mob/user, params)
|
||||
if(isrobot(user))
|
||||
@@ -160,17 +152,9 @@
|
||||
icon_beaker.pixel_x = rand(-10,5)
|
||||
overlays += icon_beaker
|
||||
|
||||
/obj/machinery/chem_dispenser/attack_ai(mob/user)
|
||||
return src.attack_hand(user)
|
||||
|
||||
/obj/machinery/chem_dispenser/attack_paw(mob/user)
|
||||
return src.attack_hand(user)
|
||||
|
||||
/obj/machinery/chem_dispenser/attack_hand(mob/user)
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
|
||||
ui_interact(user)
|
||||
if (!user) return
|
||||
interact(user)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1476,15 +1460,14 @@
|
||||
return 1
|
||||
|
||||
/obj/machinery/chem_heater/attack_hand(mob/user)
|
||||
ui_interact(user)
|
||||
if (!user) return
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/chem_heater/Topic(href, href_list)
|
||||
if(..())
|
||||
return 0
|
||||
if(..()) return
|
||||
|
||||
if(href_list["toggle_on"])
|
||||
on = !on
|
||||
. = 1
|
||||
|
||||
if(href_list["adjust_temperature"])
|
||||
var/val = href_list["adjust_temperature"]
|
||||
@@ -1493,17 +1476,22 @@
|
||||
else if(val == "input")
|
||||
desired_temp = Clamp(input("Please input the target temperature", name) as num, 0, 1000)
|
||||
else
|
||||
return 0
|
||||
. = 1
|
||||
return
|
||||
|
||||
if(href_list["eject_beaker"])
|
||||
eject_beaker()
|
||||
. = 0 //updated in eject_beaker() already
|
||||
|
||||
/obj/machinery/chem_heater/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null)
|
||||
if(user.stat || user.restrained()) return
|
||||
add_fingerprint(usr)
|
||||
|
||||
ui = SSnano.push_open_or_new_ui(user, src, ui_key, ui, "chem_heater.tmpl", "ChemHeater", 350, 270, 0)
|
||||
/obj/machinery/chem_heater/interact(mob/user)
|
||||
if(stat & BROKEN) return
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/chem_heater/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
|
||||
SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "chem_heater.tmpl", name, 350, 270)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/chem_heater/get_ui_data()
|
||||
var/data = list()
|
||||
|
||||
Reference in New Issue
Block a user