Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish Dropship Weapons UI #5298

Merged
merged 15 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 18 additions & 2 deletions code/game/cas_manager/datums/cas_fire_envelope.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
var/datum/cas_signal/recorded_loc = null

var/obj/effect/firemission_guidance/guidance

var/atom/tracked_object
Drulikar marked this conversation as resolved.
Show resolved Hide resolved

/datum/cas_fire_envelope/New()
..()
Expand Down Expand Up @@ -151,7 +151,10 @@
recorded_loc = marker
return TRUE

/datum/cas_fire_envelope/proc/change_current_loc(location)
/datum/cas_fire_envelope/proc/change_current_loc(location, atom/object)
if(object)
if(tracked_object)
UnregisterSignal(tracked_object, COMSIG_PARENT_QDELETING)
if(!location && guidance)
for(var/mob/M in guidance.users)
if(istype(M) && M.client)
Expand All @@ -162,6 +165,19 @@
guidance = new /obj/effect/firemission_guidance()
guidance.forceMove(location)
guidance.updateCameras(linked_console)
if(object)
tracked_object = object
RegisterSignal(tracked_object, COMSIG_PARENT_QDELETING, PROC_REF(on_tracked_object_del))

/datum/cas_fire_envelope/proc/untrack_object()
if(tracked_object)
UnregisterSignal(tracked_object, COMSIG_PARENT_QDELETING)
tracked_object = null

/datum/cas_fire_envelope/proc/on_tracked_object_del(atom/target)
SIGNAL_HANDLER
tracked_object = null
change_current_loc()

/datum/cas_fire_envelope/proc/user_is_guided(user)
return guidance && (user in guidance.users)
Expand Down
27 changes: 22 additions & 5 deletions code/game/machinery/computer/dropship_weapons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
var/camera_width = 11
var/camera_height = 11
var/camera_map_name
///Tracks equipment with a camera that is deployed and we are viewing
var/obj/structure/dropship_equipment/camera_area_equipment = null

var/registered = FALSE

Expand Down Expand Up @@ -305,12 +307,14 @@
var/mount_point = equipment.ship_base.attach_id
if(mount_point != equipment_tag)
continue
if (istype(equipment, /obj/structure/dropship_equipment/sentry_holder))
if(istype(equipment, /obj/structure/dropship_equipment/sentry_holder))
var/obj/structure/dropship_equipment/sentry_holder/sentry = equipment
var/obj/structure/machinery/defenses/sentry/defense = sentry.deployed_turret
if (defense.has_camera)
if(defense.has_camera)
defense.set_range()
var/datum/shape/rectangle/current_bb = defense.range_bounds
camera_area_equipment = sentry
// TODO: Determine why the width/height only properly updates if the camera was previously looking at nothing (or if view closed and returned to)
SEND_SIGNAL(src, COMSIG_CAMERA_SET_AREA, current_bb.center_x, current_bb.center_y, defense.loc.z, current_bb.width, current_bb.height)
return TRUE

Expand All @@ -331,6 +335,7 @@
if(medevac.linked_stretcher)
SEND_SIGNAL(src, COMSIG_CAMERA_SET_TARGET, medevac.linked_stretcher, 5, 5)
return TRUE

if("fulton-target")
var/equipment_tag = params["equipment_id"]
for(var/obj/structure/dropship_equipment/equipment as anything in shuttle.equipments)
Expand All @@ -342,6 +347,7 @@
var/target_ref = params["ref"]
fulton.automate_interact(user, target_ref)
return TRUE

if("fire-weapon")
var/weapon_tag = params["eqp_tag"]
var/obj/structure/dropship_equipment/weapon/DEW = get_weapon(weapon_tag)
Expand All @@ -354,14 +360,19 @@
return FALSE

selected_equipment = DEW
ui_open_fire(user, shuttle, camera_target_id)
if(ui_open_fire(user, shuttle, camera_target_id))
if(firemission_envelope)
firemission_envelope.untrack_object()
return TRUE

if("deploy-equipment")
var/equipment_tag = params["equipment_id"]
for(var/obj/structure/dropship_equipment/equipment as anything in shuttle.equipments)
var/mount_point = equipment.ship_base.attach_id
if(mount_point != equipment_tag)
continue
if(camera_area_equipment == equipment)
set_camera_target(null)
equipment.equipment_interact(user)
return TRUE

Expand Down Expand Up @@ -410,12 +421,14 @@
current.y + dy,
current.z)

firemission_envelope.change_current_loc(new_target)

camera_area_equipment = null
firemission_envelope.change_current_loc(new_target, cas_sig)
return TRUE

if("nvg-enable")
SEND_SIGNAL(src, COMSIG_CAMERA_SET_NVG, 5, "#7aff7a")
return TRUE

if("nvg-disable")
SEND_SIGNAL(src, COMSIG_CAMERA_CLEAR_NVG)
return TRUE
Expand Down Expand Up @@ -467,6 +480,10 @@


