How to set the draw order of HUD elements?

User avatar
Wuzzy
Member
 
Posts: 3432
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

How to set the draw order of HUD elements?

by Wuzzy » Fri Dec 02, 2016 23:48

Hi!
I don't know if it is possible to set or tweak the draw order of HUD elements directly. I want to make sure HUD element A gets drawn in front of HUD element B, provided I have the identifiers of those elements.

The bigger problem I face is that I don't know how to make sure a particular HUD element gets drawn over or behind a builtin statbar (health, breath). In relation to these HUD elements, the draw order seems pretty random/unpredictable, which makes it hard to design my HUD around the builtin statbars.

For example, if I want to make sure I can draw an image below the builtin health bar, I am unable to do it. :-(
Oddly, when I try to draw something in front of the builtin breath bar, I am also unable to do it (the breath bar is drawn above my custom HUD element).

If I can't set the draw order directly, can you maybe tell me some rules of how the draw order is determined? Maybe I can use these rules for the goal I want to achieve.

Any help is appreciated.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

User avatar
D00Med
Member
 
Posts: 939
Joined: Sat Feb 07, 2015 22:49
Location: Australia...somewhere
GitHub: D00Med

Re: How to set the draw order of HUD elements?

by D00Med » Mon Dec 05, 2016 08:32

^I'm interested in finding out this too.
I've noticed that when adding hud images, if creative isn't on, some parts of the normal hud are missing.
Is this also related to layering?
 

User avatar
ErrorNull
Member
 
Posts: 201
Joined: Thu Mar 03, 2016 00:43

Re: How to set the draw order of HUD elements?

by ErrorNull » Mon Dec 05, 2016 11:11

I had the same question several weeks ago viewtopic.php?f=47&t=15908

What I resorted to was to make cut-out holes so that my hud image allowed the main hotbar to peek through. lol. it's a funny solution... until we have some way of controlling the hud layering order. Anyone know if we can control that?
 

TeTpaAka
Member
 
Posts: 141
Joined: Sat Dec 28, 2013 21:54

Re: How to set the draw order of HUD elements?

by TeTpaAka » Wed Dec 21, 2016 01:21

Looking at the code, this seems to be impossible at the moment, but I can explain the behaviour at least:

The engine first draws the item bar (+ the health and breath bars for compatibility with older clients. They are redrawn later, so we can ignore them for now) and then it draws the hud elements defined by lua.

The order of the hud elements is determined by the ID of the element, which it gets on initialization, so, in theory, later elements are above the previous ones. But on assignment, the engine finds the first free ID, so the order can get mixed up, if elements are deleted and added.

The health bar is defined in "builtin", so it is added before any mod can add hud elements. It is at the bottom of the stack, everything else is drawn above it.

The breath bar is also defined in "builtin", but it is only added, if the player has breath below 11 (So it only displays bubbles from 1 to 10). This way, it gets added after your hud elements and is therefore (most of the time, see above) above your hud elements.

I hope, this helps.
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 3 guests