04-15-12, 04:09 AM | #1 |
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! |
|
04-16-12, 08:38 AM | #2 |
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.
|
|
04-16-12, 01:30 PM | #3 |
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. |
|
04-17-12, 12:11 PM | #4 |
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; |
|
04-17-12, 03:47 PM | #5 | |
Code:
## Interface: 40300 addon.lua |
||
05-10-12, 03:58 PM | #6 |
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 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 Last edited by lerb : 05-10-12 at 05:11 PM. |
|
05-10-12, 11:11 PM | #7 |
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. |
|
05-11-12, 01:49 PM | #8 |
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
|
|
05-11-12, 08:27 PM | #9 |
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.
|
|
05-12-12, 03:42 AM | #10 |
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.
|
|
05-13-12, 04:47 AM | #11 |
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 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 |
|
05-13-12, 05:52 AM | #12 |
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 |
|
05-13-12, 08:00 AM | #13 |
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:
|
|
05-13-12, 02:03 PM | #14 | |
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.
__________________
|
||
05-14-12, 09:56 AM | #15 |
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:
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 |
|
05-14-12, 11:02 AM | #16 | ||
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:
>.> I'm still learning here too.
__________________
Last edited by unlimit : 05-14-12 at 11:20 AM. |
|||
05-14-12, 11:47 AM | #17 |
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\ Lua Code:
|
|
05-14-12, 12:48 PM | #18 | |
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! >.<
__________________
|
||
05-14-12, 11:26 PM | #19 |
I feel exactly the same way every time I get help on this forum but still have to crawl back for more
|
|
05-15-12, 12:42 AM | #20 | |
Well, here is one problem:
Lua Code:
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. |
||
WoWInterface » Developer Discussions » Lua/XML Help » Beautycase borders on Grid2 units |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|