-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Action Event Layers, multifocus for split screen #20091
Conversation
Only call _gui_remove_focus for the current focus_layer
Used by input_map to filter input events from the action map
I'm still not sure this is the best solution to solve the problem. But it seems we really need a way to handle several players for a single action. Regarding the per-viewport focus, I don't think it is a good idea. It's not generic enough because you could have two focus points on the same screen (like in super smash bros I'd say or any other character selection menu) |
Maybe making a bitmask like the rest of the layer systems? So a single viewport can handle many layers. |
This PR is very close to what I had in mind. Let me explain you my idea, which is almost the same so we can agree on something. I think the right solution is something along the lines of:
This would allow the following scenarios to work smoothly:
Why not bitmasks?While bitmasks make more sense from the code side and are more flexible, they have the big downside that most game developers don't really understand how to set bitmasks manually. Making the API like:
Will freak out a lot of users. @Faless what do you think? |
I'd say @reduz 's solution is a pretty clean way to solve both issues. I like it. We may want to have a look to previous PR about adding multiplayer support to actions. (I think I remember a PR from Odino, but I cannot check now I am on my phone) |
Nevermind, I cannot find it. It may simply have been discussed via IRC. |
@reduz , I agree with pretty much everything, I'll work on that. |
@Faless In fact, I think it would make more sense to rename "layer" to just "player". |
Had any time to think of a better solution to the one I proposed? Otherwise we can kick to 3.2 as we are too close to Alpha. |
I tried. Not hacking the player into InputEvents means either changing the InputMap API (which is not doable for 3.1) or doing a lot of hacking in the way the action maps are handled internally. As much as I would love to see this feature in |
Now would probably be a good time to revisit this PR and see if/how we want to merge it for 3.2 (or 4.0) |
Not going to happen, apparently there's not enough interest in adding this "complication". |
This is something I briefly discussed with some devs at last GodotCon.
Closes #10755
TL;DR;
This PR adds adds Viewport-based multifocus support to GUI elements.
Additionally, it adds a new
layer
property in the Input Map editor to control this new focus behaviour.Check out the demo: ActionLayer.zip
How does it work?
InputEvent
now has a newlayer
property.Each Viewport is assigned a new
focus_layer
property.Focusing something inside that Viewport will only remove the focus from elements in viewports that have the same
focus_layer
.When receiving input the
Viewport
(orViewportContainer
) will set the InputEventlayer
property to the currentfocus_layer
.The
InputMap._find_event
(and thus allis_action
,add_action
, ...) will ignore actions with mismatching layers, causing UI inside each Viewport to only react to the appropriate input.How do I use it?
Create a scene with multiple Viewports, eg:
Assign to the Viewport the desired focus_layer:
Consigure Input Map
Layer
property accordingly: