Files
Waterpig d3d3a12540 The big fix for pixel_x and pixel_y use cases. (#90124)
## About The Pull Request

516 requires float layered overlays to be using pixel_w and pixel_z
instead of pixel_x and pixel_y respectively, unless we want
visual/layering errors. This makes sense, as w,z are for visual effects
only. Sadly seems we were not entirely consistent in this, and many
things seem to have been using x,y incorrectly.

This hopefully fixes that, and thus also fixes layering issues. Complete
1:1 compatibility not guaranteed.

I did the lazy way suggested to me by SmArtKar to speed it up (Runtiming
inside apply_overlays), and this is still included in the PR to flash
out possible issues in a TM (Plus I will need someone to grep the
runtimes for me after the TM period to make sure nothing was missed).
After this is done I'll remove all these extra checks.

Lints will probably be failing for a bit, got to wait for [this
update](https://github.com/SpaceManiac/SpacemanDMM/commit/4b77cd487d0a7b6a069df20356b701af5b20489d)
to them to make it into release. Or just unlint the lines, though that's
probably gonna produce code debt

## Why It's Good For The Game

Fixes this massive 516 mess, hopefully.

closes #90281

## Changelog
🆑
refactor: Changed many of our use cases for pixel_x and pixel_y
correctly into pixel_w and pixel_z, fixing layering issues in the
process.
/🆑

---------

Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
Co-authored-by: SmArtKar <master.of.bagets@gmail.com>
2025-03-28 14:18:45 +00:00

70 lines
2.3 KiB
Plaintext

#define COMP_BAR_OVERLAY_VERTICAL "Vertical"
#define COMP_BAR_OVERLAY_HORIZONTAL "Horizontal"
/**
* # Bar Overlay Component
*
* Basically an advanced verion of object overlay component that shows a horizontal/vertical bar.
* Requires a BCI shell.
*/
/obj/item/circuit_component/object_overlay/bar
display_name = "Bar Overlay"
desc = "Requires a BCI shell. A component that shows a bar overlay atop an object, ranging from 0 to 100."
category = "BCI"
var/datum/port/input/option/bar_overlay_options
var/datum/port/input/bar_number
var/overlay_limit = 10
/obj/item/circuit_component/object_overlay/bar/populate_ports()
. = ..()
bar_number = add_input_port("Number", PORT_TYPE_NUMBER)
/obj/item/circuit_component/object_overlay/bar/populate_options()
var/static/component_options_bar = list(
COMP_BAR_OVERLAY_VERTICAL = "barvert",
COMP_BAR_OVERLAY_HORIZONTAL = "barhoriz"
)
bar_overlay_options = add_option_port("Bar Overlay Options", component_options_bar)
options_map = component_options_bar
/obj/item/circuit_component/object_overlay/bar/show_to_owner(atom/target_atom, mob/living/owner)
if(LAZYLEN(active_overlays) >= overlay_limit)
return
var/current_option = bar_overlay_options.value
if(active_overlays[target_atom])
QDEL_NULL(active_overlays[target_atom])
var/number_clear = clamp(bar_number.value, 0, 100)
if(current_option == COMP_BAR_OVERLAY_HORIZONTAL)
number_clear = round(number_clear / 6.25) * 6.25
else if(current_option == COMP_BAR_OVERLAY_VERTICAL)
number_clear = round(number_clear / 10) * 10
var/image/cool_overlay = image(icon = 'icons/hud/screen_bci.dmi', loc = target_atom, icon_state = "[options_map[current_option]][number_clear]", layer = RIPPLE_LAYER)
SET_PLANE_EXPLICIT(cool_overlay, ABOVE_LIGHTING_PLANE, target_atom)
if(image_pixel_x.value != null)
cool_overlay.pixel_w = image_pixel_x.value
if(image_pixel_y.value != null)
cool_overlay.pixel_z = image_pixel_y.value
var/datum/atom_hud/alternate_appearance/basic/one_person/alt_appearance = target_atom.add_alt_appearance(
/datum/atom_hud/alternate_appearance/basic/one_person,
"bar_overlay_[REF(src)]",
cool_overlay,
null,
owner,
)
alt_appearance.show_to(owner)
active_overlays[target_atom] = WEAKREF(alt_appearance)
#undef COMP_BAR_OVERLAY_VERTICAL
#undef COMP_BAR_OVERLAY_HORIZONTAL