Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 2 | Wildbreath-135052 | local parent, ns = ... |
2 | Wildbreath-135052 | local oUF = ns.oUF |
|
3 | Wildbreath-135052 | ||
4 | Wildbreath-135052 | local Update = function(self, event, unit) |
|
5 | Wildbreath-135052 | if(not UnitIsUnit(self.unit, unit)) then return end |
|
6 | Wildbreath-135052 | if(self.PreUpdatePortrait) then self:PreUpdatePortrait(event, unit) end |
|
7 | Wildbreath-135052 | ||
8 | Wildbreath-135052 | local portrait = self.Portrait |
|
9 | Wildbreath-135052 | if(portrait:IsObjectType'Model') then |
|
10 | Wildbreath-135052 | local name = UnitName(unit) |
|
11 | Wildbreath-135052 | if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then |
|
12 | Wildbreath-135052 | portrait:SetModelScale(4.25) |
|
13 | Wildbreath-135052 | portrait:SetPosition(0, 0, -1.5) |
|
14 | Wildbreath-135052 | portrait:SetModel"Interface\\Buttons\\talktomequestionmark.mdx" |
|
15 | Wildbreath-135052 | elseif(portrait.name ~= name or event == 'UNIT_MODEL_CHANGED') then |
|
16 | Wildbreath-135052 | local alpha = portrait:GetAlpha() |
|
17 | Wildbreath-135052 | portrait:SetUnit(unit) |
|
18 | Wildbreath-135052 | portrait:SetCamera(0) |
|
19 | Wildbreath-135052 | portrait:SetAlpha(alpha) |
|
20 | Wildbreath-135052 | ||
21 | Wildbreath-135052 | portrait.name = name |
|
22 | Wildbreath-135052 | else |
|
23 | Wildbreath-135052 | portrait:SetCamera(0) |
|
24 | Wildbreath-135052 | end |
|
25 | Wildbreath-135052 | else |
|
26 | Wildbreath-135052 | SetPortraitTexture(portrait, unit) |
|
27 | Wildbreath-135052 | end |
|
28 | Wildbreath-135052 | ||
29 | Wildbreath-135052 | if(self.PostUpdatePortrait) then |
|
30 | Wildbreath-135052 | return self:PostUpdatePortrait(event, unit) |
|
31 | Wildbreath-135052 | end |
|
32 | Wildbreath-135052 | end |
|
33 | Wildbreath-135052 | ||
34 | Wildbreath-135052 | local Enable = function(self) |
|
35 | Wildbreath-135052 | if(self.Portrait) then |
|
36 | Wildbreath-135052 | self:RegisterEvent("UNIT_PORTRAIT_UPDATE", Update) |
|
37 | Wildbreath-135052 | self:RegisterEvent("UNIT_MODEL_CHANGED", Update) |
|
38 | Wildbreath-135052 | ||
39 | Wildbreath-135052 | return true |
|
40 | Wildbreath-135052 | end |
|
41 | Wildbreath-135052 | end |
|
42 | Wildbreath-135052 | ||
43 | Wildbreath-135052 | local Disable = function(self) |
|
44 | Wildbreath-135052 | if(self.Portrait) then |
|
45 | Wildbreath-135052 | self:UnregisterEvent("UNIT_PORTRAIT_UPDATE", Update) |
|
46 | Wildbreath-135052 | self:UnregisterEvent("UNIT_MODEL_CHANGED", Update) |
|
47 | Wildbreath-135052 | end |
|
48 | Wildbreath-135052 | end |
|
49 | Wildbreath-135052 | ||
50 | Wildbreath-135052 | oUF:AddElement('Portrait', Update, Enable, Disable) |