Same background for multiple frames?
Hi there,
I've been using the same code to place the same background on different frames in my UI. It works fine but I'd like to figure out a more efficient way. For example, on my PlayerFrame (courtesy of LynMinimap) I might have the following code: Code:
local bg = CreateFrame('Frame', nil, PlayerFrame) Any help is greatly appreciated! |
Create a wrapper function that passes a variable, in this case, your intended frame. You can also combine lines 2 & 3.
Code:
local player_frame = MyAddOn:SkinFrame(PlayerFrame) |
You are already on the right track, spotting the fact the code is the same except in a very few locations. So fixing this shouldn't be hard. We first wrap this in a function, then we give that function an argument we call "parentFrame", then we can easily call the same code as many times as we like, and just provide it with a new frame to work with and do the exact operations.
Code:
local function SkinFrame(parentFrame) Code:
local BG_BACKDROP = { |
Vlad, no worries. I didn't even think about reusing the texture look up more effieciently. Good catch!
|
Wow, thanks for the quick replies! Tried it and it works perfectly! And now I see how you guys did it, it makes perfect sense. Thanks so much!
However, I noticed that when two of the "trans" backdrops overlap, the alpha doubles and becomes darker. Is there anyway to avoid this? Let them blend smoothly? Lastly, a side question, is there an easy way to show frames that are normally not shown, say if I wanted to put the same background on my party frames and wanted to see what it looks like? I'm no longer at my computer atm, but would it just be a case of PartyFrame1:Show() kind of deal? Thanks again! |
Quote:
Quote:
http://wowprogramming.com/docs http://wowprogramming.com/docs/widgets/VisibleRegion Widgets are basically special tables Blizzard created with their own metatables, often inheriting methods from parent widgets, there is a graph on the site above to illustrate the relations. Note that stuff like "PlayerFrame" are defined in the FrameXML of the game, you can find the sources online here: https://www.townlong-yak.com/framexml/beta https://www.townlong-yak.com/framexm...yerFrame.xml#7 You either have the widgets defined/created in the XML files, or you can find lua calling CreateFrame and specifying a widget type to create. http://wow.gamepedia.com/API_CreateFrame When modifying the default interface, I recommend first looking the code up and see how it works, usually you want to modify it at certain times, like events or specific function calls, and you can hooksecurefunc/HookScript accordingly and do your own stuff right after Blizzards code does its own thing. It can get a bit tricky with secure frames, if you manage to taint it, secure functions will stop working, like targeting when it comes to unit frames. Anyway that went far out of scope of the questions you asked. Sorry. |
Quote:
To work around this, you can temporarily set the frame to show the player unit: Code:
PartyMemberFrame1.unit = "player" Here's a small addon that provides a /fakeunits command to toggle the unit on a bunch of Blizzard unit frames: Code:
local frames = { |
All times are GMT -6. The time now is 09:15 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI