Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 197 additions & 0 deletions tgui/packages/voidcrew_tgui/interfaces/VoidcrewManagement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
import { map } from '../../common/collections';
import { useBackend, useLocalState } from '../../tgui/backend';
import {Box, Button, Divider, Section, Table, Tabs } from '../../tgui/components';
import { Window } from '../../tgui/layouts';

export const VoidcrewManagement = (props, context) => {
const [tab, setTab] = useLocalState(context, 'tab', 1);
return (
<Window title="Voidcrew Management System" width={800} height={600} theme="hackerman">
<Window.Content scrollable>
<Tabs>
<Tabs.Tab selected={tab === 1} onClick={() => setTab(1)}>
Ships
</Tabs.Tab>
<Tabs.Tab selected={tab === 2} onClick={() => setTab(2)}>
Planets
</Tabs.Tab>
</Tabs>
{tab === 1 && <VoidcrewManagementShips />}
{tab === 2 && <VoidcrewManagementPlanets />}
</Window.Content>
</Window>
);
};

export const VoidcrewManagementShips = (props, context) => {
const { act, data } = useBackend(context);
const ships = data.ships || [];
return (
<Section>
<Table collapsing>
{ships.map((ship) => (
<Table.Row key={ship.id}>
<Table.Cell>
<Button
content="JMP"
key={ship.id}
onClick={() =>
act('jump_to', {
type: 'mobile',
id: ship.id,
})
}
/>
</Table.Cell>
<Table.Cell>
<Button
content="VV"
onClick={() =>
act('vv', {
ref: ship.ref,
})
}
/>
</Table.Cell>
<Table.Cell>
<Button
content={ship.docked ? "UNDOCK" : "DOCK"}
onClick={() =>
act('dock', {
ref: ship.ref,
})
}
/>
</Table.Cell>
<Table.Cell>
<Button
content="CTRL"
onClick={() =>
act('control', {
ref: ship.ref,
})
}
/>
</Table.Cell>
<Table.Cell>
<Button
content={ship.locked ? "UNLOCK" : "LOCK"}
onClick={() =>
act('lock', {
ref: ship.ref,
})
}
/>
</Table.Cell>
<Table.Cell>
<Button
content="RECALC"
onClick={() =>
act('recalc', {
id: ship.id,
})
}
/>
</Table.Cell>
<Table.Cell>{ship.name}</Table.Cell>
<Table.Cell>{ship.short_name}</Table.Cell>
<Table.Cell>{ship.status}</Table.Cell>
</Table.Row>
))}
</Table>
<Divider />
<Box>
<Button
content="Spawn ship"
onClick={() =>
act('spawn', {
type: 'ship',
})
}
/>
<Button
content="Toggle Ship Purchasing"
onClick={() =>
act('toggle_ship_purchases')
}
/>
</Box>
</Section>
);
};

export const VoidcrewManagementPlanets = (props, context) => {
const { act, data } = useBackend(context);
const planets = data.planets || [];
return (
<Section>
<Table collapsing>
{planets.map((planet) => (
<Table.Row key={planet.ref}>
<Table.Cell>
<Button
content="JMP"
key={planet.ref}
onClick={() =>
act('jump_to', {
type: 'planet',
ref: planet.ref,
})
}
/>
</Table.Cell>
<Table.Cell>
<Button
content="VV"
onClick={() =>
act('vv', {
ref: planet.ref,
})
}
/>
</Table.Cell>
<Table.Cell>
<Button
content={planet.loaded ? "UNLOAD" : "LOAD"}
key={planet.ref}
onClick={() =>
act('load_unload', {
type: 'planet',
ref: planet.ref,
})
}
/>
</Table.Cell>
<Table.Cell>
<Button
content={planet.preserved ? "UNPRESERVE" : "PRESERVE"}
key={planet.ref}
onClick={() =>
act('preserve', {
type: 'planet',
ref: planet.ref,
})
}
/>
</Table.Cell>
<Table.Cell>{planet.name}</Table.Cell>
<Table.Cell>{planet.loaded ? "Loaded" : "Unloaded"}</Table.Cell>
<Table.Cell>{planet.preserved ? "Preserved" : "Unpreserved"}</Table.Cell>
</Table.Row>
))}
</Table>
<Divider />
<Box>
<Button
content="Spawn planet"
onClick={() =>
act('spawn', {
type: 'planet',
})
}
/>
</Box>
</Section>
);
};

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ SUBSYSTEM_DEF(overmap)
var/list/turf/radius_tiles = list()
/// List of all events
var/list/events = list()
/// List of all dynamic overmap objects
var/list/dynamic_objects = list()

var/size = OVERMAP_SIZE

Expand Down Expand Up @@ -235,6 +237,7 @@ SUBSYSTEM_DEF(overmap)
planet_to_spawn.color = planet_info.color
qdel(planet_info)

/datum/controller/subsystem/overmap/proc/spawn_planet()
// TODO - MULTI-Z VLEVELS
/datum/controller/subsystem/overmap/proc/calculate_turf_above(turf/T)
return
Expand Down
154 changes: 153 additions & 1 deletion voidcrew/modules/overmap/code/controllers/subsystem/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
/client/proc/initiate_jump,
/client/proc/cancel_jump,
/client/proc/team_panel,
/client/proc/togglepurchasing
/client/proc/togglepurchasing,
/client/proc/manage_ships
))

