View Single Post
10-21-12, 05:18 AM   #3
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Thank you Phanx I searched the forums before I posted and saw some similar responses, but I couldn't wrap my head around this anyhow. I don't know if it's because of oUF_Simple or my poor Lua knowledge, but probably a mix of the two

Anyhow, it's working! I'll post this here so people searching in the future might get something out of it. And, please, correct me if what I'm stating is wrong. It's based only on my poor Lua knowledge

oUF_Simple, like a lot of other layouts, has a core.lua that handles all the functions for the unitframes. These functions create castbars, healthbars and all that. Then we have the style.lua that "activates" all these for the different units aswell as some other options such as each units individual height and width, for example.

First, we need a function that handles the frame for Harmony using oUFs element ClassIcons.

This is what I added to my core.lua:

Lua Code:
  1. lib.gen_ClassIcons = function(f)
  2.  
  3.     local ci = CreateFrame("Frame", nil, f)
  4.     ci:SetPoint('CENTER', f.Health, 'TOP', 0, 1)
  5.     ci:SetSize(200, 16)
  6.         for i = 1, 5 do
  7.             ci[i] = CreateFrame("StatusBar", f:GetName().."_ClassBar"..i, f)
  8.             ci[i]:SetSize(36, 16)
  9.             ci[i]:SetStatusBarTexture(cfg.statusbar_texture)
  10.             ci[i]:SetFrameLevel(11)
  11.             ci[i].SetVertexColor = ci[i].SetStatusBarColor
  12.             CreateBorder(ci[i],12,1,1,1,2) -- !beautycase border
  13.             local h = CreateFrame("Frame", nil, ci[i])
  14.             h:SetFrameLevel(10)
  15.             h:SetPoint("TOPLEFT",-4,3)
  16.             h:SetPoint("BOTTOMRIGHT",4,-3)
  17.             lib.gen_backdrop(h)
  18.             if (i == 1) then
  19.                 ci[i]:SetPoint('BOTTOMLEFT', f, 'TOPLEFT', -2, 7)
  20.             else
  21.                 ci[i]:SetPoint('TOPLEFT', ci[i-1], "TOPRIGHT", 6, 0)
  22.             end
  23.            
  24.         end
  25.     f.ClassIcons = ci
  26.   end

Here's what the player unit looked like in style.lua before adding ClassIcons:

Lua Code:
  1. --the player style
  2.   local function CreatePlayerStyle(self)
  3.     --style specific stuff
  4.     self.width = 200
  5.     self.height = 54
  6.     self.mystyle = "player"
  7.     init(self)
  8.     self.Health:SetStatusBarColor(.35,.35,.35)
  9.     self.Health.bg:SetVertexColor(.15,.15,.15)
  10.     self.Power.colorClass = true
  11.     self.Power.bg.multiplier = 0.2
  12.     self.Power.Smooth = true
  13.     self.Power.frequentUpdates = true
  14.     lib.gen_castbar(self)
  15.     lib.gen_portrait(self)
  16.   end

Simply add "lib.gen_ClassIcons(self)" which will attach ClassIcons to this unitframe:

Lua Code:
  1. --the player style
  2.   local function CreatePlayerStyle(self)
  3.     --style specific stuff
  4.     self.width = 200
  5.     self.height = 54
  6.     self.mystyle = "player"
  7.     init(self)
  8.     self.Health:SetStatusBarColor(.35,.35,.35)
  9.     self.Health.bg:SetVertexColor(.15,.15,.15)
  10.     self.Power.colorClass = true
  11.     self.Power.bg.multiplier = 0.2
  12.     self.Power.Smooth = true
  13.     self.Power.frequentUpdates = true
  14.     lib.gen_ClassIcons(self)
  15.     lib.gen_castbar(self)
  16.     lib.gen_portrait(self)
  17.   end

I hope this makes sense and that it's somewhat well executed. I'm still learning, so any inputs are welcome Thank you again Phanx.
  Reply With Quote