Thread Tools Display Modes
10-07-09, 01:37 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Runebar and combobar

Yesterday I added the runebar and combobar to my oUF_Simple layout. Just want to share how I did it.

The basis of my runebar was p3lims code.
The basis for my combobar was Dawns code.

Result:
Combobar - Runebar

Runebar function hasn't changed much, just some small tweaks.

Code snipplets
Code:
  
  ----------------------------
  --variables
  ----------------------------
  
  local _, myclass = UnitClass("player")
  local castcol = { r = 0.9, g = 0.6, b = 0.4, }
  local bdc = { r = castcol.r*0.2, g = castcol.g*0.2, b = castcol.b*0.2, a = 0.93, }
  local mytexture = "Interface\\AddOns\\oUF_Simple\\statusbar"

  local tabvalues = {
    runes = {
      [1] = { 1, 0, 0  },
      [2] = { 1, 0, 0  },
      [3] = { 0, 0.5, 0 },
      [4] = { 0, 0.5, 0 },
      [5] = { 0, 1, 1 },
      [6] = { 0, 1, 1 },
    },
  }
  
  ----------------------------
  --functions
  ----------------------------
  
  --do me a backdrop
  local function kiss_set_me_a_backdrop(f)
    f:SetBackdrop( { 
      bgFile = mytexture, 
      edgeFile = "", tile = false, tileSize = 0, edgeSize = 32, 
      insets = { left = -2, right = -2, top = -2, bottom = -2 }
    })
    f:SetBackdropColor(bdc.r,bdc.g,bdc.b,bdc.a)
  end
  
  --combopoint unit changer by p3lim
  local function updateCombo(self, event, unit)
    if(unit == PlayerFrame.unit and unit ~= self.CPoints.unit) then
      self.CPoints.unit = unit
    end
  end
  
  --idea for code taken from oUF_viv by Dawn
  local function kiss_createComboPoints(self,unit)
    self.CPoints = {}
    self.CPoints.unit = "player"
    
    for i = 1, 5 do
      self.CPoints[i] = CreateFrame("Frame", nil, self)
      self.CPoints[i]:SetHeight(6)
      self.CPoints[i]:SetWidth((self.width+2) / 5 - 2 )
      kiss_set_me_a_backdrop(self.CPoints[i])
      self.CPoints[i].bg = self.CPoints[i]:CreateTexture(nil, "LOW")
      self.CPoints[i].bg:SetTexture(mytexture)
      self.CPoints[i].bg:SetAllPoints(self.CPoints[i])
      local y = ((-1)*(0.25*(i-1)))+1
      self.CPoints[i].bg:SetVertexColor(1,y,0)
      if(i==1) then
        self.CPoints[i]:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -5)
      else
        self.CPoints[i]:SetPoint("TOPLEFT", self.CPoints[i-1], "TOPRIGHT", 2, 0)
      end
    end
    --call function from p3lim
    self:RegisterEvent("UNIT_COMBO_POINTS", updateCombo)
  end
  
  --runebar func
  --code taken from oUF_P3lim (edited)
  local function kiss_CreateRuneBar(self,unit)  
    self.Runes = CreateFrame("Frame", nil, self)
    self.Runes:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -5)
    self.Runes:SetHeight(6)
    self.Runes:SetWidth(self.width)
    self.Runes.anchor = "TOPLEFT"
    self.Runes.growth = "RIGHT"
    self.Runes.height = 6
    self.Runes.spacing = 2
    self.Runes.width = (self.width+2) / 6 - 2
    for index = 1, 6 do
      self.Runes[index] = CreateFrame("StatusBar", nil, self.Runes)
      self.Runes[index]:SetStatusBarTexture(mytexture)
      local r, g, b = unpack(tabvalues.runes[index])
      self.Runes[index]:SetStatusBarColor(r, g, b)
      kiss_set_me_a_backdrop(self.Runes[index])
    end    
    --the following line will adjust the debuff to become reanchored.
    --self.Debuffs:SetPoint("TOP", self.Runes, "BOTTOM", 0, -5)    
  end
  
  ----------------------------
  --styles
  ----------------------------
  
  --create the player style
  local function CreatePlayerStyle(self, unit)
    self.width = 250
    -- ...
    if myclass == "DEATHKNIGHT" then
      kiss_CreateRuneBar(self,unit)
    end
  end  
    
  --create the target style
  local function CreateTargetStyle(self, unit)
    self.width = 250
    -- ...
    kiss_createComboPoints(self,unit)
  end  
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

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

