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:
and hp bar function: lua Code:
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! |
I think that StatusBars delay re-anchoring their textures until just before the next OnUpdate, so you'll have to use an OnUpdate handler to re-position the texture. Here's the function I use to create a reverse status bar in my UI:
http://code.google.com/p/wow-saiket/...lua?r=1574#313 |
Couldn't you just switch colors. (dark foreground, light background). That way if the bar depletes the bright color will become more and more visible.
|
Quote:
Quote:
i.e. I want this bar to overlay the background with the portrait |
Quote:
|
Quote:
P.S. Just out of curiosity why do you wrap your OnUpdate functions in 'do ... end' loop? I've read something about this a while ago... something about optimizing lua code, but can't really find it right now, so could you please enlighten me? |
They don't improve performance, but they are useful for creating private variable scopes. Only the CreateBarReverse function can see and use OnChanged and UpdaterOnUpdate, since they're declared inside of the do-end block.
|
Other thing you can do. Have a transparent statusbar just for the values and have two simple textures that get updated once the statusbar OnValueChanged event get's fired.
|
Quote:
Anyway I got it working, just not sure whether I like the outcome or not :P |
You might consider sharing your solution, other might be interested in it, too. As this has been brought up quite a few times in the past. :)
|
Quote:
so first of all we make updater frame and ReverseBar function that will be used to create our reverse bars lua Code:
lua Code:
So then in your style function you just use ReverseBar() instead of 'CreateFrame("StatusBar"...' to make hp bar. lua Code:
here's the result: and I actually quite like it |
I feel like I'm necro-ing this thread a bit but ohh well here goes....
I'm working on modifying a version oUF_Sandman for my UI, and I am trying to get this to work for me, but I just can't seem to get it. Not sure if I'm missing something or just being an overtired/over-caffinated idiot. I haven't changed any other code from the original yet, just messing with getting the textures right for now. Where should this be added to the code/or what needs to be changed to get this to work? |
As of 4.3, you only need to do StatusBar:SetReverseFill(true) to reverse the direction of the statusbar.
|
OK let me try editing the right version of the file first before I say it didn't work /facepalm. Never code before coffee and smoke in the morning.....
|
I added the SetReverseFill(true) to the style section:
Code:
--gen healthbar func |
1 Attachment(s)
Here's a quick screenshot of what I have now. Not sure if I just need to mess with the set points more or what, but I'll try again in the morning when I get home from work . I'm still working on powerbar textures which is why they're just green blobs in the screenie.
Attachment 6756 well I tried messing with this some more this morning, and I'm still having no luck. I tried adding a new texture file that is a mirror image of the player hpbar texture and pointing to it in the style functions and still got no where. StatusBar:SetReverseFill(true) either breaks the textures without throwing an error (see previous post) or just doesn't work if I only put it in the gen healthbar function or the helper section individually. I know I have to be missing something, I just have no idea what. |
Quote:
StatusBar:SetReverseFill(true) will just essentially mirror your status bar, and what I meant with "Reverse status bars" is that it also changes the way it behaves, i.e. at 100% HP status bar would stay at 0% mark, at 70% HP it would be 30% filled etc. (picture above actually represents it quite well). The method posted above still works flawlessly @ live realms and should be quite easy to implement in any layout. Actually I think it can be done a little bit differently using SetReverseFill, but it would require pretty much the same texture manipulations in PostUpdate or Override callbacks. MAYBE it would be a little bit more efficient performance-wise though. |
I finally got my textures switched around so everything looked better but SetReverseFill(true) still didn't really work out for me. I tried to enable it on my player frame to get the bars to fill from left to right, and instead of filling the bars it actually shifted the textures and skewed them as the bar depleted. I tried a bunch of stuff to try to get them right but nothing seemed to work. I'll probably try again either later tonight or tomorrow and I'll see if I can fraps a vid of it.
oUF_Lust is the outcome of it for now. |
Quote:
|
Quote:
Lua Code:
|
All times are GMT -6. The time now is 07:40 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI