From ff067a43bed808a6bf4f4455feadc7d0aff25451 Mon Sep 17 00:00:00 2001 From: TiviPlus <57223640+TiviPlus@users.noreply.github.com> Date: Wed, 20 Sep 2023 23:20:24 +0200 Subject: [PATCH] Mostly redoes the CAS UI (#13965) * Mostly redoes the CAS UI * Fix warning --------- Co-authored-by: TiviPlus <572233640+TiviPlus@users.noreply.com> --- code/game/objects/structures/dropship_ammo.dm | 2 +- code/modules/condor/cas_chair.dm | 8 +- code/modules/condor/cas_shuttle.dm | 41 +-- .../tgui/interfaces/MarineCasship.tsx | 313 +++++++++++------- 4 files changed, 207 insertions(+), 157 deletions(-) diff --git a/code/game/objects/structures/dropship_ammo.dm b/code/game/objects/structures/dropship_ammo.dm index dfa518dd24a1b..b81430eafa003 100644 --- a/code/game/objects/structures/dropship_ammo.dm +++ b/code/game/objects/structures/dropship_ammo.dm @@ -580,7 +580,7 @@ S.start() /obj/structure/ship_ammo/cas/minirocket/illumination - name = "illumination rocket-launched flare stack" + name = "illumination rocket flare stack" desc = "A pack of laser guided mini rockets, each loaded with a payload of white-star illuminant and a parachute, while extremely ineffective at damaging the enemy, it is very effective at lighting the battlefield so marines can damage the enemy. Moving this will require some sort of lifter." icon_state = "minirocket_ilm" point_cost = 25 // Not a real rocket, so its cheap diff --git a/code/modules/condor/cas_chair.dm b/code/modules/condor/cas_chair.dm index 54ceb9fbaca29..e74c69be0292d 100644 --- a/code/modules/condor/cas_chair.dm +++ b/code/modules/condor/cas_chair.dm @@ -192,6 +192,11 @@ owner.turn_on_engines() if(PLANE_STATE_PREPARED) owner.turn_off_engines() + if(action == "eject") + if(owner.state != PLANE_STATE_ACTIVATED) + return + resisted_against() + ui.close() if(owner.state == PLANE_STATE_ACTIVATED) return @@ -219,9 +224,6 @@ if("change_weapon") var/selection = text2num(params["selection"]) owner.active_weapon = owner.equipments[selection] - if("deselect") - owner.active_weapon = null - . = TRUE if("cycle_attackdir") if(params["newdir"] == null) owner.attackdir = turn(owner.attackdir, 90) diff --git a/code/modules/condor/cas_shuttle.dm b/code/modules/condor/cas_shuttle.dm index ad66e4e27740b..c22e249cc470e 100644 --- a/code/modules/condor/cas_shuttle.dm +++ b/code/modules/condor/cas_shuttle.dm @@ -255,43 +255,22 @@ .["plane_mode"] = mode .["fuel_left"] = fuel_left .["fuel_max"] = fuel_max - .["ship_status"] = getStatusText() .["attackdir"] = uppertext(dir2text(attackdir)) + .["active_lasers"] = length(GLOB.active_cas_targets) + var/element_nbr = 1 .["all_weapons"] = list() - for(var/i in equipments) - var/obj/structure/dropship_equipment/cas/weapon/weapon = i - .["all_weapons"] += list(list("name"= sanitize(copytext(weapon.name,1,MAX_MESSAGE_LEN)), "ammo" = weapon?.ammo_equipped?.ammo_count, "eqp_tag" = element_nbr)) + for(var/obj/structure/dropship_equipment/cas/weapon/weapon in equipments) + .["all_weapons"] += list(list( + "name"= sanitize(copytext(weapon.name,1,MAX_MESSAGE_LEN)), + "ammo" = weapon.ammo_equipped?.ammo_count, + "max_ammo" = weapon.ammo_equipped?.max_ammo_count, + "ammo_name" = weapon.ammo_equipped?.name, + "eqp_tag" = element_nbr, + )) if(weapon == active_weapon) .["active_weapon_tag"] = element_nbr element_nbr++ - .["active_lasers"] = length(GLOB.active_cas_targets) - .["active_weapon_name"] = null - .["active_weapon_ammo"] = null - .["active_weapon_max_ammo"] = null - .["active_weapon_ammo_name"] = null - if(active_weapon) - .["active_weapon_name"] = sanitize(copytext(active_weapon?.name,1,MAX_MESSAGE_LEN)) - if(active_weapon.ammo_equipped) - .["active_weapon_ammo"] = active_weapon.ammo_equipped.ammo_count - .["active_weapon_max_ammo"] = active_weapon.ammo_equipped.max_ammo_count - .["active_weapon_ammo_name"] = active_weapon.ammo_equipped.name - -/obj/docking_port/mobile/marine_dropship/casplane/getStatusText() - switch(mode) - if(SHUTTLE_IDLE, SHUTTLE_RECHARGING) - switch(state) - if(PLANE_STATE_FLYING) - return "In-mission" - if(PLANE_STATE_PREPARED) - return "Engines online and ready for launch." - if(PLANE_STATE_ACTIVATED) - return "Engines Offline. Idle mode engaged." - if(SHUTTLE_IGNITING) - return "Accelerating to new destination." - if(SHUTTLE_PREARRIVAL) - return "Decelerating." - return "Unknown status" /// Used to intercept JUMP links. /obj/docking_port/mobile/marine_dropship/casplane/proc/handle_topic(datum/source, mob/user, list/href_list) diff --git a/tgui/packages/tgui/interfaces/MarineCasship.tsx b/tgui/packages/tgui/interfaces/MarineCasship.tsx index 98fffdc1a97da..364bb748dbe82 100644 --- a/tgui/packages/tgui/interfaces/MarineCasship.tsx +++ b/tgui/packages/tgui/interfaces/MarineCasship.tsx @@ -1,36 +1,41 @@ import { useBackend } from '../backend'; -import { Box, Button, LabeledList, ProgressBar, NoticeBox, Section } from '../components'; +import { Button, ProgressBar, NoticeBox, Stack } from '../components'; import { KEY_DOWN, KEY_ENTER, KEY_LEFT, KEY_RIGHT, KEY_SPACE, KEY_UP, KEY_W, KEY_D, KEY_S, KEY_A, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6 } from '../../common/keycodes'; import { Window } from '../layouts'; +// _DEFINES/cas.dm +const PLANE_STATE_ACTIVATED = 0; +const PLANE_STATE_DEACTIVATED = 1; +const PLANE_STATE_PREPARED = 2; +const PLANE_STATE_FLYING = 3; + type CasData = { plane_state: number; plane_mode: string; fuel_left: number; fuel_max: number; - ship_status: string; attackdir: string; all_weapons: CasWeapon[]; active_lasers: number; active_weapon_tag: number; - active_weapon_name: string | null; - active_weapon_ammo: number | null; - active_weapon_max_ammo: number | null; - active_weapon_ammo_name: string | null; }; type CasWeapon = { name: string; - ammo: number; + ammo?: number; + max_ammo?: number; + ammo_name?: string; eqp_tag: number; }; export const MarineCasship = (props, context) => { const { act, data } = useBackend(context); return ( - + { const keyCode = window.event ? event.which : event.keyCode; if (keyCode === KEY_ENTER) { @@ -57,7 +62,7 @@ export const MarineCasship = (props, context) => { if (keyCode === KEY_6) { act('deselect'); } - if (data.plane_state !== 0) { + if (data.plane_state !== PLANE_STATE_ACTIVATED) { let newdir = 0; switch (keyCode) { case KEY_UP: @@ -94,7 +99,11 @@ export const MarineCasship = (props, context) => { act('cycle_attackdir', { newdir: newdir }); } }}> - {data.plane_state === 0 ? : } + {data.plane_state === PLANE_STATE_ACTIVATED ? ( + + ) : ( + + )} ); @@ -102,23 +111,42 @@ export const MarineCasship = (props, context) => { const EnginesOff = (props, context) => { const { act, data } = useBackend(context); - const { ship_status, fuel_left, fuel_max } = data; + const { fuel_left, fuel_max } = data; return ( - <> -
{ship_status}
-
- -
- + + + - - )) - ) : ( - No equipment installed. - )} - - {data.active_weapon_name ? ( -
act('deselect')}>Deselect}> - {active_weapon_ammo === null || active_weapon_max_ammo === null ? ( - No ammo loaded - ) : ( - - - {active_weapon_ammo_name} - - - - - - )} -
- ) : ( -
- )} -
- -
- + + + + + + + ))} + + ); +}; + +const LaunchLandButton = (props, context) => { + const { act, data } = useBackend(context); + const { plane_state, plane_mode } = data; + return plane_state === PLANE_STATE_FLYING ? ( +