Thread Tools Display Modes
08-24-11, 05:26 AM   #1
Jonisaurus
An Aku'mai Servant
 
Jonisaurus's Avatar
Join Date: Aug 2011
Posts: 35
oUF Powerbar editing

I downloaded the oUF_Phanx setup and I'm trying to edit the Powerbar, healthbar, and their respective texts.

Currently in the oUF_Phanx setup the bars only show a percentage text when injured/not at max mana, and show an exact deficit text once you mouseover.

I'm trying to increase the size of the mana text (power text) and change its colour and position.

These are two extracts from Core.lua (oUF_Phanx) that I THINK are responsible for those things.

Code:
------------------------------------------------------------------------

ns.PostUpdatePower = function(self, unit, cur, max)
	local shown = self:IsShown()
	if max == 0 then
		if shown then
			self:Hide()
		end
		return
	elseif not shown then
		self:Show()
	end

	if UnitIsDeadOrGhost(unit) then
		self:SetValue(0)
		if self.value then
			self.value:SetText(nil)
		end
		return
	end

	if cur > 0 then
		self:GetStatusBarTexture():SetTexCoord(0, cur / max, 0, 1)
	end

	if not self.value then return end

	local _, type = UnitPowerType(unit)
	local color = colors.power[type] or colors.power.FUEL
	if cur < max then
		if self.__owner.isMouseOver then
			self.value:SetFormattedText("%s.|cff%02x%02x%02x%s|r", si(UnitPower(unit)), color[1] * 255, color[2] * 255, color[3] * 255, si(UnitPowerMax(unit)))
		elseif type == "MANA" then
			self.value:SetFormattedText("%d|cff%02x%02x%02x%%|r", floor(UnitPower(unit) / UnitPowerMax(unit) * 100 + 0.5), color[1] * 255, color[2] * 255, color[3] * 255)
		elseif cur > 0 then
			self.value:SetFormattedText("%d|cff%02x%02x%02x|r", floor(UnitPower(unit) / UnitPowerMax(unit) * 100 + 0.5), color[1] * 255, color[2] * 255, color[3] * 255)
		else
			self.value:SetText(nil)
		end
	elseif type == "MANA" and self.__owner.isMouseOver then
		self.value:SetFormattedText("|cff%02x%02x%02x%s|r", color[1] * 255, color[2] * 255, color[3] * 255, si(UnitPowerMax(unit)))
	else
		self.value:SetText(nil)
	end
end

------------------------------------------------------------------------
Code:
if uconfig.power then
		local power = ns.CreateStatusBar(self, ( uconfig.width or 1 ) > 0.75 and 16, "LEFT", true )
		power:SetFrameLevel( self.Health:GetFrameLevel() + 2 )
		power:SetPoint( "BOTTOMLEFT", self, "BOTTOMLEFT", 1, 1 )
		power:SetPoint( "BOTTOMRIGHT", self, "BOTTOMRIGHT", -1, 1 )
		power:SetHeight( config.height * config.powerHeight )
		self.Power = power

		if power.value then
			power.value:SetPoint( "BOTTOMLEFT", self, "BOTTOMLEFT", 4, config.height * config.powerHeight - 2 )
			power.value:SetPoint( "BOTTOMRIGHT", self.Health.value, "BOTTOMLEFT", -8, 0 )

			tinsert( self.mouseovers,power )
		end

		local powerColorMode = config.powerColorMode
		power.colorClass = powerColorMode == "CLASS"
		power.colorReaction = powerColorMode == "CLASS"
		power.colorPower = powerColorMode == "POWER"

		local powerBG = config.powerBG
		power.bg.multiplier = powerBG

		if powerColorMode == "CUSTOM" then
			local r, g, b = unpack( config.powerColor )
			power:SetStatusBarColor( r, g, b )
			power.bg:SetVertexColor( r / powerBG, g / powerBG, b / powerBG )
		end

		power.frequentUpdates = unit == "player"
		power.PostUpdate = ns.PostUpdatePower
	end
Thanks for your help!
  Reply With Quote
08-24-11, 06:09 AM   #2
nin
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 213
Hey!

Code:
local power = ns.CreateStatusBar(self, ( uconfig.width or 1 ) > 0.75 and 16, "LEFT", true )
Code:
if power.value then
			power.value:SetPoint( "BOTTOMLEFT", self, "BOTTOMLEFT", 4, config.height * config.powerHeight - 2 )
			power.value:SetPoint( "BOTTOMRIGHT", self.Health.value, "BOTTOMLEFT", -8, 0 )

* Fontsize
* Position, play with the values. changing 4 too 40 for example would move the power text more to the center of the uf's.


About coloring, what do you want too color?


Code:
color[1] * 255, color[2] * 255, color[3] * 255
* Changing these will change color. you probably want too check out a rgb table too see what color you want. 255,255,255 is white for example.

Edited: What phanx said.. thanks :-)

hope that helps, Good luck!

Last edited by nin : 08-26-11 at 04:01 AM.
  Reply With Quote
08-25-11, 06:41 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by nin View Post
If you want too change the color of the actual power text you can probably just try add this...
Code:
if power.value then
self.Power.value:SetTextColor(R,G,B)
			power.value:SetPoint( "BOTTOMLEFT", self, "BOTTOMLEFT", 4, config.height * config.powerHeight - 2 )
			power.value:SetPoint( "BOTTOMRIGHT", self.Health.value, "BOTTOMLEFT", -8, 0 )
That block of code is executed only once per unit frame, when the frame is created. Changing the color of the power text there will have absolutely no effect, since the color of the power text is set every time the power text changes (every time the unit's power changes).

You would actually need to change this line in the PostUpdatePower function:

Code:
local color = colors.power[type] or colors.power.FUEL
Since you did not specify what you want to change the color to, you'll have to figure out exactly what change is required yourself.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » oUF Powerbar editing


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