Fixes the paper (#5829)

This commit is contained in:
Erki
2018-12-24 22:21:16 +02:00
committed by Werner
parent a1c5c86101
commit c23065ff2c
7 changed files with 35 additions and 14 deletions

14
code/_helpers/mouse.dm Normal file
View File

@@ -0,0 +1,14 @@
/**
* @brief Returns a list of "icon-x" and "icon-y" from mouse parameters, which
* are safely clamped to 0-32 for icon operations.
*/
/proc/mouse_safe_xy(params, lim_x = 32, lim_y = 32)
if (!params)
return list("icon-x" = 0, "icon-y" = 0)
. = params2list(params)
testing("X: [.["icon-x"]], Y: [.["icon-y"]]")
return list("icon-x" = Clamp(text2num(.["icon-x"]), 0, lim_x),
"icon-y" = Clamp(text2num(.["icon-y"]), 0, lim_y))