Z Layer of GUI elements

  • English

We've posted a status update with some first screenshots of the new terrain generation. There is also a new update available for the Java version!

  • Z Layer of GUI elements

    Hi @red51

    I'm working on some code that uses a GUI when items are moved from or to a chest (for player operated shops).

    The problem I am having is the GUI always appears underneath the in-game inventory's GUI. So I could do with something like:

    Source Code

    1. GuiConfirmScreen gcs = new GuiConfirmScreen (plugin, event.getPlayer(), 6, "test");
    2. //where gcs extends GuiPanel
    3. //so I need a method in GuiPanel something like
    4. gcs.setZLayer(1000);
    5. //or
    6. gcs.setAlwaysOnTop(true);



    Behind this screen (indicated by red arrow) appears my confirmation GUI. Which is only visible once you close the inventory screen.





    As it appears behind the inventory screen its not much use currently ;(


    Edit: Maybe a way to show and hide (.setVisible(false || true) ) the inventory screen might work?
    play: server.medievalrealms.co.uk website: medievalrealms.co.uk discord: discord.medievalrealms.co.uk
  • Hmm... well, just changing the Z order might not work in this case =O In Rising World, the Z order always depends on the Z order of the parent, or in other words, the parent automatically restricts the Z order of its childs (to avoid situations like having a button [child] being visible in front of the inventory, while the messagebox [parent] is shown behind the inventory)...

    API elements are always attached to the HUD, and the HUD is always rendered behind the inventory/journal/crafting GUI.

    However, our GUI already has an option to set a GUI element being always visible in front of other GUI elements (this setting is just not yet exposed to the API), internally this overrides the Z order. Maybe that would work in your case? You could set your confirmation window to be "always on top", so it will definitely be visible in front of the inventory or any other screen. Then we could add the .setAlwaysOnTop() method (and maybe also a .setAlwaysInBackground() method) with the next update ;)

    yahwho wrote:

    Edit: Maybe a way to show and hide (.setVisible(false true) ) the inventory screen might work?
    There will be some methods in the next update to show/hide the inventory as well as other screens (journal, chest content, map) :)
  • Hi @red51

    red51 wrote:

    There will be some methods in the next update to show/hide the inventory as well as other screens (journal, chest content, map)

    Would it also be possible to hide show the icons for say health bar, food, water, bleeding, freezing, and sprint? (and others I may have missed off that list).
    play: server.medievalrealms.co.uk website: medievalrealms.co.uk discord: discord.medievalrealms.co.uk