Skip to content

Commit

Permalink
fixes alignment issues with macros/micros/etc (#5992)
Browse files Browse the repository at this point in the history
closes #5875

Co-authored-by: silicons <[email protected]>
  • Loading branch information
silicons and silicons authored Sep 19, 2023
1 parent 299b58b commit 816a22c
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 30 deletions.
8 changes: 4 additions & 4 deletions code/game/atoms/atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1081,21 +1081,21 @@
return base_pixel_y

/**
* get the pixel_x needed to adjust an atom on our turf **to the position of our visual center**
* get the pixel_x needed to adjust ourselves to be centered on our turf. this is used for alignment with buckles and whatnot.
*
* e.g. even if we are a 3x3 sprite with -32 x/y offsets, this would be 0
* if we were, for some reason, a 4x4 with -32 x/y, this would probably be 16/16 x/y.
*/
/atom/proc/get_centering_pixel_x_offset(dir, atom/aligning)
/atom/proc/get_centering_pixel_x_offset(dir)
return base_pixel_x + (icon_x_dimension - WORLD_ICON_SIZE) / 2

/**
* get the pixel_y needed to adjust an atom on our turf **to the position of our visual center**
* get the pixel_y needed to adjust ourselves to be centered on our turf. this is used for alignment with buckles and whatnot.
*
* e.g. even if we are a 3x3 sprite with -32 x/y offsets, this would be 0
* if we were, for some reason, a 4x4 with -32 x/y, this would probably be 16/16 x/y.
*/
/atom/proc/get_centering_pixel_y_offset(dir, atom/aligning)
/atom/proc/get_centering_pixel_y_offset(dir)
return base_pixel_y + (icon_y_dimension - WORLD_ICON_SIZE) / 2

/// Setter for the `base_pixel_x` variable to append behavior related to its changing.
Expand Down
10 changes: 8 additions & 2 deletions code/game/atoms/movable/movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,20 @@
update_emissive_layers()

//? Pixel Offsets
/atom/movable/get_centering_pixel_x_offset(dir, atom/aligning)
/atom/movable/get_centering_pixel_x_offset(dir)
. = ..()
. *= icon_scale_x

/atom/movable/get_centering_pixel_y_offset(dir, atom/aligning)
/atom/movable/get_centering_pixel_y_offset(dir)
. = ..()
. *= icon_scale_y

/atom/movable/proc/get_buckled_x_offset(atom/buckled)
return buckle_pixel_x

/atom/movable/proc/get_buckled_y_offset(atom/buckled)
return buckle_pixel_y

//? Emissives
/atom/movable/proc/update_emissive_layers()
em_block?.layer = MANGLE_PLANE_AND_LAYER(plane, layer)
Expand Down
16 changes: 7 additions & 9 deletions code/game/objects/structures/stool_bed_chair_nest/bed.dm
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,21 @@
/obj/structure/bed/double/padded/Initialize(mapload)
. = ..(mapload, "wood", "cotton")

/obj/structure/bed/double/padded/get_centering_pixel_y_offset(dir, atom/aligning)
if(!aligning)
/obj/structure/bed/double/padded/get_buckled_y_offset(atom/buckled)
if(isnull(buckled))
return ..()
if(!has_buckled_mobs())
return ..()
var/index = buckled_mobs.Find(aligning)
var/index = buckled_mobs?.Find(buckled)
if(!index)
return ..()
switch(index)
if(1)
return -6
return 0
if(2)
return 6
return 12
if(3)
return 3
return 6
else
return rand(-6, 6)
return rand(0, 12)

/*
* Roller beds
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@
LAZYDISTINCTADD(., SLOT_FEET)

//! Pixel Offsets
/mob/living/carbon/human/get_centering_pixel_x_offset(dir, atom/aligning)
/mob/living/carbon/human/get_centering_pixel_x_offset(dir)
. = ..()
// uh oh stinky
if(!isTaurTail(tail_style) || !(dir & (EAST|WEST)))
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,10 @@ default behaviour is:

//* Pixel Offsets

/mob/living/get_centering_pixel_y_offset(dir, atom/aligning)
/mob/living/get_centering_pixel_y_offset(dir)
. = ..()
// since we're shifted up by transforms..
. += ((size_multiplier * icon_scale_y) - 1) * 16
. -= ((size_multiplier * icon_scale_y) - 1) * 16

/mob/living/get_managed_pixel_y()
. = ..()
Expand Down
5 changes: 1 addition & 4 deletions code/modules/mob/living/silicon/pai/pai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,10 @@
if(!chassis)
var/icon_width = last_rendered_hologram_icon.Width()
icon_x_dimension = icon_width
buckle_pixel_x = (icon_x_dimension - WORLD_ICON_SIZE) / 2
else
icon_x_dimension = 32
buckle_pixel_x = 0
reset_pixel_offsets()


/// camera handling
/mob/living/silicon/pai/check_eye(var/mob/user as mob)
if (!src.current)
Expand Down Expand Up @@ -345,5 +342,5 @@
/mob/living/silicon/pai/proc/get_holo_image()
return render_hologram_icon(usr.client.prefs.render_to_appearance(PREF_COPY_TO_FOR_RENDER | PREF_COPY_TO_NO_CHECK_SPECIES | PREF_COPY_TO_UNRESTRICTED_LOADOUT), 210)

/mob/living/silicon/pai/get_centering_pixel_x_offset(dir, atom/aligning)
/mob/living/silicon/pai/get_centering_pixel_x_offset(dir)
return base_pixel_x + (WORLD_ICON_SIZE - icon_x_dimension) / 2
18 changes: 14 additions & 4 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1140,24 +1140,34 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0)
/mob/proc/get_buckled_pixel_x_offset()
if(!buckled)
return 0
return buckled.get_centering_pixel_x_offset(NONE, src) - get_centering_pixel_x_offset() + buckled.buckle_pixel_x
// todo: this doesn't properly take into account all transforms of both us and the buckled object
. = get_centering_pixel_x_offset(dir)
if(lying != 0)
. *= cos(lying)
. += sin(lying) * get_centering_pixel_y_offset(dir)
return buckled.pixel_x + . - buckled.get_centering_pixel_x_offset(buckled.dir) + buckled.get_buckled_x_offset(src)

/mob/proc/get_buckled_pixel_y_offset()
if(!buckled)
return 0
return buckled.get_centering_pixel_y_offset(NONE, src) - get_centering_pixel_y_offset() + buckled.buckle_pixel_y
// todo: this doesn't properly take into account all transforms of both us and the buckled object
. = get_centering_pixel_y_offset(dir)
if(lying != 0)
. *= cos(lying)
. += sin(lying) * get_centering_pixel_x_offset(dir)
return buckled.pixel_y + . - buckled.get_centering_pixel_y_offset(buckled.dir) + buckled.get_buckled_y_offset(src)

/mob/get_managed_pixel_x()
return ..() + shift_pixel_x + get_buckled_pixel_x_offset()

/mob/get_managed_pixel_y()
return ..() + shift_pixel_y + get_buckled_pixel_y_offset()

/mob/get_centering_pixel_x_offset(dir, atom/aligning)
/mob/get_centering_pixel_x_offset(dir)
. = ..()
. += shift_pixel_x

/mob/get_centering_pixel_y_offset(dir, atom/aligning)
/mob/get_centering_pixel_y_offset(dir)
. = ..()
. += shift_pixel_y

Expand Down
4 changes: 0 additions & 4 deletions code/modules/vore/resizing/resize_vr.dm
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,3 @@ var/const/RESIZE_A_SMALLTINY = (RESIZE_SMALL + RESIZE_TINY) / 2

#undef STEP_TEXT_OWNER
#undef STEP_TEXT_PREY

/mob/living/get_standard_pixel_y_offset(lying)
. = ..()
. += (size_multiplier - 1) * 16

0 comments on commit 816a22c

Please sign in to comment.