Thread Tools Display Modes
04-15-12, 04:09 AM   #1
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Beautycase borders on Grid2 units

So, I've been trying to find where Grid2 handles its healthbars so I can add !beautycase borders to them with its "createborderlight" function, but I can't find it. Anyone that can help me with this?

Or, if there's another way to skin the borders of the actual unitframes, not just the background frame, that would be great

Thanks in advance!
  Reply With Quote
04-16-12, 08:38 AM   #2
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
I've been trying to find something similar with "statusbar", or a createframe that creates the health statusbar, or just the background of each unit. Without luck, though.
  Reply With Quote
04-16-12, 01:30 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Post

Here is a standalone version of the code I use to apply borders to Grid. It's been a while since I looked at the internals of Grid2, but I don't think the basics of frame setup is that different. Maybe it will give you some clues, especially the parts I highlighted in gold. The parts highlighted in green are specific to my border code, so may need changes for use with Beautycase.
Code:
local function SkinGrid()
	local GridFrame = Grid and Grid:GetModule("GridFrame")
	if GridFrame and GridFrame.registeredFrames then
		-- print("Adding borders to Grid frames")

		local function Grid_SetBackdropBorderColor(f, r, g, b, a)
			if a and a == 0 then
				f:SetBorderColor()
			else
				f:SetBorderColor(r, g, b)
			end
		end

		local function Grid_AddBorder(f)
			if not f.SetBorderColor then
				f:SetBorderSize(0.1)
				AddBorder(f)
				f.SetBackdropBorderColor = Grid_SetBackdropBorderColor
				f.SetBorderSize = noop
			end
		end

		for frame in pairs(GridFrame.registeredFrames) do
			Grid_AddBorder(_G[frame])
		end

		local o = GridFrame.RegisterFrame
		GridFrame.RegisterFrame = function(self, f)
			o(self, f)
			Grid_AddBorder(f)
		end

		return true
	end
end

if not SkinGrid() then
	local f = CreateFrame("Frame")
	f:RegisterEvent("ADDON_LOADED")
	f:RegisterEvent("PLAYER_LOGIN")
	f:SetScript("OnEvent", function()
		if SkinGrid() then
			f:UnregisterAllEvents()
			f:SetScript("OnEvent", nil)
			SkinGrid = nil
		end
	end)
end

Last edited by Phanx : 04-17-12 at 03:48 PM.
  Reply With Quote
04-17-12, 12:11 PM   #4
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Thanks for sharing Phanx! Really nice of you, I think I took water over my head on this one

I've moved back to Grid because I like it better, and trying to get your code to work. To be honest, LUA is still an unfamiliar thing for me so I don't really know what to do with this code. Could I please ask for your help?

Here are the borders I'm trying to add btw;

  Reply With Quote
04-17-12, 03:47 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by lerb View Post
To be honest, LUA is still an unfamiliar thing for me so I don't really know what to do with this code. Could I please ask for your help?
Create a folder named "GridBorders" in your AddOns folder. Inside it, create a file named "addon.lua" and paste the code into it, and then create a basic TOC file named "GridBorders.toc" and paste this into it:
Code:
## Interface: 40300
addon.lua
Also, I edited my previous post to highlight the lines that may need to be changed for use with Beautycase instead of my personal border addon.
  Reply With Quote
05-10-12, 03:58 PM   #6
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Hi again Phanx! Hope you don't mind me necroing this thread.

I've been playing around with this again lately and got it working a little bit, but I can't get it to skin all the units. I've used /fstack to find out the names of the frames for the actual units in grid, not the background frame, and tried to attach a beautycase border to them with the beautycase function, which looks like this when I'm using your code;

Code:
		local function Grid_AddBorder(f)
			CreateBorderChat(GridLayoutHeader1UnitButton1, LeUI.media.bordersize, LeUI.bordercolor, LeUI.bordercolor, LeUI.bordercolor, 2)
		end
As you can see, if I hover myself in grid the frame is named GridLayoutHeader1UnitButton1. There was a couple of different frames to choose from but this one worked. Problem is, sometimes there's up to 40 of these. Do you have any clue how I could get a border on every unit? I guess I could create 40 CreateBorder lines, but that doesn't seem to be the correct way to go.

The different frames appearing when hovering the first unit in my party/raid with /fstack is;

1. GridLayoutHeader1UnitButton1
2. GridLayoutHeader1
3. GridLayoutFrame

Here's the full code as it looks right now, I have no way if it is efficient as it is now but at least it's partially working;

Code:
local function SkinGrid()
	local GridFrame = Grid and Grid:GetModule("GridFrame")
	if GridFrame and GridFrame.registeredFrames then
		-- print("Adding borders to Grid frames")

		local function Grid_AddBorder(f)
			CreateBorderChat(GridLayoutHeader1UnitButton1, LeUI.media.bordersize, LeUI.bordercolor, LeUI.bordercolor, LeUI.bordercolor, 2)
		end

		local o = GridFrame.RegisterFrame
		GridFrame.RegisterFrame = function(self, f)
			o(self, f)
			Grid_AddBorder(f)
		end

		return true
	end
end

if not SkinGrid() then
	local f = CreateFrame("Frame")
	f:RegisterEvent("ADDON_LOADED")
	f:RegisterEvent("PLAYER_LOGIN")
	f:SetScript("OnEvent", function()
		if SkinGrid() then
			f:UnregisterAllEvents()
			f:SetScript("OnEvent", nil)
			SkinGrid = nil
		end
	end)
end
And here's a screen to explain what I mean. As you can see, only the first "UnitButton" is skinned.


Last edited by lerb : 05-10-12 at 05:11 PM.
  Reply With Quote
05-10-12, 11:11 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That's because only the first frame exists when the addons load (eg. one frame for yourself, since the game doesn't yet know you're in a group).

You need to figure out what Grid's equivalent of :RegisterFrame is, and adjust the code accordingly. This is the function that is called when a new frame is created, and adds all of the visible elements (such as the frame's backdrop) and indicators to the frame.
  Reply With Quote
05-11-12, 01:49 PM   #8
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Alright! I'll hunt through grid's Lua-files when I get the time. If I do and find myself still clueless, could I ask you for more help? I like it when I have to do stuff myself so I learn, but still a newbie
  Reply With Quote
05-11-12, 08:27 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Isn't that the point of this forum? If you have a question, ask it. If you don't understand the answer, ask another question. If you need help with code, post the code and explain what you need help with.
  Reply With Quote
05-12-12, 03:42 AM   #10
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Yeah, with the risk of feeling annoying You know, when someone explains something and you think you undertand, but it turns out you don't so you have to ask them to explain even more. It's a rare thing that's going on in this forum, where people are so helpful.
  Reply With Quote
05-13-12, 04:47 AM   #11
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
I found this line in "GridFrame.lua"

Code:
function GridFrame:RegisterFrame(frame)
	self:Debug("RegisterFrame", frame:GetName())

	self.registeredFrameCount = (self.registeredFrameCount or 0) + 1
	self.registeredFrames[frame:GetName()] = self:InitializeFrame(frame)
	self:UpdateFrameUnits()
end
Changing it to this did exactly what I wanted! Thanks for the hints Phanx

Code:
function GridFrame:RegisterFrame(frame)
	self:Debug("RegisterFrame", frame:GetName())
	
	CreateBorderLight(frame, LeUI.media.bordersize, LeUI.bordercolor, LeUI.bordercolor, LeUI.bordercolor, 2)

	self.registeredFrameCount = (self.registeredFrameCount or 0) + 1
	self.registeredFrames[frame:GetName()] = self:InitializeFrame(frame)
	self:UpdateFrameUnits()
end
  Reply With Quote
05-13-12, 05:52 AM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You should generally avoid modifying addon files directly. The only reason to do so would be if the function you need to modify is declared as a local, and cannot be accessed from outside the file.

Code:
hooksecurefunc(GridFrame, "RegisterFrame", function(frame)
	CreateBorderLight(frame, LeUI.media.bordersize, LeUI.bordercolor, LeUI.bordercolor, LeUI.bordercolor, 2)
end
  Reply With Quote
05-13-12, 08:00 AM   #13
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Alright. But where should I be putting that hooksecurefunc? I've tried adding it to the SkinGrid addon but can't get it to work.

Here's how the code looks now, but it doesn't do anything since I don't have anything in the Grid_AddBorder funcion. If you could point out where to add it that would be awesome

lua Code:
  1. local function SkinGrid()
  2.     local GridFrame = Grid and Grid:GetModule("GridFrame")
  3.     if GridFrame and GridFrame.registeredFrames then
  4.         -- print("Adding borders to Grid frames")
  5.  
  6.         local function Grid_AddBorder(f)
  7.            
  8.         end
  9.  
  10.         local o = GridFrame.RegisterFrame
  11.         GridFrame.RegisterFrame = function(self, f)
  12.             o(self, f)
  13.             Grid_AddBorder(f)
  14.         end
  15.  
  16.         return true
  17.     end
  18. end
  19.  
  20. if not SkinGrid() then
  21.     local f = CreateFrame("Frame")
  22.     f:RegisterEvent("ADDON_LOADED")
  23.     f:RegisterEvent("PLAYER_LOGIN")
  24.     f:SetScript("OnEvent", function()
  25.         if SkinGrid() then
  26.             f:UnregisterAllEvents()
  27.             f:SetScript("OnEvent", nil)
  28.             SkinGrid = nil
  29.         end
  30.     end)
  31. end
  Reply With Quote
05-13-12, 02:03 PM   #14
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Originally Posted by lerb View Post
Alright. But where should I be putting that hooksecurefunc? I've tried adding it to the SkinGrid addon but can't get it to work.
I'd assume that if you're adding the hooksecurefunc to your addon, you should confirm that Grid2 actually loads up before your addon does by putting it as a dependency in your TOC file, then adding the hooksecurefunc before your other two functions.
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **
  Reply With Quote
05-14-12, 09:56 AM   #15
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Thanks for the hints unlimit. I did what you said, but still there seems to be something I'm missing. To make it simple, I tried using this code;

Lua Code:
  1. local function SkinGrid()
  2.     local GridFrame = Grid and Grid:GetModule("GridFrame")
  3.     if GridFrame and GridFrame.registeredFrames then
  4.         -- print("Adding borders to Grid frames")
  5.        
  6.         local function Grid_AddBorder(f)
  7.             CreateBorderLight(frame, LeUI.media.bordersize, LeUI.bordercolor, LeUI.bordercolor, LeUI.bordercolor, 2)
  8.         end
  9.        
  10.         hooksecurefunc(GridFrame, "RegisterFrame", function(frame)
  11.             Grid_AddBorder(f)
  12.         end)
  13.  
  14.         return true
  15.     end
  16. end
  17.  
  18. if not SkinGrid() then
  19.     local f = CreateFrame("Frame")
  20.     f:RegisterEvent("ADDON_LOADED")
  21.     f:RegisterEvent("PLAYER_LOGIN")
  22.     f:SetScript("OnEvent", function()
  23.         if SkinGrid() then
  24.             f:UnregisterAllEvents()
  25.             f:SetScript("OnEvent", nil)
  26.             SkinGrid = nil
  27.         end
  28.     end)
  29. end

Sadly, that doesn't do anything. I'm not sure about how hooksecurefunc works, but I'm guessing out of the blue that this code is something like this; "When grid spawns a new frame, this hooksecurefunc 'senses' it and fires my Grid_AddBorder function, which is a command that tells !beautycase to add a border to the frame spawned by grid".

Please, correct me if I'm wrong. Which I probably am
  Reply With Quote
05-14-12, 11:02 AM   #16
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Signature:
hooksecurefunc([table,] "function", hookfunc)

Arguments:
table - A table object that contains the function to be hooked (table)
function - The name of the function to be hooked (string)
hookfunc - The function to be called each time the original function is called (function)
So every time, in your case, GridFrame:RegisterFrame is called, the function you specify will also run along side of it. (I think.)

Also, I think half of the advice I gave you is also wrong. <.< Setting it as a dependency is right, but honestly I don't really know where to put the hooksecurefunc now that I look at the code? Possibly just:

lua Code:
  1. local function SkinGrid()
  2.     local GridFrame = Grid and Grid:GetModule("GridFrame")
  3.     if GridFrame and GridFrame.registeredFrames then
  4.        
  5.         hooksecurefunc(GridFrame, "RegisterFrame", function(frame)
  6.             CreateBorderLight(frame, LeUI.media.bordersize, LeUI.bordercolor, LeUI.bordercolor, LeUI.bordercolor, 2)
  7.             print("Adding borders to Grid frame")
  8.         end)
  9.  
  10.         return true
  11.     end
  12. end
  13.  
  14. if not SkinGrid() then
  15.     local f = CreateFrame("Frame")
  16.     f:RegisterEvent("ADDON_LOADED")
  17.     f:RegisterEvent("PLAYER_LOGIN")
  18.     f:SetScript("OnEvent", function()
  19.         if SkinGrid() then
  20.             f:UnregisterAllEvents()
  21.             f:SetScript("OnEvent", nil)
  22.             SkinGrid = nil
  23.         end
  24.     end)
  25. end

>.> I'm still learning here too.
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **

Last edited by unlimit : 05-14-12 at 11:20 AM.
  Reply With Quote
05-14-12, 11:47 AM   #17
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Using that code does not print the message, and gives this error;

Code:
Message: Interface\AddOns\!Beautycase\!Beautycase.lua:11: attempt to call method 'CreateTexture' (a nil value)
Time: 05/14/12 19:45:55
Count: 6
Stack: Interface\AddOns\!Beautycase\!Beautycase.lua:11: in function `CreateBorderLight'
Interface\AddOns\SkinGrid\SkinGrid.lua:6: in function <Interface\AddOns\SkinGrid\SkinGrid.lua:5>
[C]: in function `RegisterFrame'
Interface\AddOns\Grid\GridFrame.lua:33: in function `InitialConfigFunction'
Interface\AddOns\Grid\GridLayout.lua:122: in function `GridLayout_InitialConfigFunction'
Interface\AddOns\Grid\GridLayout.lua:144: in function `method'
Interface\FrameXML\RestrictedFrames.lua:721: in function <Interface\FrameXML\RestrictedFrames.lua:713>
[C]: ?
[C]: ?
Interface\FrameXML\RestrictedFrames.lua:740: in function `CallMethod'
[string "		RegisterUnitWatch(self)..."]:14: in function <[string "		RegisterUnitWatch(self)..."]:1>
(tail call): ?
...
(tail call): ?
[C]: ?
[string "safecall Dispatcher[1]"]:9: in function <[string "safecall Dispatcher[1]"]:5>
(tail call): ?
...AddOns\Bartender4\libs\AceAddon-3.0\AceAddon-3.0.lua:543: in function `EnableAddon'
...AddOns\Bartender4\libs\AceAddon-3.0\AceAddon-3.0.lua:636: in function <...AddOns\Bartender4\libs\AceAddon-3.0\AceAddon-3.0.lua:621>
[C]: in function `LoadAddOn'
Interface\FrameXML\UIParent.lua:274: in function `UIParentLoadAddOn'
Interface\FrameXML\UIParent.lua:297: in function `CombatLog_LoadUI'
Interface\FrameXML\UIParent.lua:616: in function <Interface\FrameXML\UIParent.lua:582>

Locals: self = <table> {
 SetDefaultModuleLibraries = <function> defined @Interface\AddOns\Bartender4\libs\AceAddon-3.0\AceAddon-3.0.lua:383
 UpdateFrameUnits = <function> defined @Interface\AddOns\Grid\GridFrame.lua:1320
 EnableModule = <function> defined @Interface\AddOns\Bartender4\libs\AceAddon-3.0\AceAddon-3.0.lua:348
 modules = <table> {
 }
 CancelTimer = <function> defined @Interface\AddOns\Grid\Libs\AceTimer-3.0\AceTimer-3.0.lua:311
 IterateEmbeds = <function> defined @Interface\AddOns\Bartender4\libs\AceAddon-3.0\AceAddon-3.0.lua:458
 ResetAllFrames = <function> defined @Interface\AddOns\Grid\GridFrame.lua:1291
 RegisterFrame = <function> defined =[C]:-1
 SendMessage_UpdateFrameUnits = <function> defined @Interface\AddOns\Grid\GridFrame.lua:1239
 debugging = false
 InvertBarColor = <function> defined @Interface\AddOns\Grid\GridFrame.lua:1312
 defaultModuleState = true
 IsEnabled = <function> defined @Interface\AddOns\Bartender4\libs\AceAddon-3.0\AceAddon-3.0.lua:467
 ScheduleTimer = <function> defined @Interface\AddOns\Grid\Libs\AceTimer-3.0\AceTimer-3.0.lua:276
 DisableModule = <function> defined @Interface\AddOns\Bartender4\libs\AceAddon-3.0\AceAddon-3.0.lua:366
 RegisterMessage = <function> defined @Interface\AddOns\Bartender4\libs\CallbackHandler-1.0\CallbackHandler-1.0.lua:118
 UnregisterMessage = <function> defined @Interface\AddOns\Bartender4\libs\CallbackHandler-1.0\CallbackHandler-1.0.lua:181
 RegisterBucketEvent = <function> defined @Interface\AddOns\Grid\Libs\AceBucket-3.0\AceBucket-3.0.lua:213
 Grid_StatusLost = <function> defined @Interface\AddOns\Grid\GridFrame.lua:1466
 db = <table> {
 }
 LibSharedMedia_Update = <function> defined @Interface\AddOns\Grid\GridFrame.lua:1243
 StatusForIndicator = <function> defined @Interface\AddOns\Grid\GridFrame.lua:1399
 SetEnabledState = <function> defined @Interface\AddOns\Bartender4\libs\AceAddon-3.0\AceAddon-3.0.lua:440
 enabledState = true
 RegisterEvent = <function> defined @Interface\AddOns\Bartender4\libs\CallbackHandler-1.0\CallbackHandler-1.0.lua:118
 IterateModules = <function> defined @Interface\AddOns\Bartender4\libs\AceAddon-3.0\AceAddon-3.0.lua:453
 UpdateOptionsMenu = <function> defined @Interface\AddOns\Grid\GridFrame.lua:1476
 registeredFrameCount = 6
 InitializeFrame = <function> defined @Interface\AddOns\Grid\GridFrame.lua:43
 InitialConfigFunction = <function> defined @Interface\AddOns\Grid\GridFrame.lua:32
 Enable = <function> defined @Interface\AddOns\Bartender4\libs\AceAddon-3.0\
I don't really know why. Here's the function in !beautycase that gave the error;

Lua Code:
  1. function CreateBorderLight(self, borderSize, R, G, B, ...)
  2.     local uL1, uL2, uR1, uR2, bL1, bL2, bR1, bR2 = ...
  3.     if (uL1) then
  4.         if (not uL2 and not uR1 and not uR2 and not bL1 and not bL2 and not bR1 and not bR2) then
  5.             uL2, uR1, uR2, bL1, bL2, bR1, bR2 = uL1, uL1, uL1, uL1, uL1, uL1, uL1
  6.         end
  7.     end
  8.     if (not self.HasBorder) then
  9.         self.Border = {}
  10.         for i = 1, 8 do
  11.             self.Border[i] = self:CreateTexture(nil, 'OVERLAY')
  12.             self.Border[i]:SetParent(self)
  13.             self.Border[i]:SetTexture(LeUI.media.borderlight)
  14.             self.Border[i]:SetSize(borderSize,borderSize)
  15.             self.Border[i]:SetVertexColor(R, G, B)
  16.         end
  17.        
  18.         self.Border[1]:SetTexCoord(0, 1/3, 0, 1/3)
  19.         self.Border[1]:SetPoint('TOPLEFT', self, -(uL1 or 0), uL2 or 0)
  20.  
  21.         self.Border[2]:SetTexCoord(2/3, 1, 0, 1/3)
  22.         self.Border[2]:SetPoint('TOPRIGHT', self, uR1 or 0, uR2 or 0)
  23.  
  24.         self.Border[3]:SetTexCoord(0, 1/3, 2/3, 1)
  25.         self.Border[3]:SetPoint('BOTTOMLEFT', self, -(bL1 or 0), -(bL2 or 0))
  26.  
  27.         self.Border[4]:SetTexCoord(2/3, 1, 2/3, 1)
  28.         self.Border[4]:SetPoint('BOTTOMRIGHT', self, bR1 or 0, -(bR2 or 0))
  29.  
  30.         self.Border[5]:SetTexCoord(1/3, 2/3, 0, 1/3)
  31.         self.Border[5]:SetPoint('TOPLEFT', self.Border[1], 'TOPRIGHT')
  32.         self.Border[5]:SetPoint('TOPRIGHT', self.Border[2], 'TOPLEFT')
  33.  
  34.         self.Border[6]:SetTexCoord(1/3, 2/3, 2/3, 1)
  35.         self.Border[6]:SetPoint('BOTTOMLEFT', self.Border[3], 'BOTTOMRIGHT')
  36.         self.Border[6]:SetPoint('BOTTOMRIGHT', self.Border[4], 'BOTTOMLEFT')
  37.  
  38.         self.Border[7]:SetTexCoord(0, 1/3, 1/3, 2/3)
  39.         self.Border[7]:SetPoint('TOPLEFT', self.Border[1], 'BOTTOMLEFT')
  40.         self.Border[7]:SetPoint('BOTTOMLEFT', self.Border[3], 'TOPLEFT')
  41.  
  42.         self.Border[8]:SetTexCoord(2/3, 1, 1/3, 2/3)
  43.         self.Border[8]:SetPoint('TOPRIGHT', self.Border[2], 'BOTTOMRIGHT')
  44.         self.Border[8]:SetPoint('BOTTOMRIGHT', self.Border[4], 'TOPRIGHT')
  45.        
  46.         local space
  47.         if (borderSize >= 10) then
  48.             space = 3.1
  49.         else
  50.             space = borderSize/3.5
  51.         end
  52.        
  53.         self.Shadow = {}       
  54.         for i = 1, 8 do
  55.             self.Shadow[i] = self:CreateTexture(nil, 'BORDER')
  56.             self.Shadow[i]:SetParent(self)
  57.             self.Shadow[i]:SetTexture(LeUI.media.shadow)
  58.             self.Shadow[i]:SetSize(borderSize, borderSize)  
  59.             self.Shadow[i]:SetVertexColor(0, 0, 0, 1)
  60.         end
  61.        
  62.         self.Shadow[1]:SetTexCoord(0, 1/3, 0, 1/3)
  63.         self.Shadow[1]:SetPoint('TOPLEFT', self, -(uL1 or 0)-space, (uL2 or 0)+space)
  64.  
  65.         self.Shadow[2]:SetTexCoord(2/3, 1, 0, 1/3)
  66.         self.Shadow[2]:SetPoint('TOPRIGHT', self, (uR1 or 0)+space, (uR2 or 0)+space)
  67.  
  68.         self.Shadow[3]:SetTexCoord(0, 1/3, 2/3, 1)
  69.         self.Shadow[3]:SetPoint('BOTTOMLEFT', self, -(bL1 or 0)-space, -(bL2 or 0)-space)
  70.  
  71.         self.Shadow[4]:SetTexCoord(2/3, 1, 2/3, 1)
  72.         self.Shadow[4]:SetPoint('BOTTOMRIGHT', self, (bR1 or 0)+space, -(bR2 or 0)-space)
  73.  
  74.         self.Shadow[5]:SetTexCoord(1/3, 2/3, 0, 1/3)
  75.         self.Shadow[5]:SetPoint('TOPLEFT', self.Shadow[1], 'TOPRIGHT')
  76.         self.Shadow[5]:SetPoint('TOPRIGHT', self.Shadow[2], 'TOPLEFT')
  77.  
  78.         self.Shadow[6]:SetTexCoord(1/3, 2/3, 2/3, 1)
  79.         self.Shadow[6]:SetPoint('BOTTOMLEFT', self.Shadow[3], 'BOTTOMRIGHT')
  80.         self.Shadow[6]:SetPoint('BOTTOMRIGHT', self.Shadow[4], 'BOTTOMLEFT')
  81.  
  82.         self.Shadow[7]:SetTexCoord(0, 1/3, 1/3, 2/3)
  83.         self.Shadow[7]:SetPoint('TOPLEFT', self.Shadow[1], 'BOTTOMLEFT')
  84.         self.Shadow[7]:SetPoint('BOTTOMLEFT', self.Shadow[3], 'TOPLEFT')
  85.  
  86.         self.Shadow[8]:SetTexCoord(2/3, 1, 1/3, 2/3)
  87.         self.Shadow[8]:SetPoint('TOPRIGHT', self.Shadow[2], 'BOTTOMRIGHT')
  88.         self.Shadow[8]:SetPoint('BOTTOMRIGHT', self.Shadow[4], 'TOPRIGHT')
  89.  
  90.         self.HasBorder = true
  91.     end
  92. end
  Reply With Quote
05-14-12, 12:48 PM   #18
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Gee Wizz. D: Errors left and right. Yeah, like I said, I'm not really sure. Phanx or someone else who actually knows what they're doing is going to look at that code and think: "Nice job retard Unlimit!" the next time they get the chance! >.<
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **
  Reply With Quote
05-14-12, 11:26 PM   #19
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
I feel exactly the same way every time I get help on this forum but still have to crawl back for more
  Reply With Quote
05-15-12, 12:42 AM   #20
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, here is one problem:

Originally Posted by lerb View Post
Code:
		local function Grid_AddBorder(f)
			CreateBorderLight(frame, LeUI.media.bordersize, LeUI.bordercolor, LeUI.bordercolor, LeUI.bordercolor, 2)
Here is a more commented version of what should, theoretically, be working code:

Lua Code:
  1. local function SkinGrid()
  2.     print("SkinGrid")
  3.  
  4.     -- IMPORTANT: If Grid2 gives each of its parts a cluttery global name,
  5.     -- leave this line commented. Otherwise, uncomment it and adjust as
  6.     -- needed:
  7.  
  8.     -- local GridFrame = Grid and Grid:GetModule("GridFrame")
  9.  
  10.     if GridFrame and GridFrame.registeredFrames then
  11.         -- Grid is already loaded. Go ahead and skin the frames.
  12.         print("Grid is loaded!")
  13.  
  14.         -- This function will be used to override the default border
  15.         -- coloring method on a Grid frame.
  16.         local function Grid_SetBackdropBorderColor(frame, r, g, b, a)
  17.             if a and a == 0 then
  18.                 -- Instead of hiding the border when it's not showing a
  19.                 -- status, we want to reset it to the default color.
  20.                 frame:SetBorderColor()
  21.             else
  22.                 -- Otherwise, we want to ignore the status's alpha value
  23.                 -- and always show the border at 100% opacity.
  24.                 frame:SetBorderColor(r, g, b)
  25.             end
  26.         end
  27.  
  28.         -- This function adds a border to a single frame.
  29.         local function Grid_AddBorder(frame)
  30.             -- Check if we already added a border to this frame:
  31.             if not frame.SetBorderColor then
  32.                 -- Tell Grid the border is very small, so it will adjust
  33.                 -- the insets on the frame accordingly:
  34.  
  35.                 -- IMPORTANT: You will need to find the equivalent
  36.                 -- function in Grid2 and change/uncomment this line:
  37.  
  38.                 -- frame:SetBorderSize(0.1)
  39.  
  40.                 -- Actually add the border:
  41.                 CreateBorderChat(frame,
  42.                     LeUI.media.bordersize,
  43.                     LeUI.bordercolor,
  44.                     LeUI.bordercolor,
  45.                     LeUI.bordercolor,
  46.                     2)
  47.  
  48.                 -- Hook the frame's border coloring method:
  49.  
  50.                 -- IMPORTANT: Find out if this is necessary with Grid2
  51.                 -- and/or !Beautycase, and uncomment this line if so:
  52.  
  53.                 -- frame.SetBackdropBorderColor = Grid_SetBackdropBorderColor
  54.  
  55.  
  56.  
  57.                 -- Disable Grid's method for changing the border size:
  58.  
  59.                 -- IMPORTANT: Find the equiavlent function in Grid2 and
  60.                 -- change/uncomment this line:
  61.  
  62.                 -- frame.SetBorderSize = noop
  63.             end
  64.         end
  65.  
  66.         -- Loop through all of the frames that have already been created
  67.         -- and add a border to each one:
  68.         for frameName in pairs(GridFrame.registeredFrames) do
  69.             Grid_AddBorder(_G[frameName])
  70.             print("Added border to", frameName, "in SkinGrid.")
  71.         end
  72.  
  73.         -- Hook Grid's RegisterFrame method to catch new frames when
  74.         -- they are created in the future:
  75.         hooksecurefunc(GridFrame, "RegisterFrame", function(frame)
  76.             Grid_AddBorder(frame)
  77.             print("Added border to", frame:GetName(), "in RegisterFrame hook.")
  78.         end
  79.  
  80.         -- Return true, since the function successfully ran.
  81.         return true
  82.     end
  83. end
  84.  
  85. if not SkinGrid() then
  86.     print("Grid not loaded.")
  87.     -- A nil return value indicates that Grid was not loaded yet,
  88.     -- so we need to watch for that:
  89.     local f = CreateFrame("Frame")
  90.     f:RegisterEvent("ADDON_LOADED")
  91.     f:RegisterEvent("PLAYER_LOGIN")
  92.     f:SetScript("OnEvent", function()
  93.         if SkinGrid() then
  94.             -- Grid is now loaded, and has been skinned.
  95.             -- Stop listening for addon loading events.
  96.             print("Grid is now loaded. Stop listening.")
  97.             f:UnregisterAllEvents()
  98.             f:SetScript("OnEvent", nil)
  99.             SkinGrid = nil
  100.         else
  101.             -- If SkinGrid() returned nil again, that means Grid is
  102.             -- still not loaded, so we should keep listening.
  103.             print("Grid is still not loaded. Keep listening.")
  104.         end
  105.     end)
  106. end

Comments beginning with "IMPORTANT:" indicate sections that may need to be changed depending on how !Beautycase and/or Grid2 work internally. The code should work as-is, but if something doesn't work, those are the sections you should check first.

Not tested in-game, so may contain syntax errors.

Last edited by Phanx : 05-15-12 at 12:44 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Beautycase borders on Grid2 units

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