/obj/structure/machinery/computer/dropship_weapons/proc/set_camera_target(target_ref)
camera_area_equipment = null
if(firemission_envelope)
firemission_envelope.untrack_object()

var/datum/cas_signal/target = get_cas_signal(target_ref)
camera_target_id = target_ref
if(!target)
Expand Down
20 changes: 12 additions & 8 deletions code/modules/cm_marines/dropship_equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@

/obj/structure/dropship_equipment/mg_holder/ui_data(mob/user)
. = list()
var/is_deployed = deployed_mg.loc == src
var/is_deployed = deployed_mg.loc != src
.["name"] = name
.["selection_state"] = list()
.["health"] = health
.["health_max"] = 100
.["health_max"] = initial(health)
.["rounds"] = deployed_mg.rounds
.["max_rounds"] = deployed_mg.rounds_max
.["deployed"] = is_deployed
Expand Down Expand Up @@ -486,8 +486,6 @@
point_cost = 0


#define LIGHTING_MAX_LUMINOSITY_SHIPLIGHTS 12

/obj/structure/dropship_equipment/electronics/spotlights
name = "\improper AN/LEN-15 Spotlight"
shorthand = "Spotlight"
Expand All @@ -502,7 +500,7 @@
if(spotlights_cooldown > world.time)
to_chat(user, SPAN_WARNING("[src] is busy."))
return //prevents spamming deployment/undeployment
if(luminosity != brightness)
if(!light_on)
set_light(brightness)
icon_state = "spotlights_on"
to_chat(user, SPAN_NOTICE("You turn on [src]."))
Expand All @@ -515,13 +513,13 @@
/obj/structure/dropship_equipment/electronics/spotlights/update_equipment()
..()
if(ship_base)
if(luminosity != brightness)
if(!light_on)
icon_state = "spotlights_off"
else
icon_state = "spotlights_on"
else
icon_state = "spotlights"
if(luminosity)
if(light_on)
set_light(0)

/obj/structure/dropship_equipment/electronics/spotlights/on_launch()
Expand All @@ -530,7 +528,13 @@
/obj/structure/dropship_equipment/electronics/spotlights/on_arrival()
set_light(brightness)

#undef LIGHTING_MAX_LUMINOSITY_SHIPLIGHTS
/obj/structure/dropship_equipment/electronics/spotlights/ui_data(mob/user)
. = list()
var/is_deployed = light_on
.["name"] = name
.["health"] = health
.["health_max"] = initial(health)
.["deployed"] = is_deployed



Expand Down
22 changes: 18 additions & 4 deletions tgui/packages/tgui/interfaces/DropshipWeaponsConsole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SupportMfdPanel } from './MfdPanels/SupportPanel';
import { FiremissionMfdPanel } from './MfdPanels/FiremissionPanel';
import { TargetAquisitionMfdPanel } from './MfdPanels/TargetAquisition';
import { mfdState } from './MfdPanels/stateManagers';
import { otherMfdState } from './MfdPanels/stateManagers';
import { Dpad } from './common/Dpad';

