Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mullenpaul committed May 25, 2024
1 parent 892a50d commit 0146fd2
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 25 deletions.
54 changes: 41 additions & 13 deletions code/modules/shuttle/computers/dropship_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@
.["max_refuel_duration"] = shuttle.rechargeTime / 10
.["max_engine_start_duration"] = shuttle.ignitionTime / 10
.["door_data"] = list("port", "starboard", "aft")
.["alternative_shuttles"] = alternative_shuttles()
.["alternative_shuttles"] = list()
if(can_change_shuttle)
.["alternative_shuttles"] = alternative_shuttles()

/obj/structure/machinery/computer/shuttle/dropship/flight/proc/alternative_shuttles()
. = list()
Expand Down Expand Up @@ -208,6 +210,23 @@

var/obj/docking_port/mobile/shuttle = SSshuttle.getShuttle(shuttleId)
if(linked_lz)
var/obj/docking_port/stationary/landing_zone = SSshuttle.getDock(linked_lz)
var/obj/docking_port/mobile/maybe_dropship = landing_zone.get_docked()

if(maybe_dropship)
to_chat(xeno, SPAN_NOTICE("A metal bird already is here."))
return

var/conflicting_transit = FALSE
for(var/obj/docking_port/mobile/other_shuttle in SSshuttle.mobile)
if(landing_zone == other_shuttle.destination)
conflicting_transit = TRUE
break

if(conflicting_transit)
to_chat(xeno, SPAN_NOTICE("A metal bird is already coming."))
return

playsound(loc, 'sound/machines/terminal_success.ogg', KEYBOARD_SOUND_VOLUME, 1)
if(shuttle.mode == SHUTTLE_IDLE && !is_ground_level(shuttle.z))
var/result = SSshuttle.moveShuttle(shuttleId, linked_lz, TRUE)
Expand Down Expand Up @@ -235,7 +254,7 @@

/obj/structure/machinery/computer/shuttle/dropship/flight/attack_alien(mob/living/carbon/xenomorph/xeno)
// if the shuttleid is null or the shuttleid references a shuttle that has been removed from play, pick one
if(!shuttleId || !SSshuttle.hasShuttle(shuttleId))
if(!shuttleId || !SSshuttle.getShuttle(shuttleId, FALSE))
var/list/alternatives = alternative_shuttles()
shuttleId = pick(alternatives)["id"]

Expand Down Expand Up @@ -421,6 +440,10 @@
return
var/obj/docking_port/mobile/marine_dropship/shuttle = SSshuttle.getShuttle(shuttleId)
if(disabled || (shuttle && shuttle.is_hijacked))
switch(action)
if ("change_shuttle")
var/new_shuttle = params["new_shuttle"]
return set_shuttle(new_shuttle)
return
var/mob/user = usr
if (shuttle)
Expand Down Expand Up @@ -560,19 +583,24 @@
stop_playing_launch_announcement_alarm()
return TRUE
if ("change_shuttle")
var/list/alternatives = alternative_shuttles()
var/new_shuttle = params["new_shuttle"]
var/found = FALSE
for(var/alt_shuttle in alternatives)
if(alt_shuttle["id"] == new_shuttle)
found = TRUE
if(found)
shuttleId = new_shuttle
update_static_data(user, ui)
else
log_admin("Player [user] attempted to change shuttle illegally.")
return TRUE
return set_shuttle(new_shuttle)

/obj/structure/machinery/computer/shuttle/dropship/flight/proc/set_shuttle(new_shuttle)
var/mob/user = usr
if(!new_shuttle || shuttleId == new_shuttle)
return FALSE
var/found = FALSE
var/list/alternatives = alternative_shuttles()
for(var/alt_shuttle in alternatives)
if(alt_shuttle["id"] == new_shuttle)
found = TRUE
if(found)
shuttleId = new_shuttle
update_static_data(user)
else
log_admin("Player [user] attempted to change shuttle illegally.")
return TRUE

