Thread Tools Display Modes
11-24-10, 03:41 AM   #1
Pyrates
A Cliff Giant
 
Pyrates's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 77
Making an alternative power bar

Hey all I'm using a nice oUf layout that has a power bar already (yay ). I want to make an alternative one and switch between those two ingame (on shapeshift, I guess). I know how to make a power bar, so let's just say I have oUF_player.Power (the original working bar) and oUF_player.altpower (my newly constructed bar not in use). On login, I'd execute "oUF_player.oldpower = oUF_player.Power" to save the original bar in an independent variable. Now my idea would be to catch the shapeshift event and then as appropriate use the following code:

Code:
oUF_player.Power = oUF_player.altpower
oUF_player.oldpower:Hide()
On shifting back, I'd use

Code:
oUF_player.Power = oUF_player.oldpower
oUF_player.altpower:Hide()
I have the following questions now:
  • Does it work this way, or did I miss something?
  • What if I call this function in combat? I have no experience what one can do in combat, but of course I can protect the whole thing via InCombatLockdown(), but is it necessary?
  • Any good way to find out which one is the active power bar via code? Can I use something like "oUF_player.Power == oUF_player.oldpower" to check if the original power bar is active? Or what else should I do (thing that comes to my mind would be a global variable for that, or a local one of oUF_player, but that sounds kinda... constructed ^^).

Thanks for any help and pointers
__________________
" ... and the Vogon will do things to you that you wish you'd never been born, or, if you're a clearer minded thinker, that the Vogon had never been born."
  Reply With Quote
11-24-10, 07:35 PM   #2
Krag72
A Deviate Faerie Dragon
Join Date: Sep 2008
Posts: 14
I don't see why something like that wouldn't work. UNIT_DISPLAYPOWER is fired when the power type changes so you can catch than and then use UnitPowerType(unit) to check which bar you want hidden/displayed.

If you want to be able to check which bar you have you can always add a field to the bars like oUF_player.Power.BarNumber = 1 and 2 respectively.
  Reply With Quote
11-25-10, 02:54 PM   #3
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
The swap solution will work as long as you don't try to call element:ForceUpdate() and use frequentUpdates.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
11-26-10, 03:54 AM   #4
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Are you just trying to make a druid mana bar? Look at the code posted in this addon's description:

http://www.wowinterface.com/download...DruidMana.html

If you want it to completely replace the normal mana bar just place it at the same location, and hide/show each one as needed. You can hide every individual unit frame element in combat, they're just unprotected widgets. The only thing you can't change is the base unit frame's (self) visibility / position / etc attributes in combat.
  Reply With Quote
11-26-10, 09:12 AM   #5
Pyrates
A Cliff Giant
 
Pyrates's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 77
Originally Posted by haste View Post
The swap solution will work as long as you don't try to call element:ForceUpdate() and use frequentUpdates.
Actually I kinda need frequentUpdates, but I think I have a solution (see below). Why wouldn't it work with frequentUpdates?

Are you just trying to make a druid mana bar? Look at the code posted in this addon's description:

http://www.wowinterface.com/download...DruidMana.html

If you want it to completely replace the normal mana bar just place it at the same location, and hide/show each one as needed.
Actually I'm making an energy bar. But I only want it under certain circumstances, that's why I'm thinking about the switching thing.

You can hide every individual unit frame element in combat, they're just unprotected widgets. The only thing you can't change is the base unit frame's (self) visibility / position / etc attributes in combat.
That sounds good, thank you.

So, a possible (and kinda nice) solution seems to make just a second bar, and attach that to self.Power (as opposed to the original bar self.power), and then just self.power:Hide() or self.Power:Hide() depending on which one you want. Did not yet test, but having both bars at the same time works.
__________________
" ... and the Vogon will do things to you that you wish you'd never been born, or, if you're a clearer minded thinker, that the Vogon had never been born."
  Reply With Quote
11-26-10, 04:15 PM   #6
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
If you switch to cat, the power bar becomes the energy bar. Which updates as fast as necessary, if you have frequent updates for power enabled. I don't understand what you are trying to do? Why would one need a second power bar?

Especially if it is NOT to display druid mana in cat/bear?! Which, btw, could be done with a tag, easily, no need for a bar.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
11-29-10, 06:13 AM   #7
Pyrates
A Cliff Giant
 
Pyrates's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 77
Originally Posted by Dawn View Post
If you switch to cat, the power bar becomes the energy bar. Which updates as fast as necessary, if you have frequent updates for power enabled. I don't understand what you are trying to do? Why would one need a second power bar?
Because right now the "bar" is just a font string, which is exactly how I want it for all caster forms, because mana is more of a long-time resource. But if I switch to Cat/Bear, I want a real bar, and that's what I'm making

Especially if it is NOT to display druid mana in cat/bear?! Which, btw, could be done with a tag, easily, no need for a bar.
Ah, I just started looking into that as well, thanks for the hint
__________________
" ... and the Vogon will do things to you that you wish you'd never been born, or, if you're a clearer minded thinker, that the Vogon had never been born."
  Reply With Quote
11-29-10, 10:42 AM   #8
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
So you are going to track all kinds of power with a text based display? No bar?
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
12-01-10, 09:30 AM   #9
Pyrates
A Cliff Giant
 
Pyrates's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 77
Originally Posted by Dawn View Post
So you are going to track all kinds of power with a text based display? No bar?
Not sure if I'm confusing or if you are *G* I'm using ouf_Hank, which does indeed track all power types with a text. I'm changing that to have a bar at least when in cat/bear form, that's what the second bar is for. ouf_Hank does not track druid mana, but I'm gonna add that, and it's gonna be a text, too.
__________________
" ... and the Vogon will do things to you that you wish you'd never been born, or, if you're a clearer minded thinker, that the Vogon had never been born."
  Reply With Quote
12-01-10, 11:50 AM   #10
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Guess no one is confused, there was just a lack of information that could have helped in the first place.

So you want to add a bar (for druid mana) to a text based layout. That might be a little confusing, though.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
12-02-10, 07:44 AM   #11
Pyrates
A Cliff Giant
 
Pyrates's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 77
Originally Posted by Dawn View Post
So you want to add a bar (for druid mana) to a text based layout. That might be a little confusing, though.
ARg, no No idea why I can't express myself properly here, sorry! I do have what I wanted though, so in any case you might want to save your brainpower and not think about it anymore
__________________
" ... and the Vogon will do things to you that you wish you'd never been born, or, if you're a clearer minded thinker, that the Vogon had never been born."
  Reply With Quote
12-02-10, 10:24 AM   #12
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Originally Posted by Pyrates View Post
...
I'm changing that to have a bar at least when in cat/bear form, that's what the second bar is for.
...

Originally Posted by Pyrates View Post
...
but I'm gonna add that, and it's gonna be a text, too.
That's why!

Anyway, I'm just a little amused, nevermind.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Making an alternative power bar


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