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 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
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
Drulikar marked this conversation as resolved.
Show resolved Hide resolved

/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 @@ -257,7 +262,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 @@ -305,12 +310,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 @@ -331,6 +337,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,26 +349,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 @@ -386,13 +398,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 @@ -410,12 +417,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 @@ -449,24 +458,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