Jump to content

[1.18.2] Best approach for a radial menu?


_Beau

Recommended Posts

Hi-

I'm developing a small mod where the player will have access to a range of abilities and, to keep the keybind clutter down, I've decided to implement a single keybind that will trigger a radial menu for ability selection.

Normally I'd just make a Screen for this, but I'd like to let keyboard input pass since the radial menu itself won't use any keybinds and allowing the player to move while in the menu will be quite nice. Thus my question: Is there a way to let keyboard input pass a Screen? Or should I make an IIngameOverlay and manually releaseMouse() for the selection?

I've tried setting Screen.passEvents to true, but I don't think I read its usages in the code properly since it doesn't seem to allow the player to move while in the screen.

Thanks.

Edited by _Beau
additional info
Link to comment
Share on other sites

  • _Beau changed the title to [1.18.2] Best approach for a radial menu?

After a bit more of a dive through the code I've figured out roughly how player movement inputs are interrupted by screens and it's looking like it would require a mixin to unlock movement for my radial menu if it's implemented as a screen. Will investigate the idea of an overlay and manually releasing the mouse for menu selection.

Link to comment
Share on other sites

Manually releasing and grabbing the mouse seems to have done the trick.

I'm doing it quite simply- not sure if using these methods outside a vanilla context could have any weird side effects.

public void setActive(boolean active)
{
    if(active)
    {
        Minecraft.getInstance().mouseHandler.releaseMouse();
    }
    else
    {
        Minecraft.getInstance().mouseHandler.grabMouse();
    }

    this.active = active;
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.