Last edited by zork : 10-07-09 at 01:56 AM.
  Reply With Quote
08-15-10, 07:25 PM   #2
tmcnabb
A Fallenroot Satyr
 
tmcnabb's Avatar
Join Date: Feb 2005
Posts: 22
sorry to rez your old thread Zork

But for the life of me I can't get the runbar to show

Is this still the code you use?

Code:
  local function kiss_CreateRuneBar(self,unit)  
    self.Runes = CreateFrame("Frame", nil, self)
    self.Runes:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -5)
    self.Runes:SetHeight(6)
    self.Runes:SetWidth(self.width)
    self.Runes.anchor = "TOPLEFT"
    self.Runes.growth = "RIGHT"
    self.Runes.height = 6
    self.Runes.spacing = 2
    self.Runes.width = (self.width+2) / 6 - 2
    for index = 1, 6 do
      self.Runes[index] = CreateFrame("StatusBar", nil, self.Runes)
      self.Runes[index]:SetStatusBarTexture(mytexture)
      local r, g, b = unpack(tabvalues.runes[index])
      self.Runes[index]:SetStatusBarColor(r, g, b)
      kiss_set_me_a_backdrop(self.Runes[index])
    end    
    --the following line will adjust the debuff to become reanchored.
    --self.Debuffs:SetPoint("TOP", self.Runes, "BOTTOM", 0, -5)    
  end
  Reply With Quote
08-15-10, 08:25 PM   #3
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
sorry, I realize this thread is necroed lol.

Here is the code: (modified from oUF_Freeb). Put this in player style

lua Code:
  1. local _, class = UnitClass("player")
  2.         if class == "DEATHKNIGHT" then
  3.             self.Runes = CreateFrame("Frame", nil, self)
  4.             self.Runes:SetPoint("TOPRIGHT", self, "BOTTOMRIGHT", 0, 0)
  5.             self.Runes:SetSize(208/6 - 5, 7)
  6.             self.Runes.anchor = 'BOTTOM'
  7.             self.Runes.growth = 'RIGHT'
  8.             self.Runes.height = 8
  9.             self.Runes.width = 150
  10.                
  11.             for i = 1, 6 do
  12.                 self.Runes[i] = CreateFrame("StatusBar", nil, self.Runes)
  13.                 self.Runes[i]:SetStatusBarTexture(yourtexturehere)
  14.                 self.Runes[i]:SetSize(208/6 - 5, 7)
  15.    
  16.                 if i == 1 then
  17.                     self.Runes[i]:SetPoint("TOPLEFT", self.Runes, "TOPLEFT")
  18.                 else
  19.                     self.Runes[i]:SetPoint("RIGHT", self.Runes[i - 1], "LEFT", -5, 0)
  20.                 end
  21.                
  22.                 self.Runes[i].bg = self.Runes[i]:CreateTexture(nil, "BACKGROUND")
  23.                 self.Runes[i].bg:SetAllPoints(self.Runes[i])
  24.                 self.Runes[i].bg:SetTexture(yourtexturehere)
  25.                 self.Runes[i].bg.multiplier = .2
  26.                
  27.                 self.Runes[i].bd = CreateFrame("Frame", nil, self.Runes[i])
  28.                 self.Runes[i].bd:SetPoint("TOPLEFT", self.Runes[i], "TOPLEFT", 0, 0)
  29.                 self.Runes[i].bd:SetPoint("BOTTOMRIGHT", self.Runes[i], "BOTTOMRIGHT", 0, 0)
  30.                 self.Runes[i].bd:SetFrameStrata("LOW")
  31.                 self.Runes[i].bd:SetBackdrop(backdrophere)
  32.                 self.Runes[i].bd:SetBackdropColor(0, 0, 0, 1)
  33.                 self.Runes[i].bd:SetBackdropBorderColor(0, 0, 0)
  34.             end
  35.         end

