Thread Tools Display Modes
03-18-11, 08:20 AM   #21
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
This is what I use to add the altpower bar:
lua Code:
  1. local function AddAltPowerBar(self)
  2.     self.AltPowerBar = CreateFrame("StatusBar", "oUF_Rain_AltPowerBar", self)
  3.     self.AltPowerBar:SetHeight(3)
  4.     self.AltPowerBar:SetPoint("BOTTOMLEFT", self.Overlay, "TOPLEFT", 0, 1)
  5.     self.AltPowerBar:SetPoint("BOTTOMRIGHT", self.Overlay, "TOPRIGHT", 0, 1)
  6.     self.AltPowerBar:SetFrameLevel(self.Overlay:GetFrameLevel() + 1)
  7.     self.AltPowerBar:SetStatusBarTexture(cfg.TEXTURE)
  8.     self.AltPowerBar:SetStatusBarColor(0, 0.5, 1)
  9.     self.AltPowerBar:SetBackdrop(cfg.BACKDROP)
  10.     self.AltPowerBar:SetBackdropColor(0, 0, 0)
  11.    
  12.     self.AltPowerBar.Text = PutFontString(self.AltPowerBar, cfg.FONT2, 8, nil, "CENTER")
  13.     self.AltPowerBar.Text:SetPoint("CENTER", self.AltPowerBar, 0, 0)
  14.     self:Tag(self.AltPowerBar.Text, "[rain:altpower]")
  15.    
  16.     self.AltPowerBar.Tooltip = function(self)
  17.         local unit = self.__owner.unit
  18.         -- XXX Temp fix for vehicle
  19.         if unit == "vehicle" then unit = "player" end
  20.         -- XXX
  21.         local powerName = select(10, UnitAlternatePowerInfo(unit))
  22.         local powerTooltip = select(11, UnitAlternatePowerInfo(unit))
  23.        
  24.         if powerName then
  25.             GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT", 0, 5)
  26.             GameTooltip:AddLine(powerName)
  27.             if powerTooltip then
  28.                 GameTooltip:AddLine("\n"..powerTooltip, nil, nil, nil, true)
  29.             end
  30.             GameTooltip:Show()
  31.         end
  32.     end
  33.    
  34.     self.AltPowerBar:EnableMouse()
  35.     self.AltPowerBar:HookScript("OnLeave", GameTooltip_Hide)
  36.     self.AltPowerBar:HookScript("OnEnter", self.AltPowerBar.Tooltip)
  37.    
  38.     self.AltPowerBar.PostUpdate = ns.PostUpdateAltPower
  39. end

And this is how I call it from within UnitSpecific
lua Code:
  1. pet = function(self)
  2.     ns.AddAltPowerBar(self) -- we need to pass the player frame here or rework positioning code to use player frame name
  3.     end,

So the question is if I could pass the player frame to AddAltPowerBar from within the pet function or do I have to use the player frame name for positioning the bar. This is because I use different styles for player and pet and the Overlay element is only defined for player and target.

This is how it currently looks: http://img850.imageshack.us/i/wowscr...911213539.jpg/
  Reply With Quote
03-18-11, 02:19 PM   #22
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
As you say, you could just anchor the pet's AltPowerBar on the player frame. I don't really understand your question tho'.

You have pretty much full control over how units are spawned in your layout, and maintaining your own units table would just be a matter of populating it when your style function is called. That way you'd get something like oUF.units (which is most likely to be removed) just for your layout and frames.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
03-19-11, 04:49 AM   #23
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Maybe I can help out.

create altPowerBar function:
http://code.google.com/p/rothui/sour...ctions.lua#170

player frame function call:
http://code.google.com/p/rothui/sour...player.lua#795

pet frame function call:
http://code.google.com/p/rothui/sour...ts/pet.lua#160

If you use no lib just create a function at the top of your layout and create it twice. I added movability thus I need a global frame name. If you need that too add it, if not not.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
03-19-11, 03:15 PM   #24
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
Thanks zork. I actually had a look at your code before I posted my previous question. You anchor your altpower bar to UIParent, me to an element of the player frame (Overlay in the code in my previous post). When I name the element I could anchor to it, that is not the problem.

In
Code:
pet = function(self)
	ns.AddAltPowerBar(self)
end
'self' is the table containing the elements for the pet frame. I was just curious if I could pass the table for the player frame instead of the pet table. Something like this:
Code:
pet = function(self)
	ns.AddAltPowerBar(playerframe)
end
I know I don't profit from it more than just naming the elements and using those names for anchoring.
  Reply With Quote
03-19-11, 08:14 PM   #25
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Well I have a unit variable in my layout. Once I spawn a unit I save it in that so each "self" is accessible later if needed. (Which I don't atm.)

local unit = {}

--spawn player
--spawn playerAltPower
unit.player = self


-spawn pet
...
spawn pet altPower
petAltPower:SetAllPoints(unit.player.altPowerBar)

sth alike.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » UnitPowerAlt


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