Files
CHOMPStation2/code/_helpers/view.dm
CHOMPStation2 cb45bebdc3 [MIRROR] General improvements to Action Buttons (#9250)
Co-authored-by: ShadowLarkens <shadowlarkens@gmail.com>
Co-authored-by: Kashargul <KashL@t-online.de>
2024-10-18 21:20:38 +02:00

26 lines
802 B
Plaintext

/proc/getviewsize(view)
var/viewX
var/viewY
if(isnum(view))
var/totalviewrange = 1 + 2 * view
viewX = totalviewrange
viewY = totalviewrange
else
var/list/viewrangelist = splittext(view,"x")
viewX = text2num(viewrangelist[1])
viewY = text2num(viewrangelist[2])
return list(viewX, viewY)
/// Takes a string or num view, and converts it to pixel width/height in a list(pixel_width, pixel_height)
/proc/view_to_pixels(view)
if(!view)
return list(0, 0)
var/list/view_info = getviewsize(view)
view_info[1] *= ICON_SIZE_X
view_info[2] *= ICON_SIZE_Y
return view_info
// Used to get `atom/O as obj|mob|turf in view()` to match against strings containing apostrophes immediately after substrings that match to other objects. Somehow. - Ater
/proc/_validate_atom(atom/A)
return view()