Go to most recent revision | Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 2 | Blooblahguy-207965 | --[[ Element: Resurrect Icon |
2 | Blooblahguy-207965 | ||
3 | Blooblahguy-207965 | Handles updating and toggles visibility of incoming resurrect icon. |
|
4 | Blooblahguy-207965 | ||
5 | Blooblahguy-207965 | Widget |
|
6 | Blooblahguy-207965 | ||
7 | Blooblahguy-207965 | ResurrectIcon - A Texture used to display if the unit has an incoming |
|
8 | Blooblahguy-207965 | resurrect. |
|
9 | Blooblahguy-207965 | ||
10 | Blooblahguy-207965 | Notes |
|
11 | Blooblahguy-207965 | ||
12 | Blooblahguy-207965 | The default resurrect icon will be used if the UI widget is a texture and |
|
13 | Blooblahguy-207965 | doesn't have a texture or color defined. |
|
14 | Blooblahguy-207965 | ||
15 | Blooblahguy-207965 | Examples |
|
16 | Blooblahguy-207965 | ||
17 | Blooblahguy-207965 | -- Position and size |
|
18 | Blooblahguy-207965 | local ResurrectIcon = self:CreateTexture(nil, 'OVERLAY') |
|
19 | Blooblahguy-207965 | ResurrectIcon:SetSize(16, 16) |
|
20 | Blooblahguy-207965 | ResurrectIcon:SetPoint('TOPRIGHT', self) |
|
21 | Blooblahguy-207965 | ||
22 | Blooblahguy-207965 | -- Register it with oUF |
|
23 | Blooblahguy-207965 | self.ResurrectIcon = ResurrectIcon |
|
24 | Blooblahguy-207965 | ||
25 | Blooblahguy-207965 | Hooks |
|
26 | Blooblahguy-207965 | ||
27 | Blooblahguy-207965 | Override(self) - Used to completely override the internal update function. |
|
28 | Blooblahguy-207965 | Removing the table key entry will make the element fall-back |
|
29 | Blooblahguy-207965 | to its internal function again. |
|
30 | Blooblahguy-207965 | ]] |
|
31 | Blooblahguy-207965 | ||
32 | Blooblahguy-207965 | local parent, ns = ... |
|
33 | Blooblahguy-207965 | local oUF = ns.oUF |
|
34 | Blooblahguy-207965 | ||
35 | Blooblahguy-207965 | local Update = function(self, event) |
|
36 | Blooblahguy-207965 | local resurrect = self.ResurrectIcon |
|
37 | Blooblahguy-207965 | if(resurrect.PreUpdate) then |
|
38 | Blooblahguy-207965 | resurrect:PreUpdate() |
|
39 | Blooblahguy-207965 | end |
|
40 | Blooblahguy-207965 | ||
41 | Blooblahguy-207965 | local incomingResurrect = UnitHasIncomingResurrection(self.unit) |
|
42 | Blooblahguy-207965 | if(incomingResurrect) then |
|
43 | Blooblahguy-207965 | resurrect:Show() |
|
44 | Blooblahguy-207965 | else |
|
45 | Blooblahguy-207965 | resurrect:Hide() |
|
46 | Blooblahguy-207965 | end |
|
47 | Blooblahguy-207965 | ||
48 | Blooblahguy-207965 | if(resurrect.PostUpdate) then |
|
49 | Blooblahguy-207965 | return resurrect:PostUpdate(incomingResurrect) |
|
50 | Blooblahguy-207965 | end |
|
51 | Blooblahguy-207965 | end |
|
52 | Blooblahguy-207965 | ||
53 | Blooblahguy-207965 | local Path = function(self, ...) |
|
54 | Blooblahguy-207965 | return (self.ResurrectIcon.Override or Update) (self, ...) |
|
55 | Blooblahguy-207965 | end |
|
56 | Blooblahguy-207965 | ||
57 | Blooblahguy-207965 | local ForceUpdate = function(element) |
|
58 | Blooblahguy-207965 | return Path(element.__owner, 'ForceUpdate') |
|
59 | Blooblahguy-207965 | end |
|
60 | Blooblahguy-207965 | ||
61 | Blooblahguy-207965 | local Enable = function(self) |
|
62 | Blooblahguy-207965 | local resurrect = self.ResurrectIcon |
|
63 | Blooblahguy-207965 | if(resurrect) then |
|
64 | Blooblahguy-207965 | resurrect.__owner = self |
|
65 | Blooblahguy-207965 | resurrect.ForceUpdate = ForceUpdate |
|
66 | Blooblahguy-207965 | ||
67 | Blooblahguy-207965 | self:RegisterEvent('INCOMING_RESURRECT_CHANGED', Path, true) |
|
68 | Blooblahguy-207965 | ||
69 | Blooblahguy-207965 | if(resurrect:IsObjectType('Texture') and not resurrect:GetTexture()) then |
|
70 | Blooblahguy-207965 | resurrect:SetTexture[[Interface\RaidFrame\Raid-Icon-Rez]] |
|
71 | Blooblahguy-207965 | end |
|
72 | Blooblahguy-207965 | ||
73 | Blooblahguy-207965 | return true |
|
74 | Blooblahguy-207965 | end |
|
75 | Blooblahguy-207965 | end |
|
76 | Blooblahguy-207965 | ||
77 | Blooblahguy-207965 | local Disable = function(self) |
|
78 | Blooblahguy-207965 | local resurrect = self.ResurrectIcon |
|
79 | Blooblahguy-207965 | if(resurrect) then |
|
80 | Blooblahguy-207965 | self:UnregisterEvent('INCOMING_RESURRECT_CHANGED', Path) |
|
81 | Blooblahguy-207965 | end |
|
82 | Blooblahguy-207965 | end |
|
83 | Blooblahguy-207965 | ||
84 | Blooblahguy-207965 | oUF:AddElement('ResurrectIcon', Path, Enable, Disable) |