mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
TGUI Camera Console Part 3: Modular computers support
This commit is contained in:
@@ -163,6 +163,7 @@
|
||||
idle_threads.Add(active_program)
|
||||
active_program.program_state = PROGRAM_STATE_BACKGROUND // Should close any existing UIs
|
||||
SSnanoui.close_uis(active_program.NM ? active_program.NM : active_program)
|
||||
SStgui.close_uis(active_program.TM ? active_program.TM : active_program)
|
||||
active_program = null
|
||||
update_icon()
|
||||
if(istype(user))
|
||||
@@ -202,7 +203,6 @@
|
||||
minimize_program(user)
|
||||
|
||||
if(P.run_program(user))
|
||||
active_program = P
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
|
||||
@@ -5,8 +5,13 @@
|
||||
var/required_access = null // List of required accesses to run/download the program.
|
||||
var/requires_access_to_run = 1 // Whether the program checks for required_access when run.
|
||||
var/requires_access_to_download = 1 // Whether the program checks for required_access when downloading.
|
||||
// NanoModule
|
||||
var/datum/nano_module/NM = null // If the program uses NanoModule, put it here and it will be automagically opened. Otherwise implement ui_interact.
|
||||
var/nanomodule_path = null // Path to nanomodule, make sure to set this if implementing new program.
|
||||
// TGUIModule
|
||||
var/datum/tgui_module/TM = null // If the program uses TGUIModule, put it here and it will be automagically opened. Otherwise implement tgui_interact.
|
||||
var/tguimodule_path = null // Path to tguimodule, make sure to set this if implementing new program.
|
||||
// Etc Program stuff
|
||||
var/program_state = PROGRAM_STATE_KILLED// PROGRAM_STATE_KILLED or PROGRAM_STATE_BACKGROUND or PROGRAM_STATE_ACTIVE - specifies whether this program is running.
|
||||
var/obj/item/modular_computer/computer // Device that runs this program.
|
||||
var/filedesc = "Unknown Program" // User-friendly name of this program.
|
||||
@@ -125,9 +130,14 @@
|
||||
// When implementing new program based device, use this to run the program.
|
||||
/datum/computer_file/program/proc/run_program(var/mob/living/user)
|
||||
if(can_run(user, 1) || !requires_access_to_run)
|
||||
computer.active_program = src
|
||||
if(nanomodule_path)
|
||||
NM = new nanomodule_path(src, new /datum/topic_manager/program(src), src)
|
||||
NM.using_access = user.GetAccess()
|
||||
if(tguimodule_path)
|
||||
TM = new tguimodule_path(src)
|
||||
TM.using_access = user.GetAccess()
|
||||
TM.tgui_interact(user)
|
||||
if(requires_ntnet && network_destination)
|
||||
generate_network_log("Connection opened to [network_destination].")
|
||||
program_state = PROGRAM_STATE_ACTIVE
|
||||
@@ -139,9 +149,11 @@
|
||||
program_state = PROGRAM_STATE_KILLED
|
||||
if(network_destination)
|
||||
generate_network_log("Connection to [network_destination] closed.")
|
||||
if(NM)
|
||||
qdel(NM)
|
||||
NM = null
|
||||
QDEL_NULL(NM)
|
||||
if(TM)
|
||||
SStgui.close_uis(TM)
|
||||
qdel(TM)
|
||||
TM = null
|
||||
return 1
|
||||
|
||||
// This is called every tick when the program is enabled. Ensure you do parent call if you override it. If parent returns 1 continue with UI initialisation.
|
||||
@@ -154,9 +166,11 @@
|
||||
if(istype(NM))
|
||||
NM.ui_interact(user, ui_key, null, force_open)
|
||||
return 0
|
||||
if(istype(TM))
|
||||
TM.tgui_interact(user)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
// CONVENTIONS, READ THIS WHEN CREATING NEW PROGRAM AND OVERRIDING THIS PROC:
|
||||
// Topic calls are automagically forwarded from NanoModule this program contains.
|
||||
// Calls beginning with "PRG_" are reserved for programs handling.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/datum/computer_file/program/camera_monitor/hacked
|
||||
filename = "camcrypt"
|
||||
filedesc = "Camera Decryption Tool"
|
||||
nanomodule_path = /datum/nano_module/camera_monitor/hacked
|
||||
tguimodule_path = /datum/tgui_module/camera/ntos/hacked
|
||||
program_icon_state = "hostile"
|
||||
program_key_state = "security_key"
|
||||
program_menu_icon = "zoomin"
|
||||
@@ -15,25 +15,8 @@
|
||||
if(program_state != PROGRAM_STATE_ACTIVE) // Background programs won't trigger alarms.
|
||||
return
|
||||
|
||||
var/datum/nano_module/camera_monitor/hacked/HNM = NM
|
||||
|
||||
// The program is active and connected to one of the station's networks. Has a very small chance to trigger IDS alarm every tick.
|
||||
if(HNM && HNM.current_network && (HNM.current_network in using_map.station_networks) && prob(0.1))
|
||||
if(prob(0.1))
|
||||
if(ntnet_global.intrusion_detection_enabled)
|
||||
ntnet_global.add_log("IDS WARNING - Unauthorised access detected to camera network [HNM.current_network] by device with NID [computer.network_card.get_network_tag()]")
|
||||
ntnet_global.add_log("IDS WARNING - Unauthorised access detected to camera network by device with NID [computer.network_card.get_network_tag()]")
|
||||
ntnet_global.intrusion_detection_alarm = 1
|
||||
|
||||
|
||||
/datum/nano_module/camera_monitor/hacked
|
||||
name = "Hacked Camera Monitoring Program"
|
||||
//available_to_ai = FALSE
|
||||
|
||||
/datum/nano_module/camera_monitor/hacked/can_access_network(var/mob/user, var/network_access)
|
||||
return 1
|
||||
|
||||
// The hacked variant has access to all commonly used networks.
|
||||
/datum/nano_module/camera_monitor/hacked/modify_networks_list(var/list/networks)
|
||||
networks.Add(list(list("tag" = NETWORK_MERCENARY, "has_access" = 1)))
|
||||
networks.Add(list(list("tag" = NETWORK_ERT, "has_access" = 1)))
|
||||
networks.Add(list(list("tag" = NETWORK_CRESCENT, "has_access" = 1)))
|
||||
return networks
|
||||
@@ -30,7 +30,7 @@
|
||||
/datum/computer_file/program/camera_monitor
|
||||
filename = "cammon"
|
||||
filedesc = "Camera Monitoring"
|
||||
nanomodule_path = /datum/nano_module/camera_monitor
|
||||
tguimodule_path = /datum/tgui_module/camera/ntos
|
||||
program_icon_state = "cameras"
|
||||
program_key_state = "generic_key"
|
||||
program_menu_icon = "search"
|
||||
@@ -39,163 +39,11 @@
|
||||
available_on_ntnet = 1
|
||||
requires_ntnet = 1
|
||||
|
||||
/datum/nano_module/camera_monitor
|
||||
name = "Camera Monitoring program"
|
||||
var/obj/machinery/camera/current_camera = null
|
||||
var/current_network = null
|
||||
|
||||
/datum/nano_module/camera_monitor/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, state = default_state)
|
||||
var/list/data = host.initial_data()
|
||||
|
||||
data["current_camera"] = current_camera ? current_camera.nano_structure() : null
|
||||
data["current_network"] = current_network
|
||||
|
||||
var/list/all_networks[0]
|
||||
for(var/network in using_map.station_networks)
|
||||
if(can_access_network(user, get_camera_access(network), 1))
|
||||
all_networks.Add(list(list(
|
||||
"tag" = network,
|
||||
"has_access" = 1
|
||||
)))
|
||||
for(var/network in using_map.secondary_networks)
|
||||
if(can_access_network(user, get_camera_access(network), 0))
|
||||
all_networks.Add(list(list(
|
||||
"tag" = network,
|
||||
"has_access" = 1
|
||||
)))
|
||||
|
||||
all_networks = modify_networks_list(all_networks)
|
||||
|
||||
data["networks"] = all_networks
|
||||
|
||||
// var/list/map_levels = using_map.get_map_levels(get_z(nano_host()), TRUE, om_range = DEFAULT_OVERMAP_RANGE)
|
||||
|
||||
// if(current_network) // TODO: Fix
|
||||
// data["cameras"] = camera_repository.cameras_in_network(current_network, map_levels)
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "mod_sec_camera.tmpl", "Camera Monitoring", 900, 800)
|
||||
// ui.auto_update_layout = 1 // Disabled as with suit sensors monitor - breaks the UI map. Re-enable once it's fixed somehow.
|
||||
|
||||
ui.add_template("mapContent", "sec_camera_map_content.tmpl")
|
||||
ui.add_template("mapHeader", "mod_sec_camera_map_header.tmpl")
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
|
||||
// Intended to be overriden by subtypes to manually add non-station networks to the list.
|
||||
/datum/nano_module/camera_monitor/proc/modify_networks_list(var/list/networks)
|
||||
return networks
|
||||
|
||||
/datum/nano_module/camera_monitor/proc/can_access_network(var/mob/user, var/network_access, var/station_network = 0)
|
||||
// No access passed, or 0 which is considered no access requirement. Allow it.
|
||||
if(!network_access)
|
||||
return 1
|
||||
|
||||
if(station_network)
|
||||
return check_access(user, network_access) || check_access(user, access_security) || check_access(user, access_heads)
|
||||
else
|
||||
return check_access(user, network_access)
|
||||
|
||||
/datum/nano_module/camera_monitor/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if(href_list["switch_camera"])
|
||||
var/obj/machinery/camera/C = locate(href_list["switch_camera"]) in cameranet.cameras
|
||||
if(!C)
|
||||
return
|
||||
if(!(current_network in C.network))
|
||||
return
|
||||
|
||||
switch_to_camera(usr, C)
|
||||
return 1
|
||||
|
||||
else if(href_list["switch_network"])
|
||||
// Either security access, or access to the specific camera network's department is required in order to access the network.
|
||||
if(can_access_network(usr, get_camera_access(href_list["switch_network"]), (href_list["switch_network"] in using_map.station_networks)))
|
||||
current_network = href_list["switch_network"]
|
||||
else
|
||||
to_chat(usr, "\The [nano_host()] shows an \"Network Access Denied\" error message.")
|
||||
return 1
|
||||
|
||||
else if(href_list["reset"])
|
||||
reset_current()
|
||||
usr.reset_view(current_camera)
|
||||
return 1
|
||||
|
||||
/datum/nano_module/camera_monitor/proc/switch_to_camera(var/mob/user, var/obj/machinery/camera/C)
|
||||
//don't need to check if the camera works for AI because the AI jumps to the camera location and doesn't actually look through cameras.
|
||||
if(isAI(user))
|
||||
var/mob/living/silicon/ai/A = user
|
||||
// Only allow non-carded AIs to view because the interaction with the eye gets all wonky otherwise.
|
||||
if(!A.is_in_chassis())
|
||||
return 0
|
||||
|
||||
A.eyeobj.setLoc(get_turf(C))
|
||||
A.client.eye = A.eyeobj
|
||||
return 1
|
||||
|
||||
set_current(C)
|
||||
user.machine = nano_host()
|
||||
user.reset_view(C)
|
||||
return 1
|
||||
|
||||
/datum/nano_module/camera_monitor/proc/set_current(var/obj/machinery/camera/C)
|
||||
if(current_camera == C)
|
||||
return
|
||||
|
||||
if(current_camera)
|
||||
reset_current()
|
||||
|
||||
current_camera = C
|
||||
if(current_camera)
|
||||
var/mob/living/L = current_camera.loc
|
||||
if(istype(L))
|
||||
L.tracking_initiated()
|
||||
|
||||
/datum/nano_module/camera_monitor/proc/reset_current()
|
||||
if(current_camera)
|
||||
var/mob/living/L = current_camera.loc
|
||||
if(istype(L))
|
||||
L.tracking_cancelled()
|
||||
current_camera = null
|
||||
|
||||
/datum/nano_module/camera_monitor/check_eye(var/mob/user as mob)
|
||||
if(!current_camera)
|
||||
return 0
|
||||
var/viewflag = current_camera.check_eye(user)
|
||||
if ( viewflag < 0 ) //camera doesn't work
|
||||
reset_current()
|
||||
return viewflag
|
||||
|
||||
|
||||
// ERT Variant of the program
|
||||
/datum/computer_file/program/camera_monitor/ert
|
||||
filename = "ntcammon"
|
||||
filedesc = "Advanced Camera Monitoring"
|
||||
extended_desc = "This program allows remote access to the camera system. Some camera networks may have additional access requirements. This version has an integrated database with additional encrypted keys."
|
||||
size = 14
|
||||
nanomodule_path = /datum/nano_module/camera_monitor/ert
|
||||
tguimodule_path = /datum/tgui_module/camera/ntos/ert
|
||||
available_on_ntnet = 0
|
||||
|
||||
/datum/nano_module/camera_monitor/ert
|
||||
name = "Advanced Camera Monitoring Program"
|
||||
//available_to_ai = FALSE
|
||||
|
||||
// The ERT variant has access to ERT and crescent cams, but still checks for accesses. ERT members should be able to use it.
|
||||
/datum/nano_module/camera_monitor/ert/modify_networks_list(var/list/networks)
|
||||
..()
|
||||
networks.Add(list(list("tag" = NETWORK_ERT, "has_access" = 1)))
|
||||
networks.Add(list(list("tag" = NETWORK_CRESCENT, "has_access" = 1)))
|
||||
return networks
|
||||
|
||||
/datum/nano_module/camera_monitor/apply_visual(mob/M)
|
||||
if(current_camera)
|
||||
current_camera.apply_visual(M)
|
||||
else
|
||||
remove_visual(M)
|
||||
|
||||
/datum/nano_module/camera_monitor/remove_visual(mob/M)
|
||||
if(current_camera)
|
||||
current_camera.remove_visual(M)
|
||||
|
||||
Reference in New Issue
Block a user