Thread Tools Display Modes
Prev Previous Post   Next Post Next
01-03-21, 12:20 AM   #1
Xaxziminrax the Second
A Murloc Raider
Join Date: Apr 2009
Posts: 5
Unconventionally shaped health bar issue

Hi, when experimenting with oUF I came across a healthbar style I like, which is fatter at low health so it's easier to notice. However, when implementing it, I realized that statusbars don't actually shrink or clip... they just slide along their axis.

Please look at this image on full life:


And now, when I am damaged:


The dark health bar is just moving, which makes sense for some layouts, but not for something like this. I had thought, due to some previous discussion, that unconventionally shaped status bars weren't a problem these days.

I'm unsure how to proceed to get the desired effect of just clipping off the end of the bar with the more damage you take.

Here's the current code generating my health bar. Any advice on what to add or change to be able to use this awkwardly-shaped health effectively would be very appreciated.

Lua Code:
  1. local Health = CreateFrame("StatusBar", "hiuiPlayerHealthBar", self)
  2.  
  3. --[[        Player Health Border (Art)
  4.             Art frame keeping the health bar in check.
  5. --]]
  6. local HealthBorder = Health:CreateTexture("hiuiPlayerHealthArt", "ARTWORK", nil, 1)
  7. HealthBorder:SetTexture(defaults.player.textures.border)
  8. HealthBorder:SetTexCoord(0, 377/512, 0, 60/64)
  9. HealthBorder:SetPoint("TOPLEFT", self, "TOPLEFT")
  10. HealthBorder:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT")
  11.  
  12.  
  13.  
  14. --[[        Player Health Status Bar
  15.             Dark bar that moves when you take damage.
  16. --]]
  17. Health:SetStatusBarTexture(defaults.player.textures.healthBarStretch)
  18. -- The border art on +1 and the bg on -1, so don't need this.
  19. --Health:GetStatusBarTexture():SetDrawLayer("ARTWORK", 0)
  20.  
  21. Health:SetPoint("TOPLEFT", HealthBorder, "TOPLEFT", 0, 0)
  22. Health:SetPoint("BOTTOMRIGHT", HealthBorder, "BOTTOMRIGHT", 0, 0)
  23.  
  24. Health:SetReverseFill(defaults.player.reverseFill);
  25. Health.frequentUpdates = defaults.player.frequent
  26.  
  27.  
  28.  
  29. --[[        Player Health Bar Background
  30.             Bright background that's revealed as damage is taken.
  31. --]]
  32. local HealthBg = Health:CreateTexture("hiuiPlayerHealthBg", "ARTWORK", nil, -1)
  33. HealthBg:SetTexture(defaults.player.textures.healthBgStretch)
  34.  
  35. HealthBg:SetPoint("TOPLEFT", HealthBorder, "TOPLEFT", 0, 0)
  36. HealthBg:SetPoint("BOTTOMRIGHT", HealthBorder, "BOTTOMRIGHT", 0, 0)
  37.  
  38.  
  39. self.Health = Health
  40.  
  41.  
  42. do -- bad practice, code abuse, programming under the influence
  43.     local function fixInnerElementsPos()
  44.         local l = 29/377 * hiuiPlayerHealthArt:GetWidth()
  45.         local t = 14/60 * hiuiPlayerHealthArt:GetHeight()
  46.  
  47.         hiuiPlayerHealthBar:SetPoint("TOPLEFT", "hiuiPlayerHealthArt", "TOPLEFT", l, -t)
  48.         hiuiPlayerHealthBar:SetPoint("BOTTOMRIGHT", "hiuiPlayerHealthArt", "BOTTOMRIGHT", -l, t)
  49.  
  50.         hiuiPlayerHealthBg:SetPoint("TOPLEFT", "hiuiPlayerHealthArt", "TOPLEFT", l, -t)
  51.         hiuiPlayerHealthBg:SetPoint("BOTTOMRIGHT", "hiuiPlayerHealthArt", "BOTTOMRIGHT", -l, t)
  52.     end
  53.  
  54.     C_Timer.After(0.8, fixInnerElementsPos)
  55. end
  Reply With Quote
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Unconventionally shaped health bar issue


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off