AltPower.lua 1.82 KB
Newer Older
1 2 3
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local UF = E:GetModule('UnitFrames');

Simpy's avatar
stuff  
Simpy committed
4
local CreateFrame = CreateFrame
Simpy's avatar
Simpy committed
5

6
function UF:Construct_AltPowerBar(frame)
Simpy's avatar
Simpy committed
7
	local altpower = CreateFrame('StatusBar', '$parent_AlternativePower', frame)
Simpy's avatar
Simpy committed
8
	altpower:SetStatusBarTexture(E.media.blankTex)
Azilroka's avatar
Azilroka committed
9
	altpower:SetStatusBarColor(.7, .7, .6)
10
	altpower:GetStatusBarTexture():SetHorizTile(false)
Simpy's avatar
Simpy committed
11
	UF.statusbars[altpower] = true
Merathilis's avatar
Merathilis committed
12

13
	altpower:CreateBackdrop(nil, nil, nil, nil, true)
Simpy's avatar
Simpy committed
14 15 16
	altpower.BG = altpower:CreateTexture(nil, 'BORDER')
	altpower.BG:SetAllPoints()
	altpower.BG:SetTexture(E.media.blankTex)
17

18
	altpower.RaisedElementParent = CreateFrame('Frame', nil, altpower)
19 20 21 22
	altpower.RaisedElementParent:SetFrameLevel(altpower:GetFrameLevel() + 100)
	altpower.RaisedElementParent:SetAllPoints()

	altpower.value = altpower.RaisedElementParent:CreateFontString(nil, 'OVERLAY')
Simpy's avatar
Simpy committed
23
	altpower.value:Point('CENTER')
Simpy's avatar
Simpy committed
24
	altpower.value:SetJustifyH('CENTER')
Azilroka's avatar
Azilroka committed
25
	UF:Configure_FontString(altpower.value)
26

Simpy's avatar
Simpy committed
27 28
	altpower:SetScript('OnShow', UF.ToggleResourceBar)
	altpower:SetScript('OnHide', UF.ToggleResourceBar)
Azilroka's avatar
Azilroka committed
29
	altpower:Hide()
Rubgrsch's avatar
Rubgrsch committed
30

31 32 33
	return altpower
end

Azilroka's avatar
Azilroka committed
34
function UF:Configure_AltPowerBar(frame)
Simpy's avatar
Simpy committed
35
	local db = frame.db.classbar
36

Simpy's avatar
Simpy committed
37
	if db.enable then
Azilroka's avatar
Azilroka committed
38 39 40
		if not frame:IsElementEnabled('AlternativePower') then
			frame:EnableElement('AlternativePower')
			frame.AlternativePower:Show()
41
		end
42

Simpy's avatar
Simpy committed
43
		frame:Tag(frame.AlternativePower.value, db.altPowerTextFormat)
Simpy's avatar
Simpy committed
44
		UF:ToggleTransparentStatusBar(false, frame.AlternativePower, frame.AlternativePower.BG)
Simpy's avatar
Simpy committed
45

Simpy's avatar
Simpy committed
46 47 48
		local color = db.altPowerColor
		frame.AlternativePower:SetStatusBarColor(color.r, color.g, color.b)

Simpy's avatar
Simpy committed
49
		E:SetSmoothing(frame.AlternativePower, UF.db.smoothbars)
Simpy's avatar
Simpy committed
50 51 52
	elseif frame:IsElementEnabled('AlternativePower') then
		frame:DisableElement('AlternativePower')
		frame.AlternativePower:Hide()
53 54
	end
end