-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
castbar.lua
122 lines (98 loc) · 3.72 KB
/
castbar.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
local addonName, ns = ...
function ns.CreateCastbar(self, parent, _width, _height, spark)
local bar = CreateFrame("StatusBar",nil,parent)
local width = _width or 150
local height = _height or 20
width = width - height -1
bar:SetHeight(height)
bar:SetWidth(width - height - 1)
local texture = [[Interface\AddOns\oUF_NugTarget\castbar.tga]]
bar:SetStatusBarTexture(texture)
-- bar:GetStatusBarTexture():SetDrawLayer("ARTWORK")
-- local backdrop = {
-- bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 0,
-- insets = {left = -3-height, right = -2, top = -2, bottom = -2},
-- }
-- bar:SetBackdrop(backdrop)
-- bar:SetBackdropColor(0, 0, 0, 0.7)
local backdrop = bar:CreateTexture(nil, "BACKGROUND", nil, 0)
backdrop:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
backdrop:SetVertexColor(0,0,0,0.7)
backdrop:SetPoint("TOPLEFT", bar, "TOPLEFT", -3-height, 2)
backdrop:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT", 2, -2)
local ict = bar:CreateTexture(nil,"ARTWORK",nil,0)
ict:SetPoint("TOPRIGHT",bar,"TOPLEFT", -1, 0)
ict:SetWidth(height)
ict:SetHeight(height)
ict:SetTexCoord(.07, .93, .07, .93)
bar.Icon = ict
if spark then
self:CastbarAddSpark(bar)
end
local m = 0.4
bar.SetColor = function(self, r,g,b)
self:SetStatusBarColor(r,g,b)
self.bg:SetVertexColor(r*m,g*m,b*m)
end
bar.bg = bar:CreateTexture(nil, "BORDER")
bar.bg:SetAllPoints(bar)
bar.bg:SetTexture(texture)
local font = [[Interface\AddOns\oUF_NugTarget\fonts\AlegreyaSans-Medium.ttf]]
local textColor = {1,1,1, 0.6}
local timeFont = font
local timeFontSize = 10
local timeText = bar:CreateFontString();
timeText:SetFont(timeFont, timeFontSize)
timeText:SetJustifyH("RIGHT")
timeText:SetVertexColor(1,1,1)
timeText:SetPoint("TOPRIGHT", bar, "TOPRIGHT",-6,0)
timeText:SetPoint("BOTTOMLEFT", bar, "BOTTOMLEFT",0,0)
timeText:SetTextColor(unpack(textColor))
bar.Time = timeText
local spellFont = font
local spellFontSize = 12
local spellText = bar:CreateFontString();
spellText:SetFont(spellFont, spellFontSize)
spellText:SetWidth(width/4*3 -12)
spellText:SetHeight(height/2+1)
spellText:SetJustifyH("CENTER")
spellText:SetTextColor(unpack(textColor))
spellText:SetPoint("LEFT", bar, "LEFT",6,0)
bar.Text = spellText
local shield = bar:CreateTexture(nil,"ARTWORK",nil,2)
shield:SetTexture([[Interface\AchievementFrame\UI-Achievement-IconFrame]])
shield:SetTexCoord(0,0.5625,0,0.5625)
shield:SetWidth(height*1.8)
shield:SetHeight(height*1.8)
shield:SetPoint("CENTER", ict,"CENTER",0,0)
shield:Hide()
bar.Shield = shield
return bar
end
function ns.CastbarAddSpark(self, bar)
local spark = bar:CreateTexture(nil, "ARTWORK", nil, 4)
spark:SetBlendMode("ADD")
spark:SetTexture([[Interface\AddOns\oUF_NugTarget\vialSparkH.tga]])
spark:SetSize(bar:GetHeight()*2, bar:GetHeight())
spark:SetPoint("CENTER", bar, "TOP",0,0)
bar.spark = spark
local OriginalSetValue = bar.SetValue
bar.SetValue = function(self, v)
local min, max = self:GetMinMaxValues()
local total = max-min
local p
if total == 0 then
p = 0
else
p = (v-min)/(max-min)
end
local len = p*self:GetWidth()
self.spark:SetPoint("CENTER", self, "LEFT", len, 0)
return OriginalSetValue(self, v)
end
local OriginalSetStatusBarColor = bar.SetStatusBarColor
bar.SetStatusBarColor = function(self, r,g,b,a)
self.spark:SetVertexColor(r,g,b,a)
return OriginalSetStatusBarColor(self, r,g,b,a)
end
end