/client/remove_admin_verbs()
Expand All @@ -53,6 +54,7 @@
/client/proc/cancel_jump,
/client/proc/team_panel,
/client/proc/togglepurchasing,
/client/proc/manage_ships
))

#define RESPAWN_FORCE "Force Respawn"
Expand Down Expand Up @@ -83,6 +85,19 @@
var/obj/structure/overmap/ship/spawned = SSshuttle.create_ship(choices[ship_to_spawn])
mob.client?.admin_follow(spawned.shuttle)

/client/proc/spawn_specific_planet()
var/static/list/choices
if(!choices)
choices = list()
for(var/planet in subtypesof(/obj/structure/overmap/planet))
var/obj/structure/overmap/planet/V = planet
choices[initial(V.name)] = V
var/planet_to_spawn = tgui_input_list(usr, "Which planet do you want to spawn?", "Spawn Specific Planet", choices)
if(!planet_to_spawn)
return
var/final_planet = choices[planet_to_spawn]
new final_planet(SSovermap.get_unused_overmap_square())

/client/proc/initiate_jump()
set name = "Initiate Jump"
set category = "Overmap.Jump"
Expand Down Expand Up @@ -141,5 +156,142 @@
world.update_status()
SSblackbox.record_feedback("nested tally", "admin_toggle", 1, list("Toggle Ship Purchasing", "[GLOB.ship_buying ? "Enabled" : "Disabled"]")) //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

/client/proc/manage_ships()
set category = "Overmap.Ships"
set desc="Ship Management Console"
set name="Ship/Planet Management"
if(!check_rights(R_ADMIN))
return
new /datum/ship_management(usr)//create the datum

/datum/ship_management
var/client/holder //client of whoever is using this datum

/datum/ship_management/New(user) //user can either be a client or a mob
if (istype(user,/client))
var/client/user_client = user
holder = user_client //if its a client, assign it to holder
else
var/mob/user_mob = user
holder = user_mob.client //if its a mob, assign the mob's client to holder
ui_interact(holder.mob)

/datum/ship_management/ui_state(mob/user)
return GLOB.admin_state

/datum/ship_management/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
// Open UI
ui = new(user, src, "VoidcrewManagement")
ui.open()

/datum/ship_management/ui_data(mob/user)
var/list/data = list()
data["ships"] = list()
for(var/i in SSovermap.simulated_ships)
var/obj/structure/overmap/ship/M = i
var/list/L = list()
L["name"] = M.name
L["id"] = M.shuttle.shuttle_id
L["ref"] = REF(M)
L["short_name"] = M.source_template.short_name
L["status"] = M.state
L["docked"] = M.docked
L["locked"] = M.helm_locked
data["ships"] += list(L)
data["planets"] = list()
for(var/i in SSovermap.dynamic_objects)
var/obj/structure/overmap/planet/M = i
var/list/L = list()
L["name"] = M.name
L["ref"] = REF(M)
L["loaded"] = FALSE
L["preserved"] = M.preserve_level
if(M.mapzone)
L["loaded"] = TRUE
data["planets"] += list(L)
return data

/datum/ship_management/ui_act(action, params)
. = ..()
if(.)
return
var/mob/user = usr
var/obj/docking_port/mobile/mobile_dock
var/obj/structure/overmap/planet/planet
var/obj/structure/overmap/ship/ship
if(params["id"])
for(var/i in SSshuttle.mobile_docking_ports)
mobile_dock = i
if(mobile_dock.shuttle_id == params["id"])
break
if(params["ref"])
var/located = locate(params["ref"])
if(istype(located, /obj/structure/overmap/ship))
ship = located
if(istype(located, /obj/structure/overmap/planet))
planet = located

switch(action)
if("jump_to")
if(params["type"] == "mobile")
user.forceMove(get_turf(mobile_dock))
return TRUE
else
if(planet.reserve_dock)
user.forceMove(get_turf(planet.reserve_dock))
return TRUE
else
user.forceMove(planet.loc)
return TRUE
if("spawn")
if(params["type"] == "ship")
user.client.spawn_specific_ship()
if(params["type"] == "planet")
user.client.spawn_specific_planet()
if("toggle_ship_purchases")
user.client.togglepurchasing()
if("recalc")
mobile_dock.recalculate_bounds()
if("load_unload")
if(!planet.mapzone)
planet.load_level()
else
if(!planet.unload_level())
if(tgui_alert(usr, "A ship or alive mobs have been detected, do you want to force an unload?","LIFESIGNS DETECTED", list("Yes", "No")) == "Yes")
planet.unload_level(TRUE)
if("preserve")
planet.preserve_level = !planet.preserve_level
if("dock")
if(!ship.docked)
var/available_overmap_planets = list()
for(var/obj/structure/overmap/planet/planets as anything in SSovermap.dynamic_objects)
available_overmap_planets["[planets.name] X:[planets.x] Y:[planets.y]"] = planets
var/obj/structure/overmap/planet/option = available_overmap_planets[tgui_input_list(usr, "Select dock type", "Dock Type Selection", available_overmap_planets)]
if(!option)
return
option.ship_act(usr, ship)
else
ship.undock()
if("vv")
if(ship)
user.client.debug_variables(ship)
if(planet)
user.client.debug_variables(planet)
if("lock")
ship.helm_locked = !ship.helm_locked
if("control")
if(ship.helms[1])
var/obj/machinery/computer/helm/helm_console = ship.helms[1]
helm_console.ui_interact(usr)










Loading