Mouse Position

by Forum_account
Mouse Position
Provides a way to get pixel-precise mouse coordinates.
ID:861630
 
Keywords: click, mouse_opacity
Hey there!

I'm having a small issue when attempting to click anything that is underneath the mouse_tracker. All Click()s done by the client end up being clicks to the /obj/mouse_tracker. I understand why, since the mouse_tracker has its mouse_opacity set to TRUE, and it covers the entirety of the screen.

I'm currently considering parsing the parameters received by client/Click(); more specifically, parsing screen-loc:

screen-loc: Pixel coordinates in screen_loc format ("[tile_x]:[pixel_x],[tile_y]:[pixel_y]")

...and then calculating the offset there in comparison to the mob's location on the map, and then locate()ing the turf there:

client
// 'object' here will always be the mouse_tracker
Click(atom/object,location,control,params)
var/list/parameters = params2list(params)

// With tile_x and tile_y being already parsed from the 'screen-loc' param,
var/turf/t = locate(
mob.x + tile_x - round(CLIENT_VIEW_WIDTH/2),
mob.y + tile_y - round(CLIENT_VIEW_HEIGHT/2),
mob.z)
t.Click()

..()


...but this all seems to be unnecessarily hacky/clunky.

The case is, is there a better way of going about this? Maybe add a default behavior to /obj/mouse_tracker/Click() so it 'passes down' a Click() to whatever atom is under it?

Thanks in advance; keep up the good work!
If you only need it for certain objects you can give them a higher layer than the mouse_tracker object. The next easiest way is to bump the BYOND feature request that asks for this kind of mouse support as a built-in feature. The next easiest way is to do what you've described.
Here's a link to the BYOND feature request: http://www.byond.com/forum/?post=92356