StatusBar / Texture - Width/Coloring issues
I've been slowly working on the nUI replacement. But I have hit a snag with creating a simple health bar.
I tried StatusBar control which correctly resized the bar according to the min/max and value settings. But, it wouldn't let me change the bar color based on the percentage. I noticed nUI used a regular frame with a texture, so thought I would try that route. So, I had a frame holding a black texture that was always max width to the frame width and a texture holding the bar that adjusts its colours according to the percentage of health. However, I have not been able to get the SetWidth command to work with the resizable texture. If I clear all its points and then set the single TOPLEFT point it stays at minWidth (0), if I don't clear all the points it stays at max width (150). The new width is correctly being calculated according to current heath and max health ratio and the parent frames width but the function to actually SetWidth appears to be ignoring it. I keep going through the code but can't see anything I have missed or added extra. Below should be all the pertinent code blocks that affects the element in question. Hopefully someone will see something my eyes are clearly missing, or I am misunderstanding in general rofl. Thanks in advance. This is the template that I created for it Lua Code:
This is the layout settings being used ( will become the default settings when finished ) Lua Code:
The frame is being created with this code and is called when the unit frame in question has finished it's creation stage Lua Code:
-- This is used to apply the layout information and is called by the unit frame when doing their layout updates. It is also aimed to be used when the layout is changed ( at present just a default layout used ) Lua Code:
And this is the code it executes whenever there is a health related event triggered ( currently UNIT_HEALTH and UNIT_MAXHEALTH and PLAYER_ENTERING_WORLD ) Lua Code:
|
From a quick look, I don't see .Bar ever getting a SetHeight() setting, just a width so you won't ever actually see the bar using a single anchor point. Maybe use "TOPLEFT" and "BOTTOMLEFT" in the template if it's only ever going to size in one direction
|
That is a good point. I totally forgot it didn't have a height either.
But, I somehow managed to get things to work again as a status bar. Can't think what is different outside of using a different texture. Instead of setting BarTexture in the xml to an atlas ( example from one of the blizzard files) , I used SetStatusBarTexture with the texture used in the example here ( https://warcraft.wiki.gg/wiki/UIOBJECT_StatusBar ). I changed the following in ApplyLayout after changing the Frame to StatusBar in the xml and removing the alternative bar texture section. Lua Code:
And the following in UpdateBarTexture Lua Code:
The bar is shrinking and the color is changing as expected. Thanks for the reminder though. |
All times are GMT -6. The time now is 11:03 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI