Quantcast
Classicon help - WoWInterface
Thread Tools Display Modes
03-03-15, 01:33 AM   #1
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 581
Classicon help

So trying to skin classicon with !beautycase it seems to cause errors when I call the !Beautycase "CreateBeautyBorder" function. Anyone know if I can do this or should I just not bother skinning them with !Beautycase?

current code
Lua Code:
  1. local isBeautiful = IsAddOnLoaded("!Beautycase") --!Beautycase check
  2. local ClassIcons = {}
  3. for index = 1, 5 do
  4.   local Icon = self:CreateTexture(nil, 'BACKGROUND')
  5.   Icon:SetTexture(cfg.statusbar_texture)
  6.   Icon:SetSize(cfg.player.width/5,cfg.player.height/4)
  7.   Icon:SetPoint("TOPRIGHT", self.Power, "BOTTOMLEFT", index * Icon:GetWidth(),0)
  8.  
  9.   ClassIcons[index] = Icon
  10.   if isBeautiful then --!Beautycase load check
  11.     ClassIcons:CreateBeautyBorder(12)
  12.     ClassIcons:SetBeautyBorderPadding(1)
  13.   end
  14. end
  15.        
  16. -- Register with oUF
  17. self.ClassIcons = ClassIcons

Also how does one put space in between each icon?
__________________
Tweets YouTube Website
  Reply With Quote
03-03-15, 04:45 AM   #2
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
I am not sure how BeautyCase approaches adding borders to objects, but textures do not have borders to work on; typically you manipulate the border of a frame.

You would need to create a frame the size of the class icon, place the class icon on the frame, and manipulate the border of the frame to achieve the desired effect.
  Reply With Quote
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
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Donít message me about addon bugs or programming questions.
  Reply With Quote
03-04-15, 12:26 AM   #4
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 581
Originally Posted by Phanx View Post
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
Oh, that's makes sense now.
__________________
Tweets YouTube Website
  Reply With Quote
03-08-15, 06:05 PM   #5
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 581
Lua Code:
  1. local numIcons = 5
  2. local iconSpacing = 5 -- need wider spacing
  3. local iconWidth = ((cfg.player.width/5) - (iconSpacing * (numIcons - 1)) / numIcons)
  4. local iconHeight = (cfg.player.height / 4)
  5.  
  6. local ClassIcons = {}
  7.  
  8. for index = 1, numIcons do
  9.     local Icon = CreateFrame("Button", nil, self)
  10.     Icon:SetNormalTexture(cfg.statusbar_texture)
  11.     Icon:GetNormalTexture():SetAllPoints(true)
  12.     Icon:SetSize(iconWidth, iconHeight)
  13.     if index > 1 then
  14.         Icon:SetPoint("LEFT", ClassIcons[index-1], "RIGHT", iconSpacing, 0)
  15.     else
  16.         Icon:SetPoint("TOPLEFT", self.Power, "BOTTOMLEFT")
  17.     end
  18.     if isBeautiful then -- !Beautycase load check
  19.         Icon:CreateBeautyBorder(12)
  20.         Icon:SetBeautyBorderPadding(1)
  21.     end
  22.     ClassIcons[index] = Icon
  23. end
  24.  
  25. self.ClassIcons = ClassIcons
  26. end

nets me this error
Code:
2x oUF\elements\classicons.lua:81: attempt to call method 'SetVertexColor' (a nil value)
oUF\elements\classicons.lua:81: in function <oUF\elements\classicons.lua:60>
oUF\elements\classicons.lua:248: in function 'enable'
oUF\ouf-1.6.8.lua:99: in function 'EnableElement'
oUF\ouf-1.6.8.lua:269: in function <oUF\ouf.lua:192>
(tail call): ?
oUF\ouf-1.6.8.lua:552: in function 'Spawn'
oUF_Bob\modules\units.lua:690: in function 'func'
oUF\factory.lua:20: in function <oUF\factory.lua:16>
(tail call): ?
Did i miss something?
__________________
Tweets YouTube Website
  Reply With Quote
03-08-15, 06:54 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
No; oUF annoyingly assumes the objects are textures. Just add a dummy method to shut it up:

Code:
for index = 1, numIcons do
    local Icon = CreateFrame("Button", nil, self)
    Icon.SetVertexColor = nop
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Donít message me about addon bugs or programming questions.
  Reply With Quote
03-08-15, 07:28 PM   #7
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 581
Originally Posted by Phanx View Post
No; oUF annoyingly assumes the objects are textures. Just add a dummy method to shut it up:

Code:
for index = 1, numIcons do
    local Icon = CreateFrame("Button", nil, self)
    Icon.SetVertexColor = nop
ah ok thank you Phanx!
__________________
Tweets YouTube Website
  Reply With Quote
03-10-15, 01:01 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The other option, if you actually wanted to let oUF control the color, would be to point the SetVertexColor method to something useful:

Code:
local function SetVertexColor(self, r, g, b)
    self:GetNormalTexture():SetVertexColor(r, g, b)
end
for index = 1, numIcons do
    local Icon = CreateFrame("Button", nil, self)
    Icon:SetNormalTexture(cfg.statusbar_texture)
    Icon:GetNormalTexture():SetAllPoints(true)
    Icon.SetVertexColor = SetVertexColor
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Donít message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Classicon help

Thread Tools
Display Modes

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