Thread Tools Display Modes
Prev Previous Post   Next Post Next
07-23-16, 08:07 AM   #1
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Setting frame levels

Hi all,

Since yesterday, I have started to create my own unitframe with oUF which I am feeling a lot of fun !!

I Just got some questions regarding frame creation(?).

Let's have a look at the code first:
Lua Code:
  1. A.CreateHealth = function(f, unit)
  2.     A.CreateHealthBar(f, unit);
  3. end
  4.  
  5. A.CreateHealthBar = function(f, unit)
  6.     local Health = CreateFrame("StatusBar", f:GetName() .. "HealthBar", f);
  7.     Health:SetStatusBarTexture(HEALTH_BAR);
  8.     Health:SetStatusBarColor(0, 0, 0, 1);
  9.     Health:SetFrameLevel(3);
  10.  
  11.     if unit == "player" then
  12.         Health:SetPoint("TOPRIGHT", f, "TOPRIGHT", -1, -1);
  13.         Health:SetSize(f:GetWidth() - 12, f:GetHeight() - 12);
  14.     end
  15.  
  16.     local backdrop = CreateFrame("Frame", nil, Health);
  17.     backdrop:SetSize(Health:GetWidth() + 2, Health:GetHeight() + 2);
  18.     backdrop:SetPoint("CENTER");
  19.     backdrop:SetBackdrop({
  20.         edgeFile = BACKDROP,
  21.         edgeSize = 1,
  22.     });
  23.     backdrop:SetBackdropBorderColor(1, 0, 0, 1);
  24.  
  25.     Health.bg = Health:CreateTexture(nil, "BACKGROUND");
  26.     Health.bg:SetAllPoints(true);
  27.     Health.bg:SetTexture(BACKDROP);
  28.     Health.bg:SetVertexColor(0.5, 0.5, 0.5, 1);
  29.  
  30.     f.Health = Health;
  31.     f.Health.bg = Health.bg;
  32. end
  33.  
  34. A.CreatePower = function(f, unit)
  35.     A.CreatePowerBar(f, unit);
  36. end
  37.  
  38. A.CreatePowerBar = function(f, unit)
  39.     local Power = CreateFrame("StatusBar", f:GetName() .. "PowerBar", f);
  40.     Power:SetStatusBarTexture(HEALTH_BAR);
  41.     Power:SetStatusBarColor(1, 1, 1, 1);
  42.     Power:SetFrameLevel(2);
  43.  
  44.     if unit == "player" then
  45.         Power:SetPoint("BOTTOMLEFT", f, "BOTTOMLEFT", 1, 1);
  46.         Power:SetSize(f:GetWidth() - 12, f:GetHeight() - 12);
  47.     end
  48.  
  49.     local backdrop = CreateFrame("Frame", nil, Power);
  50.     backdrop:SetSize(Power:GetWidth() + 2, Power:GetHeight() + 2);
  51.     backdrop:SetPoint("CENTER");
  52.     backdrop:SetBackdrop({
  53.         edgeFile = BACKDROP,
  54.         edgeSize = 1,
  55.     });
  56.     backdrop:SetBackdropBorderColor(0, 0, 1, 1);
  57.  
  58.     f.Power = Power;
  59. end

The code above currently results in the following:

Health Bar - Black status bar with Red border and Grey background
Power Bar - White status bar with Blue border (currently have no background)


SO..... here's my question.

1. Would it be possible to create a border for status bar frame without creating another frame (which is called 'backdrop' in this case).

2. As you can see, Power Bar's border is sitting on top of the Health Bar's background. What would be the best solution to fix this problem?
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Setting frame levels


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off