/obj/structure/machinery/computer/shuttle/dropship/flight/proc/stop_playing_launch_announcement_alarm()
var/obj/docking_port/mobile/marine_dropship/shuttle = SSshuttle.getShuttle(shuttleId)
Expand Down
8 changes: 4 additions & 4 deletions maps/map_files/USS_Almayer/USS_Almayer.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -29437,8 +29437,8 @@
},
/obj/structure/machinery/computer/shuttle/dropship/flight/remote_control{
dir = 4;
name = "Secondary Remote Control Console";
pixel_y = -12
pixel_y = -12;
name = "Remote dropship navigation computer"
},
/turf/open/floor/almayer{
icon_state = "redfull"
Expand Down Expand Up @@ -65347,9 +65347,9 @@
},
/obj/structure/machinery/computer/shuttle/dropship/flight/remote_control{
dir = 8;
name = "Primary Remote Control Console";
pixel_y = 12;
shuttleId = "dropship_alamo"
shuttleId = "dropship_alamo";
name = "Remote dropship navigation computer"
},
/turf/open/floor/almayer{
icon_state = "redfull"
Expand Down
44 changes: 37 additions & 7 deletions tgui/packages/tgui/interfaces/DropshipFlightControl.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect, useState } from 'react';
import { useBackend, useSharedState } from '../backend';
import {
Box,
Expand Down Expand Up @@ -371,32 +372,51 @@ const LaunchAnnouncementAlarm = () => {
);
};

const DropshipButton = (props: { readonly ship: ShuttleRef }) => {
const DropshipButton = (props: { readonly shipId: string, readonly shipName: string, readonly disable, onClick: () => void }) => {
const { act, data } = useBackend<DropshipNavigationProps>();
const match = props.ship.id === data.shuttle_id;
const match = props.shipId === data.shuttle_id;

return (
<Button
disabled={match}
disabled={match || props.disable }
onClick={() => {
act('change_shuttle', { new_shuttle: props.ship.id });
act('change_shuttle', { new_shuttle: props.shipId });
act('button-push');
props.onClick();
}}>
{match && '['}
{props.ship.name}
{props.shipName}
{match && ']'}
</Button>
);
};

const DropshipSelector = () => {
const { data } = useBackend<DropshipNavigationProps>();
const [refreshTimeout, setRefreshTimeout] = useState<NodeJS.Timeout | undefined>(undefined);

useEffect(() => {
if(refreshTimeout) {
return () => clearTimeout(refreshTimeout);
}
return () => {};
}, [refreshTimeout]);

return (
<Section title="Select Dropship">
<Stack>
{data.alternative_shuttles
.sort((a, b) => a.id.localeCompare(b.id))
.map((x) => (
<DropshipButton ship={x} key={x.id} />
<DropshipButton
key={x.id}
shipId={x.id}
shipName={x.name}
disable={refreshTimeout !== undefined}
onClick={() => {
const freeze = setTimeout(() => setRefreshTimeout(undefined), 2000)
setRefreshTimeout(freeze);
}}/>
))}
</Stack>
</Section>
Expand Down Expand Up @@ -427,12 +447,22 @@ const RenderScreen = () => {
);
};

const DropshipDisabledScreen = () => {
const { data } = useBackend<DropshipNavigationProps>();
return (
<>
{data.alternative_shuttles.length > 0 && <DropshipSelector />}
<DisabledScreen />
</>
)
}

export const DropshipFlightControl = () => {
const { data } = useBackend<DropshipNavigationProps>();
return (
<Window theme="crtgreen" height={500} width={700}>
<Window.Content className="NavigationMenu" scrollable>
{data.is_disabled === 0 ? <RenderScreen /> : <DisabledScreen />}
{data.is_disabled === 0 ? <RenderScreen /> : <DropshipDisabledScreen />}
</Window.Content>
</Window>
);
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui/interfaces/NavigationShuttle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const DoorControls = () => {
};

export const DisabledScreen = (props) => {
const { data, act } = useBackend<NavigationProps>();
const { data } = useBackend<NavigationProps>();

const disabled_text = data.mission_accomplished
? 'Auto-navigation protocol completed - return home complete. Shuttle disabled.'
Expand Down

0 comments on commit 0146fd2

Please sign in to comment.