From 051ef3cdd366c030fc4154d1a86debde9755eb10 Mon Sep 17 00:00:00 2001 From: NullSnapshot Date: Tue, 12 Jul 2016 22:03:44 -0700 Subject: [PATCH] tgui for airlock electronics. --- .../machinery/doors/airlock_electronics.dm | 134 ++++++++---------- tgui/src/interfaces/airlock_electronics.ract | 7 + 2 files changed, 70 insertions(+), 71 deletions(-) diff --git a/code/game/machinery/doors/airlock_electronics.dm b/code/game/machinery/doors/airlock_electronics.dm index 3ae0891b891d8..3b5dce639e276 100644 --- a/code/game/machinery/doors/airlock_electronics.dm +++ b/code/game/machinery/doors/airlock_electronics.dm @@ -11,100 +11,92 @@ req_access = list(access_engine) var/secure = 0 //if set, then wires will be randomized and bolts will drop if the door is broken - var/list/conf_access = null + var/list/conf_access = list() var/one_access = 0 //if set to 1, door would receive req_one_access instead of req_access var/last_configurator = null var/locked = 1 - attack_self(mob/user as mob) - if (!ishuman(user) && !istype(user,/mob/living/silicon/robot)) - return ..(user) - var/t1 = text("Access control
\n") - if (last_configurator) - t1 += "Operator: [last_configurator]
" +/obj/item/weapon/airlock_electronics/attack_self(mob/user as mob) + if (!ishuman(user) && !istype(user,/mob/living/silicon/robot)) + return ..(user) - if (locked) - t1 += "Swipe ID
" - else - t1 += "Block
" + tg_ui_interact(user) - t1 += "Access requirement is set to " - t1 += one_access ? "ONE
" : "ALL
" - t1 += conf_access == null ? "All
" : "All
" - t1 += "
" +//tgui interact code generously lifted from tgstation. +/obj/item/weapon/airlock_electronics/tg_ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \ + datum/tgui/master_ui = null, datum/ui_state/state = hands_state) - var/list/accesses = get_all_station_access() - for (var/acc in accesses) - var/aname = get_access_desc(acc) + tgui_process.try_update_ui(user, src, ui_key, ui, force_open) + if(!ui) + ui = new(user, src, ui_key, "airlock_electronics", src.name, 1000, 500, master_ui, state) + ui.open() - if (!conf_access || !conf_access.len || !(acc in conf_access)) - t1 += "[aname]
" - else if(one_access) - t1 += "[aname]
" - else - t1 += "[aname]
" - - t1 += text("

Close

\n", src) +/obj/item/weapon/airlock_electronics/ui_data(mob/user) + var/list/data = list() + var/list/regions = list() - user << browse(t1, "window=airlock_electronics") - onclose(user, "airlock") + for(var/i in ACCESS_REGION_SECURITY to ACCESS_REGION_SUPPLY) //code/game/jobs/_access_defs.dm + var/list/region = list() + var/list/accesses = list() + for(var/j in get_region_accesses(i)) + var/list/access = list() + access["name"] = get_access_desc(j) + access["id"] = j + access["req"] = (j in src.conf_access) + accesses[++accesses.len] = access + region["name"] = get_region_accesses_name(i) + region["accesses"] = accesses + regions[++regions.len] = region + data["regions"] = regions + data["oneAccess"] = one_access + data["locked"] = locked - Topic(href, href_list) - ..() - if (usr.stat || usr.restrained() || (!ishuman(usr) && !istype(usr,/mob/living/silicon))) - return - if (href_list["close"]) - usr << browse(null, "window=airlock") - return + return data - if (href_list["login"]) +/obj/item/weapon/airlock_electronics/ui_act(action, params) + if(..()) + return TRUE + switch(action) + if("clear") + conf_access = list() + one_access = 0 + return TRUE + if("one_access") + one_access = !one_access + return TRUE + if("set") + var/access = text2num(params["access"]) + if (!(access in conf_access)) + conf_access += access + else + conf_access -= access + return TRUE + if("unlock") if(istype(usr,/mob/living/silicon)) - src.locked = 0 - src.last_configurator = usr.name + locked = 0 + last_configurator = usr.name + return TRUE else var/obj/item/I = usr.get_active_hand() if (istype(I, /obj/item/device/pda)) var/obj/item/device/pda/pda = I I = pda.id + if(!istype(I, /obj/item/weapon/card/id)) + usr << "[\src] flashes a yellow LED near the ID scanner. Did you remember to scan your ID or PDA?" + return TRUE if (I && src.check_access(I)) - src.locked = 0 - src.last_configurator = I:registered_name - - if (locked) - return - - if (href_list["logout"]) - locked = 1 - - if (href_list["one_access"]) - one_access = !one_access - - if (href_list["access"]) - toggle_access(href_list["access"]) - - attack_self(usr) - - proc - toggle_access(var/acc) - if (acc == "all") - conf_access = null - else - var/req = text2num(acc) - - if (conf_access == null) - conf_access = list() - - if (!(req in conf_access)) - conf_access += req + locked = 0 + last_configurator = I:registered_name else - conf_access -= req - if (!conf_access.len) - conf_access = null - + usr << "[\src] flashes a red LED near the ID scanner, indicating your access has been denied." + return TRUE + if("lock") + locked = 1 + . = TRUE /obj/item/weapon/airlock_electronics/secure name = "secure airlock electronics" diff --git a/tgui/src/interfaces/airlock_electronics.ract b/tgui/src/interfaces/airlock_electronics.ract index f41cf6ad13fe5..2642d1e1fc4e1 100644 --- a/tgui/src/interfaces/airlock_electronics.ract +++ b/tgui/src/interfaces/airlock_electronics.ract @@ -1,7 +1,13 @@ + {{#if data.locked}} + + Swipe ID to continue: Unlock + + {{else}} {{data.oneAccess ? "One" : "All"}} Required Clear + Lock
@@ -20,6 +26,7 @@ {{/each}}
+{{/if}}