Skip to content

Commit

Permalink
Polish Dropship Weapons UI (#5298)
Browse files Browse the repository at this point in the history
# About the pull request

This PR is a follow up to #4812 polishing minor issues that were
discovered but not addressed in that PR.

- Fire missions can now be scrolled in target acquisition
- The target selection in equipment view is now the same as other panels
(and can be scrolled now too)
- Fixed deploying equipment like the spotlight and sentry
- ~~Partially~~ fixed camera view for sentry ~~(map size doesn't always
get set correctly some reason)~~
- Fixed the extra scrolling of fire missions
- Fixed the scrolling of target selection being a fixed quantity of 10
targets
- Improved menuing for the fire mission and strike sub menus
- Fixed strike ready messaging
- Map and Cam buttons are now mutually exclusive to one another (would
just break the byond UI)
- Camera now resets when a CAS flare is destroyed (unless fire mission
is underway)
- Camera now resets when sentry undeploys (if it was being used)
- Tweaked some button placements
- Fixed medevac layout
- Fixed direct fire (strike & equipment)
- Fixed camera views not handling /datum/component/overlay_lighting
correctly (fixed by using TILE_BOUND planes; but will note it won't work
completely correct if on a byond version prior to 515.1609 because of
https://www.byond.com/forum/post/2873835)
- Fixed some hard deletes in `/client/proc/clear_map` based on
tgstation/tgstation#61562
- Renamed nvgon and nvgoff to NV-ON and NV-OFF

# Explain why it's good for the game

Fixes issues such as (but not limited to): 

![target](https://github.com/cmss13-devs/cmss13/assets/76988376/7e1b8389-d466-4ef0-a436-a91c19c53c60)

![image](https://github.com/cmss13-devs/cmss13/assets/76988376/5c291ca5-204a-49c3-b281-32b7f4fc530a)

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>


![image](https://github.com/cmss13-devs/cmss13/assets/76988376/f8db9791-5c8d-4dc2-90bb-7a8b91f6fde9)

![image](https://github.com/cmss13-devs/cmss13/assets/76988376/c1a659af-8d05-408f-89e8-c95597cfc79a)

![image](https://github.com/cmss13-devs/cmss13/assets/76988376/858c307c-1914-48dc-98ed-5fba6c2429e0)

![light](https://github.com/cmss13-devs/cmss13/assets/76988376/755c270f-5269-473f-897f-354bba3a5353)

</details>


# Changelog
:cl: Drathek
ui: Polished various aspects of the new dropship weapons UI
fix: Fixed CAS direct firing
fix: Fixed Medevac buttons not moving the dropship (still currently
requires manual winch)
fix: Fixed camera_manager resizing the view incorrectly because of
overlay_lighting
refactor: Ported some hard delete fixes for maps.
/:cl:
  • Loading branch information
Drulikar committed Jan 6, 2024
1 parent f587c00 commit b6ed599
Show file tree
Hide file tree
Showing 21 changed files with 365 additions and 212 deletions.
3 changes: 2 additions & 1 deletion code/_onclick/hud/map_popups.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@
* anyway. they're effectively qdel'd.
*/
/client/proc/clear_map(map_name)
if(!map_name || !(map_name in screen_maps))
if(!map_name || !screen_maps[map_name])
return FALSE
for(var/atom/movable/screen/screen_obj in screen_maps[map_name])
screen_maps[map_name] -= screen_obj
remove_from_screen(screen_obj)
if(screen_obj.del_on_map_removal)
qdel(screen_obj)
screen_maps -= map_name
Expand Down
26 changes: 14 additions & 12 deletions code/game/camera_manager/camera_manager.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
. = ..()
map_name = "camera_manager_[REF(src)]_map"
cam_screen = new
cam_screen.icon = null
cam_screen.name = "screen"
cam_screen.assigned_map = map_name
cam_screen.del_on_map_removal = FALSE
cam_screen.screen_loc = "[map_name]:1,1"
cam_screen.appearance_flags |= TILE_BOUND
cam_background = new
cam_background.assigned_map = map_name
cam_background.del_on_map_removal = FALSE
cam_background.appearance_flags |= TILE_BOUND

cam_plane_masters = list()
for(var/plane in subtypesof(/atom/movable/screen/plane_master) - /atom/movable/screen/plane_master/blackness)
Expand All @@ -42,14 +45,17 @@
. = ..()
range_turfs = null
current_area = null
cam_plane_masters = null
QDEL_LIST_ASSOC_VAL(cam_plane_masters)
QDEL_NULL(cam_background)
QDEL_NULL(cam_screen)
if(current)
UnregisterSignal(current, COMSIG_PARENT_QDELETING)
current = null
last_camera_turf = null

/datum/component/camera_manager/proc/add_plane(atom/movable/screen/plane_master/instance)
instance.assigned_map = map_name
instance.appearance_flags |= TILE_BOUND
instance.del_on_map_removal = FALSE
if(instance.blend_mode_override)
instance.blend_mode = instance.blend_mode_override
Expand All @@ -61,8 +67,8 @@
var/client/user_client = user.client
if(!user_client)
return
user_client.register_map_obj(cam_background)
user_client.register_map_obj(cam_screen)
user_client.register_map_obj(cam_background)
for(var/plane_id in cam_plane_masters)
user_client.register_map_obj(cam_plane_masters[plane_id])

Expand All @@ -71,14 +77,10 @@
var/client/user_client = user.client
if(!user_client)
return
user_client.clear_map(cam_background)
user_client.clear_map(cam_screen)
for(var/plane_id in cam_plane_masters)
user_client.clear_map(cam_plane_masters[plane_id])
user_client.clear_map(map_name)

/datum/component/camera_manager/RegisterWithParent()
. = ..()
START_PROCESSING(SSdcs, src)
SEND_SIGNAL(parent, COMSIG_CAMERA_MAPNAME_ASSIGNED, map_name)
RegisterSignal(parent, COMSIG_CAMERA_REGISTER_UI, PROC_REF(register))
RegisterSignal(parent, COMSIG_CAMERA_UNREGISTER_UI, PROC_REF(unregister))
Expand All @@ -90,8 +92,6 @@

/datum/component/camera_manager/UnregisterFromParent()
. = ..()
STOP_PROCESSING(SSdcs, src)

UnregisterSignal(parent, COMSIG_CAMERA_REGISTER_UI)
UnregisterSignal(parent, COMSIG_CAMERA_UNREGISTER_UI)
UnregisterSignal(parent, COMSIG_CAMERA_SET_NVG)
Expand Down Expand Up @@ -134,6 +134,8 @@
target_x = x
target_y = y
target_z = z
target_width = w
target_height = h
update_area_camera()

/datum/component/camera_manager/proc/enable_nvg(source, power, matrixcol)
Expand All @@ -152,10 +154,10 @@

/datum/component/camera_manager/proc/sync_lighting_plane_alpha(lighting_alpha)
var/atom/movable/screen/plane_master/lighting/lighting = cam_plane_masters["[LIGHTING_PLANE]"]
if (lighting)
if(lighting)
lighting.alpha = lighting_alpha
var/atom/movable/screen/plane_master/lighting/exterior_lighting = cam_plane_masters["[EXTERIOR_LIGHTING_PLANE]"]
if (exterior_lighting)
if(exterior_lighting)
exterior_lighting.alpha = min(GLOB.minimum_exterior_lighting_alpha, lighting_alpha)

/**
Expand Down Expand Up @@ -215,7 +217,7 @@
var/turf/target = locate(current_area.center_x, current_area.center_y, target_z)

var/list/visible_things = isXRay ? range("[x_size]x[y_size]", target) : view("[x_size]x[y_size]", target)
src.render_objects(visible_things)
render_objects(visible_things)

/datum/component/camera_manager/proc/render_objects(list/visible_things)
var/list/visible_turfs = list()
Expand Down
22 changes: 20 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,14 +19,15 @@
var/datum/cas_signal/recorded_loc = null

var/obj/effect/firemission_guidance/guidance

var/atom/tracked_object

/datum/cas_fire_envelope/New()
..()
missions = list()

/datum/cas_fire_envelope/Destroy(force, ...)
linked_console = null
untrack_object()
return ..()

/datum/cas_fire_envelope/ui_data(mob/user)
Expand Down Expand Up @@ -151,7 +152,9 @@
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)
untrack_object()
if(!location && guidance)
for(var/mob/M in guidance.users)
if(istype(M) && M.client)
Expand All @@ -162,6 +165,21 @@
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))

/// Call to unregister the on_tracked_object_del behavior
/datum/cas_fire_envelope/proc/untrack_object()
if(tracked_object)
UnregisterSignal(tracked_object, COMSIG_PARENT_QDELETING)
tracked_object = null

/// Signal handler for when we are viewing a object in cam is qdel'd (but camera actually is actually some other obj)
/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
3 changes: 1 addition & 2 deletions code/game/machinery/computer/camera_console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@
SStgui.close_uis(src)
QDEL_NULL(current)
QDEL_NULL(cam_screen)
qdel(cam_screen)
QDEL_NULL(cam_background)
qdel(cam_background)
QDEL_NULL_LIST(cam_plane_masters)
last_camera_turf = null
concurrent_users = null
return ..()
Expand Down
79 changes: 46 additions & 33 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 @@ -62,17 +64,20 @@
/obj/structure/machinery/computer/dropship_weapons/attack_hand(mob/user)
if(..())
return
if(!allowed(user))

if(!allowed(user))
// TODO: Restore cas simulator
to_chat(user, SPAN_WARNING("Weapons modification access denied."))
return TRUE
// everyone can access the simulator, requested feature.
to_chat(user, SPAN_WARNING("Weapons modification access denied, attempting to launch simulation."))
/*to_chat(user, SPAN_WARNING("Weapons modification access denied, attempting to launch simulation."))
if(!selected_firemission)
to_chat(user, SPAN_WARNING("Firemission must be selected before attempting to run the simulation"))
return
return TRUE
tgui_interact(user)
return 1
return FALSE*/

user.set_interaction(src)
ui_interact(user)
Expand Down Expand Up @@ -100,7 +105,7 @@

/obj/structure/machinery/computer/dropship_weapons/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 0)
var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttle_tag)
if (!istype(dropship))
if(!istype(dropship))
return

var/screen_mode = 0
Expand Down Expand Up @@ -129,22 +134,22 @@
if(screen_mode != 3 || !selected_firemission || dropship.mode != SHUTTLE_CALL)
update_location(user, null)

ui_data(user)
if(!tacmap.map_holder)
var/level = SSmapping.levels_by_trait(tacmap.targeted_ztrait)
tacmap.map_holder = SSminimaps.fetch_tacmap_datum(level[1], tacmap.allowed_flags)
user.client.register_map_obj(tacmap.map_holder.map)
tgui_interact(user)

/obj/structure/machinery/computer/dropship_weapons/tgui_interact(mob/user, datum/tgui/ui)
if(!registered)
var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttle_tag)
RegisterSignal(dropship, COMSIG_DROPSHIP_ADD_EQUIPMENT, PROC_REF(equipment_update))
RegisterSignal(dropship, COMSIG_DROPSHIP_REMOVE_EQUIPMENT, PROC_REF(equipment_update))
registered=TRUE
registered = TRUE

if(!tacmap.map_holder)
var/level = SSmapping.levels_by_trait(tacmap.targeted_ztrait)
tacmap.map_holder = SSminimaps.fetch_tacmap_datum(level[1], tacmap.allowed_flags)

ui = SStgui.try_update_ui(user, src, ui)
if (!ui)
if(!ui)
user.client.register_map_obj(tacmap.map_holder.map)
SEND_SIGNAL(src, COMSIG_CAMERA_REGISTER_UI, user)
ui = new(user, src, "DropshipWeaponsConsole", "Weapons Console")
ui.open()
Expand Down Expand Up @@ -255,7 +260,7 @@
switch(action)
if("button_push")
playsound(src, get_sfx("terminal_button"), 25, FALSE)
return TRUE
return FALSE

if("select_equipment")
var/base_tag = params["equipment_id"]
Expand Down Expand Up @@ -303,12 +308,13 @@
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
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 @@ -329,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 @@ -340,26 +347,31 @@
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)
if(!DEW)
return FALSE

var/datum/cas_signal/sig = get_cas_signal(camera_target_id)

if(!sig)
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 All @@ -384,13 +396,8 @@
var/x_offset_value = params["x_offset_value"]
var/y_offset_value = params["y_offset_value"]

var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction]
var/datum/cas_signal/cas_sig
for(var/X in cas_group.cas_signals)
var/datum/cas_signal/LT = X
if(LT.target_id == target_id && LT.valid_signal())
cas_sig = LT
break
camera_target_id = target_id
var/datum/cas_signal/cas_sig = get_cas_signal(camera_target_id, valid_only = TRUE)
// we don't want rapid offset changes to trigger admin warnings
// and block the user from accessing TGUI
// we change the minute_count
Expand All @@ -408,12 +415,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 @@ -447,24 +456,28 @@

/obj/structure/machinery/computer/dropship_weapons/proc/get_weapon(eqp_tag)
var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttle_tag)
for(var/obj/structure/dropship_equipment/equipment in dropship.equipments)
if(istype(equipment, /obj/structure/dropship_equipment/weapon))
//is weapon
if(selected_equipment == equipment)
return equipment
var/obj/structure/dropship_equipment/equipment = dropship.equipments[eqp_tag]
if(istype(equipment, /obj/structure/dropship_equipment/weapon))
//is weapon
return equipment
return

/obj/structure/machinery/computer/dropship_weapons/proc/get_cas_signal(target_ref)
/obj/structure/machinery/computer/dropship_weapons/proc/get_cas_signal(target_ref, valid_only = FALSE)
if(!target_ref)
return

var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction]
for(var/datum/cas_signal/sig in cas_group.cas_signals)
if(sig.target_id == target_ref)
if(valid_only && !sig.valid_signal())
continue
return sig


/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
Loading

0 comments on commit b6ed599

Please sign in to comment.