/
targettarget.lua
executable file
·177 lines (133 loc) · 4.74 KB
/
targettarget.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
166
167
168
169
170
171
172
173
174
175
176
177
--get the addon namespace
local addon, ns = ...
--get oUF namespace (just in case needed)
local oUF = ns.oUF or oUF
--get the config
local cfg = ns.cfg
--get the functions
local func = ns.func
--get the unit container
local unit = ns.unit
---------------------------------------------
-- UNIT SPECIFIC FUNCTIONS
---------------------------------------------
--init parameters
local initUnitParameters = function(self)
self:SetFrameStrata("LOW")
self:SetFrameLevel(1)
self:SetSize(self.cfg.width, self.cfg.height)
self:SetScale(self.cfg.scale)
self:SetPoint(self.cfg.pos.a1,self.cfg.pos.af,self.cfg.pos.a2,self.cfg.pos.x,self.cfg.pos.y)
self:RegisterForClicks("AnyDown")
self:SetScript("OnEnter", UnitFrame_OnEnter)
self:SetScript("OnLeave", UnitFrame_OnLeave)
func.applyDragFunctionality(self)
self:SetHitRectInsets(10,10,10,10)
end
--actionbar background
local createArtwork = function(self)
local t = self:CreateTexture(nil,"BORDER",nil,-8)
t:SetAllPoints(self)
t:SetTexture("Interface\\AddOns\\Roth_UI\\media\\targettarget")
end
--create health frames
local createHealthFrame = function(self)
local cfg = self.cfg.health
--health
local h = CreateFrame("StatusBar", nil, self)
h:SetPoint("TOP",0,-29)
h:SetPoint("LEFT",30.5,0)
h:SetPoint("RIGHT",-30.5,0)
h:SetPoint("BOTTOM",0,25.7)
h:SetFrameStrata("BACKGROUND")
h:SetStatusBarTexture(cfg.texture)
h.bg = h:CreateTexture(nil,"BACKGROUND",nil,-6)
h.bg:SetTexture(cfg.texture)
h.bg:SetAllPoints(h)
h.glow = h:CreateTexture(nil,"OVERLAY",nil,-5)
h.glow:SetTexture("Interface\\AddOns\\Roth_UI\\media\\targettarget_hpglow")
h.glow:SetPoint("TOP",0,-33)
h.glow:SetPoint("LEFT",-27.5,0)
h.glow:SetPoint("RIGHT",27.5,0)
h.glow:SetPoint("BOTTOM",0,27)
h.glow:SetVertexColor(0,0,0,1)
h.highlight = h:CreateTexture(nil,"OVERLAY",nil,-4)
h.highlight:SetTexture("Interface\\AddOns\\Roth_UI\\media\\targettarget_highlight")
h.highlight:SetAllPoints(h.glow)
self.Health = h
self.Health.Smooth = true
end
--create power frames
local createPowerFrame = function(self)
local cfg = self.cfg.power
--power
local h = CreateFrame("StatusBar", nil, self.Health)
h:SetPoint("TOP",0,-12)
h:SetPoint("LEFT",4,0)
h:SetPoint("RIGHT",-4,0)
h:SetPoint("BOTTOM",0,-10)
h:SetStatusBarTexture(cfg.texture)
h.bg = h:CreateTexture(nil,"BACKGROUND",nil,-6)
h.bg:SetTexture(cfg.texture)
h.bg:SetAllPoints(h)
h.glow = h:CreateTexture(nil,"OVERLAY",nil,-5)
h.glow:SetTexture("Interface\\AddOns\\Roth_UI\\media\\targettarget_ppglow")
h.glow:SetAllPoints(self)
h.glow:SetVertexColor(0,0,0,1)
self.Power = h
self.Power.Smooth = true
end
--create health power strings
local createHealthPowerStrings = function(self)
local name = func.createFontString(self, cfg.font, 14, "THINOUTLINE")
name:SetPoint("BOTTOM", self, "TOP", 0, -13)
name:SetPoint("LEFT", self.Health, 0, 0)
name:SetPoint("RIGHT", self.Health, 0, 0)
self.Name = name
local hpval = func.createFontString(self.Health, cfg.font, 11, "THINOUTLINE")
hpval:SetPoint("RIGHT", -2,0)
self:Tag(name, "[diablo:name]")
self:Tag(hpval, self.cfg.health.tag or "")
end
---------------------------------------------
-- TARGETTARGET STYLE FUNC
---------------------------------------------
local function createStyle(self)
--apply config to self
self.cfg = cfg.units.targettarget
self.cfg.style = "targettarget"
--init
initUnitParameters(self)
--create the art
createArtwork(self)
--createhealthPower
createHealthFrame(self)
createPowerFrame(self)
--health power strings
createHealthPowerStrings(self)
--health power update
self.Health.PostUpdate = func.updateHealth
self.Power.PostUpdate = func.updatePower
--auras
if self.cfg.auras.show then
func.createDebuffs(self)
self.Debuffs.PostCreateIcon = func.createAuraIcon
end
--debuffglow
func.createDebuffGlow(self)
--icons
self.RaidIcon = func.createIcon(self,"BACKGROUND",20,self.Name,"BOTTOM","TOP",0,0,-1)
self.RaidIcon:SetTexture("Interface\\AddOns\\Roth_UI\\media\\raidicons")
--add heal prediction
func.healPrediction(self)
--add self to unit container (maybe access to that unit is needed in another style)
unit.targettarget = self
end
---------------------------------------------
-- SPAWN TARGETTARGET UNIT
---------------------------------------------
if cfg.units.targettarget.show then
oUF:RegisterStyle("diablo:targettarget", createStyle)
oUF:SetActiveStyle("diablo:targettarget")
oUF:Spawn("targettarget", "Roth_UITargetTargetFrame")
end