Click point on screen...possible?

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
xavram
Dragon
Posts: 833
Joined: Tue Apr 20, 2010 8:22 pm

Click point on screen...possible?

Post by xavram »

I'm wondering if there is any way to pull this off, for a player to click on the screen and have the nearest intersection of the grid be returned? Something like, "Click on a macro button, this puts them into 'Select Grid' state, next click returns closest X/Y of grid"?

My guess is that if it is possible, someone has already done it! :)

User avatar
aliasmask
Deity
Posts: 8694
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Click point on screen...possible?

Post by aliasmask »

Nope, no event to return mouse position on screen. You can click a token and get where it is on grid. You can also figure out where your view port is with getViewCenter and getViewArea.

xavram
Dragon
Posts: 833
Joined: Tue Apr 20, 2010 8:22 pm

Re: Click point on screen...possible?

Post by xavram »

Thanks AM, I will stop beating my head trying to figure out the impossible!

JoeDuncan
Cave Troll
Posts: 69
Joined: Sun Nov 22, 2020 9:02 pm

Re: Click point on screen...possible?

Post by JoeDuncan »

xavram wrote:
Fri Jan 17, 2020 12:09 pm
I'm wondering if there is any way to pull this off, for a player to click on the screen and have the nearest intersection of the grid be returned? Something like, "Click on a macro button, this puts them into 'Select Grid' state, next click returns closest X/Y of grid"?

My guess is that if it is possible, someone has already done it! :)
Not yet that I know of, but I can do this for you.

Take a look at the "Joe's Ugly Hacks" posts (I really gotta link that in my sig.!) in "User Creations".

I have already implemented most mouse events, so this is trivial. Simply hook into my (soon to be existing) "[email protected]:events" get the X/Y coords in pixels and then find nearest grid vertex.

(for a preview, check out the pre-release lib token I made for user FullBleed - otherwise, full event management system will be released this coming weekend)

How would you like it to work?

Generally, my approach is to scan "lib:" tokens for defined events (e.g. you make a "lib:" token and define a macro called "onMouseClick" on it, which receives x=arg(0), y=arg(1)) and then register those methods as callbacks.

As it stands, the simplest approach would be to add "onMouseClick" and then handle the "nearest vertex" logic yourself in your lib's callback.

If that's too much, I can implement an "onClosestGrid" (or something) which you can define and then just receives the x/y coords of the nearest vertex on every mouse click.

let me know
"Joe's Ugly Hacks - Get 'em while their hot! Guaranteed ugliest hacks around or your money back!"

User avatar
wolph42
Deity
Posts: 9898
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Click point on screen...possible?

Post by wolph42 »

xavram wrote:
Fri Jan 17, 2020 12:09 pm
I'm wondering if there is any way to pull this off, for a player to click on the screen and have the nearest intersection of the grid be returned? Something like, "Click on a macro button, this puts them into 'Select Grid' state, next click returns closest X/Y of grid"?

My guess is that if it is possible, someone has already done it! :)
it looks like you have a problem and already started thinking about one solution without analyzing alternatives to solve that problem. Perhaps you could start posting the problem first?

xavram
Dragon
Posts: 833
Joined: Tue Apr 20, 2010 8:22 pm

Re: Click point on screen...possible?

Post by xavram »

Obviously, its been some time since I originally posted this Wolph, but my thought process at the time was, "It would be nice if a player could say, "I'm casting Fireball HERE"" and click on the spot on the map where they wanted it to be and then have Maptool show the resulting AoE effect on that spot. My players have said, "it would be cool to have something like that, so we're not meta gaming the exact point, to just narrowly miss an ally". But I did not pursue it much after the initial responses of "No, there are no mouse click events".

JoeDuncan
Cave Troll
Posts: 69
Joined: Sun Nov 22, 2020 9:02 pm

Re: Click point on screen...possible?

Post by JoeDuncan »

