mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Shuttle control panel (rebundled)
This commit is contained in:
committed by
Darlantan
parent
83b3f7aef3
commit
37031c2c9b
@@ -78,10 +78,10 @@ Code is pretty much ripped verbatim from nano modules, but with un-needed stuff
|
||||
return TRUE
|
||||
|
||||
// Just a nice little default interact in case the subtypes don't need any special behavior here
|
||||
/datum/tgui_module/tgui_interact(mob/user, datum/tgui/ui = null)
|
||||
/datum/tgui_module/tgui_interact(mob/user, datum/tgui/ui = null, datum/tgui/parent_ui = null)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, tgui_id, name)
|
||||
ui = new(user, src, tgui_id, name, parent_ui)
|
||||
ui.open()
|
||||
|
||||
// This is a helper for anything that wants to render the map.
|
||||
|
||||
102
code/modules/tgui/modules/admin_shuttle_controller.dm
Normal file
102
code/modules/tgui/modules/admin_shuttle_controller.dm
Normal file
@@ -0,0 +1,102 @@
|
||||
/* This is an admin tool to control all shuttles, including overmap & classic. */
|
||||
|
||||
/datum/tgui_module/admin_shuttle_controller
|
||||
name = "Admin Shuttle Controller"
|
||||
tgui_id = "AdminShuttleController"
|
||||
|
||||
/datum/tgui_module/admin_shuttle_controller/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
|
||||
var/list/data = ..()
|
||||
|
||||
var/list/shuttles = list()
|
||||
for(var/shuttle_name in SSshuttles.shuttles)
|
||||
var/datum/shuttle/S = SSshuttles.shuttles[shuttle_name]
|
||||
shuttles.Add(list(list(
|
||||
"name" = shuttle_name,
|
||||
"ref" = REF(S),
|
||||
"current_location" = S.get_location_name(),
|
||||
"status" = S.moving_status,
|
||||
)))
|
||||
data["shuttles"] = shuttles
|
||||
|
||||
var/list/overmap_ships = list()
|
||||
for(var/ship in SSshuttles.ships)
|
||||
var/obj/effect/overmap/visitable/ship/S = ship
|
||||
overmap_ships.Add(list(list(
|
||||
"name" = S.scanner_name || S.name,
|
||||
"ref" = REF(S),
|
||||
)))
|
||||
data["overmap_ships"] = overmap_ships
|
||||
|
||||
return data
|
||||
|
||||
/datum/tgui_module/admin_shuttle_controller/tgui_state(mob/user)
|
||||
return GLOB.tgui_admin_state
|
||||
|
||||
/datum/tgui_module/admin_shuttle_controller/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
|
||||
if(..())
|
||||
return
|
||||
|
||||
switch(action)
|
||||
if("adminobserve")
|
||||
var/datum/shuttle/S = locate(params["ref"])
|
||||
if(istype(S))
|
||||
var/client/C = usr.client
|
||||
if(!isobserver(usr))
|
||||
C.admin_ghost()
|
||||
spawn(2)
|
||||
C.jumptoturf(get_turf(S.current_location))
|
||||
else if(istype(S, /obj/effect/overmap/visitable))
|
||||
var/obj/effect/overmap/visitable/V = S
|
||||
var/client/C = usr.client
|
||||
if(!isobserver(usr))
|
||||
C.admin_ghost()
|
||||
spawn(2)
|
||||
var/atom/target
|
||||
if(LAZYLEN(V.generic_waypoints))
|
||||
target = V.generic_waypoints[1]
|
||||
else if(LAZYLEN(V.restricted_waypoints))
|
||||
target = V.restricted_waypoints[1]
|
||||
else
|
||||
to_chat(C, "<span class='warning'>Unable to jump to [V].</span>")
|
||||
return FALSE
|
||||
var/turf/T = get_turf(target)
|
||||
if(!istype(T))
|
||||
to_chat(C, "<span class='warning'>Unable to jump to [V].</span>")
|
||||
return FALSE
|
||||
C.jumptoturf(T)
|
||||
return TRUE
|
||||
if("classicmove")
|
||||
var/datum/shuttle/S = locate(params["ref"])
|
||||
if(istype(S, /datum/shuttle/autodock/multi))
|
||||
var/datum/shuttle/autodock/multi/shuttle = S
|
||||
var/dest_key = input("Choose shuttle destination", "Shuttle Destination") as null|anything in shuttle.get_destinations()
|
||||
if(dest_key)
|
||||
shuttle.set_destination(dest_key, usr)
|
||||
shuttle.launch(src)
|
||||
else if(istype(S, /datum/shuttle/autodock/overmap))
|
||||
var/datum/shuttle/autodock/overmap/shuttle = S
|
||||
var/list/possible_d = shuttle.get_possible_destinations()
|
||||
var/D
|
||||
if(!LAZYLEN(possible_d))
|
||||
to_chat(usr, "<span class='warning'>There are no possible destinations for [shuttle] ([shuttle.type])</span>")
|
||||
return FALSE
|
||||
D = input("Choose shuttle destination", "Shuttle Destination") as null|anything in possible_d
|
||||
if(D)
|
||||
shuttle.set_destination(possible_d[D])
|
||||
shuttle.launch()
|
||||
else if(istype(S, /datum/shuttle/autodock))
|
||||
var/datum/shuttle/autodock/shuttle = S
|
||||
if(alert(usr, "Are you sure you want to launch [shuttle]?", "Launching Shuttle", "Yes", "No") == "Yes")
|
||||
shuttle.launch(src)
|
||||
else
|
||||
to_chat(usr, "<span class='notice'>The shuttle control panel isn't quite sure how to move [S] ([S?.type]).</span>")
|
||||
return FALSE
|
||||
to_chat(usr, "<span class='notice'>Launching shuttle [S].</span>")
|
||||
return TRUE
|
||||
if("overmap_control")
|
||||
var/obj/effect/overmap/visitable/ship/V = locate(params["ref"])
|
||||
if(istype(V))
|
||||
var/datum/tgui_module/ship/fullmonty/F = new(src, V)
|
||||
F.tgui_interact(usr, null, ui)
|
||||
|
||||
return TRUE
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
/datum/tgui_module/ship/proc/look(var/mob/user)
|
||||
if(linked)
|
||||
user.set_machine(tgui_host())
|
||||
user.set_machine(src)
|
||||
user.reset_view(linked)
|
||||
user.set_viewsize(world.view + extra_view)
|
||||
GLOB.moved_event.register(user, src, /datum/tgui_module/ship/proc/unlook)
|
||||
@@ -134,4 +134,327 @@
|
||||
return TRUE
|
||||
|
||||
/datum/tgui_module/ship/nav/ntos
|
||||
ntos = TRUE
|
||||
ntos = TRUE
|
||||
|
||||
// Full monty control computer
|
||||
/datum/tgui_module/ship/fullmonty
|
||||
name = "Full Monty Overmap Control"
|
||||
tgui_id = "OvermapFull"
|
||||
// HELM
|
||||
var/autopilot = 0
|
||||
var/autopilot_disabled = TRUE
|
||||
var/list/known_sectors = list()
|
||||
var/dx //desitnation
|
||||
var/dy //coordinates
|
||||
var/speedlimit = 1/(20 SECONDS) //top speed for autopilot, 5
|
||||
var/accellimit = 0.001 //manual limiter for acceleration
|
||||
// SENSORS
|
||||
var/obj/machinery/shipsensors/sensors
|
||||
|
||||
/datum/tgui_module/ship/fullmonty/tgui_state(mob/user)
|
||||
return GLOB.tgui_admin_state
|
||||
|
||||
/datum/tgui_module/ship/fullmonty/New(host, obj/effect/overmap/visitable/ship/new_linked)
|
||||
. = ..()
|
||||
if(!istype(new_linked))
|
||||
CRASH("Warning, [new_linked] is not an overmap ship! Something went horribly wrong for [usr]!")
|
||||
return
|
||||
linked = new_linked
|
||||
name = initial(name) + " ([linked.name])"
|
||||
// HELM
|
||||
var/area/overmap/map = locate() in world
|
||||
for(var/obj/effect/overmap/visitable/sector/S in map)
|
||||
if(S.known)
|
||||
var/datum/computer_file/data/waypoint/R = new()
|
||||
R.fields["name"] = S.name
|
||||
R.fields["x"] = S.x
|
||||
R.fields["y"] = S.y
|
||||
known_sectors[S.name] = R
|
||||
// SENSORS
|
||||
for(var/obj/machinery/shipsensors/S in global.machines)
|
||||
if(linked.check_ownership(S))
|
||||
sensors = S
|
||||
break
|
||||
|
||||
/datum/tgui_module/ship/fullmonty/relaymove(var/mob/user, direction)
|
||||
if(viewing_overmap(user) && linked)
|
||||
direction = turn(direction,pick(90,-90))
|
||||
linked.relaymove(user, direction, accellimit)
|
||||
return 1
|
||||
return ..()
|
||||
|
||||
// Beware ye eyes. This holds all of the data from helm, engine, and sensor control all at once.
|
||||
/datum/tgui_module/ship/fullmonty/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
|
||||
var/list/data = ..()
|
||||
|
||||
// HELM
|
||||
var/turf/T = get_turf(linked)
|
||||
var/obj/effect/overmap/visitable/sector/current_sector = locate() in T
|
||||
|
||||
data["sector"] = current_sector ? current_sector.name : "Deep Space"
|
||||
data["sector_info"] = current_sector ? current_sector.desc : "Not Available"
|
||||
data["landed"] = linked.get_landed_info()
|
||||
data["s_x"] = linked.x
|
||||
data["s_y"] = linked.y
|
||||
data["dest"] = dy && dx
|
||||
data["d_x"] = dx
|
||||
data["d_y"] = dy
|
||||
data["speedlimit"] = speedlimit ? speedlimit*1000 : "Halted"
|
||||
data["accel"] = min(round(linked.get_acceleration()*1000, 0.01),accellimit*1000)
|
||||
data["heading"] = linked.get_heading_degrees()
|
||||
data["autopilot_disabled"] = autopilot_disabled
|
||||
data["autopilot"] = autopilot
|
||||
data["manual_control"] = viewing_overmap(user)
|
||||
data["canburn"] = linked.can_burn()
|
||||
data["accellimit"] = accellimit*1000
|
||||
|
||||
var/speed = round(linked.get_speed()*1000, 0.01)
|
||||
var/speed_color = null
|
||||
if(linked.get_speed() < SHIP_SPEED_SLOW)
|
||||
speed_color = "good"
|
||||
if(linked.get_speed() > SHIP_SPEED_FAST)
|
||||
speed_color = "average"
|
||||
data["speed"] = speed
|
||||
data["speed_color"] = speed_color
|
||||
|
||||
if(linked.get_speed())
|
||||
data["ETAnext"] = "[round(linked.ETA()/10)] seconds"
|
||||
else
|
||||
data["ETAnext"] = "N/A"
|
||||
|
||||
var/list/locations[0]
|
||||
for (var/key in known_sectors)
|
||||
var/datum/computer_file/data/waypoint/R = known_sectors[key]
|
||||
var/list/rdata[0]
|
||||
rdata["name"] = R.fields["name"]
|
||||
rdata["x"] = R.fields["x"]
|
||||
rdata["y"] = R.fields["y"]
|
||||
rdata["reference"] = "\ref[R]"
|
||||
locations.Add(list(rdata))
|
||||
|
||||
data["locations"] = locations
|
||||
|
||||
// ENGINES
|
||||
data["global_state"] = linked.engines_state
|
||||
data["global_limit"] = round(linked.thrust_limit*100)
|
||||
var/total_thrust = 0
|
||||
|
||||
var/list/enginfo = list()
|
||||
for(var/datum/ship_engine/E in linked.engines)
|
||||
var/list/rdata = list()
|
||||
rdata["eng_type"] = E.name
|
||||
rdata["eng_on"] = E.is_on()
|
||||
rdata["eng_thrust"] = E.get_thrust()
|
||||
rdata["eng_thrust_limiter"] = round(E.get_thrust_limit()*100)
|
||||
var/list/status = E.get_status()
|
||||
if(!islist(status))
|
||||
log_runtime(EXCEPTION("Warning, ship [E.name] (\ref[E]) for [linked.name] returned a non-list status!"))
|
||||
status = list("Error")
|
||||
rdata["eng_status"] = status
|
||||
rdata["eng_reference"] = "\ref[E]"
|
||||
total_thrust += E.get_thrust()
|
||||
enginfo.Add(list(rdata))
|
||||
|
||||
data["engines_info"] = enginfo
|
||||
data["total_thrust"] = total_thrust
|
||||
|
||||
// SENSORS
|
||||
data["viewing"] = viewing_overmap(user)
|
||||
data["on"] = 0
|
||||
data["range"] = "N/A"
|
||||
data["health"] = 0
|
||||
data["max_health"] = 0
|
||||
data["heat"] = 0
|
||||
data["critical_heat"] = 0
|
||||
data["status"] = "MISSING"
|
||||
data["contacts"] = list()
|
||||
|
||||
if(sensors)
|
||||
data["on"] = sensors.use_power
|
||||
data["range"] = sensors.range
|
||||
data["health"] = sensors.health
|
||||
data["max_health"] = sensors.max_health
|
||||
data["heat"] = sensors.heat
|
||||
data["critical_heat"] = sensors.critical_heat
|
||||
if(sensors.health == 0)
|
||||
data["status"] = "DESTROYED"
|
||||
else if(!sensors.powered())
|
||||
data["status"] = "NO POWER"
|
||||
else if(!sensors.in_vacuum())
|
||||
data["status"] = "VACUUM SEAL BROKEN"
|
||||
else
|
||||
data["status"] = "OK"
|
||||
var/list/contacts = list()
|
||||
for(var/obj/effect/overmap/O in view(7,linked))
|
||||
if(linked == O)
|
||||
continue
|
||||
if(!O.scannable)
|
||||
continue
|
||||
var/bearing = round(90 - ATAN2(O.x - linked.x, O.y - linked.y),5)
|
||||
if(bearing < 0)
|
||||
bearing += 360
|
||||
contacts.Add(list(list("name"=O.name, "ref"="\ref[O]", "bearing"=bearing)))
|
||||
data["contacts"] = contacts
|
||||
|
||||
|
||||
return data
|
||||
|
||||
// Beware ye eyes. This holds all of the ACTIONS from helm, engine, and sensor control all at once.
|
||||
/datum/tgui_module/ship/fullmonty/tgui_act(action, params)
|
||||
if(..())
|
||||
return TRUE
|
||||
|
||||
switch(action)
|
||||
/* HELM */
|
||||
if("add")
|
||||
var/datum/computer_file/data/waypoint/R = new()
|
||||
var/sec_name = input("Input navigation entry name", "New navigation entry", "Sector #[known_sectors.len]") as text
|
||||
if(!sec_name)
|
||||
sec_name = "Sector #[known_sectors.len]"
|
||||
R.fields["name"] = sec_name
|
||||
if(sec_name in known_sectors)
|
||||
to_chat(usr, "<span class='warning'>Sector with that name already exists, please input a different name.</span>")
|
||||
return TRUE
|
||||
switch(params["add"])
|
||||
if("current")
|
||||
R.fields["x"] = linked.x
|
||||
R.fields["y"] = linked.y
|
||||
if("new")
|
||||
var/newx = input("Input new entry x coordinate", "Coordinate input", linked.x) as num
|
||||
var/newy = input("Input new entry y coordinate", "Coordinate input", linked.y) as num
|
||||
R.fields["x"] = CLAMP(newx, 1, world.maxx)
|
||||
R.fields["y"] = CLAMP(newy, 1, world.maxy)
|
||||
known_sectors[sec_name] = R
|
||||
. = TRUE
|
||||
|
||||
if("remove")
|
||||
var/datum/computer_file/data/waypoint/R = locate(params["remove"])
|
||||
if(R)
|
||||
known_sectors.Remove(R.fields["name"])
|
||||
qdel(R)
|
||||
. = TRUE
|
||||
|
||||
if("setcoord")
|
||||
if(params["setx"])
|
||||
var/newx = input("Input new destiniation x coordinate", "Coordinate input", dx) as num|null
|
||||
if(newx)
|
||||
dx = CLAMP(newx, 1, world.maxx)
|
||||
|
||||
if(params["sety"])
|
||||
var/newy = input("Input new destiniation y coordinate", "Coordinate input", dy) as num|null
|
||||
if(newy)
|
||||
dy = CLAMP(newy, 1, world.maxy)
|
||||
. = TRUE
|
||||
|
||||
if("setds")
|
||||
dx = text2num(params["x"])
|
||||
dy = text2num(params["y"])
|
||||
. = TRUE
|
||||
|
||||
if("reset")
|
||||
dx = 0
|
||||
dy = 0
|
||||
. = TRUE
|
||||
|
||||
if("speedlimit")
|
||||
var/newlimit = input("Input new speed limit for autopilot (0 to brake)", "Autopilot speed limit", speedlimit*1000) as num|null
|
||||
if(newlimit)
|
||||
speedlimit = CLAMP(newlimit/1000, 0, 100)
|
||||
. = TRUE
|
||||
|
||||
if("accellimit")
|
||||
var/newlimit = input("Input new acceleration limit", "Acceleration limit", accellimit*1000) as num|null
|
||||
if(newlimit)
|
||||
accellimit = max(newlimit/1000, 0)
|
||||
. = TRUE
|
||||
|
||||
if("move")
|
||||
var/ndir = text2num(params["dir"])
|
||||
ndir = turn(ndir,pick(90,-90))
|
||||
linked.relaymove(usr, ndir, accellimit)
|
||||
. = TRUE
|
||||
|
||||
if("brake")
|
||||
linked.decelerate()
|
||||
. = TRUE
|
||||
|
||||
if("apilot")
|
||||
if(autopilot_disabled)
|
||||
autopilot = FALSE
|
||||
else
|
||||
autopilot = !autopilot
|
||||
. = TRUE
|
||||
|
||||
if("apilot_lock")
|
||||
autopilot_disabled = !autopilot_disabled
|
||||
autopilot = FALSE
|
||||
. = TRUE
|
||||
|
||||
if("manual")
|
||||
viewing_overmap(usr) ? unlook(usr) : look(usr)
|
||||
. = TRUE
|
||||
/* END HELM */
|
||||
/* ENGINES */
|
||||
if("global_toggle")
|
||||
linked.engines_state = !linked.engines_state
|
||||
for(var/datum/ship_engine/E in linked.engines)
|
||||
if(linked.engines_state == !E.is_on())
|
||||
E.toggle()
|
||||
. = TRUE
|
||||
|
||||
if("set_global_limit")
|
||||
var/newlim = input("Input new thrust limit (0..100%)", "Thrust limit", linked.thrust_limit*100) as num
|
||||
linked.thrust_limit = clamp(newlim/100, 0, 1)
|
||||
for(var/datum/ship_engine/E in linked.engines)
|
||||
E.set_thrust_limit(linked.thrust_limit)
|
||||
. = TRUE
|
||||
|
||||
if("global_limit")
|
||||
linked.thrust_limit = clamp(linked.thrust_limit + text2num(params["global_limit"]), 0, 1)
|
||||
for(var/datum/ship_engine/E in linked.engines)
|
||||
E.set_thrust_limit(linked.thrust_limit)
|
||||
. = TRUE
|
||||
|
||||
if("set_limit")
|
||||
var/datum/ship_engine/E = locate(params["engine"])
|
||||
var/newlim = input("Input new thrust limit (0..100)", "Thrust limit", E.get_thrust_limit()) as num
|
||||
var/limit = clamp(newlim/100, 0, 1)
|
||||
if(istype(E))
|
||||
E.set_thrust_limit(limit)
|
||||
. = TRUE
|
||||
|
||||
if("limit")
|
||||
var/datum/ship_engine/E = locate(params["engine"])
|
||||
var/limit = clamp(E.get_thrust_limit() + text2num(params["limit"]), 0, 1)
|
||||
if(istype(E))
|
||||
E.set_thrust_limit(limit)
|
||||
. = TRUE
|
||||
|
||||
if("toggle_engine")
|
||||
var/datum/ship_engine/E = locate(params["engine"])
|
||||
if(istype(E))
|
||||
E.toggle()
|
||||
. = TRUE
|
||||
/* END ENGINES */
|
||||
/* SENSORS */
|
||||
if("range")
|
||||
var/nrange = input("Set new sensors range", "Sensor range", sensors.range) as num|null
|
||||
if(nrange)
|
||||
sensors.set_range(CLAMP(nrange, 1, world.view))
|
||||
. = TRUE
|
||||
if("toggle_sensor")
|
||||
sensors.toggle()
|
||||
. = TRUE
|
||||
if("viewing")
|
||||
if(usr && !isAI(usr))
|
||||
viewing_overmap(usr) ? unlook(usr) : look(usr)
|
||||
. = TRUE
|
||||
/* END SENSORS */
|
||||
|
||||
// We don't want these to do anything.
|
||||
/datum/tgui_module/ship/fullmonty/sync_linked()
|
||||
return
|
||||
/datum/tgui_module/ship/fullmonty/attempt_hook_up_recursive()
|
||||
return
|
||||
/datum/tgui_module/ship/fullmonty/attempt_hook_up()
|
||||
return
|
||||
Reference in New Issue
Block a user