Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 

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