Files
Aurora.3/code/modules/overmap/ships/computers/helm.dm
Karolis 8b785b3815 New record consoles and removal of old datacore, adds SSrecords (#4878)
This PR is depending on #4868 for it's ui framework. This PR mostly makes new SSrecords subsystem responsible for storing records. This should replace old datacore.

Make new SSrecords.
Make things use SSrecords and whole code compile
Made VueUi button <vui-button> to push parameters as JSON, preserving client side data stricture.

    Add new records console and admin record management.

I am mostly looking for feedback regarding SSrecords and it's data storage mechanism criticism (It's using lists for storage)
2019-07-27 12:24:16 +03:00

177 lines
4.5 KiB
Plaintext

/obj/machinery/computer/helm
name = "helm control console"
icon_screen = "id"
var/state = "status"
var/obj/effect/map/ship/linked //connected overmap object
var/autopilot = 0
var/manual_control = 0
var/list/known_sectors = list()
var/dx //desitnation
var/dy //coordinates
/obj/machinery/computer/helm/Initialize()
. = ..()
linked = map_sectors["[z]"]
if (linked)
if(!linked.nav_control)
linked.nav_control = src
testing("Helm console at level [z] found a corresponding overmap object '[linked.name]'.")
else
testing("Helm console at level [z] was unable to find a corresponding overmap object.")
for(var/level in map_sectors)
var/obj/effect/map/sector/S = map_sectors["[level]"]
if (istype(S) && S.always_known)
var/list/R = list()
R["name"] = S.name
R["x"] = S.x
R["y"] = S.y
known_sectors += list(R)
/obj/machinery/computer/helm/machinery_process()
if (autopilot && dx && dy)
var/turf/T = locate(dx,dy,1)
if(linked.loc == T)
if(linked.is_still())
autopilot = 0
else
linked.decelerate()
var/brake_path = linked.get_brake_path()
if(get_dist(linked.loc, T) > brake_path)
linked.accelerate(get_dir(linked.loc, T))
else
linked.decelerate()
return
/obj/machinery/computer/helm/relaymove(var/mob/user, direction)
if(manual_control && linked)
linked.relaymove(user,direction)
return 1
/obj/machinery/computer/helm/check_eye(var/mob/user as mob)
if (!manual_control)
return -1
if (!get_dist(user, src) > 1 || user.blinded || !linked )
return -1
return 0
/obj/machinery/computer/helm/attack_hand(var/mob/user as mob)
if(..())
user.unset_machine()
manual_control = 0
return
if(!isAI(user))
user.set_machine(src)
if(linked)
user.reset_view(linked)
ui_interact(user)
/obj/machinery/computer/helm/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
if(!linked)
return
var/data[0]
data["state"] = state
data["sector"] = linked.current_sector ? linked.current_sector.name : "Deep Space"
data["sector_info"] = linked.current_sector ? linked.current_sector.desc : "Not Available"
data["s_x"] = linked.x
data["s_y"] = linked.y
data["dest"] = dy && dx
data["d_x"] = dx
data["d_y"] = dy
data["speed"] = linked.get_speed()
data["accel"] = round(linked.get_acceleration())
data["heading"] = linked.get_heading() ? dir2angle(linked.get_heading()) : 0
data["autopilot"] = autopilot
data["manual_control"] = manual_control
var/list/locations[0]
for (var/list/R in known_sectors)
var/list/rdata[0]
rdata["name"] = R["name"]
rdata["x"] = R["x"]
rdata["y"] = R["y"]
rdata["reference"] = "\ref[R]"
locations.Add(list(rdata))
data["locations"] = locations
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "helm.tmpl", "[linked.name] Helm Control", 380, 530)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
/obj/machinery/computer/helm/Topic(href, href_list)
if(..())
return 1
if (!linked)
return
if (href_list["add"])
var/list/R = new()
var/sec_name = input("Input naviation entry name", "New navigation entry", "Sector #[known_sectors.len]") as text
if(!sec_name)
sec_name = "Sector #[known_sectors.len]"
R["name"] = sec_name
switch(href_list["add"])
if("current")
R["x"] = linked.x
R["y"] = linked.y
if("new")
var/newx = input("Input new entry x coordinate", "Coordinate input", linked.x) as num
R["x"] = Clamp(newx, 1, world.maxx)
var/newy = input("Input new entry y coordinate", "Coordinate input", linked.y) as num
R["y"] = Clamp(newy, 1, world.maxy)
known_sectors += list(R)
if (href_list["remove"])
var/list/R = locate(href_list["remove"])
known_sectors.Remove(R)
if (href_list["setx"])
var/newx = input("Input new destiniation x coordinate", "Coordinate input", dx) as num|null
if (newx)
dx = Clamp(newx, 1, world.maxx)
if (href_list["sety"])
var/newy = input("Input new destiniation y coordinate", "Coordinate input", dy) as num|null
if (newy)
dy = Clamp(newy, 1, world.maxy)
if (href_list["x"] && href_list["y"])
dx = text2num(href_list["x"])
dy = text2num(href_list["y"])
if (href_list["reset"])
dx = 0
dy = 0
if (href_list["move"])
var/ndir = text2num(href_list["move"])
linked.relaymove(usr, ndir)
if (href_list["brake"])
linked.decelerate()
if (href_list["apilot"])
autopilot = !autopilot
if (href_list["manual"])
manual_control = !manual_control
if (href_list["state"])
state = href_list["state"]
add_fingerprint(usr)
updateUsrDialog()