Well, here is one problem:
Originally Posted by lerb
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:
local function SkinGrid()
print("SkinGrid")
-- IMPORTANT: If Grid2 gives each of its parts a cluttery global name,
-- leave this line commented. Otherwise, uncomment it and adjust as
-- needed:
-- local GridFrame = Grid and Grid:GetModule("GridFrame")
if GridFrame and GridFrame.registeredFrames then
-- Grid is already loaded. Go ahead and skin the frames.
print("Grid is loaded!")
-- This function will be used to override the default border
-- coloring method on a Grid frame.
local function Grid_SetBackdropBorderColor(frame, r, g, b, a)
if a and a == 0 then
-- Instead of hiding the border when it's not showing a
-- status, we want to reset it to the default color.
frame:SetBorderColor()
else
-- Otherwise, we want to ignore the status's alpha value
-- and always show the border at 100% opacity.
frame:SetBorderColor(r, g, b)
end
end
-- This function adds a border to a single frame.
local function Grid_AddBorder(frame)
-- Check if we already added a border to this frame:
if not frame.SetBorderColor then
-- Tell Grid the border is very small, so it will adjust
-- the insets on the frame accordingly:
-- IMPORTANT: You will need to find the equivalent
-- function in Grid2 and change/uncomment this line:
-- frame:SetBorderSize(0.1)
-- Actually add the border:
CreateBorderChat(frame,
LeUI.media.bordersize,
LeUI.bordercolor,
LeUI.bordercolor,
LeUI.bordercolor,
2)
-- Hook the frame's border coloring method:
-- IMPORTANT: Find out if this is necessary with Grid2
-- and/or !Beautycase, and uncomment this line if so:
-- frame.SetBackdropBorderColor = Grid_SetBackdropBorderColor
-- Disable Grid's method for changing the border size:
-- IMPORTANT: Find the equiavlent function in Grid2 and
-- change/uncomment this line:
-- frame.SetBorderSize = noop
end
end
-- Loop through all of the frames that have already been created
-- and add a border to each one:
for frameName in pairs(GridFrame.registeredFrames) do
Grid_AddBorder(_G[frameName])
print("Added border to", frameName, "in SkinGrid.")
end
-- Hook Grid's RegisterFrame method to catch new frames when
-- they are created in the future:
hooksecurefunc(GridFrame, "RegisterFrame", function(frame)
Grid_AddBorder(frame)
print("Added border to", frame:GetName(), "in RegisterFrame hook.")
end
-- Return true, since the function successfully ran.
return true
end
end
if not SkinGrid() then
print("Grid not loaded.")
-- A nil return value indicates that Grid was not loaded yet,
-- so we need to watch for that:
local f = CreateFrame("Frame")
f:RegisterEvent("ADDON_LOADED")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function()
if SkinGrid() then
-- Grid is now loaded, and has been skinned.
-- Stop listening for addon loading events.
print("Grid is now loaded. Stop listening.")
f:UnregisterAllEvents()
f:SetScript("OnEvent", nil)
SkinGrid = nil
else
-- If SkinGrid() returned nil again, that means Grid is
-- still not loaded, so we should keep listening.
print("Grid is still not loaded. Keep listening.")
end
end)
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.