Last edited by Ferous : 08-15-10 at 08:32 PM.
  Reply With Quote
08-15-10, 09:57 PM   #4
tmcnabb
A Fallenroot Satyr
 
tmcnabb's Avatar
Join Date: Feb 2005
Posts: 22
woot

thanks Ferous This didnt work for me out of the box but you gave me a nudge in the right direciton to get it working ..

replaced
Code:
self.Runes[i].bd:SetBackdrop(backdrop) 
self.Runes[i].bd:SetBackdropColor(0, 0, 0, 1)
self.Runes[i].bd:SetBackdropBorderColor(0, 0, 0)
with

Code:
kiss_set_me_a_backdrop(self.Runes[i])
thanks again ... now I will take this corpse of a thread and re-bury it.
  Reply With Quote
08-16-10, 12:33 PM   #5
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
...not yet...

Is there a new way to spawn graphical cpoints with oUF4? Or do we stick with how Zork/Dawn did it above?

Tried hacking mine together based on what worked for me prior to oUF 1.4 and what has been shown as the acceptable code for 1.4. I've created a mess - however when I click on a target it shows all 5 graphical elements - just doesn't update them. Any help would be appreciated.

Code:
		-- below function from Zork and p3lim

		local function kiss_set_me_a_backdrop(f)
			f:SetBackdrop( { 
			  bgFile = texture, 
			  edgeFile = "", tile = false, tileSize = 0, edgeSize = 32, 
			  insets = { left = -2, right = -2, top = -2, bottom = -2 }
			})
			f:SetBackdropColor(0,0,0,1)
		end
		
		local function updateCPoints(self, event, unit)
			if unit == PlayerFrame.unit and unit ~= self.CPoints.unit then
				self.CPoints.unit = unit
			end
		end
Code:
		local CPoints = {}
		CPoints.unit = "player"
		for index = 1, MAX_COMBO_POINTS do
			local CPoint = CreateFrame("Frame", nil, self.Health)
			CPoint:SetSize(9, 39)
			kiss_set_me_a_backdrop(CPoint)
			CPoint.bg = CPoint:CreateTexture(nil, "LOW")
			CPoint.bg:SetTexture(texture)
			CPoint.bg:SetAllPoints(CPoint)
			CPoint:SetPoint('LEFT', index == 1 and self.Health or CPoints[index - 1], 'RIGHT', 5, 0)

			if(index == 1) then CPoint.bg:SetVertexColor(1,1,0) end
			if(index == 2) then CPoint.bg:SetVertexColor(1,0.75,0) end
			if(index == 3) then CPoint.bg:SetVertexColor(1,0.5,0) end
			if(index == 4) then CPoint.bg:SetVertexColor(1,.6,0) end
			if(index == 5) then CPoint.bg:SetVertexColor(1,0,0) end
			self:RegisterEvent("UNIT_COMBO_POINTS", updateCPoints)
			CPoints[index] = CPoint
		end
		self.CPoints = CPoints

Last edited by Toran : 08-16-10 at 02:17 PM.
  Reply With Quote
08-16-10, 02:50 PM   #6
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
put the
Code:
self:RegisterEvent("UNIT_COMBO_POINTS", updateCPoints)
outside the loop for.
  Reply With Quote
08-16-10, 03:04 PM   #7
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
I just use the [cpoint] tag
  Reply With Quote
08-16-10, 03:44 PM   #8
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
http://wiki.github.com/haste/oUF/element-combo-points
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-16-10, 04:43 PM   #9
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Originally Posted by Rostok View Post
put the
Code:
self:RegisterEvent("UNIT_COMBO_POINTS", updateCPoints)
outside the loop for.
Thank you!

Here's the chunk of code that worked:

