mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-24 12:37:50 +01:00
Merge pull request #7478 from GinjaNinja32/cameras
Converts camera console to NanoUI
This commit is contained in:
@@ -23,6 +23,69 @@
|
||||
user.reset_view(current)
|
||||
return 1
|
||||
|
||||
ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
|
||||
if(src.z > 6) return
|
||||
if(stat & (NOPOWER|BROKEN)) return
|
||||
if(user.stat) return
|
||||
|
||||
var/data[0]
|
||||
|
||||
data["current"] = null
|
||||
|
||||
var/list/L = list()
|
||||
for (var/obj/machinery/camera/C in cameranet.cameras)
|
||||
if(can_access_camera(C))
|
||||
L.Add(C)
|
||||
|
||||
camera_sort(L)
|
||||
|
||||
var/cameras[0]
|
||||
for(var/obj/machinery/camera/C in L)
|
||||
var/cam[0]
|
||||
cam["name"] = C.c_tag
|
||||
cam["deact"] = !C.can_use()
|
||||
cam["camera"] = "\ref[C]"
|
||||
cam["x"] = C.x
|
||||
cam["y"] = C.y
|
||||
cam["z"] = C.z
|
||||
|
||||
cameras[++cameras.len] = cam
|
||||
|
||||
if(C == current)
|
||||
data["current"] = cam
|
||||
|
||||
data["cameras"] = cameras
|
||||
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "sec_camera.tmpl", "Camera Console", 900, 800)
|
||||
|
||||
// adding a template with the key "mapContent" enables the map ui functionality
|
||||
ui.add_template("mapContent", "sec_camera_map_content.tmpl")
|
||||
// adding a template with the key "mapHeader" replaces the map header content
|
||||
ui.add_template("mapHeader", "sec_camera_map_header.tmpl")
|
||||
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
Topic(href, href_list)
|
||||
if(href_list["switchTo"])
|
||||
if(src.z>6 || stat&(NOPOWER|BROKEN)) return
|
||||
if(usr.stat || ((get_dist(usr, src) > 1 || !( usr.canmove ) || usr.blinded) && !istype(usr, /mob/living/silicon))) return
|
||||
var/obj/machinery/camera/C = locate(href_list["switchTo"]) in cameranet.cameras
|
||||
if(!C) return
|
||||
|
||||
switch_to_camera(usr, C)
|
||||
return 1
|
||||
else if(href_list["reset"])
|
||||
if(src.z>6 || stat&(NOPOWER|BROKEN)) return
|
||||
if(usr.stat || ((get_dist(usr, src) > 1 || !( usr.canmove ) || usr.blinded) && !istype(usr, /mob/living/silicon))) return
|
||||
current = null
|
||||
usr.check_eye(current)
|
||||
return 1
|
||||
else
|
||||
. = ..()
|
||||
|
||||
attack_hand(var/mob/user as mob)
|
||||
if (src.z > 6)
|
||||
@@ -32,35 +95,7 @@
|
||||
|
||||
if(!isAI(user))
|
||||
user.set_machine(src)
|
||||
|
||||
var/list/L = list()
|
||||
for (var/obj/machinery/camera/C in cameranet.cameras)
|
||||
L.Add(C)
|
||||
|
||||
camera_sort(L)
|
||||
|
||||
var/list/D = list()
|
||||
D["Cancel"] = "Cancel"
|
||||
for(var/obj/machinery/camera/C in L)
|
||||
if(can_access_camera(C))
|
||||
D[text("[][]", C.c_tag, (C.can_use() ? null : " (Deactivated)"))] = C
|
||||
|
||||
var/t = input(user, "Which camera should you change to?") as null|anything in D
|
||||
if(!t)
|
||||
user.unset_machine()
|
||||
return 0
|
||||
|
||||
var/obj/machinery/camera/C = D[t]
|
||||
|
||||
if(t == "Cancel")
|
||||
user.unset_machine()
|
||||
return 0
|
||||
|
||||
if(C)
|
||||
switch_to_camera(user, C)
|
||||
spawn(5)
|
||||
attack_hand(user)
|
||||
return
|
||||
ui_interact(user)
|
||||
|
||||
proc/can_access_camera(var/obj/machinery/camera/C)
|
||||
var/list/shared_networks = src.network & C.network
|
||||
@@ -79,6 +114,7 @@
|
||||
if (!C.can_use() || user.stat || (get_dist(user, src) > 1 || user.machine != src || user.blinded || !( user.canmove ) && !istype(user, /mob/living/silicon)))
|
||||
return 0
|
||||
src.current = C
|
||||
check_eye(user)
|
||||
use_power(50)
|
||||
return 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user