Quantcast WoWInterface - View Single Post - Needs Graphics Help regarding frame level and layers.
View Single Post
02-27-16, 03:25 AM   #1
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Needs Graphics Help regarding frame level and layers.

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:
  1. A.CreateHealthBar = function(f, unit)
  2.     local Health = CreateFrame("StatusBar", f:GetName() .. "HealthBar", f);
  3.     Health:SetFrameStrata("LOW");
  4.     Health:SetSize(f:GetWidth() - 12, f:GetHeight() - 12);
  5.  
  6.     if (unit == "player") then
  7.         Health:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1);
  8.     elseif (unit == "target") then
  9.         Health:SetPoint("TOPRIGHT", f, "TOPRIGHT", -1, -1);
  10.  
  11.         Health:SetReverseFill(true);
  12.     end
  13.  
  14.     Health:SetStatusBarTexture(STATUSBAR);
  15.     Health:SetStatusBarColor(0.4, 0.4, 0.4, 1);
  16.  
  17.     local backdrop = CreateFrame("Frame", nil, Health);
  18.     backdrop:SetSize(Health:GetWidth() + 2, Health:GetHeight() + 2);
  19.     backdrop:SetPoint("CENTER");
  20.     backdrop:SetBackdrop({
  21.         bgFile = nil,
  22.         edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
  23.         edgeSize = 1,
  24.         insets = {
  25.             left = 1,
  26.             right = 1,
  27.             top = 1,
  28.             bottom = 1,
  29.         },
  30.     });
  31.     backdrop:SetBackdropBorderColor(0.8, 0.8, 0.8, 1);
  32.  
  33.     Health.backdrop = backdrop;
  34.  
  35.     Health.bg = Health:CreateTexture(nil, "BACKGROUND");
  36.     Health.bg:SetAllPoints(true);
  37.     Health.bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground");
  38.     Health.bg:SetVertexColor(0.2, 0.2, 0.2, 1);
  39.  
  40.     A.AddOptions(Health, "frequentUpdates");
  41.  
  42.     f.Health = Health;
  43.     f.Health.bg = Health.bg;
  44. end
  45.  
  46. A.CreatePowerBar = function(f, unit)
  47.     local Power = CreateFrame("StatusBar", f:GetName() .. "PowerBar", f);
  48.     Power:SetFrameStrata("LOW");
  49.     Power:SetSize(f.Health:GetWidth(), f.Health:GetHeight());
  50.  
  51.     if (unit == "player") then
  52.         Power:SetPoint("TOPLEFT", f.Health.backdrop, "TOPLEFT", 11, -11);
  53.     elseif (unit == "target") then
  54.         Power:SetPoint("TOPRIGHT", f.Health.backdrop, "TOPRIGHT", -11, -11);
  55.  
  56.         Power:SetReverseFill(true);
  57.     end
  58.  
  59.     Power:SetStatusBarTexture(STATUSBAR);
  60.  
  61.     local backdrop = CreateFrame("Frame", nil, Power);
  62.     backdrop:SetSize(Power:GetWidth() + 2, Power:GetHeight() + 2);
  63.     backdrop:SetPoint("CENTER");
  64.     backdrop:SetBackdrop({
  65.         bgFile = nil,
  66.         edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
  67.         edgeSize = 1,
  68.         insets = {
  69.             left = 1,
  70.             right = 1,
  71.             top = 1,
  72.             bottom = 1,
  73.         },
  74.     });
  75.     backdrop:SetBackdropBorderColor(0.8, 0.8, 0.8, 1);
  76.  
  77.     Power.backdrop = backdrop;
  78.  
  79.     Power.bg = Power:CreateTexture(nil, "BACKGROUND");
  80.     Power.bg:SetAllPoints(true);
  81.     Power.bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground");
  82.     Power.bg:SetVertexColor(0.2, 0.2, 0.2, 1);
  83.     Power.bg.multiplier = 0.3;
  84.  
  85.     A.AddOptions(Power, "frequentUpdates", "colorClass", "colorClassNPC");
  86.  
  87.     f.Power = Power;
  88.     f.Power.bg = Power.bg;
  89. 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

Last edited by Layback_ : 02-27-16 at 05:04 AM.
  Reply With Quote