NanoMap QoL Changes (#25487)

* Introduce constants for map size and pixes per turf

* Scale markers with zoom

* Remove unused state

* Center map by default

* Fix zooming offset

* Add view reset button

* Fix exaggerated dragging when zoomed

* Remove zoom from local state

* Rewrite centering code

* Allow opening air alarms from map view

* Rename Marker to MarkerIcon

* Factor out generic map marker

* Implement name highlighting

* Fix oversight

* Save settings across UI opens

* Do not sanitize air alarm names

They are already automatically sanitized by Inferno

* Build and update tgui

* force ci

* Make labelStyle optional

* Make labelStyle optional again

* [ci skip]

* Build and update /tg/ui

* Reformat /tg/ui

* Autodec variables

[ci skip]

---------

Co-authored-by: Arthri <41360489+a@users.noreply.github.com>
Co-authored-by: /tg/ui Builder <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
This commit is contained in:
Arthri
2024-07-31 08:48:23 +00:00
committed by GitHub
co-authored by Arthri /tg/ui Builder <41898282+github-actions[bot]@users.noreply.github.com> Burzah
parent 2f91dcb5df
commit 69e7b890a5
14 changed files with 490 additions and 271 deletions
@@ -654,7 +654,7 @@
/obj/machinery/alarm/ui_data(mob/user)
var/list/data = list()
data["name"] = sanitize(name)
data["name"] = name
data["air"] = ui_air_status()
data["alarmActivated"] = alarmActivated || danger_level == ATMOS_ALARM_DANGER
data["thresholds"] = generate_thresholds_menu()
@@ -694,7 +694,7 @@
for(var/obj/machinery/atmospherics/unary/vent_pump/P as anything in alarm_area.vents)
var/list/vent_info = list()
vent_info["id_tag"] = P.UID()
vent_info["name"] = sanitize(P.name)
vent_info["name"] = P.name
vent_info["power"] = P.on
vent_info["direction"] = P.releasing
vent_info["checks"] = P.pressure_checks
@@ -707,7 +707,7 @@
for(var/obj/machinery/atmospherics/unary/vent_scrubber/S as anything in alarm_area.scrubbers)
var/list/scrubber_info = list()
scrubber_info["id_tag"] = S.UID()
scrubber_info["name"] = sanitize(S.name)
scrubber_info["name"] = S.name
scrubber_info["power"] = S.on
scrubber_info["scrubbing"] = S.scrubbing
scrubber_info["widenet"] = S.widenet
@@ -722,11 +722,11 @@
/obj/machinery/alarm/proc/get_console_data(mob/user)
var/list/data = list()
data["name"] = sanitize(name)
data["name"] = name
data["ref"] = "\ref[src]"
data["danger"] = max(danger_level, alarm_area.atmosalm)
var/area/A = get_area(src)
data["area"] = sanitize(A.name)
data["area"] = A.name
var/turf/T = get_turf(src)
data["x"] = T.x
data["y"] = T.y
+54
View File
@@ -1,9 +1,26 @@
#define MIN_ZOOM 1
#define MAX_ZOOM 8
#define MIN_TAB_INDEX 0
#define MAX_TAB_INDEX 1
/datum/ui_module/crew_monitor
name = "Crew monitor"
var/is_advanced = FALSE
var/viewing_current_z_level
/// If true, we'll see everyone, regardless of their suit sensors.
var/ignore_sensors = FALSE
/// The ID of the currently opened UI tab
var/tab_index = 0
/// The zoom level of the UI map view
var/zoom = 1
/// The X offset of the UI map
var/offset_x = 0
/// The Y offset of the UI map
var/offset_y = 0
/// A list of displayed names. Displayed names were intentionally chosen over ckeys,
/// refs, or uids, because exposing any of the aforementioned to the client could allow
/// an exploit to detect changelings on sensors.
var/highlighted_names = list()
/datum/ui_module/crew_monitor/ui_act(action, params)
if(..())
@@ -31,6 +48,33 @@
if(!is_advanced)
return
viewing_current_z_level = text2num(params["new_level"])
if("set_tab_index")
var/new_tab_index = text2num(params["tab_index"])
if(isnull(new_tab_index) || new_tab_index < MIN_TAB_INDEX || new_tab_index > MAX_TAB_INDEX)
return
tab_index = new_tab_index
if("set_zoom")
var/new_zoom = text2num(params["zoom"])
if(isnull(new_zoom) || new_zoom < MIN_ZOOM || new_zoom > MAX_ZOOM)
return
zoom = new_zoom
if("set_offset")
var/new_offset_x = text2num(params["offset_x"])
var/new_offset_y = text2num(params["offset_y"])
if(isnull(new_offset_x) || isnull(new_offset_y))
return
offset_x = new_offset_x
offset_y = new_offset_y
if("add_highlighted_name")
// Intentionally not sanitized as the name is not used for rendering
var/name = params["name"]
highlighted_names += list(name)
if("remove_highlighted_name")
// Intentionally not sanitized as the name is not used for rendering
var/name = params["name"]
highlighted_names -= list(name)
if("clear_highlighted_names")
highlighted_names = list()
/datum/ui_module/crew_monitor/ui_state(mob/user)
return GLOB.default_state
@@ -56,11 +100,16 @@
viewing_current_z_level = level_name_to_num(MAIN_STATION) // by default, set it to the station
data["viewing_current_z_level"] = viewing_current_z_level
data["tabIndex"] = tab_index
data["zoom"] = zoom
data["offsetX"] = offset_x
data["offsetY"] = offset_y
data["isAI"] = isAI(user)
data["isObserver"] = isobserver(user)
data["ignoreSensors"] = ignore_sensors
data["crewmembers"] = GLOB.crew_repository.health_data(viewing_current_z_level, ignore_sensors)
data["highlightedNames"] = highlighted_names
data["critThreshold"] = HEALTH_THRESHOLD_CRIT
return data
@@ -82,3 +131,8 @@
/datum/ui_module/crew_monitor/ghost/ui_state(mob/user)
return GLOB.observer_state
#undef MIN_ZOOM
#undef MAX_ZOOM
#undef MIN_TAB_INDEX
#undef MAX_TAB_INDEX