From c67a85d375f0d03b9cc40d5337ed397e476f4e3a Mon Sep 17 00:00:00 2001 From: ShadowLarkens Date: Wed, 14 Aug 2024 03:50:53 -0700 Subject: [PATCH] Add our_view to screen_loc_to_offset in view_audit_buttons (#85300) ## About The Pull Request Relative positions are calculated incorrectly in widescreen mode without this. To demonstrate, call ``` screen_loc_to_offset("EAST-4,SOUTH", null) = [-128,32] ``` When passed to offset_to_screen_loc, this will be clamped to (32,32) ``` offset_to_screen_loc(-128, 32, view = our_view) = "1,1" ``` And returned as 1,1 - moving the action button incorrectly. By including our_view in the call to `screen_loc_to_offset`, this entire problem is avoided. ## Why It's Good For The Game If someone sets a floating action button to be relative to EAST, SOUTH, or CENTER, they run into this bug. As far as I can tell, nothing currently does this and therefore it isn't meaningful, but I've run into this twice now downstream. ## Changelog :cl: fix: Fixed action buttons relative to EAST,SOUTH, or CENTER being improperly moved during view_audit_buttons() /:cl: --- code/_onclick/hud/hud.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index 4b4ea89b1d8..acee755d36c 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -585,7 +585,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list( listed_actions.check_against_view() palette_actions.check_against_view() for(var/atom/movable/screen/movable/action_button/floating_button as anything in floating_actions) - var/list/current_offsets = screen_loc_to_offset(floating_button.screen_loc) + var/list/current_offsets = screen_loc_to_offset(floating_button.screen_loc, our_view) // We set the view arg here, so the output will be properly hemm'd in by our new view floating_button.screen_loc = offset_to_screen_loc(current_offsets[1], current_offsets[2], view = our_view)