WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Classicon help (https://www.wowinterface.com/forums/showthread.php?t=52020)

10leej 03-03-15 01:33 AM

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?

Clamsoda 03-03-15 04:45 AM

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.

Phanx 03-03-15 05:43 AM

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


10leej 03-04-15 12:26 AM

Quote:

Originally Posted by Phanx (Post 307209)
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.

10leej 03-08-15 06:05 PM

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?

Phanx 03-08-15 06:54 PM

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


10leej 03-08-15 07:28 PM

Quote:

Originally Posted by Phanx (Post 307415)
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!

Phanx 03-10-15 01:01 AM

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



All times are GMT -6. The time now is 07:17 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI