View Single Post
07-24-16, 10:09 AM   #11
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
I was thinking more along the lines of:
Code:
local function ChangeDrawLayer(regionType, oldDrawLayer, newDrawLayer, ...)
	for index = 1, select('#', ...) do
		local region = select(index, ...)
		if region:IsObjectType(regionType) and region:GetDrawLayer() == oldDrawLayer then
			region:SetDrawLayer(newDrawLayer)
		end
	end
end

A.CreateHealth = function(f, unit)
    A.CreateHealthBar(f, unit);
    A.CreateHealthText(f, unit);
end
 
A.CreateHealthBar = function(f, unit)
    local Health = CreateFrame("StatusBar", f:GetName() .. "HealthBar", f);
    Health:SetFrameLevel(Health:GetFrameLevel() + 1);
    Health:SetStatusBarTexture(HEALTH_BAR);
    Health:SetStatusBarColor(0, 0, 0, 1);
 
    if unit == "player" then
        Health:SetPoint("TOPRIGHT", f, "TOPRIGHT", 0, 0);
        Health:SetSize(f:GetWidth() - 10, f:GetHeight() - 10);
    end
 
    Health:SetBackdrop({
        edgeFile = BACKDROP,
        edgeSize = 1,
        insets = {
            left = 1,
            right = 1,
            top = 1,
            bottom = 1,
        },
    });
    Health:SetBackdropBorderColor(1, 0, 0, 1);

    ChangeDrawLayer('Texture', 'BORDER', 'OVERLAY', Health:GetRegions())

    Health.bg = Health:CreateTexture(nil, "BACKGROUND");
    Health.bg:SetAllPoints(true);
    Health.bg:SetTexture(BACKDROP);
    Health.bg:SetVertexColor(0.5, 0.5, 0.5, 1);
 
    f.Health = Health;
    f.Health.bg = Health.bg;
end
 
A.CreateHealthText = function(f, unit)
 
end
 
A.CreatePower = function(f, unit)
    A.CreatePowerBar(f, unit);
    A.CreatePowerText(f, unit);
end
 
A.CreatePowerBar = function(f, unit)
    local Power = CreateFrame("StatusBar", f:GetName() .. "PowerBar", f);
    Power:SetFrameLevel(f.Health:GetFrameLevel() - 1);
    Power:SetStatusBarTexture(HEALTH_BAR);
    Power:SetStatusBarColor(1, 1, 1, 1);
 
    if unit == "player" then
        Power:SetPoint("BOTTOMLEFT", f, "BOTTOMLEFT", 0, 0);
        Power:SetSize(f:GetWidth() - 10, f:GetHeight() - 10);
    end
 
    Power:SetBackdrop({
        edgeFile = BACKDROP,
        edgeSize = 1,
        insets = {
            left = 1,
            right = 1,
            top = 1,
            bottom = 1,
        },
    });
    Power:SetBackdropBorderColor(0, 0, 1, 1);

    ChangeDrawLayer('Texture', 'BORDER', 'OVERLAY', Power:GetRegions())
 
    f.Power = Power;
end
 
A.CreatePowerText = function(f, unit)
 
end
  Reply With Quote