mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-19 11:05:03 +01:00
[TGUI] Keycard Swiper
This commit is contained in:
@@ -4,17 +4,17 @@
|
||||
icon = 'icons/obj/monitors.dmi'
|
||||
icon_state = "auth_off"
|
||||
|
||||
var/active = 0 //This gets set to 1 on all devices except the one where the initial request was made.
|
||||
var/event = ""
|
||||
var/screen = 1
|
||||
var/active = FALSE // This gets set to TRUE on all devices except the one where the initial request was made.
|
||||
var/event
|
||||
var/swiping = FALSE // on swiping screen?
|
||||
var/list/ert_chosen = list()
|
||||
var/confirmed = 0 //This variable is set by the device that confirms the request.
|
||||
var/confirm_delay = 20 //(2 seconds)
|
||||
var/busy = 0 //Busy when waiting for authentication or an event request has been sent from this device.
|
||||
var/confirmed = FALSE // This variable is set by the device that confirms the request.
|
||||
var/confirm_delay = 20 // (2 seconds)
|
||||
var/busy = FALSE // Busy when waiting for authentication or an event request has been sent from this device.
|
||||
var/obj/machinery/keycard_auth/event_source
|
||||
var/mob/event_triggered_by
|
||||
var/mob/event_confirmed_by
|
||||
var/ert_reason = "Reason for ERT"
|
||||
var/ert_reason
|
||||
|
||||
anchored = 1
|
||||
use_power = IDLE_POWER_USE
|
||||
@@ -35,16 +35,19 @@
|
||||
return
|
||||
if(istype(W, /obj/item/card/id) || istype(W, /obj/item/pda))
|
||||
if(check_access(W))
|
||||
if(active == 1)
|
||||
if(active)
|
||||
//This is not the device that made the initial request. It is the device confirming the request.
|
||||
if(event_source)
|
||||
event_source.confirmed = 1
|
||||
event_source.confirmed = TRUE
|
||||
event_source.event_confirmed_by = usr
|
||||
else if(screen == 2)
|
||||
if(event == "Emergency Response Team" && ert_reason == "Reason for ERT")
|
||||
to_chat(user, "<span class='notice'>Supply a reason for calling the ERT first!</span>")
|
||||
SStgui.update_uis(event_source)
|
||||
SStgui.update_uis(src)
|
||||
else if(swiping)
|
||||
if(event == "Emergency Response Team" && !ert_reason)
|
||||
to_chat(user, "<span class='warning'>Supply a reason for calling the ERT first!</span>")
|
||||
return
|
||||
event_triggered_by = usr
|
||||
SStgui.update_uis(src)
|
||||
broadcast_request() //This is the device making the initial event request. It needs to broadcast to other devices
|
||||
else
|
||||
to_chat(user, "<span class='warning'>Access denied.</span>")
|
||||
@@ -59,57 +62,55 @@
|
||||
stat |= NOPOWER
|
||||
|
||||
/obj/machinery/keycard_auth/attack_ghost(mob/user)
|
||||
ui_interact(user)
|
||||
tgui_interact(user)
|
||||
|
||||
/obj/machinery/keycard_auth/attack_hand(mob/user as mob)
|
||||
/obj/machinery/keycard_auth/attack_hand(mob/user)
|
||||
if(..())
|
||||
return 1
|
||||
ui_interact(user)
|
||||
tgui_interact(user)
|
||||
|
||||
/obj/machinery/keycard_auth/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(busy)
|
||||
to_chat(user, "This device is busy.")
|
||||
return
|
||||
|
||||
user.set_machine(src)
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
/obj/machinery/keycard_auth/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = TRUE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "keycard_auth.tmpl", "Keycard Authentication Device UI", 540, 320)
|
||||
ui = new(user, src, ui_key, "KeycardAuth", name, 540, 320, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/keycard_auth/ui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
|
||||
var/data[0]
|
||||
data["screen"] = screen
|
||||
data["event"] = event
|
||||
|
||||
/obj/machinery/keycard_auth/tgui_data()
|
||||
var/list/data = list()
|
||||
data["redAvailable"] = GLOB.security_level == SEC_LEVEL_RED ? FALSE : TRUE
|
||||
data["swiping"] = swiping
|
||||
data["busy"] = busy
|
||||
data["event"] = active && event_source && event_source.event ? event_source.event : event
|
||||
data["ertreason"] = ert_reason
|
||||
data["isRemote"] = active ? TRUE : FALSE
|
||||
data["hasSwiped"] = event_triggered_by ? TRUE : FALSE
|
||||
data["hasConfirm"] = event_confirmed_by || (active && event_source && event_source.event_confirmed_by) ? TRUE : FALSE
|
||||
return data
|
||||
|
||||
/obj/machinery/keycard_auth/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
/obj/machinery/keycard_auth/tgui_act(action, params)
|
||||
if(..() || !allowed(usr))
|
||||
return
|
||||
if(busy)
|
||||
to_chat(usr, "This device is busy.")
|
||||
return
|
||||
. = TRUE
|
||||
switch(action)
|
||||
if("ert")
|
||||
ert_reason = stripped_input(usr, "Reason for ERT Call:", "", "")
|
||||
if("reset")
|
||||
reset()
|
||||
if("triggerevent")
|
||||
event = params["triggerevent"]
|
||||
swiping = TRUE
|
||||
|
||||
if(href_list["triggerevent"])
|
||||
event = href_list["triggerevent"]
|
||||
screen = 2
|
||||
if(href_list["reset"])
|
||||
reset()
|
||||
if(href_list["ert"])
|
||||
ert_reason = stripped_input(usr, "Reason for ERT Call:", "", "")
|
||||
|
||||
SSnanoui.update_uis(src)
|
||||
add_fingerprint(usr)
|
||||
return
|
||||
|
||||
/obj/machinery/keycard_auth/proc/reset()
|
||||
active = 0
|
||||
event = ""
|
||||
screen = 1
|
||||
confirmed = 0
|
||||
active = FALSE
|
||||
event = null
|
||||
swiping = FALSE
|
||||
confirmed = FALSE
|
||||
event_source = null
|
||||
icon_state = "auth_off"
|
||||
event_triggered_by = null
|
||||
@@ -125,7 +126,7 @@
|
||||
|
||||
sleep(confirm_delay)
|
||||
if(confirmed)
|
||||
confirmed = 0
|
||||
confirmed = FALSE
|
||||
trigger_event(event)
|
||||
log_game("[key_name(event_triggered_by)] triggered and [key_name(event_confirmed_by)] confirmed event [event]")
|
||||
message_admins("[key_name_admin(event_triggered_by)] triggered and [key_name_admin(event_confirmed_by)] confirmed event [event]", 1)
|
||||
@@ -135,16 +136,17 @@
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
return
|
||||
event_source = source
|
||||
busy = 1
|
||||
active = 1
|
||||
busy = TRUE
|
||||
active = TRUE
|
||||
SStgui.update_uis(src)
|
||||
icon_state = "auth_on"
|
||||
|
||||
sleep(confirm_delay)
|
||||
|
||||
event_source = null
|
||||
icon_state = "auth_off"
|
||||
active = 0
|
||||
busy = 0
|
||||
active = FALSE
|
||||
busy = FALSE
|
||||
|
||||
/obj/machinery/keycard_auth/proc/trigger_event()
|
||||
switch(event)
|
||||
@@ -178,7 +180,7 @@
|
||||
if(fullmin_count)
|
||||
GLOB.ert_request_answered = TRUE
|
||||
ERT_Announce(ert_reason , event_triggered_by, 0)
|
||||
ert_reason = "Reason for ERT"
|
||||
ert_reason = null
|
||||
feedback_inc("alert_keycard_auth_ert",1)
|
||||
spawn(3000)
|
||||
if(!GLOB.ert_request_answered)
|
||||
|
||||
Reference in New Issue
Block a user