vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | function DUF_Aura_OnUpdate(elapsed, filter) |
2 | if (not DUF_INITIALIZED) then return; end |
||
3 | if (this.flashing) then |
||
4 | this.timer = this.timer - elapsed; |
||
5 | if (this.timer < 0) then |
||
6 | this.timer = .5; |
||
7 | if (this.direction) then |
||
8 | this.direction = nil; |
||
9 | else |
||
10 | this.direction = true; |
||
11 | end |
||
12 | end |
||
13 | if (this.direction) then |
||
14 | this:SetAlpha(this.timer + .5); |
||
15 | else |
||
16 | this:SetAlpha(1 - this.timer); |
||
17 | end |
||
18 | end |
||
19 | if (not this.playerbuff) then return; end |
||
20 | local buffID = this:GetID(); |
||
21 | local altformat; |
||
22 | if (filter == "HELPFUL") then |
||
23 | altformat = DUF_Settings[DUF_INDEX].player.Buffs.altformat; |
||
24 | else |
||
25 | altformat = DUF_Settings[DUF_INDEX].player.Debuffs.altformat; |
||
26 | end |
||
27 | if (filter == "HELPFUL" and DUF_Settings[DUF_INDEX].player.Buffs.reverse) then |
||
28 | buffID = 17 - buffID; |
||
29 | elseif (filter == "HARMFUL" and DUF_Settings[DUF_INDEX].player.Debuffs.reverse) then |
||
30 | buffID = 17 - buffID; |
||
31 | end |
||
32 | local buffIndex, untilCancelled = GetPlayerBuff(buffID - 1, filter); |
||
33 | local buffText = getglobal(this:GetName().."_Text"); |
||
34 | local timeLeft = math.floor(GetPlayerBuffTimeLeft(buffIndex)); |
||
35 | if (timeLeft and timeLeft > 0) then |
||
36 | if (altformat) then |
||
37 | if (timeLeft > 60) then |
||
38 | local seconds = timeLeft - math.floor(timeLeft / 60) * 60; |
||
39 | if (seconds < 10) then |
||
40 | buffText:SetText(math.floor(timeLeft / 60)..":0"..seconds); |
||
41 | else |
||
42 | buffText:SetText(math.floor(timeLeft / 60)..":"..seconds); |
||
43 | end |
||
44 | else |
||
45 | if (timeLeft < 10) then |
||
46 | buffText:SetText("0:0"..timeLeft); |
||
47 | else |
||
48 | buffText:SetText("0:"..timeLeft); |
||
49 | end |
||
50 | end |
||
51 | else |
||
52 | buffText:SetText(SecondsToTimeAbbrev(timeLeft)); |
||
53 | end |
||
54 | if ((not untilCancelled) and timeLeft < 61 and timeLeft > 0) then |
||
55 | if (not this.flashing) then |
||
56 | this.flashing = true; |
||
57 | this.timer = .5; |
||
58 | this.direction = 1; |
||
59 | end |
||
60 | elseif (this.flashing) then |
||
61 | if (filter == "HELPFUL") then |
||
62 | this.flashing = nil; |
||
63 | this:SetAlpha(1); |
||
64 | elseif (not DUF_Settings[DUF_INDEX].player.Debuffs.flash) then |
||
65 | this.flashing = nil; |
||
66 | this:SetAlpha(1); |
||
67 | end |
||
68 | end |
||
69 | elseif (DUF_OPTIONS_VISIBLE) then |
||
70 | if (altformat) then |
||
71 | buffText:SetText("99:99"); |
||
72 | else |
||
73 | buffText:SetText("99 m"); |
||
74 | end |
||
75 | else |
||
76 | buffText:SetText(""); |
||
77 | end |
||
78 | if ( GameTooltip:IsOwned(this) ) then |
||
79 | GameTooltip:SetPlayerBuff(buffIndex); |
||
80 | end |
||
81 | end |
||
82 | |||
83 | function DUF_Buff_OnClick(button) |
||
84 | if (this.playerbuff and button == "RightButton") then |
||
85 | local buffID = this:GetID(); |
||
86 | if (DUF_Settings[DUF_INDEX].player.Buffs.reverse) then |
||
87 | buffID = 17 - buffID; |
||
88 | end |
||
89 | CancelPlayerBuff(GetPlayerBuff(buffID - 1, "HELPFUL")); |
||
90 | end |
||
91 | end |
||
92 | |||
93 | function DUF_Buff_OnEnter() |
||
94 | local buffID = this:GetID(); |
||
95 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this:GetParent():GetParent().unit].index].Buffs.reverse) then |
||
96 | buffID = 17 - buffID; |
||
97 | end |
||
98 | if (this:GetRight() > UIParent:GetRight() / 2) then |
||
99 | GameTooltip:SetOwner(this, "ANCHOR_LEFT"); |
||
100 | else |
||
101 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
102 | end |
||
103 | if (this.playerbuff) then |
||
104 | GameTooltip:SetPlayerBuff(GetPlayerBuff(buffID - 1, "HELPFUL")); |
||
105 | else |
||
106 | GameTooltip:SetUnitBuff(this:GetParent():GetParent().unit, buffID); |
||
107 | end |
||
108 | end |
||
109 | |||
110 | |||
111 | function DUF_Buff_OnLeave() |
||
112 | GameTooltip:Hide(); |
||
113 | end |
||
114 | |||
115 | function DUF_Debuff_OnClick(button) |
||
116 | if (this.playerbuff and button == "RightButton") then |
||
117 | local buffID = this:GetID(); |
||
118 | if (DUF_Settings[DUF_INDEX].player.Debuffs.reverse) then |
||
119 | buffID = 17 - buffID; |
||
120 | end |
||
121 | CancelPlayerBuff(GetPlayerBuff(buffID - 1, "HARMFUL")); |
||
122 | end |
||
123 | end |
||
124 | |||
125 | function DUF_Debuff_OnEnter() |
||
126 | local buffID = this:GetID(); |
||
127 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this:GetParent():GetParent().unit].index].Debuffs.reverse) then |
||
128 | buffID = 17 - buffID; |
||
129 | end |
||
130 | if (this:GetRight() > UIParent:GetRight() / 2) then |
||
131 | GameTooltip:SetOwner(this, "ANCHOR_LEFT"); |
||
132 | else |
||
133 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
134 | end |
||
135 | if (this.playerbuff) then |
||
136 | GameTooltip:SetPlayerBuff(GetPlayerBuff(buffID - 1, "HARMFUL")); |
||
137 | else |
||
138 | GameTooltip:SetUnitDebuff(this:GetParent():GetParent().unit, buffID); |
||
139 | end |
||
140 | end |
||
141 | |||
142 | function DUF_Debuff_OnLeave() |
||
143 | GameTooltip:Hide(); |
||
144 | end |
||
145 | |||
146 | function DUF_UnitFrame_OnClick(button) |
||
147 | local unit = this.unit; |
||
148 | |||
149 | if ( SpellIsTargeting() ) then |
||
150 | if (button == "RightButton") then |
||
151 | SpellStopTargeting(); |
||
152 | else |
||
153 | SpellTargetUnit(unit); |
||
154 | end |
||
155 | return; |
||
156 | elseif (CursorHasItem()) then |
||
157 | DropItemOnUnit(unit); |
||
158 | return; |
||
159 | end |
||
160 | |||
161 | local frameindex = DUF_FRAME_DATA[unit].index |
||
162 | local action; |
||
163 | if (button == "LeftButton") then |
||
164 | action = DUF_Settings[DUF_INDEX][frameindex].leftclick; |
||
165 | elseif (button == "RightButton") then |
||
166 | action = DUF_Settings[DUF_INDEX][frameindex].rightclick; |
||
167 | elseif (button == "MiddleButton") then |
||
168 | action = DUF_Settings[DUF_INDEX][frameindex].middleclick; |
||
169 | end |
||
170 | if (action == 1) then |
||
171 | TargetUnit(unit); |
||
172 | elseif (action == 2) then |
||
173 | AssistUnit(unit); |
||
174 | elseif (action == 3) then |
||
175 | DUF_UnitPopup_ShowMenu(unit); |
||
176 | end |
||
177 | end |
||
178 | |||
179 | function DUF_UnitFrame_OnDragStart() |
||
180 | if (DUF_FRAMES_UNLOCKED) then |
||
181 | this:StartMoving(); |
||
182 | this.moving = true; |
||
183 | end |
||
184 | end |
||
185 | |||
186 | function DUF_UnitFrame_OnDragStop() |
||
187 | if (DUF_FRAMES_UNLOCKED) then |
||
188 | this:StopMovingOrSizing(); |
||
189 | this.moving = nil; |
||
190 | local frameindex = DUF_FRAME_DATA[this.unit].index; |
||
191 | local xoffset, yoffset = DL_Get_Offsets(this, UIParent, "TOPLEFT", "TOPLEFT"); |
||
192 | DUF_Settings[DUF_INDEX][frameindex].xos[this:GetID()] = xoffset; |
||
193 | DUF_Settings[DUF_INDEX][frameindex].yos[this:GetID()] = yoffset; |
||
194 | this:ClearAllPoints(); |
||
195 | this:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", xoffset, yoffset); |
||
196 | end |
||
197 | end |
||
198 | |||
199 | function DUF_UnitFrame_OnEnter() |
||
200 | local unit = this.unit; |
||
201 | local settings = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index]; |
||
202 | |||
203 | if (settings.usemouseovercolor) then |
||
204 | getglobal(this:GetName().."_Background"):SetBackdropColor(settings.mouseovercolor.r, settings.mouseovercolor.g, settings.mouseovercolor.b, settings.bgalpha); |
||
205 | end |
||
206 | |||
207 | if (settings.mouseovergroup) then |
||
208 | local unitFrame = this; |
||
209 | local unitFrameName = unitFrame:GetName(); |
||
210 | local element; |
||
211 | for index, value in DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index] do |
||
212 | if (type(value) == "table") then |
||
213 | if (index == "StatusBar") then |
||
214 | for i = 1,6 do |
||
215 | if (value[i]) then |
||
216 | if (value[i].mouseovergroup == settings.mouseovergroup) then |
||
217 | if (value[i].mouseover) then |
||
218 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Show(); |
||
219 | end |
||
220 | if (value[i].usemouseovercolor) then |
||
221 | getglobal(unitFrameName..DUF_Get_ElementName(index, i).."_Background"):SetBackdropColor(value[i].mouseovercolor.r, value[i].mouseovercolor.g, value[i].mouseovercolor.b, value[i].bgalpha); |
||
222 | end |
||
223 | end |
||
224 | end |
||
225 | end |
||
226 | elseif (index == "TextBox") then |
||
227 | for i = 1,10 do |
||
228 | if (value[i].mouseovergroup == settings.mouseovergroup) then |
||
229 | if (value[i].mouseover) then |
||
230 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Show(); |
||
231 | end |
||
232 | if (value[i].usemouseovercolor) then |
||
233 | getglobal(unitFrameName..DUF_Get_ElementName(index, i).."_Background"):SetBackdropColor(value[i].mouseovercolor.r, value[i].mouseovercolor.g, value[i].mouseovercolor.b, value[i].bgalpha); |
||
234 | end |
||
235 | end |
||
236 | end |
||
237 | else |
||
238 | if (value.mouseovergroup == settings.mouseovergroup) then |
||
239 | if (value.mouseover) then |
||
240 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Show(); |
||
241 | end |
||
242 | if (value.usemouseovercolor) then |
||
243 | getglobal(unitFrameName..DUF_Get_ElementName(index).."_Background"):SetBackdropColor(value.mouseovercolor.r, value.mouseovercolor.g, value.mouseovercolor.b, value.bgalpha); |
||
244 | end |
||
245 | end |
||
246 | end |
||
247 | end |
||
248 | end |
||
249 | end |
||
250 | |||
251 | if (settings.disabletooltip) then |
||
252 | return; |
||
253 | end |
||
254 | if (unit and UnitName(unit)) then |
||
255 | if (settings.usecustomtooltip) then |
||
256 | local text = settings.customtooltip; |
||
257 | if (text) then |
||
258 | for var, value in DUF_VARIABLE_FUNCTIONS do |
||
259 | if (string.find(text, var)) then |
||
260 | text = value.func(text, unit); |
||
261 | end |
||
262 | end |
||
263 | GameTooltip_SetDefaultAnchor(GameTooltip, this) |
||
264 | GameTooltip:SetText(text, 1, 1, 1, 1, 1); |
||
265 | GameTooltip:Show(); |
||
266 | end |
||
267 | else |
||
268 | UnitFrame_OnEnter(); |
||
269 | end |
||
270 | end |
||
271 | end |
||
272 | |||
273 | function DUF_UnitFrame_OnEvent(event) |
||
274 | if (not DUF_INITIALIZED) then return; end |
||
275 | if (not this:IsVisible()) then return; end |
||
276 | |||
277 | if (event == DUF_UNIT_CHANGED_EVENTS[this.unit]) then |
||
278 | this:Hide() |
||
279 | this:Show() |
||
280 | elseif (event == "RAID_TARGET_UPDATE") then |
||
281 | DUF_Set_RaceIcon(this.unit) |
||
282 | DUF_Set_RankIcon(this.unit) |
||
283 | end |
||
284 | |||
285 | if (arg1 ~= this.unit) then return; end |
||
286 | |||
287 | if (event == "UNIT_AURA") then |
||
288 | this.updateauras = true; |
||
289 | elseif (event == "UNIT_NAME_UPDATE") then |
||
290 | DUF_Set_ClassIcon(this.unit); |
||
291 | DUF_Set_RaceIcon(this.unit); |
||
292 | elseif (event == "UNIT_PORTRAIT_UPDATE") then |
||
293 | DUF_Set_Portrait(this.unit) |
||
294 | end |
||
295 | end |
||
296 | |||
297 | function DUF_UnitFrame_OnHide() |
||
298 | if (this.unit == "target") then |
||
299 | PlaySound("INTERFACESOUND_LOSTTARGETUNIT"); |
||
300 | end |
||
301 | if (this.moving) then |
||
302 | DUF_UnitFrame_OnDragStop(); |
||
303 | end |
||
304 | end |
||
305 | |||
306 | function DUF_UnitFrame_OnLeave() |
||
307 | local unit = this.unit; |
||
308 | local settings = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index]; |
||
309 | |||
310 | if (settings.usemouseovercolor) then |
||
311 | getglobal(this:GetName().."_Background"):SetBackdropColor(settings.bgcolor.r, settings.bgcolor.g, settings.bgcolor.b, settings.bgalpha); |
||
312 | end |
||
313 | |||
314 | if (settings.mouseovergroup) then |
||
315 | local unitFrame = this; |
||
316 | local unitFrameName = unitFrame:GetName(); |
||
317 | local element; |
||
318 | |||
319 | for index, value in DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index] do |
||
320 | if (type(value) == "table") then |
||
321 | if (index == "StatusBar") then |
||
322 | for i = 1,6 do |
||
323 | if (value[i]) then |
||
324 | if (value[i].mouseovergroup == settings.mouseovergroup) then |
||
325 | if (value[i].mouseover) then |
||
326 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Hide(); |
||
327 | end |
||
328 | if (value[i].usemouseovercolor) then |
||
329 | getglobal(unitFrameName..DUF_Get_ElementName(index, i).."_Background"):SetBackdropColor(value[i].bgcolor.r, value[i].bgcolor.g, value[i].bgcolor.b, value[i].bgalpha); |
||
330 | end |
||
331 | end |
||
332 | end |
||
333 | end |
||
334 | elseif (index == "TextBox") then |
||
335 | for i = 1,10 do |
||
336 | if (value[i].mouseovergroup == settings.mouseovergroup) then |
||
337 | if (value[i].mouseover) then |
||
338 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Hide(); |
||
339 | end |
||
340 | if (value[i].usemouseovercolor) then |
||
341 | getglobal(unitFrameName..DUF_Get_ElementName(index, i).."_Background"):SetBackdropColor(value[i].bgcolor.r, value[i].bgcolor.g, value[i].bgcolor.b, value[i].bgalpha); |
||
342 | end |
||
343 | end |
||
344 | end |
||
345 | else |
||
346 | if (value.mouseovergroup == settings.mouseovergroup) then |
||
347 | if (value.mouseover) then |
||
348 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Hide(); |
||
349 | end |
||
350 | if (value.usemouseovercolor) then |
||
351 | getglobal(unitFrameName..DUF_Get_ElementName(index).."_Background"):SetBackdropColor(value.bgcolor.r, value.bgcolor.g, value.bgcolor.b, value.bgalpha); |
||
352 | end |
||
353 | end |
||
354 | end |
||
355 | end |
||
356 | end |
||
357 | end |
||
358 | if (UnitName(this.unit)) then |
||
359 | UnitFrame_OnLeave(); |
||
360 | end |
||
361 | end |
||
362 | |||
363 | function DUF_UnitFrame_OnLoad() |
||
364 | for unit, data in DUF_FRAME_DATA do |
||
365 | if (this:GetName() == data.frame) then |
||
366 | this.unit = unit; |
||
367 | end |
||
368 | end |
||
369 | |||
370 | this:RegisterEvent("UNIT_AURA"); |
||
371 | this:RegisterEvent("UNIT_COMBAT"); |
||
372 | this:RegisterEvent("UNIT_NAME_UPDATE"); |
||
373 | this:RegisterEvent("UNIT_PORTRAIT_UPDATE"); |
||
374 | this:RegisterEvent("RAID_TARGET_UPDATE"); |
||
375 | if (DUF_UNIT_CHANGED_EVENTS[this.unit]) then |
||
376 | this:RegisterEvent(DUF_UNIT_CHANGED_EVENTS[this.unit]) |
||
377 | end |
||
378 | this:RegisterForDrag("LeftButton", "RightButton"); |
||
379 | this:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up"); |
||
380 | end |
||
381 | |||
382 | function DUF_UnitFrame_OnShow() |
||
383 | if (not DUF_INITIALIZED) then return; end |
||
384 | DUF_HealthBar_Update(); |
||
385 | DUF_LootIcon_Update(this.unit); |
||
386 | DUF_LeaderIcon_Update(this.unit); |
||
387 | DUF_PVPIcon_Update(this.unit); |
||
388 | DUF_StatusIcon_Update(this.unit); |
||
389 | DUF_UnitFrame_UpdateBuffs(this.unit); |
||
390 | DUF_UnitFrame_UpdateDebuffs(this.unit); |
||
391 | DUF_Set_ClassIcon(this.unit); |
||
392 | DUF_Set_Portrait(this.unit); |
||
393 | DUF_Set_RaceIcon(this.unit); |
||
394 | DUF_Set_RankIcon(this.unit); |
||
395 | |||
396 | local background = getglobal(this:GetName().."_Background"); |
||
397 | if (not background) then return end |
||
398 | local r, g, b; |
||
399 | local context = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].context; |
||
400 | local bgcontext = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgcontext; |
||
401 | local bordercontext = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercontext; |
||
402 | if (context == 1 or bgcontext == 1) then |
||
403 | r, g, b = DUF_Get_DifficultyColor(this.unit, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgcolor); |
||
404 | elseif (context == 2 or bgcontext == 2) then |
||
405 | r, g, b = DUF_Get_ReactionColor(this.unit, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgcolor); |
||
406 | elseif (context == 3 or bgcontext == 3) then |
||
407 | r, g, b = DUF_Get_ClassColor(this.unit, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgcolor); |
||
408 | else |
||
409 | r, g, b = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgcolor.r, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgcolor.g, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgcolor.b; |
||
410 | end |
||
411 | this.basecolor = {}; |
||
412 | this.basecolor.r = r; |
||
413 | this.basecolor.g = g; |
||
414 | this.basecolor.b = b; |
||
415 | background:SetBackdropColor(r, g, b, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgalpha); |
||
416 | |||
417 | if (bordercontext == 1) then |
||
418 | r, g, b = DUF_Get_DifficultyColor(this.unit, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercolor); |
||
419 | elseif (bordercontext == 2) then |
||
420 | r, g, b = DUF_Get_ReactionColor(this.unit, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercolor); |
||
421 | elseif (bordercontext == 3) then |
||
422 | r, g, b = DUF_Get_ClassColor(this.unit, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercolor); |
||
423 | else |
||
424 | r, g, b = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercolor.r, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercolor.g, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercolor.b; |
||
425 | end |
||
426 | background:SetBackdropBorderColor(r, g, b, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].borderalpha); |
||
427 | |||
428 | this.mana = nil; |
||
429 | this.health = nil; |
||
430 | this.manatarget = nil; |
||
431 | this.healthtarget = nil; |
||
432 | |||
433 | if (this.unit == "target") then |
||
434 | if ( UnitIsEnemy("target", "player") ) then |
||
435 | PlaySound("igCreatureAggroSelect"); |
||
436 | elseif ( UnitIsFriend("player", "target") ) then |
||
437 | PlaySound("igCharacterNPCSelect"); |
||
438 | else |
||
439 | PlaySound("igCreatureNeutralSelect"); |
||
440 | end |
||
441 | end |
||
442 | |||
443 | local frame = DUF_FRAME_DATA[this.unit].frame |
||
444 | for i=1,10 do |
||
445 | this = getglobal(frame.."_TextBox_"..i); |
||
446 | DUF_TextBox_Update(); |
||
447 | end |
||
448 | end |
||
449 | |||
450 | function DUF_UnitFrame_OnUpdate(elapsed) |
||
451 | if (not DUF_INITIALIZED) then return; end |
||
452 | local targettarget; |
||
453 | if (this.index == "targettarget" and (not UnitName("targettarget")) and (not DUF_OPTIONS_VISIBLE)) then |
||
454 | this:Hide(); |
||
455 | return; |
||
456 | end |
||
457 | if (not this.timer) then this.timer = DUF_Settings[DUF_INDEX].updatespeed; end |
||
458 | this.timer = this.timer - elapsed; |
||
459 | if (this.timer < 0) then |
||
460 | this.timer = DUF_Settings[DUF_INDEX].updatespeed; |
||
461 | local health = UnitHealth(this.unit); |
||
462 | local healthmax = UnitHealthMax(this.unit); |
||
463 | local healthtarget = UnitHealth(this.unit.."target"); |
||
464 | local healthmaxtarget = UnitHealthMax(this.unit.."target"); |
||
465 | local manatarget = UnitMana(this.unit.."target"); |
||
466 | local manamaxtarget = UnitManaMax(this.unit.."target"); |
||
467 | local targetname = UnitName(this.unit.."target"); |
||
468 | local mana = UnitMana(this.unit); |
||
469 | local manamax = UnitManaMax(this.unit); |
||
470 | local manatype = UnitPowerType(this.unit); |
||
471 | local manatypetarget = UnitPowerType(this.unit.."target"); |
||
472 | local status = 0; |
||
473 | local leader = UnitIsPartyLeader(this.unit); |
||
474 | local inParty = GetNumPartyMembers() + GetNumRaidMembers(); |
||
475 | if (inParty == 0) then |
||
476 | leader = nil; |
||
477 | end |
||
478 | local pvp = UnitIsPVP(this.unit); |
||
479 | local pvpfree = UnitIsPVPFreeForAll(this.unit); |
||
480 | local _,loot = GetLootMethod(); |
||
481 | local level = UnitLevel(this.unit); |
||
482 | local reaction = DUF_Get_Reaction(this.unit); |
||
483 | local optionsvisible = DUF_OPTIONS_VISIBLE; |
||
484 | local targetIndex |
||
485 | if (this.unit == "target" or this.unit == "targettarget") then |
||
486 | targetIndex = GetRaidTargetIndex(this.unit) |
||
487 | else |
||
488 | targetIndex = GetRaidTargetIndex(this.unit.."target") |
||
489 | end |
||
490 | |||
491 | |||
492 | if ((not this.lastmana) or mana > this.lastmana) then this.lastmana = mana; end |
||
493 | if ((not this.lasthealth) or health > this.lasthealth) then this.lasthealth = health; end |
||
494 | |||
495 | if (targetIndex ~= this.targetIndex) then |
||
496 | this.targetIndex = targetIndex |
||
497 | if (targetIndex) then |
||
498 | if (this.targetIcon == 1) then |
||
499 | getglobal(this:GetName().."_RankIcon"):Show() |
||
500 | SetRaidTargetIconTexture(getglobal(this:GetName().."_RankIcon_Texture"), targetIndex) |
||
501 | elseif (this.targetIcon == 2) then |
||
502 | getglobal(this:GetName().."_RaceIcon"):Show() |
||
503 | SetRaidTargetIconTexture(getglobal(this:GetName().."_RaceIcon_Texture"), targetIndex) |
||
504 | elseif (this.targetIcon == 3) then |
||
505 | getglobal(this:GetName().."_RankIcon"):Show() |
||
506 | getglobal(this:GetName().."_RaceIcon"):Show() |
||
507 | SetRaidTargetIconTexture(getglobal(this:GetName().."_RankIcon_Texture"), targetIndex) |
||
508 | SetRaidTargetIconTexture(getglobal(this:GetName().."_RaceIcon_Texture"), targetIndex) |
||
509 | end |
||
510 | else |
||
511 | if (this.targetIcon == 1) then |
||
512 | getglobal(this:GetName().."_RankIcon"):Hide() |
||
513 | elseif (this.targetIcon == 2) then |
||
514 | getglobal(this:GetName().."_RaceIcon"):Hide() |
||
515 | elseif (this.targetIcon == 3) then |
||
516 | getglobal(this:GetName().."_RankIcon"):Hide() |
||
517 | getglobal(this:GetName().."_RaceIcon"):Hide() |
||
518 | end |
||
519 | end |
||
520 | end |
||
521 | |||
522 | if ((not inParty) or inParty == 0) then |
||
523 | loot = nil; |
||
524 | end |
||
525 | local rank = UnitPVPRank(this.unit); |
||
526 | if (health <= 0 or UnitIsGhost(this.unit)) then |
||
527 | status = 1; |
||
528 | elseif (this.unit == "player" and DL_ATTACKING) then |
||
529 | status = 2; |
||
530 | elseif (this.unit == "player" and DL_INCOMBAT) then |
||
531 | status = 2; |
||
532 | elseif (UnitAffectingCombat(this.unit)) then |
||
533 | status = 2; |
||
534 | elseif (this.unit == "player" and IsResting()) then |
||
535 | status = 3; |
||
536 | end |
||
537 | |||
538 | if (reaction ~= this.reaction) then |
||
539 | this.reaction = reaction; |
||
540 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].context == 2 or DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgcontext == 2) then |
||
541 | local r, g, b = DUF_Get_ReactionColor(this.unit, this.basecolor); |
||
542 | getglobal(this:GetName().."_Background"):SetBackdropColor(r, g, b, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgalpha); |
||
543 | end |
||
544 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercontext == 2) then |
||
545 | local r, g, b = DUF_Get_ReactionColor(this.unit, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercolor); |
||
546 | getglobal(this:GetName().."_Background"):SetBackdropBorderColor(r, g, b, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].borderalpha); |
||
547 | end |
||
548 | end |
||
549 | if (this.health ~= health or this.healthmax ~= healthmax) then |
||
550 | this.health = health; |
||
551 | this.healthmax = healthmax; |
||
552 | DUF_HealthBar_Update(); |
||
553 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].context == 4 or DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgcontext == 4) then |
||
554 | local r, g, b = DUF_Get_HealthColor(this.unit, this.basecolor); |
||
555 | getglobal(this:GetName().."_Background"):SetBackdropColor(r, g, b, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgalpha); |
||
556 | end |
||
557 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercontext == 4) then |
||
558 | local r, g, b = DUF_Get_HealthColor(this.unit, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercolor); |
||
559 | getglobal(this:GetName().."_Background"):SetBackdropBorderColor(r, g, b, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].borderalpha); |
||
560 | end |
||
561 | end |
||
562 | if (this.mana ~= mana or this.manamax ~= manamax) then |
||
563 | this.mana = mana; |
||
564 | this.manamax = manamax; |
||
565 | DUF_ManaBar_Update(); |
||
566 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].context == 5 or DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgcontext == 5) then |
||
567 | local r, g, b = DUF_Get_ManaColor(this.unit, this.basecolor); |
||
568 | getglobal(this:GetName().."_Background"):SetBackdropColor(r, g, b, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bgalpha); |
||
569 | end |
||
570 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercontext == 5) then |
||
571 | local r, g, b = DUF_Get_ManaColor(this.unit, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].bordercolor); |
||
572 | getglobal(this:GetName().."_Background"):SetBackdropBorderColor(r, g, b, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].borderalpha); |
||
573 | end |
||
574 | for i=1,10 do |
||
575 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].TextBox[i].hideifnomana) then |
||
576 | if ((not this.mana) or (not this.manamax) or this.manamax == 0) then |
||
577 | if (DUF_OPTIONS_VISIBLE and (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].TextBox[i].hide) and (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].TextBox[i].mouseover)) then |
||
578 | getglobal(this:GetName().."_TextBox_"..i):Show(); |
||
579 | else |
||
580 | getglobal(this:GetName().."_TextBox_"..i):Hide(); |
||
581 | end |
||
582 | elseif ((not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].TextBox[i].hide) and (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].TextBox[i].mouseover)) then |
||
583 | getglobal(this:GetName().."_TextBox_"..i):Show(); |
||
584 | end |
||
585 | end |
||
586 | end |
||
587 | end |
||
588 | if (this.status ~= status or this.optionsvisible ~= optionsvisible) then |
||
589 | this.status = status; |
||
590 | DUF_StatusIcon_Update(this.unit); |
||
591 | end |
||
592 | if (leader ~= this.leader or this.optionsvisible ~= optionsvisible) then |
||
593 | this.leader = leader; |
||
594 | DUF_LeaderIcon_Update(this.unit); |
||
595 | end |
||
596 | if (this.pvp ~= pvp or this.pvpfree ~= pvpfree or this.optionsvisible ~= optionsvisible) then |
||
597 | this.pvp = pvp; |
||
598 | this.pvpfree = pvpfree; |
||
599 | DUF_PVPIcon_Update(this.unit); |
||
600 | if (this.unit == "player") then |
||
601 | if (this.pvp or this.pvpfree) then |
||
602 | PlaySound("igPVPUpdate"); |
||
603 | end |
||
604 | end |
||
605 | end |
||
606 | if (this.loot ~= loot or this.optionsvisible ~= optionsvisible) then |
||
607 | this.loot = loot; |
||
608 | DUF_LootIcon_Update(this.unit); |
||
609 | end |
||
610 | if (this.rank ~= rank or this.optionsvisible ~= optionsvisible) then |
||
611 | this.rank = rank; |
||
612 | DUF_Set_RankIcon(this.unit); |
||
613 | end |
||
614 | if (this.healthtarget ~= healthtarget or this.healthmaxtarget ~= healthmaxtarget) then |
||
615 | this.healthtarget = healthtarget; |
||
616 | this.healthmaxtarget = healthmaxtarget; |
||
617 | DUF_TargetHealthBar_Update(); |
||
618 | end |
||
619 | if (this.manatarget ~= manatarget or this.manamaxtarget ~= manamaxtarget) then |
||
620 | this.manatarget = manatarget; |
||
621 | this.manamaxtarget = manamaxtarget; |
||
622 | DUF_TargetManaBar_Update(); |
||
623 | end |
||
624 | if (this.manatype ~= manatype) then |
||
625 | this.manatype = manatype; |
||
626 | DUF_ManaBar_UpdateType(); |
||
627 | end |
||
628 | if (this.manatypetarget ~= manatypetarget) then |
||
629 | this.manatypetarget = manatypetarget; |
||
630 | DUF_TargetManaBar_UpdateType(); |
||
631 | end |
||
632 | if (this.updateauras) then |
||
633 | this.updateauras = nil; |
||
634 | DUF_UnitFrame_UpdateBuffs(this.unit); |
||
635 | DUF_UnitFrame_UpdateDebuffs(this.unit); |
||
636 | end |
||
637 | if (this.targetname ~= targetname) then |
||
638 | this.targetname = targetname; |
||
639 | local textbox; |
||
640 | for i=1,10 do |
||
641 | textbox = getglobal(this:GetName().."_TextBox_"..i); |
||
642 | if (textbox.checkname) then |
||
643 | if (targetname and (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].TextBox[i].hide) and (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].TextBox[i].mouseover)) then |
||
644 | textbox:Show(); |
||
645 | elseif (not DUF_OPTIONS_VISIBLE) then |
||
646 | textbox:Hide(); |
||
647 | end |
||
648 | end |
||
649 | end |
||
650 | end |
||
651 | |||
652 | if (this.unit == "targettarget") then |
||
653 | targettarget = true; |
||
654 | for i=1,10 do |
||
655 | this = getglobal("DUF_TargetOfTargetFrame_TextBox_"..i); |
||
656 | DUF_TextBox_Update(); |
||
657 | end |
||
658 | this = DUF_TargetOfTargetFrame; |
||
659 | DUF_UnitFrame_UpdateBuffs("targettarget"); |
||
660 | DUF_UnitFrame_UpdateDebuffs("targettarget"); |
||
661 | end |
||
662 | |||
663 | this.optionsvisible = optionsvisible; |
||
664 | end |
||
665 | |||
666 | if (targettarget) then |
||
667 | this = DUF_TargetOfTargetFrame; |
||
668 | end |
||
669 | |||
670 | if (this.lastmanaalpha and this.lastmanaalpha > 0) then |
||
671 | getglobal(this:GetName().."_ManaBar_Bar2"):SetAlpha(this.lastmanaalpha); |
||
672 | this.lastmanaalpha = this.lastmanaalpha - elapsed; |
||
673 | end |
||
674 | if (this.lasthealthalpha and this.lasthealthalpha > 0) then |
||
675 | getglobal(this:GetName().."_HealthBar_Bar2"):SetAlpha(this.lasthealthalpha); |
||
676 | this.lasthealthalpha = this.lasthealthalpha - elapsed; |
||
677 | end |
||
678 | |||
679 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].incombat or DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].healthupdating or DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].manaupdating) then |
||
680 | local show; |
||
681 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].incombat and this.status == 2) then |
||
682 | show = 1; |
||
683 | end |
||
684 | if (this.health and this.healthmax) then |
||
685 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].healthupdating and this.health < this.healthmax) then |
||
686 | show = 1; |
||
687 | end |
||
688 | end |
||
689 | if (this.mana and this.manamax and DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].manaupdating) then |
||
690 | local _, class = UnitClass(this.unit); |
||
691 | if (class == "WARRIOR") then |
||
692 | if (this.mana > 0) then |
||
693 | show = 1; |
||
694 | end |
||
695 | else |
||
696 | if (this.mana < this.manamax) then |
||
697 | show = 1; |
||
698 | end |
||
699 | end |
||
700 | end |
||
701 | if (show) then |
||
702 | getglobal(this:GetName().."_HealthBar"):Show(); |
||
703 | else |
||
704 | getglobal(this:GetName().."_HealthBar"):Hide(); |
||
705 | end |
||
706 | end |
||
707 | |||
708 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].incombat or DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].healthupdating or DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].manaupdating) then |
||
709 | local show; |
||
710 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].incombat and this.status == 2) then |
||
711 | show = 1; |
||
712 | end |
||
713 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].healthupdating and this.health < this.healthmax) then |
||
714 | show = 1; |
||
715 | end |
||
716 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].manaupdating and this.mana and this.manamax and this.mana < this.manamax) then |
||
717 | show = 1; |
||
718 | end |
||
719 | if (show) then |
||
720 | getglobal(this:GetName().."_ManaBar"):Show(); |
||
721 | else |
||
722 | getglobal(this:GetName().."_ManaBar"):Hide(); |
||
723 | end |
||
724 | end |
||
725 | |||
726 | for t=1,10 do |
||
727 | local settings = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].TextBox[t]; |
||
728 | if (settings.incombat or settings.healthupdating or settings.manaupdating) then |
||
729 | local show; |
||
730 | if (settings.incombat and this.status == 2) then |
||
731 | show = 1; |
||
732 | end |
||
733 | if (settings.healthupdating and this.health and this.healthmax and this.health < this.healthmax) then |
||
734 | show = 1; |
||
735 | end |
||
736 | if (settings.manaupdating and this.mana and this.manamax and this.mana < this.manamax) then |
||
737 | show = 1; |
||
738 | end |
||
739 | if (show) then |
||
740 | getglobal(this:GetName().."_TextBox_"..t):Show(); |
||
741 | else |
||
742 | getglobal(this:GetName().."_TextBox_"..t):Hide(); |
||
743 | end |
||
744 | end |
||
745 | end |
||
746 | |||
747 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].flash) then |
||
748 | if (UnitHealth(this.unit) / UnitHealthMax(this.unit) <= DUF_Settings[DUF_INDEX].flashthreshold and UnitHealth(this.unit) > 0 and (not UnitIsGhost(this.unit))) then |
||
749 | this.Flashing = true; |
||
750 | if (not this.flashTimer) then |
||
751 | this.flashTimer = .5; |
||
752 | end |
||
753 | elseif (this.Flashing) then |
||
754 | this.Flashing = nil; |
||
755 | getglobal(this:GetName().."_Background"):SetAlpha(1); |
||
756 | return; |
||
757 | else |
||
758 | return; |
||
759 | end |
||
760 | this.flashTimer = this.flashTimer - arg1; |
||
761 | if (this.flashTimer < 0) then |
||
762 | this.flashTimer = .5; |
||
763 | if (this.Direction) then |
||
764 | this.Direction = nil; |
||
765 | else |
||
766 | this.Direction = 1; |
||
767 | end |
||
768 | else |
||
769 | if (this.Direction) then |
||
770 | getglobal(this:GetName().."_Background"):SetAlpha(this.flashTimer * 2); |
||
771 | else |
||
772 | getglobal(this:GetName().."_Background"):SetAlpha(1 - this.flashTimer * 2); |
||
773 | end |
||
774 | end |
||
775 | end |
||
776 | end |
||
777 | |||
778 | function DUF_UnitFrame_UpdateBuffs(unit) |
||
779 | local buffcount = 0; |
||
780 | local buff, button, icon, count; |
||
781 | for j=1,16 do |
||
782 | local i = j; |
||
783 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.reverse) then |
||
784 | i = 17 - j; |
||
785 | end |
||
786 | button = getglobal(DUF_FRAME_DATA[unit].frame.."_Buffs_"..i); |
||
787 | if (j <= DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.shown) then |
||
788 | if (button.playerbuff) then |
||
789 | buff = GetPlayerBuffTexture(GetPlayerBuff(j - 1, "HELPFUL")); |
||
790 | count = GetPlayerBuffApplications(GetPlayerBuff(j - 1, "HELPFUL")); |
||
791 | else |
||
792 | buff = UnitBuff(unit, j); |
||
793 | end |
||
794 | icon = getglobal(DUF_FRAME_DATA[unit].frame.."_Buffs_"..i.."_Texture"); |
||
795 | if (buff) then |
||
796 | icon:SetTexture(buff); |
||
797 | button:Show(); |
||
798 | buffcount = j; |
||
799 | if (count and count > 0) then |
||
800 | getglobal(DUF_FRAME_DATA[unit].frame.."_Buffs_"..i.."_Stack"):Show() |
||
801 | getglobal(DUF_FRAME_DATA[unit].frame.."_Buffs_"..i.."_Stack"):SetText(count); |
||
802 | else |
||
803 | getglobal(DUF_FRAME_DATA[unit].frame.."_Buffs_"..i.."_Stack"):Hide() |
||
804 | end |
||
805 | elseif (DUF_OPTIONS_VISIBLE) then |
||
806 | icon:SetTexture("Interface\\AddOns\\DiscordUnitFrames\\Icons\\Buff"); |
||
807 | button:Show(); |
||
808 | buffcount = j; |
||
809 | else |
||
810 | button:Hide(); |
||
811 | end |
||
812 | else |
||
813 | button:Hide(); |
||
814 | end |
||
815 | end |
||
816 | local background = getglobal(DUF_FRAME_DATA[unit].frame.."_Buffs"); |
||
817 | if (buffcount == 0) then |
||
818 | background:Hide(); |
||
819 | background:SetHeight(.5); |
||
820 | background:SetWidth(.5); |
||
821 | return; |
||
822 | elseif (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.hide) then |
||
823 | background:Show(); |
||
824 | else |
||
825 | return; |
||
826 | end |
||
827 | local size = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.size; |
||
828 | local hspacing = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.hspacing; |
||
829 | local vspacing = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.vspacing; |
||
830 | local height, width; |
||
831 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.tworows) then |
||
832 | local row2start = math.ceil(DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.shown / 2); |
||
833 | local rows = 1; |
||
834 | if (buffcount > row2start) then |
||
835 | buffcount = row2start; |
||
836 | rows = 2; |
||
837 | end |
||
838 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.vertical) then |
||
839 | height = size * buffcount + vspacing * (buffcount - 1); |
||
840 | width = size * rows + hspacing * (rows - 1); |
||
841 | else |
||
842 | width = size * buffcount + hspacing * (buffcount - 1); |
||
843 | height = size * rows + vspacing * (rows - 1); |
||
844 | end |
||
845 | else |
||
846 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.vertical) then |
||
847 | height = size * buffcount + vspacing * (buffcount - 1); |
||
848 | width = size; |
||
849 | else |
||
850 | width = size * buffcount + hspacing * (buffcount - 1); |
||
851 | height = size; |
||
852 | end |
||
853 | end |
||
854 | background:SetWidth(width); |
||
855 | background:SetHeight(height); |
||
856 | background = getglobal(DUF_FRAME_DATA[unit].frame.."_Buffs_Background"); |
||
857 | background:SetWidth(width + DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.bgpadding * 2); |
||
858 | background:SetHeight(height + DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Buffs.bgpadding * 2); |
||
859 | end |
||
860 | |||
861 | function DUF_UnitFrame_UpdateDebuffs(unit) |
||
862 | local buffcount = 0; |
||
863 | local buff, button, icon, debuffApplications, color, debuffType, border; |
||
864 | for j=1,16 do |
||
865 | local i = j; |
||
866 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.reverse) then |
||
867 | i = 17 - j; |
||
868 | end |
||
869 | button = getglobal(DUF_FRAME_DATA[unit].frame.."_Debuffs_"..i); |
||
870 | border = getglobal(DUF_FRAME_DATA[unit].frame.."_Debuffs_"..i.."Border"); |
||
871 | if (j <= DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.shown) then |
||
872 | if (button.playerbuff) then |
||
873 | buff = GetPlayerBuffTexture(GetPlayerBuff(j - 1, "HARMFUL")); |
||
874 | debuffApplications = GetPlayerBuffApplications(GetPlayerBuff(j - 1, "HARMFUL")); |
||
875 | debuffType = GetPlayerBuffDispelType(GetPlayerBuff(j - 1, "HARMFUL")); |
||
876 | else |
||
877 | buff, debuffApplications, debuffType = UnitDebuff(unit, j); |
||
878 | end |
||
879 | |||
880 | if ( debuffType ) then |
||
881 | color = DebuffTypeColor[debuffType]; |
||
882 | else |
||
883 | color = DebuffTypeColor["none"]; |
||
884 | end |
||
885 | border:SetVertexColor(color.r, color.g, color.b); |
||
886 | |||
887 | icon = getglobal(DUF_FRAME_DATA[unit].frame.."_Debuffs_"..i.."_Texture") |
||
888 | if (buff) then |
||
889 | icon:SetTexture(buff); |
||
890 | button:Show(); |
||
891 | buffcount = j; |
||
892 | elseif (DUF_OPTIONS_VISIBLE) then |
||
893 | icon:SetTexture("Interface\\AddOns\\DiscordUnitFrames\\Icons\\Debuff"); |
||
894 | button:Show(); |
||
895 | buffcount = j; |
||
896 | debuffApplications = 5; |
||
897 | else |
||
898 | button:Hide(); |
||
899 | end |
||
900 | if (debuffApplications and debuffApplications > 1) then |
||
901 | getglobal(DUF_FRAME_DATA[unit].frame.."_Debuffs_"..i.."_Stack"):SetText(debuffApplications); |
||
902 | else |
||
903 | getglobal(DUF_FRAME_DATA[unit].frame.."_Debuffs_"..i.."_Stack"):SetText(""); |
||
904 | end |
||
905 | else |
||
906 | button:Hide(); |
||
907 | end |
||
908 | end |
||
909 | local background = getglobal(DUF_FRAME_DATA[unit].frame.."_Debuffs"); |
||
910 | if (buffcount == 0) then |
||
911 | background:Hide(); |
||
912 | background:SetHeight(.5); |
||
913 | background:SetWidth(.5); |
||
914 | return; |
||
915 | elseif (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.hide) then |
||
916 | background:Show(); |
||
917 | else |
||
918 | return; |
||
919 | end |
||
920 | local size = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.size; |
||
921 | local hspacing = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.hspacing; |
||
922 | local vspacing = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.vspacing; |
||
923 | local height, width; |
||
924 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.tworows) then |
||
925 | local row2start = math.ceil(DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.shown / 2); |
||
926 | local rows = 1; |
||
927 | if (buffcount > row2start) then |
||
928 | buffcount = row2start; |
||
929 | rows = 2; |
||
930 | end |
||
931 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.vertical) then |
||
932 | height = size * buffcount + vspacing * (buffcount - 1); |
||
933 | width = size * rows + hspacing * (rows - 1); |
||
934 | else |
||
935 | width = size * buffcount + hspacing * (buffcount - 1); |
||
936 | height = size * rows + vspacing * (rows - 1); |
||
937 | end |
||
938 | else |
||
939 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.vertical) then |
||
940 | height = size * buffcount + vspacing * (buffcount - 1); |
||
941 | width = size; |
||
942 | else |
||
943 | width = size * buffcount + hspacing * (buffcount - 1); |
||
944 | height = size; |
||
945 | end |
||
946 | end |
||
947 | background:SetWidth(width); |
||
948 | background:SetHeight(height); |
||
949 | background = getglobal(DUF_FRAME_DATA[unit].frame.."_Debuffs_Background"); |
||
950 | background:SetWidth(width + DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.bgpadding * 2); |
||
951 | background:SetHeight(height + DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].Debuffs.bgpadding * 2); |
||
952 | end |
||
953 | |||
954 | function DUF_UnitPopup_OnLoad() |
||
955 | local unit = "player"; |
||
956 | local frame = this:GetName(); |
||
957 | if (string.find(frame, "PartyFrame")) then |
||
958 | unit = "party"; |
||
959 | elseif (string.find(frame, "PetFrame")) then |
||
960 | unit = "pet"; |
||
961 | elseif (string.find(frame, "TargetFrame")) then |
||
962 | unit = "target"; |
||
963 | end |
||
964 | UIDropDownMenu_Initialize(this, getglobal("DUF_UnitPopup_"..unit.."_Initialize"), "MENU"); |
||
965 | end |
||
966 | |||
967 | function DUF_UnitPopup_party_Initialize() |
||
968 | local dropdown; |
||
969 | if ( UIDROPDOWNMENU_OPEN_MENU ) then |
||
970 | dropdown = getglobal(UIDROPDOWNMENU_OPEN_MENU); |
||
971 | else |
||
972 | dropdown = this; |
||
973 | end |
||
974 | UnitPopup_ShowMenu(dropdown, "PARTY", dropdown:GetParent().unit); |
||
975 | end |
||
976 | |||
977 | function DUF_UnitPopup_pet_Initialize() |
||
978 | if ( UnitExists("pet") ) then |
||
979 | UnitPopup_ShowMenu(DUF_PetFrame_DropDown, "PET", "pet"); |
||
980 | end |
||
981 | end |
||
982 | |||
983 | function DUF_UnitPopup_player_Initialize() |
||
984 | UnitPopup_ShowMenu(DUF_PlayerFrame_DropDown, "SELF", "player"); |
||
985 | end |
||
986 | |||
987 | function DUF_UnitPopup_target_Initialize() |
||
988 | local menu; |
||
989 | local name; |
||
990 | if ( UnitExists("target") and UnitReaction("player", "target") and (((UnitReaction("player", "target") >= 4 and not UnitIsPlayer("target")) and not UnitIsUnit("player", "target")) or (UnitReaction("player", "target") < 4 and not UnitIsPlayer("target"))) ) then |
||
991 | menu = "RAID_TARGET_ICON"; |
||
992 | name = RAID_TARGET_ICON; |
||
993 | elseif ( UnitIsUnit("target", "player") ) then |
||
994 | menu = "SELF"; |
||
995 | elseif ( UnitIsUnit("target", "pet") ) then |
||
996 | menu = "PET"; |
||
997 | elseif ( UnitIsPlayer("target") ) then |
||
998 | if ( UnitInParty("target") ) then |
||
999 | menu = "PARTY"; |
||
1000 | else |
||
1001 | menu = "PLAYER"; |
||
1002 | end |
||
1003 | end |
||
1004 | if ( menu ) then |
||
1005 | UnitPopup_ShowMenu(DUF_TargetFrame_DropDown, menu, "target"); |
||
1006 | end |
||
1007 | end |
||
1008 | |||
1009 | function DUF_UnitPopup_ShowMenu(unit) |
||
1010 | if (unit == "targettarget" or string.find(unit, "partypet")) then return; end |
||
1011 | local popup = getglobal(DUF_FRAME_DATA[unit].frame.."_DropDown"); |
||
1012 | DUF_ToggleDropDownMenu(1, nil, popup, "cursor", 0, 0); |
||
1013 | end |
||
1014 | |||
1015 | -- Ugly piece of work to stop TitanPanel from throwing an error. |
||
1016 | function DUF_ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yOffset) |
||
1017 | if ( not level ) then |
||
1018 | level = 1; |
||
1019 | end |
||
1020 | UIDROPDOWNMENU_MENU_LEVEL = level; |
||
1021 | UIDROPDOWNMENU_MENU_VALUE = value; |
||
1022 | local listFrame = getglobal("DropDownList"..level); |
||
1023 | local listFrameName = "DropDownList"..level; |
||
1024 | local tempFrame; |
||
1025 | local point, relativePoint, relativeTo; |
||
1026 | if ( not dropDownFrame ) then |
||
1027 | tempFrame = this:GetParent(); |
||
1028 | else |
||
1029 | tempFrame = dropDownFrame; |
||
1030 | end |
||
1031 | if ( listFrame:IsVisible() and (UIDROPDOWNMENU_OPEN_MENU == tempFrame:GetName()) ) then |
||
1032 | listFrame:Hide(); |
||
1033 | else |
||
1034 | -- Set the dropdownframe scale |
||
1035 | local uiScale = 1.0; |
||
1036 | if ( GetCVar("useUiScale") == "1" ) then |
||
1037 | if ( tempFrame ~= WorldMapContinentDropDown and tempFrame ~= WorldMapZoneDropDown ) then |
||
1038 | uiScale = tonumber(GetCVar("uiscale")); |
||
1039 | end |
||
1040 | end |
||
1041 | listFrame:SetScale(uiScale); |
||
1042 | |||
1043 | -- Hide the listframe anyways since it is redrawn OnShow() |
||
1044 | listFrame:Hide(); |
||
1045 | |||
1046 | -- Frame to anchor the dropdown menu to |
||
1047 | local anchorFrame; |
||
1048 | |||
1049 | -- Display stuff |
||
1050 | -- Level specific stuff |
||
1051 | if ( level == 1 ) then |
||
1052 | if ( not dropDownFrame ) then |
||
1053 | dropDownFrame = this:GetParent(); |
||
1054 | end |
||
1055 | UIDROPDOWNMENU_OPEN_MENU = dropDownFrame:GetName(); |
||
1056 | listFrame:ClearAllPoints(); |
||
1057 | -- If there's no specified anchorName then use left side of the dropdown menu |
||
1058 | if ( not anchorName ) then |
||
1059 | -- See if the anchor was set manually using setanchor |
||
1060 | if ( dropDownFrame.xOffset ) then |
||
1061 | xOffset = dropDownFrame.xOffset; |
||
1062 | end |
||
1063 | if ( dropDownFrame.yOffset ) then |
||
1064 | yOffset = dropDownFrame.yOffset; |
||
1065 | end |
||
1066 | if ( dropDownFrame.point ) then |
||
1067 | point = dropDownFrame.point; |
||
1068 | end |
||
1069 | if ( dropDownFrame.relativeTo ) then |
||
1070 | relativeTo = dropDownFrame.relativeTo; |
||
1071 | else |
||
1072 | relativeTo = UIDROPDOWNMENU_OPEN_MENU.."Left"; |
||
1073 | end |
||
1074 | if ( dropDownFrame.relativePoint ) then |
||
1075 | relativePoint = dropDownFrame.relativePoint; |
||
1076 | end |
||
1077 | elseif ( anchorName == "cursor" ) then |
||
1078 | relativeTo = "UIParent"; |
||
1079 | local cursorX, cursorY = GetCursorPosition(); |
||
1080 | cursorX = cursorX/uiScale; |
||
1081 | cursorY = cursorY/uiScale; |
||
1082 | |||
1083 | if ( not xOffset ) then |
||
1084 | xOffset = 0; |
||
1085 | end |
||
1086 | if ( not yOffset ) then |
||
1087 | yOffset = 0; |
||
1088 | end |
||
1089 | xOffset = cursorX + xOffset; |
||
1090 | yOffset = cursorY + yOffset; |
||
1091 | else |
||
1092 | relativeTo = anchorName; |
||
1093 | end |
||
1094 | if ( not xOffset or not yOffset ) then |
||
1095 | xOffset = 8; |
||
1096 | yOffset = 22; |
||
1097 | end |
||
1098 | if ( not point ) then |
||
1099 | point = "TOPLEFT"; |
||
1100 | end |
||
1101 | if ( not relativePoint ) then |
||
1102 | relativePoint = "BOTTOMLEFT"; |
||
1103 | end |
||
1104 | listFrame:SetPoint(point, relativeTo, relativePoint, xOffset, yOffset); |
||
1105 | else |
||
1106 | if ( not dropDownFrame ) then |
||
1107 | dropDownFrame = getglobal(UIDROPDOWNMENU_OPEN_MENU); |
||
1108 | end |
||
1109 | listFrame:ClearAllPoints(); |
||
1110 | -- If this is a dropdown button, not the arrow anchor it to itself |
||
1111 | if ( strsub(this:GetParent():GetName(), 0,12) == "DropDownList" and strlen(this:GetParent():GetName()) == 13 ) then |
||
1112 | anchorFrame = this:GetName(); |
||
1113 | else |
||
1114 | anchorFrame = this:GetParent():GetName(); |
||
1115 | end |
||
1116 | listFrame:SetPoint("TOPLEFT", anchorFrame, "TOPRIGHT", 0, 0); |
||
1117 | end |
||
1118 | |||
1119 | -- Change list box appearance depending on display mode |
||
1120 | if ( dropDownFrame and dropDownFrame.displayMode == "MENU" ) then |
||
1121 | getglobal(listFrameName.."Backdrop"):Hide(); |
||
1122 | getglobal(listFrameName.."MenuBackdrop"):Show(); |
||
1123 | else |
||
1124 | getglobal(listFrameName.."Backdrop"):Show(); |
||
1125 | getglobal(listFrameName.."MenuBackdrop"):Hide(); |
||
1126 | end |
||
1127 | |||
1128 | UIDropDownMenu_Initialize(dropDownFrame, dropDownFrame.initialize, nil, level); |
||
1129 | -- If no items in the drop down don't show it |
||
1130 | if ( listFrame.numButtons == 0 ) then |
||
1131 | return; |
||
1132 | end |
||
1133 | |||
1134 | -- Check to see if the dropdownlist is off the screen, if it is anchor it to the top of the dropdown button |
||
1135 | listFrame:Show(); |
||
1136 | -- Hack since GetCenter() is returning coords relative to 1024x768 |
||
1137 | local x, y = listFrame:GetCenter(); |
||
1138 | -- Hack will fix this in next revision of dropdowns |
||
1139 | if ( not x or not y ) then |
||
1140 | listFrame:Hide(); |
||
1141 | return; |
||
1142 | end |
||
1143 | -- Determine whether the menu is off the screen or not |
||
1144 | local offscreenY, offscreenX; |
||
1145 | if ( (y - listFrame:GetHeight()/2) < 0 ) then |
||
1146 | offscreenY = 1; |
||
1147 | end |
||
1148 | if ( listFrame:GetRight() > GetScreenWidth() ) then |
||
1149 | offscreenX = 1; |
||
1150 | end |
||
1151 | |||
1152 | -- If level 1 can only go off the bottom of the screen |
||
1153 | if ( level == 1 ) then |
||
1154 | if ( offscreenY and offscreenX ) then |
||
1155 | anchorPoint = "BOTTOMRIGHT"; |
||
1156 | relativePoint = "BOTTOMLEFT"; |
||
1157 | elseif ( offscreenY ) then |
||
1158 | anchorPoint = "BOTTOMLEFT"; |
||
1159 | relativePoint = "TOPLEFT"; |
||
1160 | elseif ( offscreenX ) then |
||
1161 | anchorPoint = "TOPRIGHT"; |
||
1162 | relativePoint = "TOPLEFT"; |
||
1163 | else |
||
1164 | anchorPoint = "TOPLEFT"; |
||
1165 | end |
||
1166 | |||
1167 | listFrame:ClearAllPoints(); |
||
1168 | if ( anchorName == "cursor" ) then |
||
1169 | listFrame:SetPoint(anchorPoint, relativeTo, "BOTTOMLEFT", xOffset, yOffset); |
||
1170 | else |
||
1171 | listFrame:SetPoint(anchorPoint, relativeTo, relativePoint, xOffset, yOffset); |
||
1172 | end |
||
1173 | else |
||
1174 | local anchorPoint, relativePoint, offsetX, offsetY; |
||
1175 | if ( offscreenY and offscreenX ) then |
||
1176 | anchorPoint = "BOTTOMRIGHT"; |
||
1177 | relativePoint = "BOTTOMLEFT"; |
||
1178 | offsetX = -11; |
||
1179 | offsetY = -14; |
||
1180 | elseif ( offscreenY ) then |
||
1181 | anchorPoint = "BOTTOMLEFT"; |
||
1182 | relativePoint = "BOTTOMRIGHT"; |
||
1183 | offsetX = 0; |
||
1184 | offsetY = -14; |
||
1185 | elseif ( offscreenX ) then |
||
1186 | anchorPoint = "TOPRIGHT"; |
||
1187 | relativePoint = "TOPLEFT"; |
||
1188 | offsetX = -11; |
||
1189 | offsetY = 14; |
||
1190 | else |
||
1191 | anchorPoint = "TOPLEFT"; |
||
1192 | relativePoint = "TOPRIGHT"; |
||
1193 | offsetX = 0; |
||
1194 | offsetY = 14; |
||
1195 | end |
||
1196 | |||
1197 | listFrame:ClearAllPoints(); |
||
1198 | listFrame:SetPoint(anchorPoint, anchorFrame, relativePoint, offsetX, offsetY); |
||
1199 | end |
||
1200 | end |
||
1201 | end |