Some GUI question

  • Hi, I wan to change some internals style for player GUI elements with overwriteUIStyle, but looks like there is no list of default game GUI element names. I tried to find something, but failed. What are the names for default elements?

  • It's indeed a bit tricky to get the names/paths of the built-in UI elements... for this reason we've added a small tool which can be enabled by typing uidebugger into console - it shows the path of the currently hovered element in the top left corner of the screen ;)

    While this tool is active, you can also rightclick on an element to copy the UI path to clipboard. To close the tool, just hit the X in the top left corner (if you can't hit it properly, press ESC and try to hit it again).


    This enables you to get the paths of most elements ^^ For instance, the path to the inventory background would look like this: InventoryLayer/inventoryContainer etc.


    Unfortunately you can't access all elements this way. To overcome this limitation, you could also type uidebugger <layername> into console - this prints the paths of all elements on a particular layer into console.


    But if there is a particular UI element you're looking for, just let me know and I can post the path here :)

  • Thank you, now I know all required paths :)


    I noticed one thing - some elements will ignore style changes, is this related to overriding style by the game itself during player value updates (like hunger)?


    Another thing that I notices is that stamina value in player is not updated correctly on server side, it is always 100 and if you will spend a lot can instantly change to 20 or other number, and then back to 100. Default player UI shows it correctly. Is it possible to get correct player stamina?

  • I'm working on my own Status UI plugin, so updating some player stats is important for it.


    I also have another question - how do make elements behave similar to built-in during screenshot capture? I mean that built-in can be hidden during screenshot and I'm not sure how to reach same behaviour


  • I noticed one thing - some elements will ignore style changes, is this related to overriding style by the game itself during player value updates (like hunger)?

    Hmm... which elements do you mean exactly? And which style change do they ignore specifically?


    The game indeed changes certain style paramters of some elements, e.g. the DisplayStyle of stamina and breath bar or the broken bone icon. For some elements the backgroundImageTintColor gets also changed (e.g. for the hunger and thirst icons), but that shouldn't interfere with other style changes :wat:


    Another thing that I notices is that stamina value in player is not updated correctly on server side, it is always 100 and if you will spend a lot can instantly change to 20 or other number, and then back to 100. Default player UI shows it correctly. Is it possible to get correct player stamina?

    Oh, indeed :thinking: That seems to be a bug... thanks for bringing this to my attention! ;)


    I also have another question - how do make elements behave similar to built-in during screenshot capture? I mean that built-in can be hidden during screenshot and I'm not sure how to reach same behaviour

    Right now the screenshots only hide the HUD (and its content)... but probably it makes sense if API elements attached to the HUD (which is the default attach target) are only hidden on screenshots... we'll change that :D

  • Hmm... which elements do you mean exactly? And which style change do they ignore specifically?

    Thirst and stamina ignores visibility, opacity, width and height:

    • HudLayer/hudContainer/statusContainer/rightContainer/statusIconContainer/thirstIcon
    • HudLayer/hudContainer/statusContainer/rightContainer/statusIconContainer/thirstIcon/thirstLabel
    • HudLayer/hudContainer/statusContainer/rightContainer/statusIconContainer/hungerIcon
    • HudLayer/hudContainer/statusContainer/rightContainer/statusIconContainer/hungerIcon/hungerLabel

    But their parent element - not, so hiding statusIconContainer will hide them too


    Bar container also ignore same style changes: HudLayer/hudContainer/statusContainer/statusBarContainer/barContainer

    So, I solved its visibility simpler - I just moved it far away, so it ignores tags above but it accepts position changes


    Another small question - how does the game handle when player heal broken bones status? I noticed that game changes it to another icon visually, but there is no any player data that store that information. I tried to handle that myself with rules like "when player had break bone, and now not, and his HP is not max then display fixed bones icon", but this is potentially incorrect logic. Probably I will just display built-in icons, but they also don't accept same style changes as above so it is hard to configure them

  • Thirst and stamina ignores visibility, opacity, width and height:

    Hmm... changing visibility, opacity, width or height for the thirst or hunger icons work properly on my end :thinking:


    However, for the "thirstLabel" and "hungerLabel", the game indeed overwrites the visibility (everytime the inventory is opened). To get rid of these labels, you could set display to DisplayStyle.None though :)


    Bar container also ignore same style changes: HudLayer/hudContainer/statusContainer/statusBarContainer/barContainer

    That also works on my end (at least visibility and width/heigh [although that doesn't change the progress bar size of course, because it's just the container]) :wat: :thinking:


    Another small question - how does the game handle when player heal broken bones status?

    Unfortunately this isn't exposed yet... but we could add a hasHealedBones() method with the next hotfix :)

  • Hmm... changing visibility, opacity, width or height for the thirst or hunger icons work properly on my end :thinking:

    I think that I found an answer - if the style is created on plugin startup and applied to several elements it will change only the first element. Looks like style argument will be mutated, and if it will be applied to the next element it will not have effect.


    For example code like this:

    Java
    Internals.overwriteUIStyle(player, "HudLayer/hudContainer/statusContainer/rightContainer/statusIconContainer/thirstIcon", s1);
    Internals.overwriteUIStyle(player, "HudLayer/hudContainer/statusContainer/rightContainer/statusIconContainer/hungerIcon", s1);

    Will change thirstIcon, but hungerIcon will be same (s1 was initialised in onEnable)


  • I think that I found an answer - if the style is created on plugin startup and applied to several elements it will change only the first element. Looks like style argument will be mutated, and if it will be applied to the next element it will not have effect.

    Yes, in fact each Style field has a "dirty" flag which is set whenever a property is changed. When applying the Style, the game only serializes the dirty properties (and removes the dirty flag at the same time). So when reusing the Style object, it no longer has any dirty flags.

    For regular, built-in UI elements this usually makes sense (because you can't assign Style objects anyway), but when overriding game UI elements (through the Internals method), it's probably better if the fields remain "dirty" after serialization. We will change that with the upcoming hotfix, so Style objects will be reusable when overriding UI elements ^^ Until then, the workaround is indeed to create a new Style object everytime you override an element (which is a bit cumbersome unfortunately)^^

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!