diff --git a/code/modules/mining/aux_base.dm b/code/modules/mining/aux_base.dm
index 0c5fc7cfab5..07b82332548 100644
--- a/code/modules/mining/aux_base.dm
+++ b/code/modules/mining/aux_base.dm
@@ -10,121 +10,171 @@
name = "Auxiliary Base"
luminosity = 0 //Lighting gets lost when it lands anyway
-
/obj/machinery/computer/auxiliary_base
name = "auxiliary base management console"
+ desc = "Allows a deployable expedition base to be dropped from the station to a designated mining location. It can also \
+ interface with the mining shuttle at the landing site if a mobile beacon is also deployed."
icon = 'icons/obj/terminals.dmi'
icon_state = "dorm_available"
- var/shuttleId = "colony_drop"
- desc = "Allows a deployable expedition base to be dropped from the station to a designated mining location. It can also \
-interface with the mining shuttle at the landing site if a mobile beacon is also deployed."
- var/launch_warning = TRUE
- var/list/turrets = list() //List of connected turrets
-
req_one_access = list(ACCESS_AUX_BASE, ACCESS_HEADS)
- var/possible_destinations
circuit = /obj/item/circuitboard/computer/auxiliary_base
+ /// Shuttle ID of the base
+ var/shuttleId = "colony_drop"
+ /// If we give warnings before base is launched
+ var/launch_warning = TRUE
+ /// List of connected turrets
+ var/list/turrets = list()
+ /// List of all possible destinations
+ var/possible_destinations
+ /// ID of the currently selected destination of the attached base
+ var/destination
+ /// If blind drop option is available
+ var/blind_drop_ready = TRUE
/obj/machinery/computer/auxiliary_base/Initialize()
. = ..()
AddComponent(/datum/component/gps, "NT_AUX")
-/obj/machinery/computer/auxiliary_base/ui_interact(mob/user)
- . = ..()
+/obj/machinery/computer/auxiliary_base/ui_interact(mob/user, datum/tgui/ui)
+ ui = SStgui.try_update_ui(user, src, ui)
+ if(!ui)
+ ui = new(user, src, "AuxBaseConsole", name)
+ ui.open()
+
+/obj/machinery/computer/auxiliary_base/ui_data(mob/user)
+ var/list/data = list()
var/list/options = params2list(possible_destinations)
var/obj/docking_port/mobile/M = SSshuttle.getShuttle(shuttleId)
- var/dat = "[is_station_level(z) ? "Docking clamps engaged. Standing by." : "Mining Shuttle Uplink: [M ? M.getStatusText() : "*OFFLINE*"]"]
"
- if(M)
- var/destination_found
- for(var/obj/docking_port/stationary/S in SSshuttle.stationary)
- if(!options.Find(S.id))
- continue
- if(!M.check_dock(S, silent=TRUE))
- continue
- destination_found = 1
- dat += "Send to [S.name]
"
- if(!destination_found && is_station_level(z)) //Only available if miners are lazy and did not set an LZ using the remote.
- dat += "Prepare for blind drop? (Dangerous)
"
+ data["type"] = shuttleId == "colony_drop" ? "base" : "shuttle"
+ data["docked_location"] = M ? M.get_status_text_tgui() : "Unknown"
+ data["locations"] = list()
+ data["locked"] = FALSE
+ data["timer_str"] = M ? M.getTimerStr() : "00:00"
+ data["destination"] = destination
+ data["blind_drop"] = blind_drop_ready
+ data["turrets"] = list()
if(LAZYLEN(turrets))
- dat += "
Perimeter Defense System: Enable All / Disable All
\
- Units connected: [LAZYLEN(turrets)]
\
- Unit | Condition | Status | Direction | Distance
"
- for(var/PDT in turrets)
- var/obj/machinery/porta_turret/aux_base/T = PDT
- var/integrity = max((T.obj_integrity-T.integrity_failure * T.max_integrity)/(T.max_integrity-T.integrity_failure * max_integrity)*100, 0)
- var/status
- if(T.machine_stat & BROKEN)
- status = "ERROR"
- else if(!T.on)
- status = "Disabled"
- else if(T.raised)
- status = "Firing"
+ for(var/turret in turrets)
+ var/obj/machinery/porta_turret/aux_base/base_turret = turret
+ var/turret_integrity = max((base_turret.obj_integrity - base_turret.integrity_failure * base_turret.max_integrity) / (base_turret.max_integrity - base_turret.integrity_failure * max_integrity) * 100, 0)
+ var/turret_status
+ if(base_turret.machine_stat & BROKEN)
+ turret_status = "ERROR"
+ else if(!base_turret.on)
+ turret_status = "Disabled"
+ else if(base_turret.raised)
+ turret_status = "Firing"
else
- status = "All Clear"
- dat += "[T.name] | [integrity]% | [status] | [dir2text(get_dir(src, T))] | [get_dist(src, T)]m Toggle Power
"
+ turret_status = "All Clear"
+ var/list/turret_data = list(
+ name = base_turret.name,
+ integrity = turret_integrity,
+ status = turret_status,
+ direction = dir2text(get_dir(src, base_turret)),
+ distance = get_dist(src, base_turret),
+ ref = REF(base_turret)
+ )
+ data["turrets"] += list(turret_data)
+ if(!M)
+ data["status"] = "Missing"
+ return data
+ switch(M.mode)
+ if(SHUTTLE_IGNITING)
+ data["status"] = "Igniting"
+ if(SHUTTLE_IDLE)
+ data["status"] = "Idle"
+ if(SHUTTLE_RECHARGING)
+ data["status"] = "Recharging"
+ else
+ data["status"] = "In Transit"
+ for(var/obj/docking_port/stationary/S in SSshuttle.stationary)
+ if(!options.Find(S.port_destinations))
+ continue
+ if(!M.check_dock(S, silent = TRUE))
+ continue
+ var/list/location_data = list(
+ id = S.id,
+ name = S.name
+ )
+ data["locations"] += list(location_data)
+ if(length(data["locations"]) == 1)
+ for(var/location in data["locations"])
+ destination = location["id"]
+ data["destination"] = destination
+ if(!length(data["locations"]))
+ data["locked"] = TRUE
+ data["status"] = "Locked"
+ return data
+/**
+ * Checks if we are allowed to launch the base
+ *
+ * Arguments:
+ * * user - The mob trying to initiate the launch
+ */
+/obj/machinery/computer/auxiliary_base/proc/launch_check(mob/user)
+ if(!is_station_level(z) && shuttleId == "colony_drop")
+ to_chat(user, "You can't move the base again!")
+ return FALSE
+ return TRUE
- dat += "Close"
-
- var/datum/browser/popup = new(user, "computer", "base management", 550, 300) //width, height
- popup.set_content("
'+(n?e:ee(e,!0))+"\n":""+(n?e:ee(e,!0))+"\n"}return e}(),t.blockquote=function(){function e(e){return"\n"+e+"\n"}return e}(),t.html=function(){function e(e){return e}return e}(),t.heading=function(){function e(e,t,n,r){return this.options.headerIds?"
"+e+"
\n"}return e}(),t.table=function(){function e(e,t){return t&&(t=""+t+""),""+e+""}return e}(),t.br=function(){function e(){return this.options.xhtml?""+se(c.message+"",!0)+"";throw c}}return pe.options=pe.setOptions=function(e){return ue(pe.defaults,e),fe(pe.defaults),pe},pe.getDefaults=le,pe.defaults=de,pe.use=function(e){var t=ue({},e);if(e.renderer&&function(){var n=pe.defaults.renderer||new te,r=function(){function t(t){var r=n[t];n[t]=function(){for(var o=arguments.length,i=new Array(o),a=0;a
'+(n?e:ee(e,!0))+"\n":""+(n?e:ee(e,!0))+"\n"}return e}(),t.blockquote=function(){function e(e){return"\n"+e+"\n"}return e}(),t.html=function(){function e(e){return e}return e}(),t.heading=function(){function e(e,t,n,r){return this.options.headerIds?"
"+e+"
\n"}return e}(),t.table=function(){function e(e,t){return t&&(t=""+t+""),""+e+""}return e}(),t.br=function(){function e(){return this.options.xhtml?""+se(c.message+"",!0)+"";throw c}}return pe.options=pe.setOptions=function(e){return ue(pe.defaults,e),fe(pe.defaults),pe},pe.getDefaults=le,pe.defaults=de,pe.use=function(e){var t=ue({},e);if(e.renderer&&function(){var n=pe.defaults.renderer||new te,r=function(){function t(t){var r=n[t];n[t]=function(){for(var o=arguments.length,i=new Array(o),a=0;a