xavram wrote:
Wed Apr 14, 2021 1:45 pm
Obviously, its been some time since I originally posted this Wolph, but my thought process at the time was, "It would be nice if a player could say, "I'm casting Fireball HERE"" and click on the spot on the map where they wanted it to be and then have Maptool show the resulting AoE effect on that spot. My players have said, "it would be cool to have something like that, so we're not meta gaming the exact point, to just narrowly miss an ally". But I did not pursue it much after the initial responses of "No, there are no mouse click events".
Ah, well there definitely will be mouse events for maptool this weekend - most of them are already implemented so it's mostly polish, docs & creating demos I have left.

Given your described use case above though, I don't think a specific "onClosestGrid" (or something) event is necessary. You'll have "onMouseClick", "onMouseDown" and "onMouseUp" events in JUH alpha 2 out of the box, all of which will give you the Maptool map pixel coords where you clicked. Turning that into something like "the nearest top left cell corner location" is something probably best left to the implementation of whatever callback you hook to one of the above mouse events.

If that's something you don't think you can handle, I can whip up a quick one for you, but I'm not going to include it in the base JUH lib, it'll be like "here's a macro you can hook to JUH onMouseClick"

Regardless, everything you mention should be perfectly doable with the JUH alpha 2 macro libs.
"Joe's Ugly Hacks - Get 'em while their hot! Guaranteed ugliest hacks around or your money back!"

JoeDuncan
Cave Troll
Posts: 69
Joined: Sun Nov 22, 2020 9:02 pm

Re: Click point on screen...possible?

Post by JoeDuncan »

On further consideration a single-shot "onClickLaunch" event could be very useful.

Just feed it a macro name and some args, then the next time the screen is clicked the macro is run with the saved args and screen coords, then the event deletes itself.

So for instance you create a canned JUH animation macro for your fireball, with accepts the screen coords and the caster token id.

Then you call "[email protected]:events" and the next time the screen is clicked (only), the animation is started at the given location.

I will add this.
"Joe's Ugly Hacks - Get 'em while their hot! Guaranteed ugliest hacks around or your money back!"

User avatar
aliasmask
Deity
Posts: 8694
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Click point on screen...possible?

Post by aliasmask »

Being able to click a position on the map and get the x,y position of the map would be super handy. Ie, summon creature or dropping other tokens on to the map via macro frame.

I can imagine having a frame of images/tokens, dragging one from the frame on to the map. It would need to be apart of the same overlay though.

JoeDuncan
Cave Troll
Posts: 69
Joined: Sun Nov 22, 2020 9:02 pm

Re: Click point on screen...possible?

Post by JoeDuncan »

aliasmask wrote:
Wed Apr 14, 2021 3:40 pm
Being able to click a position on the map and get the x,y position of the map
Already done.

You can see a preview of this in the one-off lib token I made for Full Bleed in the other thread. It uses the map X/Y to select objects on the object and hidden layer.
"Joe's Ugly Hacks - Get 'em while their hot! Guaranteed ugliest hacks around or your money back!"

xavram
Dragon
Posts: 833
Joined: Tue Apr 20, 2010 8:22 pm

Re: Click point on screen...possible?

Post by xavram »

yes, just getting back the X/Y would be great...what version of Maptool do you think this will be in?

JoeDuncan
Cave Troll
Posts: 69
Joined: Sun Nov 22, 2020 9:02 pm

Re: Click point on screen...possible?

Post by JoeDuncan »

xavram wrote:
Thu Apr 22, 2021 12:49 pm
...what version of Maptool do you think this will be in?

You don't need a Maptool release for this.

It's already available in the one-off I lib posted for FullBleed in the JUH v0.2a thread. You can take that and just change the registrations and callbacks to do whatever you like.

Otherwise, it will be generally available in the "lib:mouse" module with the full release of my JUH v0.2a drop-in macro libraries that I hope to make this evening.

I was planning to release it Monday night, but I found a bug I couldn't release and I don't have much free time weeknights so it's taken me a couple of days to fix :(

Anyways, the bug is fixed now, and I'm just building demos and tidying up docs, so it will be out either this evening or tomorrow night (at the latest).
"Joe's Ugly Hacks - Get 'em while their hot! Guaranteed ugliest hacks around or your money back!"

Post Reply

Return to “MapTool”