Quantcast
WoWInterface - View Single Post - Classicon help
Thread: Classicon help
View Single Post
03-03-15, 05:43 AM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The problem with your current code is that you're trying to add a border to the whole ClassIcons object -- which is fine, except that that object is just a table, rather than a frame, so it doesn't have the necessary methods.

If you want one border around the whole set of icons, make ClassIcons a frame:
Code:
local numIcons = 5
local iconSpacing = 1
local iconWidth = (cfg.player.width - (iconSpacing * (numIcons - 1)) / numIcons
local iconHeight = cfg.player.height / 4

local ClassIcons = CreateFrame("Frame", nil, self)
ClassIcons:SetSize(cfg.player.width, iconHeight)
ClassIcons:SetPoint("TOPLEFT", self.Power, "BOTTOMLEFT")

for index = 1, numIcons do
  local Icon = self:CreateTexture(nil, "BACKGROUND")
  Icon:SetTexture(cfg.statusbar_texture)
  Icon:SetSize(iconWidth, iconHeight)
  if index > 1 then
    Icon:SetPoint("LEFT", ClassIcons[index-1], "RIGHT", iconSpacing, 0)
  else
    Icon:SetPoint("LEFT", ClassIcons)
  end
  ClassIcons[index] = Icon
end

if isBeautiful then -- !Beautycase load check
  ClassIcons:CreateBeautyBorder(12)
  ClassIcons:SetBeautyBorderPadding(1)
end

self.ClassIcons = ClassIcons
If you want individual borders on each icon, make each icon a frame:
Code:
local numIcons = 5
local iconSpacing = 5 -- need wider spacing
local iconWidth = (cfg.player.width - (iconSpacing * (numIcons - 1)) / numIcons
local iconHeight = cfg.player.height / 4

local ClassIcons = {}

for index = 1, numIcons do
  local Icon = CreateFrame("Button", nil, self)
  Icon:SetNormalTexture(cfg.statusbar_texture)
  Icon:GetNormalTexture():SetAllPoints(true)
  Icon:SetSize(iconWidth, iconHeight)
  if index > 1 then
    Icon:SetPoint("LEFT", ClassIcons[index-1], "RIGHT", iconSpacing, 0)
  else
    Icon:SetPoint("TOPLEFT", self.Power, "BOTTOMLEFT")
  end
  if isBeautiful then -- !Beautycase load check
    Icon:CreateBeautyBorder(12)
    Icon:SetBeautyBorderPadding(1)
  end
  ClassIcons[index] = Icon
end

self.ClassIcons = ClassIcons
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote