Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-02-11, 08:48 AM   #1
Monolit
A Black Drake
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 81
reverse status bars (again)

I know this topic came out a couple of times already in the past, but uhm, I've ran search few times and have yet to find a solution to my problem regarding reverse status bars.

So I want my health status bar to fill in reverse, i.e. the bigger amount of health missing - the bigger health status bar is (starting from right to left).

If I understand correctly neither default wow API or oUF allows us to do that with some simple method, so I need to make a PostUpdateHealth hook and change this by my own, but I struggle with that one ...

Setting the new value is easy, but I can't reanchor the texture itself
my PostUpdateHealth function looks like this:
lua Code:
  1. lib.PostUpdateHealth = function(s, unit, min, max)
  2.     if unit=='player' or unit=='target' then
  3.         s:SetValue(max-min)
  4.         s.t = s:GetStatusBarTexture()
  5.         s.t:SetPoint('TOPRIGHT', s, 'TOPLEFT', 0, 0)
  6.     end
  7. end

and hp bar function:
lua Code:
  1. lib.gen_hpbar = function(f)
  2.     local s = CreateFrame("StatusBar", nil, f)
  3.     s:SetStatusBarTexture(cfg.statusbar_texture)
  4.     fixStatusbar(s)
  5.     s:SetHeight(f.height)
  6.     s:SetWidth(f.width)
  7.     s:SetPoint("TOPLEFT",0,0)
  8.     s:SetAlpha(0.65)
  9.     s:SetOrientation("HORIZONTAL")
  10.     local h = CreateFrame("Frame", nil, s)
  11.     h:SetFrameLevel(0)
  12.     h:SetPoint("TOPLEFT",-4,4)
  13.     h:SetPoint("BOTTOMRIGHT",4,-4)
  14.     lib.gen_backdrop(h)
  15.     local b = s:CreateTexture(nil, "BACKGROUND")
  16.     b:SetTexture(cfg.statusbar_texture)
  17.     b:SetAllPoints(s)
  18.     s.PostUpdate = lib.PostUpdateHealth
  19.     f.Health = s
  20.     f.Health.bg = b
  21.   end

So basically I get bar with the right value, but it's placed at default position, i.e. anchored to right and filling up towards left. Any help or some kind of clues would be appreciated!

Last edited by Monolit : 04-02-11 at 02:05 PM.
  Reply With Quote
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » reverse status bars (again)


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