export interface DropshipProps {
Expand Down Expand Up @@ -271,6 +272,7 @@ const WeaponsMfdPanel = (props, context) => {

const BaseMfdPanel = (props: MfdProps, context) => {
const { setPanelState } = mfdState(context, props.panelStateId);
const { otherPanelState } = otherMfdState(context, props.otherPanelStateId);

return (
<MfdPanel
Expand All @@ -289,8 +291,14 @@ const BaseMfdPanel = (props: MfdProps, context) => {
]}
bottomButtons={[
{},
{ children: 'MAPS', onClick: () => setPanelState('map') },
{ children: 'CAMS', onClick: () => setPanelState('camera') },
{
children: otherPanelState !== 'map' ? 'MAPS' : undefined,
onClick: () => setPanelState('map'),
},
{
children: otherPanelState !== 'camera' ? 'CAMS' : undefined,
onClick: () => setPanelState('camera'),
},
]}>
<Box className="NavigationMenu">
<div className="welcome-page">
Expand Down Expand Up @@ -337,7 +345,10 @@ export const DropshipWeaponsConsole = () => {
<Box className="WeaponsConsoleBackground">
<Stack horizontal className="WeaponsConsole">
<Stack.Item>
<PrimaryPanel panelStateId="left-screen" />
<PrimaryPanel
panelStateId="left-screen"
otherPanelStateId="right-screen"
/>
</Stack.Item>
<Stack.Item>
<Stack vertical>
Expand All @@ -356,7 +367,10 @@ export const DropshipWeaponsConsole = () => {
</Stack.Item>

<Stack.Item>
<PrimaryPanel panelStateId="right-screen" />
<PrimaryPanel
panelStateId="right-screen"
otherPanelStateId="left-screen"
/>
</Stack.Item>
</Stack>
</Box>
Expand Down
20 changes: 11 additions & 9 deletions tgui/packages/tgui/interfaces/MfdPanels/FiremissionPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ const FiremissionMfdHomePage = (props: MfdProps, context) => {
const firemission =
data.firemission_data.length > x ? data.firemission_data[x] : undefined;
return {
children: firemission ? (
<div>
FM {x + 1} <br /> {firemission?.name}
</div>
) : undefined,
children: firemission ? <div>FM {x + 1}</div> : undefined,
onClick: () => setSelectedFm(firemission?.name),
};
};
Expand Down Expand Up @@ -111,7 +107,7 @@ const FiremissionMfdHomePage = (props: MfdProps, context) => {
}
: {},
{
children: <Icon name="arrow-up" />,
children: fmOffset > 0 ? <Icon name="arrow-up" /> : undefined,
onClick: () => {
if (fmOffset >= 1) {
setFmOffset(fmOffset - 1);
Expand All @@ -128,9 +124,12 @@ const FiremissionMfdHomePage = (props: MfdProps, context) => {
{},
{},
{
children: <Icon name="arrow-down" />,
children:
fmOffset + 10 < data.firemission_data?.length ? (
<Icon name="arrow-down" />
) : undefined,
onClick: () => {
if (fmOffset + 8 < data.firemission_data.length) {
if (fmOffset + 10 < data.firemission_data?.length) {
setFmOffset(fmOffset + 1);
}
},
Expand Down Expand Up @@ -212,7 +211,10 @@ const ViewFiremissionMfdPanel = (
bottomButtons={[
{
children: 'EXIT',
onClick: () => setPanelState(''),
onClick: () => {
setSelectedFm(undefined);
setPanelState('');
},
},
]}
rightButtons={editFm === true ? rightButtons : []}>
Expand Down
5 changes: 4 additions & 1 deletion tgui/packages/tgui/interfaces/MfdPanels/MGPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EquipmentContext, MGSpec } from './types';

const MgPanel = (props: DropshipEquipment) => {
const mgData = props.data as MGSpec;

return (
<Stack>
<Stack.Item width="100px">
Expand Down Expand Up @@ -44,6 +45,8 @@ export const MgMfdPanel = (props: MfdProps, context) => {
const { setPanelState } = mfdState(context, props.panelStateId);
const { equipmentState } = useEquipmentState(context, props.panelStateId);
const mg = data.equipment_data.find((x) => x.mount_point === equipmentState);
const deployLabel = (mg?.data?.deployed ?? 0) === 1 ? 'RETRACT' : 'DEPLOY';

return (
<MfdPanel
panelStateId={props.panelStateId}
Expand All @@ -52,7 +55,7 @@ export const MgMfdPanel = (props: MfdProps, context) => {
]}
leftButtons={[
{
children: 'DEPLOY',
children: deployLabel,
onClick: () =>
act('deploy-equipment', { equipment_id: mg?.mount_point }),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface MfdProps {
rightButtons?: Array<ButtonProps>;
bottomButtons?: Array<ButtonProps>;
children?: InfernoNode;
otherPanelStateId?: string;
}

export const MfdButton = (props: ButtonProps, context) => {
Expand Down
3 changes: 2 additions & 1 deletion tgui/packages/tgui/interfaces/MfdPanels/SentryPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const SentryMfdPanel = (props: MfdProps, context) => {
);
const deployLabel =
(sentry?.data?.deployed ?? 0) === 1 ? 'RETRACT' : 'DEPLOY';

return (
<MfdPanel
panelStateId={props.panelStateId}
Expand All @@ -70,7 +71,7 @@ export const SentryMfdPanel = (props: MfdProps, context) => {
act('deploy-equipment', { equipment_id: sentry?.mount_point }),
},
{
children: 'CAMERA',
children: sentry?.data?.camera_available ? 'CAMERA' : undefined,
onClick: () =>
act('set-camera-sentry', { equipment_id: sentry?.mount_point }),
},
Expand Down
5 changes: 4 additions & 1 deletion tgui/packages/tgui/interfaces/MfdPanels/SpotlightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export const SpotlightMfdPanel = (props: MfdProps, context) => {
const spotlight = data.equipment_data.find(
(x) => x.mount_point === equipmentState
);
const deployLabel =
(spotlight?.data?.deployed ?? 0) === 1 ? 'DISABLE' : 'ENABLE';

return (
<MfdPanel
panelStateId={props.panelStateId}
Expand All @@ -41,7 +44,7 @@ export const SpotlightMfdPanel = (props: MfdProps, context) => {
]}
leftButtons={[
{
children: 'DEPLOY',
children: deployLabel,
onClick: () =>
act('deploy-equipment', { equipment_id: spotlight?.mount_point }),
},
Expand Down
Loading
Loading