Code:
if playerClass == "ROGUE" or playerClass == "DRUID" then
			local CPoints = {}
			CPoints.unit = "player"
			for index = 1, MAX_COMBO_POINTS do
				local CPoint = CreateFrame("Frame", nil, self.Health)
				CPoint:SetHeight(6)
				CPoint:SetWidth(width * .96 / MAX_COMBO_POINTS)
				CPoint:SetFrameStrata("BACKGROUND")
				kiss_set_me_a_backdrop(CPoint)
				CPoint.bg = CPoint:CreateTexture(nil, "LOW")
				CPoint.bg:SetTexture(texture)
				CPoint.bg:SetAllPoints(CPoint)
				--CPoint:SetPoint('LEFT', index == 1 and self.Health or CPoints[index - 1], 'LEFT', 20, 10)
				if(index == 1) then
					CPoint:SetPoint("LEFT", self.Health, "LEFT", 0, 15)
				else
					CPoint:SetPoint("LEFT", CPoints[index-1], "RIGHT", 2, 0)
				end

				if(index == 1) then CPoint.bg:SetVertexColor(1,1,0) end
				if(index == 2) then CPoint.bg:SetVertexColor(1,0.75,0) end
				if(index == 3) then CPoint.bg:SetVertexColor(1,0.5,0) end
				if(index == 4) then CPoint.bg:SetVertexColor(1,0.25,0) end
				if(index == 5) then CPoint.bg:SetVertexColor(1,0,0) end
				CPoints[index] = CPoint
			end
			self:RegisterEvent("UNIT_COMBO_POINTS", updateCPoints)
			self.CPoints = CPoints
		end

Last edited by Toran : 08-16-10 at 04:49 PM.
  Reply With Quote
08-16-10, 07:12 PM   #10
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by Toran View Post
Thank you!

Here's the chunk of code that worked:

Code:
if playerClass == "ROGUE" or playerClass == "DRUID" then
			local CPoints = {}
			CPoints.unit = "player"
			for index = 1, MAX_COMBO_POINTS do
				local CPoint = CreateFrame("Frame", nil, self.Health)
				CPoint:SetHeight(6)
				CPoint:SetWidth(width * .96 / MAX_COMBO_POINTS)
				CPoint:SetFrameStrata("BACKGROUND")
				kiss_set_me_a_backdrop(CPoint)
				CPoint.bg = CPoint:CreateTexture(nil, "LOW")
				CPoint.bg:SetTexture(texture)
				CPoint.bg:SetAllPoints(CPoint)
				--CPoint:SetPoint('LEFT', index == 1 and self.Health or CPoints[index - 1], 'LEFT', 20, 10)
				if(index == 1) then
					CPoint:SetPoint("LEFT", self.Health, "LEFT", 0, 15)
				else
					CPoint:SetPoint("LEFT", CPoints[index-1], "RIGHT", 2, 0)
				end

				if(index == 1) then CPoint.bg:SetVertexColor(1,1,0) end
				if(index == 2) then CPoint.bg:SetVertexColor(1,0.75,0) end
				if(index == 3) then CPoint.bg:SetVertexColor(1,0.5,0) end
				if(index == 4) then CPoint.bg:SetVertexColor(1,0.25,0) end
				if(index == 5) then CPoint.bg:SetVertexColor(1,0,0) end
				CPoints[index] = CPoint
			end
			self:RegisterEvent("UNIT_COMBO_POINTS", updateCPoints)
			self.CPoints = CPoints
		end
Hmm that looks pretty, I might do that :P
  Reply With Quote
08-16-10, 11:44 PM   #11
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Toran View Post
Code:
if playerClass == "ROGUE" or playerClass == "DRUID" then
			local CPoints = {}
			CPoints.unit = "player"
			for index = 1, MAX_COMBO_POINTS do
				local CPoint = CreateFrame("Frame", nil, self.Health)
				CPoint:SetHeight(6)
				CPoint:SetWidth(width * .96 / MAX_COMBO_POINTS)
				CPoint:SetFrameStrata("BACKGROUND")
				kiss_set_me_a_backdrop(CPoint)
				CPoint.bg = CPoint:CreateTexture(nil, "LOW")
				CPoint.bg:SetTexture(texture)
				CPoint.bg:SetAllPoints(CPoint)
				--CPoint:SetPoint('LEFT', index == 1 and self.Health or CPoints[index - 1], 'LEFT', 20, 10)
				if(index == 1) then
					CPoint:SetPoint("LEFT", self.Health, "LEFT", 0, 15)
				else
					CPoint:SetPoint("LEFT", CPoints[index-1], "RIGHT", 2, 0)
				end

				if(index == 1) then CPoint.bg:SetVertexColor(1,1,0) end
				if(index == 2) then CPoint.bg:SetVertexColor(1,0.75,0) end
				if(index == 3) then CPoint.bg:SetVertexColor(1,0.5,0) end
				if(index == 4) then CPoint.bg:SetVertexColor(1,0.25,0) end
				if(index == 5) then CPoint.bg:SetVertexColor(1,0,0) end
				CPoints[index] = CPoint
			end
			self:RegisterEvent("UNIT_COMBO_POINTS", updateCPoints)
			self.CPoints = CPoints
		end
CPoints.unit = "player"
Isn't used by oUF.

self:RegisterEvent("UNIT_COMBO_POINTS", updateCPoints)
Is only used to update self.CPoints.unit, which isn't used by oUF.

Combo points also aren't restricted to class anymore, so restricting it to the player unit would be enough.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-17-10, 01:29 AM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by haste View Post
Combo points also aren't restricted to class anymore, so restricting it to the player unit would be enough.
To elaborate on this, you should always show combo points, regardless of what class the user is playing. The drakes in third phase of the Malygos encounter, for example, use combo points. If you only show combo points if the user is playing a rogue or a druid, then death knights, hunters, mages, paladins, priests, shamans, warlocks, and warriors will all be unable to see their drake's combo points.
  Reply With Quote
08-17-10, 10:28 AM   #13
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Originally Posted by haste View Post
CPoints.unit = "player"
Isn't used by oUF.

self:RegisterEvent("UNIT_COMBO_POINTS", updateCPoints)
Is only used to update self.CPoints.unit, which isn't used by oUF.

Combo points also aren't restricted to class anymore, so restricting it to the player unit would be enough.
Do I remove both of these then? Just concerned cpoints won't update.
  Reply With Quote
08-17-10, 10:31 AM   #14
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Originally Posted by Phanx View Post
To elaborate on this, you should always show combo points, regardless of what class the user is playing. The drakes in third phase of the Malygos encounter, for example, use combo points. If you only show combo points if the user is playing a rogue or a druid, then death knights, hunters, mages, paladins, priests, shamans, warlocks, and warriors will all be unable to see their drake's combo points.
Understood - and point well received. I will take that playerClass wrapper away. I also have the position of the debuffs above the combo points bar change depending on if there are cpoints or not. I don't think I had that using the playerClass conditional, but if I need to change can I use something like "if cpoints then" to detect if there are combo points and move the debuffs up?
  Reply With Quote
08-17-10, 10:33 AM   #15
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Originally Posted by Ferous View Post
Hmm that looks pretty, I might do that :P
Feel free, but I still need to clean a few things up per the replies from Haste and Phanx.
  Reply With Quote
08-17-10, 12:32 PM   #16
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Toran View Post
Do I remove both of these then? Just concerned cpoints won't update.
Yes, they have zero to do with oUF updating them or not. It was a trick to make vehicle cpoints work back in 1.3.x.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-17-10, 04:23 PM   #17
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Toran View Post
I also have the position of the debuffs above the combo points bar change depending on if there are cpoints or not. I don't think I had that using the playerClass conditional, but if I need to change can I use something like "if cpoints then" to detect if there are combo points and move the debuffs up?
Probably the cleanest way to do that would be to add a PostUpdate to your CPoints element, and move the Debuffs element up or down depending on whether any combo points are shown.
  Reply With Quote
08-17-10, 08:14 PM   #18
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Originally Posted by Phanx View Post
Probably the cleanest way to do that would be to add a PostUpdate to your CPoints element, and move the Debuffs element up or down depending on whether any combo points are shown.
Is this what I'm supposed to use? Just not clear on how to use it...

Code:
CPoints.Update(self, event)
  Reply With Quote
08-18-10, 02:42 AM   #19
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
self.CPoints.PostUpdate = somefunction
  Reply With Quote
08-18-10, 10:10 AM   #20
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Originally Posted by p3lim View Post
self.CPoints.PostUpdate = somefunction
Thanks. Still learning here, sorry for the multiple questions. Phanx said to add it to my cpoints element. Would it go under/above the "self.CPoints = CPoints"? And would it look like this (based on my code above):

Code:
self.CPoints.PostUpdate = CPoints
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Runebar and combobar


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