mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-22 04:24:20 +01:00
Makes alt-click more responsive and fixes its item handling (#31366)
* make alt click inspect responsive and fix a bug * switch to list operation wow
This commit is contained in:
@@ -112,7 +112,7 @@ SUBSYSTEM_DEF(statpanels)
|
||||
for(var/image/target_image as anything in target.images)
|
||||
if(!target_image.loc || target_image.loc.loc != target_mob.listed_turf || !target_image.override)
|
||||
continue
|
||||
overrides += target_image.loc
|
||||
overrides[target_image.loc] = TRUE
|
||||
|
||||
var/list/atoms_to_display = list(target_mob.listed_turf)
|
||||
for(var/atom/movable/turf_content as anything in target_mob.listed_turf)
|
||||
@@ -120,7 +120,7 @@ SUBSYSTEM_DEF(statpanels)
|
||||
continue
|
||||
if(turf_content.invisibility > target_mob.see_invisible)
|
||||
continue
|
||||
if(turf_content in overrides)
|
||||
if(overrides[turf_content])
|
||||
continue
|
||||
if(turf_content.IsObscured())
|
||||
continue
|
||||
@@ -129,6 +129,8 @@ SUBSYSTEM_DEF(statpanels)
|
||||
/// Set the atoms we're meant to display
|
||||
var/datum/object_window_info/obj_window = istype(target.obj_window) ? target.obj_window : new(target)
|
||||
obj_window.atoms_to_show = atoms_to_display
|
||||
// don't generate icons for stuff the user will not see
|
||||
obj_window.atoms_to_imagify &= atoms_to_display
|
||||
refresh_client_obj_view(target, obj_window.min_index, obj_window.max_index)
|
||||
|
||||
/datum/controller/subsystem/statpanels/proc/refresh_client_obj_view(client/refresh, min_index = 0, max_index = 30)
|
||||
@@ -160,6 +162,8 @@ SUBSYSTEM_DEF(statpanels)
|
||||
var/list/turf_items = list()
|
||||
var/i = 0
|
||||
var/client_uid = load_from.UID()
|
||||
// While an item's icon is being generated, we send no image URL and let the frontend render an empty slot.
|
||||
var/static/no_image_url = ""
|
||||
for(var/atom/turf_item as anything in obj_window.atoms_to_show)
|
||||
// Limit what we send to the client's rendered section.
|
||||
i++
|
||||
@@ -169,7 +173,11 @@ SUBSYSTEM_DEF(statpanels)
|
||||
// First, we fill up the list of refs to display
|
||||
// If we already have one, just use that
|
||||
var/existing_image = already_seen[turf_item]
|
||||
// rows that are still loading are still sent, we just won't send an image, frontend will hotswap it in
|
||||
if(existing_image == OBJ_IMAGE_LOADING)
|
||||
var/obj_m5_uid_loading = turf_item.MD5_UID()
|
||||
load_from.m5_uid_cache[obj_m5_uid_loading] = turf_item.unique_datum_id
|
||||
turf_items["[i]"] = list("[turf_item.name]", obj_m5_uid_loading, no_image_url, "", client_uid)
|
||||
continue
|
||||
// We already have it. Success!
|
||||
|
||||
@@ -254,6 +262,10 @@ SUBSYSTEM_DEF(statpanels)
|
||||
var/client/parent
|
||||
/// Are we currently tracking a turf?
|
||||
var/actively_tracking = FALSE
|
||||
/// Turf we are currently listening to for content changes.
|
||||
var/turf/tracked_turf
|
||||
/// Debounce flag for immediate refreshes.
|
||||
var/pending_turf_refresh = FALSE
|
||||
/// The minimum index currently sent to the client.
|
||||
var/min_index = 0
|
||||
/// The maximum index currently sent to the client.
|
||||
@@ -264,6 +276,9 @@ SUBSYSTEM_DEF(statpanels)
|
||||
src.parent = parent
|
||||
|
||||
/datum/object_window_info/Destroy(force, ...)
|
||||
if(tracked_turf)
|
||||
UnregisterSignal(tracked_turf, list(COMSIG_ATOM_ENTERED, COMSIG_ATOM_EXITED, COMSIG_TURF_CHANGE))
|
||||
tracked_turf = null
|
||||
atoms_to_show = null
|
||||
atoms_to_images = null
|
||||
atoms_to_imagify = null
|
||||
@@ -303,6 +318,13 @@ SUBSYSTEM_DEF(statpanels)
|
||||
/datum/object_window_info/proc/start_turf_tracking()
|
||||
if(actively_tracking)
|
||||
stop_turf_tracking()
|
||||
var/turf/new_tracked = parent?.mob?.listed_turf
|
||||
if(new_tracked)
|
||||
// We're setting up signals here so updates are instant rather than laggy and slow.
|
||||
tracked_turf = new_tracked
|
||||
RegisterSignal(tracked_turf, COMSIG_ATOM_ENTERED, PROC_REF(on_tracked_turf_entered))
|
||||
RegisterSignal(tracked_turf, COMSIG_ATOM_EXITED, PROC_REF(on_tracked_turf_exited))
|
||||
RegisterSignal(tracked_turf, COMSIG_TURF_CHANGE, PROC_REF(on_tracked_turf_change))
|
||||
var/static/list/connections = list(
|
||||
COMSIG_MOVABLE_MOVED = PROC_REF(on_mob_move),
|
||||
COMSIG_MOB_LOGOUT = PROC_REF(on_mob_logout),
|
||||
@@ -312,8 +334,38 @@ SUBSYSTEM_DEF(statpanels)
|
||||
|
||||
/datum/object_window_info/proc/stop_turf_tracking()
|
||||
DeleteComponent(/datum/component/connect_mob_behalf)
|
||||
if(tracked_turf)
|
||||
UnregisterSignal(tracked_turf, list(COMSIG_ATOM_ENTERED, COMSIG_ATOM_EXITED, COMSIG_TURF_CHANGE))
|
||||
tracked_turf = null
|
||||
pending_turf_refresh = FALSE
|
||||
actively_tracking = FALSE
|
||||
|
||||
/datum/object_window_info/proc/queue_listedturf_refresh()
|
||||
if(pending_turf_refresh)
|
||||
return
|
||||
pending_turf_refresh = TRUE
|
||||
// This accumulates all of our updates and does one refresh rather than calling a dozen refreshes when a dozen things change
|
||||
addtimer(CALLBACK(src, PROC_REF(do_listedturf_refresh)), 1)
|
||||
|
||||
/datum/object_window_info/proc/do_listedturf_refresh()
|
||||
pending_turf_refresh = FALSE
|
||||
if(!parent?.mob?.listed_turf)
|
||||
return
|
||||
// If the user moved away, let the existing adjacency logic close the tab.
|
||||
SSstatpanels.set_turf_examine_tab(parent, parent.mob)
|
||||
|
||||
/datum/object_window_info/proc/on_tracked_turf_entered(atom/source, atom/movable/entered, atom/old_loc)
|
||||
SIGNAL_HANDLER // COMSIG_ATOM_ENTERED
|
||||
queue_listedturf_refresh()
|
||||
|
||||
/datum/object_window_info/proc/on_tracked_turf_exited(atom/source, atom/movable/exiting, direction)
|
||||
SIGNAL_HANDLER // COMSIG_ATOM_EXITED
|
||||
queue_listedturf_refresh()
|
||||
|
||||
/datum/object_window_info/proc/on_tracked_turf_change(atom/source)
|
||||
SIGNAL_HANDLER // COMSIG_TURF_CHANGE
|
||||
queue_listedturf_refresh()
|
||||
|
||||
/datum/object_window_info/proc/on_mob_move(mob/source)
|
||||
SIGNAL_HANDLER
|
||||
var/turf/listed = source.listed_turf
|
||||
@@ -330,7 +382,7 @@ SUBSYSTEM_DEF(statpanels)
|
||||
SIGNAL_HANDLER
|
||||
atoms_to_show -= deleted
|
||||
atoms_to_imagify -= deleted
|
||||
atoms_to_images -= deleted
|
||||
atoms_to_images[deleted] = null
|
||||
|
||||
/mob/proc/set_listed_turf(turf/new_turf)
|
||||
listed_turf = new_turf
|
||||
@@ -347,3 +399,6 @@ SUBSYSTEM_DEF(statpanels)
|
||||
else
|
||||
client.stat_panel.send_message("remove_listedturf")
|
||||
client.obj_window.stop_turf_tracking()
|
||||
// Don't generate icons when the tab's closed.
|
||||
client.obj_window.atoms_to_show.Cut()
|
||||
client.obj_window.atoms_to_imagify.Cut()
|
||||
|
||||
Reference in New Issue
Block a user