ericoporto / ImGi

AGS Script Module for Immediate Gui (based on rxi's Microui)
https://www.adventuregamestudio.co.uk/forums/index.php?topic=58842.0
Other
2 stars 2 forks source link

Enhancement: Block clicks after #6

Closed ericoporto closed 3 years ago

ericoporto commented 3 years ago

Figure a way to deal with the problem of passing clicks through.

It's a bit tricky and for now I am thinking on something like having an attribute named handled or something else and you could check and see in your mouse handling code if you should just return instead of proceeding with proceeding further.

The other problem is the reverse, there's a native AGS GUI or something on top and you would like the clicks to not be detected by the ImGi windows below.

For this I think I need to better figure out how to work with the mouse in the particular AGS usage and forego the previous mouse abstractions made in the original code - this would mean using the ags callback handlers more directly. This will require a bit of a refactor.

ericoporto commented 3 years ago

In AGS the only transparent way seems to be ClaimEvent (), but for this, I would need to have the information on the GUI z-order and everything else of the mouse handling at the time of the event on_click. Need to figure out in the frame, what is the order of the things, if repeatedly executes (and similar) happen before the on_click event, then it's ok to preprocess and just claim or not at this time.

If repeatedly execute (and similar) happen AFTER the event, then I don't know how to do this.

The manual page is unclear about this or I am not clever enough to understand it: https://adventuregamestudio.github.io/ags-manual/BlockingScripts.html

I think this means running AGS under a debugger to figure out 😞

ericoporto commented 3 years ago

I can cheat and just ClaimEvent if the mouse hit one of the rect in the draw list. This would mean traversing the command list when there's a click to check if it hit something. Not efficient, and may have a one frame delay, but should maybe work and be easier then the proper thing that I don't know yet which would be - so maybe just let implemented like this until I have more time to figure this out.

I can probably just test the first rect per root element which would give me just the frame rects so this should be reasonably fast.

ericoporto commented 3 years ago

Each root element is a container, and the cnt.rect_ will give it's frame, which we will use to test the mouse clicks.

Each of these have a cnt.open which can be tested to see if the container is actually open before capturing clicks.