-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKabRageBar.lua
165 lines (147 loc) · 4.76 KB
/
KabRageBar.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
local width = 108
local height = 25
local state = 1
local xpos = 0
local ypos = -155
--
local covenant = "none" -- (none,nec,ven,kyr,fae)
local border = "classic" -- (classic, shadowlands)
---
if border == "shadowlands" then
bgPath = "Interface\\Tooltips\\UI-Tooltip-Background-Maw"
edgePath = "Interface\\Tooltips\\UI-Tooltip-Border-Maw"
ypos = -154
else
bgPath = "Interface\\Tooltips\\UI-Tooltip-Background"
edgePath = "Interface\\Tooltips\\UI-Tooltip-Border"
ypos = -155
end
if covenant == "nec" then
bdr,bdg,bdb,bda = 0.7,0.9,0.7,1 --border r,g,b,a
bkr,bkg,bkb,bka = 0.2,0.4,0.2,1 --background r,g,b,a
elseif covenant == "ven" then
bdr,bdg,bdb,bda = 1.0,0.5,0.4,1
bkr,bkg,bkb,bka = 0.2,0.1,0.1,1
elseif covenant == "kyr" then
bdr,bdg,bdb,bda = 0.7,0.8,1.0,1
bkr,bkg,bkb,bka = 0.3,0.4,0.9,1
elseif covenant == "fae" then
bdr,bdg,bdb,bda = 0.6,0.5,0.9,1
bkr,bkg,bkb,bka = 0.3,0.1,0.3,1
else
bdr,bdg,bdb,bda = 0.15,0.15,0.15,1
bkr,bkg,bkb,bka = 0.15,0.15,0.15,1
end
local r,g,b = 0,0,1 -- blue default
local _,class = UnitClass("player")
local showcapped = false
-- https://wow.gamepedia.com/Power_colors
-- https://wow.gamepedia.com/Class_colors
if class == "DEATHKNIGHT" then r,g,b = 0,0.82,1 end
--if class == "DEMONHUNTER" then r,g,b = 1,0.61,0 end -- veng
if class == "DEMONHUNTER" then r,g,b = 0.788,0.259,0.992 end -- havoc
-- if class == "DRUID" then r,g,b = 1,0,0 end -- guardian
if class == "DRUID" then r,g,b = 0,0,1 end -- resto,moonkin
--if class == "DRUID" then r,g,b = 1,1,0 end -- feral
if class == "HUNTER" then r,g,b = 1,0.5,0.25 end
--if class == "MAGE" then r,g,b = 0,0,1 end
if class == "MONK" then r,g,b = 1,1,0 end
--if class == "PALADIN" then r,g,b = 0,0,1 end
--if class == "PRIEST" then r,g,b = 0.4,0,0.8 end --shadow
--if class == "PRIEST" then r,g,b = 0,0,1 end
if class == "ROGUE" then r,g,b = 1,1,0 end
--if class == "SHAMAN" then r,g,b = 0,0.50,1 end -- enhance
--if class == "SHAMAN" then r,g,b = 0,0,1 end -- elem,resto
--if class == "WARLOCK" then r,g,b = 0,0,1 end
if class == "WARRIOR" then r,g,b = 1,0,0 end
local f = CreateFrame("Frame", nil, self, BackdropTemplateMixin and "BackdropTemplate")
--f:SetFrameStrata("LOW")
f:EnableMouse(false)
f:EnableMouseWheel(false)
f:SetSize(width,height)
f:SetPoint("CENTER",xpos,ypos)
f:SetBackdrop({ bgFile=bgPath,
edgeFile=edgePath,
tile=false,
edgeSize=16,
insets={left=3,right=3,top=3,bottom=3}})
f:SetBackdropColor(bkr,bkg,bkb,bka)
f:SetBackdropBorderColor(bdr,bdg,bdb,bda)
f.bar = f:CreateTexture(nil,"BACKGROUND",nil,1)
f.bar:SetAlpha(0)
f.bar:SetWidth(0)
f.bar:SetHeight(f:GetHeight()-6)
f.bar:SetPoint("LEFT",3,0)
f.bar:SetTexture("Interface\\TargetingFrame\\BarFill2")
f.bar:SetVertexColor(r,g,b)
--f.text = f:CreateFontString(nil,"ARTWORK","NumberFont_Outline_Med")
--f.text = f:CreateFontString(nil,"ARTWORK", "Game13Font")
f.text = f:CreateFontString(nil,"ARTWORK")
f.text:SetPoint("CENTER")
f.text:SetFont("FONTS\\FRIZQT__.TTF", 12, "OUTLINE")
f.text:Show()
f.elapsed = 0.10
local function vehicleHider()
if OverrideActionBar:IsShown() then f:SetAlpha(0) else f:SetAlpha(1) end
end
local function hideFrame()
f:SetAlpha(0)
state = 0
end
local function showFrame()
if OverrideActionBar:IsShown() then return end
f:SetAlpha(1)
state = 1
end
f:SetScript("OnEvent", function(self, event, name, ...)
if event == "UPDATE_OVERRIDE_ACTIONBAR" then
C_Timer.After(1.5, vehicleHider)
end
if event == "UNIT_ENTERED_VEHICLE" then
C_Timer.After(1.5, vehicleHider)
end
if event == "CINEMATIC_START" then
C_Timer.After(0.25, hideFrame)
--print("start")
end
if event == "CINEMATIC_STOP" then
C_Timer.After(1.5, showFrame)
--print("stop")
end
if event == "UNIT_EXITED_VEHICLE" then
C_Timer.After(1.5, showFrame)
end
end)
f:SetScript("OnUpdate", function(self, elapsed)
if state == 0 then return end
self.elapsed = self.elapsed - elapsed
if self.elapsed > 0 then return end
self.elapsed = 0.10
local power = UnitPower("player")
local maxPower = UnitPowerMax("player")
if power == 0 then
f.text:SetText(format("%d",0))
f.bar:SetAlpha(0)
elseif power == maxPower and showcapped == true then
f.bar:SetVertexColor(1,1,1) --white
f.bar:SetWidth(power*(width-6)/maxPower)
f.text:SetText(format("%d",power))
f.bar:SetAlpha(1)
else
f.bar:SetVertexColor(r,g,b)
f.bar:SetWidth(power*(width-6)/maxPower)
f.text:SetText(format("%d",power))
f.bar:SetAlpha(1)
end
end)
PlayerFrame:HookScript('OnHide', hideFrame)
PlayerFrame:HookScript('OnShow', showFrame)
--f:RegisterUnitEvent("UNIT_DISPLAYPOWER","player")
--f:RegisterEvent("PLAYER_DEAD")
--f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("UPDATE_OVERRIDE_ACTIONBAR")
f:RegisterEvent("UNIT_ENTERED_VEHICLE")
f:RegisterEvent("UNIT_EXITED_VEHICLE")
--f:RegisterEvent("PLAY_MOVIE")
f:RegisterEvent("CINEMATIC_START")
f:RegisterEvent("CINEMATIC_STOP")