Go to most recent revision | Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 2 | Blooblahguy-207965 | --[[ Element: LFD Role Icon |
2 | Blooblahguy-207965 | ||
3 | Blooblahguy-207965 | Toggles visibility of the LFD role icon based upon the units current dungeon |
|
4 | Blooblahguy-207965 | role. |
|
5 | Blooblahguy-207965 | ||
6 | Blooblahguy-207965 | Widget |
|
7 | Blooblahguy-207965 | ||
8 | Blooblahguy-207965 | LFDRole - A Texture containing the LFD role icons at specific locations. Look |
|
9 | Blooblahguy-207965 | at the default LFD role icon texture for an example of this. |
|
10 | Blooblahguy-207965 | Alternatively you can look at the return values of |
|
11 | Blooblahguy-207965 | GetTexCoordsForRoleSmallCircle(role). |
|
12 | Blooblahguy-207965 | ||
13 | Blooblahguy-207965 | Notes |
|
14 | Blooblahguy-207965 | ||
15 | Blooblahguy-207965 | The default LFD role texture will be applied if the UI widget is a texture and |
|
16 | Blooblahguy-207965 | doesn't have a texture or color defined. |
|
17 | Blooblahguy-207965 | ||
18 | Blooblahguy-207965 | Examples |
|
19 | Blooblahguy-207965 | ||
20 | Blooblahguy-207965 | -- Position and size |
|
21 | Blooblahguy-207965 | local LFDRole = self:CreateTexture(nil, "OVERLAY") |
|
22 | Blooblahguy-207965 | LFDRole:SetSize(16, 16) |
|
23 | Blooblahguy-207965 | LFDRole:SetPoint("LEFT", self) |
|
24 | Blooblahguy-207965 | ||
25 | Blooblahguy-207965 | -- Register it with oUF |
|
26 | Blooblahguy-207965 | self.LFDRole = LFDRole |
|
27 | Blooblahguy-207965 | ||
28 | Blooblahguy-207965 | Hooks |
|
29 | Blooblahguy-207965 | ||
30 | Blooblahguy-207965 | Override(self) - Used to completely override the internal update function. |
|
31 | Blooblahguy-207965 | Removing the table key entry will make the element fall-back |
|
32 | Blooblahguy-207965 | to its internal function again. |
|
33 | Blooblahguy-207965 | ]] |
|
34 | Blooblahguy-207965 | ||
35 | Blooblahguy-207965 | local parent, ns = ... |
|
36 | Blooblahguy-207965 | local oUF = ns.oUF |
|
37 | Blooblahguy-207965 | ||
38 | Blooblahguy-207965 | local Update = function(self, event) |
|
39 | Blooblahguy-207965 | local lfdrole = self.LFDRole |
|
40 | Blooblahguy-207965 | if(lfdrole.PreUpdate) then |
|
41 | Blooblahguy-207965 | lfdrole:PreUpdate() |
|
42 | Blooblahguy-207965 | end |
|
43 | Blooblahguy-207965 | ||
44 | Blooblahguy-207965 | local role = UnitGroupRolesAssigned(self.unit) |
|
45 | Blooblahguy-207965 | if(role == 'TANK' or role == 'HEALER' or role == 'DAMAGER') then |
|
46 | Blooblahguy-207965 | lfdrole:SetTexCoord(GetTexCoordsForRoleSmallCircle(role)) |
|
47 | Blooblahguy-207965 | lfdrole:Show() |
|
48 | Blooblahguy-207965 | else |
|
49 | Blooblahguy-207965 | lfdrole:Hide() |
|
50 | Blooblahguy-207965 | end |
|
51 | Blooblahguy-207965 | ||
52 | Blooblahguy-207965 | if(lfdrole.PostUpdate) then |
|
53 | Blooblahguy-207965 | return lfdrole:PostUpdate(role) |
|
54 | Blooblahguy-207965 | end |
|
55 | Blooblahguy-207965 | end |
|
56 | Blooblahguy-207965 | ||
57 | Blooblahguy-207965 | local Path = function(self, ...) |
|
58 | Blooblahguy-207965 | return (self.LFDRole.Override or Update) (self, ...) |
|
59 | Blooblahguy-207965 | end |
|
60 | Blooblahguy-207965 | ||
61 | Blooblahguy-207965 | local ForceUpdate = function(element) |
|
62 | Blooblahguy-207965 | return Path(element.__owner, 'ForceUpdate') |
|
63 | Blooblahguy-207965 | end |
|
64 | Blooblahguy-207965 | ||
65 | Blooblahguy-207965 | local Enable = function(self) |
|
66 | Blooblahguy-207965 | local lfdrole = self.LFDRole |
|
67 | Blooblahguy-207965 | if(lfdrole) then |
|
68 | Blooblahguy-207965 | lfdrole.__owner = self |
|
69 | Blooblahguy-207965 | lfdrole.ForceUpdate = ForceUpdate |
|
70 | Blooblahguy-207965 | ||
71 | Blooblahguy-207965 | if(self.unit == "player") then |
|
72 | Blooblahguy-207965 | self:RegisterEvent("PLAYER_ROLES_ASSIGNED", Path, true) |
|
73 | Blooblahguy-207965 | else |
|
74 | Blooblahguy-207965 | self:RegisterEvent("GROUP_ROSTER_UPDATE", Path, true) |
|
75 | Blooblahguy-207965 | end |
|
76 | Blooblahguy-207965 | ||
77 | Blooblahguy-207965 | if(lfdrole:IsObjectType"Texture" and not lfdrole:GetTexture()) then |
|
78 | Blooblahguy-207965 | lfdrole:SetTexture[[Interface\LFGFrame\UI-LFG-ICON-PORTRAITROLES]] |
|
79 | Blooblahguy-207965 | end |
|
80 | Blooblahguy-207965 | ||
81 | Blooblahguy-207965 | return true |
|
82 | Blooblahguy-207965 | end |
|
83 | Blooblahguy-207965 | end |
|
84 | Blooblahguy-207965 | ||
85 | Blooblahguy-207965 | local Disable = function(self) |
|
86 | Blooblahguy-207965 | local lfdrole = self.LFDRole |
|
87 | Blooblahguy-207965 | if(lfdrole) then |
|
88 | Blooblahguy-207965 | lfdrole:Hide() |
|
89 | Blooblahguy-207965 | self:UnregisterEvent("PLAYER_ROLES_ASSIGNED", Path) |
|
90 | Blooblahguy-207965 | self:UnregisterEvent("GROUP_ROSTER_UPDATE", Path) |
|
91 | Blooblahguy-207965 | end |
|
92 | Blooblahguy-207965 | end |
|
93 | Blooblahguy-207965 | ||
94 | Blooblahguy-207965 | oUF:AddElement('LFDRole', Path, Enable, Disable) |