Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFilger.lua
More file actions
Latest commit
841 lines (692 loc) · 29.1 KB
/
Copy pathFilger.lua
File metadata and controls
841 lines (692 loc) · 29.1 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
local_, ns=...
localFilger=ns.Filger
localLibDispel=LibStub("LibDispel")
assert(LibDispel, "Filger requires LibDispel")
localblacklist=ns.Filger.blacklistor {}
localcooldowns=ns.Filger.cooldownsor {}
localspells=ns.Filger.spellsor {}
-- Blizzard
localCreateFrame=_G.CreateFrame
localUnitIsUnit=_G.UnitIsUnit
localUnitIsOwnerOrControllerOfUnit=_G.UnitIsOwnerOrControllerOfUnit
localIsSpellKnown=_G.IsSpellKnown
localGetSpellInfo=C_SpellandC_Spell.GetSpellInfoor_G.GetSpellInfo
localGetSpellName=C_SpellandC_Spell.GetSpellNameor_G.GetSpellInfo
localGetSpellCooldown=_G.GetSpellCooldown
localGetInventoryItemLink=_G.GetInventoryItemLink
localGetItemInfo=_G.GetItemInfo
localGetInventoryItemCooldown=_G.GetInventoryItemCooldown
--------------------------------------------------
-- Filger
--------------------------------------------------
localisInit=false
--------------------------------------------------
-- BUTTONS
--------------------------------------------------
do
localbutton_proto= {}
functionbutton_proto:OnEnter()
if (GameTooltip:IsForbidden() andnotself:IsVisible()) thenreturnend
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
ifself.auraIndexthen
-- classic aura tooltip
GameTooltip:SetUnitAura(self.unit, self.auraIndex, self.isHarmfuland"HARMFUL" or"HELPFUL")
elseifself.auraInstanceIDandGameTooltip.SetUnitDebuffByAuraInstanceIDthen
-- retail aura tooltip
ifself.isHarmfulthen
GameTooltip:SetUnitDebuffByAuraInstanceID(self.unit, self.auraInstanceID)
else
GameTooltip:SetUnitBuffByAuraInstanceID(self.unit, self.auraInstanceID)
end
elseifself.itemIdthen
GameTooltip:SetItemByID(self.itemId)
elseifself.slotIdthen
GameTooltip:SetInventoryItem(self.unit, self.slotId)
elseifself.spellIdthen
GameTooltip:SetSpellByID(self.spellId)
end
end
functionbutton_proto:OnLeave()
ifGameTooltip:IsForbidden() thenreturnend
GameTooltip:Hide()
end
functionbutton_proto:OnUpdate(elapsed)
self.elapsed= (self.elapsedor0) +elapsed
ifself.elapsed>=0.1then
localremaining= (self.expirationTimeor0) -GetTime()
ifself.Timethen
ifremaining>0then
self.Time:SetText(Filger.FormatTime(remaining))
ifremaining<=5then
self.Time:SetTextColor(0.99, 0.31, 0.31)
else
self.Time:SetTextColor(0.84, 0.75, 0.65)
end
else
self.Time:SetText("")
self:SetScript("OnUpdate", nil)
self:Hide()
end
end
self.elapsed=0
end
end
--[[ Callback: button_proto:CreateButton(element, index)
Creates an aura/cooldown button at a given position.
* self - the widget holding the aura buttons
* index - the position at which the aura button is to be created (number)
## Returns
* button - the button used to represent the aura (Button)
--]]
functionFilger:CreateButton(element, index)
-- resources
localfont, fontSize, fontStyle=Filger.fonts.normal, 12, "OUTLINE"
localbutton=Mixin(CreateFrame("Frame", element:GetName() .."Aura" ..index, element), button_proto)
button:SetWidth(element.size)
button:SetHeight(element.size)
button:CreateBackdrop()
localcooldown=CreateFrame("Cooldown", "$parentCD", button, "CooldownFrameTemplate")
cooldown:SetAllPoints()
cooldown:SetReverse(true)
cooldown:SetDrawEdge(false)
cooldown:SetHideCountdownNumbers(true)
-- cooldown.noOCC = true
-- cooldown.noCooldownCount = true
button.Cooldown=cooldown
localicon=button:CreateTexture("$parentIcon", "ARTWORK")
icon:SetAllPoints()
icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
button.Icon=icon
localoverlay=CreateFrame("Frame", "$parentOverlay", button, nil)
overlay:SetAllPoints(button)
overlay:SetFrameLevel(cooldown:GetFrameLevel() +1)
button.Overlay=overlay
localcount=overlay:CreateFontString("$parentCount", "OVERLAY")
count:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 0, 0)
count:SetFont(font, fontSize, fontStyle)
count:SetJustifyH("RIGHT")
count:SetTextColor(0.84, 0.75, 0.65)
button.Count=count
localtime=overlay:CreateFontString("$parentTime", "OVERLAY")
time:SetPoint("CENTER", button, "CENTER", 0, 0)
time:SetFont(font, 20, fontStyle)
time:SetJustifyH("CENTER")
time:SetTextColor(0.84, 0.75, 0.65)
button.Time=time
localanimation=button:CreateAnimationGroup()
animation:SetLooping("BOUNCE")
button.Animation=animation
localfadeout=animation:CreateAnimation("Alpha")
fadeout:SetFromAlpha(1)
fadeout:SetToAlpha(0.10)
fadeout:SetDuration(0.50)
fadeout:SetSmoothing("IN_OUT")
animation.Fadeout=fadeout
ifself.config.general.gametooltipthen
button:SetScript("OnEnter", button.OnEnter)
button:SetScript("OnLeave", button.OnLeave)
end
returnbutton
end
end
--------------------------------------------------
-- AURAS
--------------------------------------------------
localaura_proto= {
createdButtons=0,
anchoredButtons=0,
visibleButtons=0
}
do
--[[ Callback: button:UpdateColor(button, unit, data)
Called after the aura button has been updated.
* self - the widget holding the aura buttons
* button - the updated aura button (Button)
* unit - the unit on which the aura is cast (string)
* data - the [UnitAuraInfo](https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo) object (table)
* index - the actual position of the aura button (number)
]]--
functionaura_proto:UpdateColor(button, unit, data)
ifbutton.Backdropthen
if (data.isHarmfulandUnitCanAssist("player", unit)) or (data.isHelpfulandUnitCanAttack(unit, "player") andUnitCanAttack("player", unit)) then
localcolor=Filger.colors[data.dispelName]
button.Backdrop:SetBackdropBorderColor(color.r, color.g, color.b, color.aor1)
else
localcolor=Filger.config.general.backdrop.color
button.Backdrop:SetBackdropBorderColor(color.r, color.g, color.b, color.aor1)
end
end
ifbutton.Iconandself.desaturated==truethen
button.Icon:SetDesaturated(data.isHarmfulandnotdata.isPlayerAuraandnotUnitIsUnit(unit, "player"))
end
ifbutton.Animationthen
ifdata.isDispelableordata.isStealablethen
button.Animation:Play()
button.Animation.playing=true
else
button.Animation:Stop()
button.Animation.playing=false
end
end
end
--[[ Callback: aura_proto:Update(unit, data, index)
Update the aura button and its components.
* self - the widget holding the aura buttons
* unit - the unit on which the aura is cast (string)
* data - the [UnitAuraInfo](https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo) object (table)
* index - the actual position of the aura button (number)
]]--
functionaura_proto:Update(unit, data, index)
ifnotdata.namethenreturnend
localbutton=self[index]
ifnotbuttonthen
button=Filger:CreateButton(self, index)
table.insert(self, button)
self.createdButtons=self.createdButtons+1
end
-- tooltips
button.unit=unit
button.filter=self.filter
button.auraInstanceID=data.auraInstanceID
button.auraIndex=data.auraIndex
button.isHarmful=data.isHarmful
-- timers
button.name=data.name
button.spellId=data.spellId
button.duration=data.durationor0
button.expirationTime=data.expirationTimeorGetTime()
ifbutton.Cooldownthen
ifdata.durationanddata.duration>0then
button.Cooldown:SetCooldown(data.expirationTime-data.duration, data.duration, data.timeMod)
button.Cooldown:Show()
else
button.Cooldown:Hide()
end
end
ifbutton.Iconthen
ifdata.iconthen
button.Icon:SetTexture(data.icon)
button.Icon:Show()
else
button.Icon:Hide()
end
end
ifbutton.Countthen
button.Count:SetText((data.applicationsanddata.applications>1) anddata.applicationsor"")
end
ifdata.durationanddata.duration>0then
button:SetScript("OnUpdate", button.OnUpdate)
end
button:Show()
self:UpdateColor(button, unit, data)
end
--[[ Override: aura_proto.SortAuras(a, b)
Defines a custom sorting algorithm for ordering the auras.
Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=DefaultAuraCompare).
Overridden by the more specific SortAuras overrides if they are defined.
--]]
aura_proto.SortAuras=function(a, b)
if (a.priority~=b.priority) then
returna.priority>b.priority
end
if (a.expirationTime~=b.expirationTime) then
returna.expirationTime<b.expirationTime
end
-- if (a.canApplyAura ~= b.canApplyAura) then
-- return a.canApplyAura
-- end
returna.auraInstanceID<b.auraInstanceID
end
--[[ Override: aura_proto:FilterAura(unit, data)
Defines a custom filter that controls if the aura button should be shown.
* self - the widget holding the aura buttons
* unit - the unit for which the update has been triggered (string)
* data - [UnitAuraInfo](https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo) object (table)
## Returns
* show - indicates whether the aura button should be shown (boolean)
--]]
functionaura_proto:FilterAura(unit, data)
returndata.enabledanddata.applications>=data.stackThreshold
end
functionaura_proto:GetAuraIndex(unit, auraInstanceID, filter)
localindex=1
repeat
localdata=C_UnitAuras.GetAuraDataByIndex(unit, index, filter)
ifnotdatathen
returnnil
elseifdata.auraInstanceID==auraInstanceIDthen
returnindex
end
index=index+1
until (notdata)
returnnil
end
--[[ Override: aura_proto:ProcessData(unit, data)
Add some custom value sto the UnitAuraInfo.
* self - the widget holding the aura buttons
* unit - the unit for which the update has been triggered (string)
* data - [UnitAuraInfo](https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo) object (table)
## Returns
* data - a custom 'UnitAuraInfo' object (table)
--]]
functionaura_proto:ProcessData(unit, data)
ifnotdatathenreturnend
data.isPlayerAura=data.sourceUnitand (UnitIsUnit("player", data.sourceUnit) orUnitIsOwnerOrControllerOfUnit("player", data.sourceUnit))
data.dispelName=LibDispel:GetDispelType(data.spellId, data.dispelName)
data.isDispelable=LibDispel:IsDispelable(unit, data.spellId, data.dispelName, data.isHarmful)
localspell=self.spells[data.spellId]
ifspellthen
data.enabled=spell.enabledorfalse
data.priority=spell.priorityor0
data.stackThreshold=spell.stackThresholdor0
else
data.enabled=true
data.priority=0
data.stackThreshold=0
end
ifblacklist[data.spellId] orblacklist[data.name] then
data.enabled=false
end
ifFilger.isClassicthen
data.auraIndex=self:GetAuraIndex(unit, data.auraInstanceID, self.filter)
end
returndata
end
functionaura_proto:UpdateAuras(event, unit, updateInfo)
if (self.unit~=unit) thenreturnend
localisFullUpdate=notupdateInfoorupdateInfo.isFullUpdate
localchanged=false
ifisFullUpdatethen
self.all=table.wipe(self.allor {})
self.actives=table.wipe(self.activesor {})
changed=true
localslots= { C_UnitAuras.GetAuraSlots(unit, self.filter) }
fori=2, #slotsdo-- #1 return is continuationToken, we don't care about it
localdata=self:ProcessData(unit, C_UnitAuras.GetAuraDataBySlot(unit, slots[i]))
self.all[data.auraInstanceID] =data
ifself:FilterAura(unit, data) then
self.actives[data.auraInstanceID] =true
end
end
else
ifupdateInfo.addedAurasthen
for_, datainnext, updateInfo.addedAurasdo
ifnotC_UnitAuras.IsAuraFilteredOutByInstanceID(unit, data.auraInstanceID, self.filter) then
self.all[data.auraInstanceID] =self:ProcessData(unit, data)
ifself:FilterAura(unit, data) then
self.actives[data.auraInstanceID] =true
changed=true
end
end
end
end
ifupdateInfo.updatedAuraInstanceIDsthen
for_, auraInstanceIDinnext, updateInfo.updatedAuraInstanceIDsdo
localdata=self.all[auraInstanceID]
ifdatathen
self.all[auraInstanceID] =self:ProcessData(unit, C_UnitAuras.GetAuraDataByAuraInstanceID(unit, auraInstanceID))
ifself:FilterAura(unit, data) then
self.actives[auraInstanceID] =true
changed=true
end
end
end
end
ifupdateInfo.removedAuraInstanceIDsthen
for_, auraInstanceIDinnext, updateInfo.removedAuraInstanceIDsdo
ifself.all[auraInstanceID] then
self.all[auraInstanceID] =nil
end
ifself.actives[auraInstanceID] then
self.actives[auraInstanceID] =nil
changed=true
end
end
end
end
ifchangedthen
-- instead of removing auras one by one, just wipe the tables entirely
-- and repopulate them, multiple table.remove calls are insanely slow
self.sorted=table.wipe(self.sortedor {})
forauraInstanceID, _innext, self.activesdo
table.insert(self.sorted, self.all[auraInstanceID])
end
table.sort(self.sorted, self.SortAuras)
numVisible=math.min(self.limit, #self.sorted)
fori=1, numVisibledo
self:Update(unit, self.sorted[i], i)
end
localvisibleChanged=true
if (numVisible~=self.visibleButtons) then
self.visibleButtons=numVisible
visibleChanged=true
end
fori=numVisible+1, #selfdo
self[i]:Hide()
end
if (visibleChangedorself.createdButtons>self.anchoredButtons) then
ifvisibleChangedthen
self:SetPosition(1, numVisible)
else
self:SetPosition(self.anchoredButtons+1, self.createdButtons)
self.anchoredButtons=self.createdButtons
end
end
end
end
functionaura_proto:ForceUpdate()
self:UpdateAuras("ForceUpdate", self.unit, nil)
end
functionaura_proto:UNIT_AURA(unit, updateInfo)
self:UpdateAuras("UNIT_AURA", unit, updateInfo)
end
functionaura_proto:PLAYER_TARGET_CHANGED(...)
self:ForceUpdate()
end
functionaura_proto:PLAYER_FOCUS_CHANGED(...)
self:ForceUpdate()
end
end
--------------------------------------------------
-- COOLDOWNS
--------------------------------------------------
localcooldown_proto= {
casted= {},
spells= {},
createdButtons=0,
anchoredButtons=0,
visibleButtons=0
}
do
--[[ Callback: cooldown_proto:Update(unit, data, index)
Update the cooldown button and its components.
* self - the widget holding the aura buttons
* unit - the unit on which the aura is cast (string)
* data - the cooldown object (table)
* index - the actual position of the aura button (number)
]]--
functioncooldown_proto:Update(unit, data, index)
ifnotdata.namethenreturnend
localbutton=self[index]
ifnotbuttonthen
button=Filger:CreateButton(self, index)
table.insert(self, button)
self.createdButtons=self.createdButtons+1
end
-- tooltips
button.unit=unit
button.spellId=data.spellId
button.slotId=data.slotId
button.itemId=data.itemId
-- timers
button.name=data.name
-- button.spellId = data.spellId
button.duration=data.durationor0
button.expirationTime=data.expirationTimeorGetTime()
ifbutton.Cooldownthen
ifdata.durationanddata.duration>0then
button.Cooldown:SetCooldown(data.expirationTime-data.duration, data.duration, data.timeMod)
button.Cooldown:Show()
else
button.Cooldown:Hide()
end
end
ifbutton.Iconthen
ifdata.iconthen
button.Icon:SetTexture(data.icon)
button.Icon:Show()
else
button.Icon:Hide()
end
end
ifdata.durationanddata.duration>0then
button:SetScript("OnUpdate", button.OnUpdate)
end
button:Show()
end
--[[ Override: cooldown_proto:FilterCooldown(data)
Defines a custom filter that controls if the cooldown button should be shown.
* self - the widget holding the aura buttons
* data - the cooldown object (table)
## Returns
* show - indicates whether the aura button should be shown (boolean)
--]]
functioncooldown_proto:FilterCooldown(data)
ifnotdata.namethenreturnend
returndata.name
anddata.enabled
anddata.isKnown
anddata.casted
and (data.durationanddata.duration>1.5) -- classic sometimes bring 1.5 duration
and (data.startanddata.start>0)
end
--[[ Override: cooldown_proto.SortCooldowns(a, b)
Defines a custom sorting algorithm for ordering the cooldowns.
Overridden by the more specific SortCooldowns overrides if they are defined.
--]]
cooldown_proto.SortCooldowns=function(a, b)
if (a.expirationTime~=b.expirationTime) then
returna.expirationTime<b.expirationTime
end
returna.index<b.index
end
functioncooldown_proto:ProcessCooldownData(unit, data)
localindex, name, icon, start, duration, enabled
ifdata.spellIdthen
index="SPELL_" ..data.spellId
localinfo=Filger.GetSpellInfo(data.spellId)
ifinfothen
name=info.name
icon=info.iconID
end
localcdInfo=Filger.GetSpellCooldown(data.spellId)
ifcdInfothen
start=cdInfo.startTime
duration=cdInfo.duration
enabled=cdInfo.enabled
end
elseifdata.slotIdthen
index="SLOT_" ..data.slotId
localitemLink=GetInventoryItemLink(unit, data.slotId)
if (itemLink) then
name, _, _, _, _, _, _, _, _, icon, _, _, _, _, _, _, _=GetItemInfo(itemLink)
start, duration, enabled=GetInventoryItemCooldown(unit, data.slotId)
else
enabled=0
end
elseifdata.itemIdthen
index="ITEM_" ..data.itemId
name, _, _, _, _, itemType, _, _, _, icon, _, _, _, _, _, _, _=GetItemInfo(data.itemId)
start, duration, enabled=GetItemCooldown(data.itemId)
end
duration=durationor0
start=startor0
return {
index=index,
name=name,
spellId=data.spellId,
slotId=data.slotId,
itemId=data.itemId,
icon=icon,
start=start,
duration=duration,
expirationTime=start+duration,
enabled= (enabled~=0),
casted= (notdata.spellId) andtrueorself.casted[data.spellId],
isKnown= (notdata.spellId) andtrueorIsSpellKnown(data.spellId)
}
end
functioncooldown_proto:UpdateCooldowns(event, unit)
localchanged=true
self.all=table.wipe(self.allor {})
self.active=table.wipe(self.activeor {})
for_, rowinnext, self.spellsdo
localdata=self:ProcessCooldownData(unit, row)
self.all[data.index] =data
ifself:FilterCooldown(data) then
self.active[data.index] =true
elseifdata.spellIdthen
self.casted[data.spellId] =nil
end
end
ifchangedthen
-- instead of removing auras one by one, just wipe the tables entirely
-- and repopulate them, multiple table.remove calls are insanely slow
self.sorted=table.wipe(self.sortedor {})
forindex, _innext, self.activedo
table.insert(self.sorted, self.all[index])
end
table.sort(self.sorted, self.SortCooldowns)
numVisible=math.min(self.limit, #self.sorted)
fori=1, numVisibledo
self:Update(unit, self.sorted[i], i)
end
localvisibleChanged=true
if (numVisible~=self.visibleButtons) then
self.visibleButtons=numVisible
visibleChanged=true
end
fori=numVisible+1, #selfdo
self[i]:Hide()
end
if (visibleChangedorself.createdButtons>self.anchoredButtons) then
ifvisibleChangedthen
self:SetPosition(1, numVisible)
else
self:SetPosition(self.anchoredButtons+1, self.createdButtons)
self.anchoredButtons=self.createdButtons
end
end
end
end
functioncooldown_proto:ForceUpdate()
self:UpdateCooldowns("ForceUpdate", self.unit, nil)
end
functioncooldown_proto:SPELL_UPDATE_COOLDOWN()
self:UpdateCooldowns("SPELL_UPDATE_COOLDOWN", self.unit)
end
-- register which spell the player cast
functioncooldown_proto:UNIT_SPELLCAST_SUCCEEDED(unit, guid, spellId)
self.casted[spellId] =true
end
end
--------------------------------------------------
-- FILGER
--------------------------------------------------
do
localelement_proto= {}
functionelement_proto:SetPosition(from, to)
localelement=self
localsizex=element.size+element.spacing
localsizey=element.size+element.spacing
localanchor=element.initialAnchoror"BOTTOMLEFT"
localgrowthx= (element["growth-x"] =="LEFT" and-1) or1
localgrowthy= (element["growth-y"] =="DOWN" and-1) or1
localcols=math.floor(element:GetWidth() /sizex+0.5)
fori=from, todo
localbutton=element[i]
if (notbutton) thenbreakend
ifanchor=="CENTER" then
-- Centralized positioning logic
localindex=i-from
localcol, row
ifindex%2==0then
col=math.floor(index/2)
else
col=-math.floor(index/2) -1
end
row=math.floor(index/cols)
button:ClearAllPoints()
button:SetPoint(anchor, element, anchor, col*sizex, row*sizey)
else
localcol= (i-1) %cols
localrow=math.floor((i-1) /cols)
button:ClearAllPoints()
button:SetPoint(anchor, element, anchor, col*sizex*growthx, row*sizey*growthy)
end
end
end
functionFilger:Spawn(data)
localindex=#self
localunit=data.unit:gsub("^%l", string.upper):gsub("t(arget)", "T%1")
localelement=Mixin(CreateFrame("Frame", self:GetName() ..unit..index, self), element_proto)
-- configuration
element.unit=data.unitor"player"
element.filter=data.filteror"HELPFUL"
element.caster=data.casterornil
element.limit=data.limitor32
element.size=data.sizeor32
element.spacing=data.spacingor5
element.initialAnchor=data.initialAnchoror"BOTTOMLEFT"
element["growth-x"] =data["growth-x"] or"LEFT"
element["growth-y"] =data["growth-y"] or"DOWN"
element:SetPoint(unpack(data.anchor))
element:SetWidth((element.limit*element.size) + (element.limit-1) *element.spacing)
element:SetHeight(element.size)
-- element:CreateBackdrop()
-- local text = element:CreateFontString(nil, "OVERLAY")
-- text:SetPoint("CENTER", element, "CENTER", 0, 1)
-- text:SetFont(Font, FontSize, FontStyle)
-- text:SetText(element:GetName())
-- text:SetJustifyH("CENTER")
-- text:Hide()
-- element.text = text
if (element.filter=="COOLDOWN") then
element=Mixin(element, cooldown_proto)
-- overrider element functions with configurations
element.SortCooldowns=data.SortCooldownsorelement.SortCooldowns
element.FilterCooldown=data.FilterCooldownorelement.FilterCooldown
element:RegisterEvent("SPELL_UPDATE_COOLDOWN")
element:RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", self.unit)
else
element=Mixin(element, aura_proto)
-- overrider element functions with configurations
element.SortAuras=data.SortAurasorelement.SortAuras
element.FilterAura=data.FilterAuraorelement.FilterAura
element:RegisterEvent("UNIT_AURA")
if (element.unit=="target") then
element:RegisterEvent("PLAYER_TARGET_CHANGED")
end
if (element.unit=="focus") then
element:RegisterEvent("PLAYER_FOCUS_CHANGED")
end
end
element.spells=data.spellsorelement.spellsor {}
element:SetScript("OnEvent", function(self, event, ...)
-- call event handler
self[event](self, ...)
end)
returnelement
end
end
Filger:RegisterEvent("ADDON_LOADED")
Filger:RegisterEvent("PLAYER_LOGIN")
Filger:SetScript("OnEvent", function(self, event, ...)
ifself[event] then
-- call event handler
self[event](self, ...)
end
end)
functionFilger:ADDON_LOADED(addon)
if (addon~="Filger") thenreturnend
self.unit="player"
self.guid=UnitGUID(self.unit)
-- Filger standalone
ifself.MergeAPIthen
self:MergeAPI()
end
end
functionFilger:PLAYER_LOGIN()
ifnotisInitthen
-- self:RegisterEvent("PLAYER_ENTERING_WORLD")
-- create panels based on spell list
for_, datainpairs(self.config.frames) do
if (data.enabled) then
localelement=self:Spawn(data)
element:ForceUpdate()
table.insert(self, element)
end
end
isInit=true
end
end