Hi all,
So, I was trying to create unit frame layout with oUF that I saw somewhere (but can't remember where it was) and stuck with frame level and layer issues.
Here's what I have done so far.
Lua Code:
A.CreateHealthBar = function(f, unit)
local Health = CreateFrame("StatusBar", f:GetName() .. "HealthBar", f);
Health:SetFrameStrata("LOW");
Health:SetSize(f:GetWidth() - 12, f:GetHeight() - 12);
if (unit == "player") then
Health:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1);
elseif (unit == "target") then
Health:SetPoint("TOPRIGHT", f, "TOPRIGHT", -1, -1);
Health:SetReverseFill(true);
end
Health:SetStatusBarTexture(STATUSBAR);
Health:SetStatusBarColor(0.4, 0.4, 0.4, 1);
local backdrop = CreateFrame("Frame", nil, Health);
backdrop:SetSize(Health:GetWidth() + 2, Health:GetHeight() + 2);
backdrop:SetPoint("CENTER");
backdrop:SetBackdrop({
bgFile = nil,
edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeSize = 1,
insets = {
left = 1,
right = 1,
top = 1,
bottom = 1,
},
});
backdrop:SetBackdropBorderColor(0.8, 0.8, 0.8, 1);
Health.backdrop = backdrop;
Health.bg = Health:CreateTexture(nil, "BACKGROUND");
Health.bg:SetAllPoints(true);
Health.bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground");
Health.bg:SetVertexColor(0.2, 0.2, 0.2, 1);
A.AddOptions(Health, "frequentUpdates");
f.Health = Health;
f.Health.bg = Health.bg;
end
A.CreatePowerBar = function(f, unit)
local Power = CreateFrame("StatusBar", f:GetName() .. "PowerBar", f);
Power:SetFrameStrata("LOW");
Power:SetSize(f.Health:GetWidth(), f.Health:GetHeight());
if (unit == "player") then
Power:SetPoint("TOPLEFT", f.Health.backdrop, "TOPLEFT", 11, -11);
elseif (unit == "target") then
Power:SetPoint("TOPRIGHT", f.Health.backdrop, "TOPRIGHT", -11, -11);
Power:SetReverseFill(true);
end
Power:SetStatusBarTexture(STATUSBAR);
local backdrop = CreateFrame("Frame", nil, Power);
backdrop:SetSize(Power:GetWidth() + 2, Power:GetHeight() + 2);
backdrop:SetPoint("CENTER");
backdrop:SetBackdrop({
bgFile = nil,
edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeSize = 1,
insets = {
left = 1,
right = 1,
top = 1,
bottom = 1,
},
});
backdrop:SetBackdropBorderColor(0.8, 0.8, 0.8, 1);
Power.backdrop = backdrop;
Power.bg = Power:CreateTexture(nil, "BACKGROUND");
Power.bg:SetAllPoints(true);
Power.bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground");
Power.bg:SetVertexColor(0.2, 0.2, 0.2, 1);
Power.bg.multiplier = 0.3;
A.AddOptions(Power, "frequentUpdates", "colorClass", "colorClassNPC");
f.Power = Power;
f.Power.bg = Power.bg;
end
and here's the image link of what it does.
<JPG>
I was thinking to use "SetFrameStrata", "SetFrameLevel" and so on, but I have been told from someone that it is very risky to use them on many frames.
"imho playing with textureSubLevels should wait until you've got some more experience with how draw layers work. Otherwise you'll fall into some horrible practices by not planning your drawlayers in advance, such as your messed up situation of two "BACKGROUND" textures with completely different widgets."
|
So, I would like to ask how I would simply(?) fix the problem.
As long as I can fix this fault, I'm more than happy to re-write the entire code.
EDIT: "Power:SetFrameLevel(f.Health:GetFrameLevel() - 1);" and "Power.backdrop:SetFrameLevel(f.Health.backdrop:GetFrameLevel() - 1);" seem to be sending "Power" and "Power.backdrop" back to "Health" and "Health.backdrop". I guess this should be fine, but "Power.backdrop" is still sitting in front of "Health.bg", the background of "Health" status bar.
Any advises or tips are welcomd
!!
EDIT 2: Another question apart from this issue.
How could I flip StatusBarTexture vertically or horizontally?
I have tried Texture:SetTexCoord() thing, but it didn't work