Mercurial > wow > buffalo2
comparison BuffFrame/RaidBuffTray.lua @ 49:16465f3fd919
- remove UpdateAnchorAnchors and use hardlink for the one frame that this applied to
author | Nenue |
---|---|
date | Fri, 29 Apr 2016 10:50:27 -0400 |
parents | 9837069e366a |
children | 5db587de8feb |
comparison
equal
deleted
inserted
replaced
48:9837069e366a | 49:16465f3fd919 |
---|---|
3 -- @project-revision@ @project-hash@ | 3 -- @project-revision@ @project-hash@ |
4 -- @file-revision@ @file-hash@ | 4 -- @file-revision@ @file-hash@ |
5 -- Created: 3/20/2016 10:00 PM | 5 -- Created: 3/20/2016 10:00 PM |
6 | 6 |
7 local _, A = ... | 7 local _, A = ... |
8 local B = A.frame | 8 local vn = A.frame |
9 local MODULE = 'BuffFrame' | 9 local MODULE = 'BuffFrame' |
10 local M = B:RegisterModule(MODULE) | 10 local Aura = vn:RegisterModule(MODULE) |
11 local displays = B.displays | |
12 | |
13 local parentAnchor, parentFrame, raidbuffsFrame | 11 local parentAnchor, parentFrame, raidbuffsFrame |
14 local band, lshift, CreateFrame = bit.band, bit.lshift, CreateFrame | 12 local unpack, band, lshift, CreateFrame = unpack,bit.band, bit.lshift, CreateFrame |
15 local raidBuffs = {} | 13 local raidBuffs = {} |
16 local raidBuffSymbols = {'St', 'HP', 'AP', 'Ha', 'SP', 'Cr', 'Ma', 'MS', 'V' } | 14 local raidBuffSymbols = {'St', 'HP', 'AP', 'Ha', 'SP', 'Cr', 'Ma', 'MS', 'V' } |
17 local missingBuffs = {} | 15 local missingBuffs = {} |
18 local playerBuffing, playerCurrentBuff | 16 local playerBuffing, playerCurrentBuff |
19 local playerBuffs = {} | 17 local playerBuffs = {} |
20 local c, ac, frameSize, frameSpacing, framePosition | 18 local c, ac, frameSize, frameSpacing, framePosition |
21 local fprint = B.fprint | 19 local fprint = vn.fprint |
20 local xprint = vn.print('XML') | |
22 local NUM_LE_MISSING_RAID_BUFFS = 0 | 21 local NUM_LE_MISSING_RAID_BUFFS = 0 |
23 local missingBuffsAnchor | 22 local missingBuffsAnchor |
24 | 23 |
25 | 24 |
26 --- Takes a given icon texture and calls the pre-defined function set | 25 --- Takes a given icon texture and calls the pre-defined function set |
27 M.UpdateBuffStyle = function(buff, style, path) | 26 Aura.UpdateBuffStyle = function(buff, style, path) |
28 local print = fprint() | 27 local print = fprint() |
29 local icon = buff.icon | 28 local icon = buff.icon |
30 local symbol = buff.symbol | 29 local symbol = buff.symbol |
31 path = path or icon.iconPath | 30 path = path or icon.iconPath |
32 --print(style, icon.iconStyle) | 31 --print(style, icon.iconStyle) |
37 icon.iconPath = path | 36 icon.iconPath = path |
38 else | 37 else |
39 --print('|cFF00FF88UpdateBuffStyle(|r', icon:GetName(), style, path, ') same values, ignore') | 38 --print('|cFF00FF88UpdateBuffStyle(|r', icon:GetName(), style, path, ') same values, ignore') |
40 return | 39 return |
41 end | 40 end |
42 local styleset = B.BuffStyles[style] | 41 local styleset = Aura.BuffStyles[style] |
43 if not path or path == '' then | 42 if not path or path == '' then |
44 print('path is nil/empty') | 43 print('path is nil/empty') |
45 icon:SetTexture(1, 1, 1, 1) | 44 icon:SetTexture(1, 1, 1, 1) |
46 icon:SetVertexColor(unpack(styleset.Color)) | 45 icon:SetVertexColor(unpack(styleset.Color)) |
47 else | 46 else |
61 --- Populates a list of targets needing a buff, fired by a handler | 60 --- Populates a list of targets needing a buff, fired by a handler |
62 local PlayerBuffTodo ={} | 61 local PlayerBuffTodo ={} |
63 local PlayerBuffStatus = {} | 62 local PlayerBuffStatus = {} |
64 local UnitClass, IsInGroup, GetNumGroupMembers, UnitAura = UnitClass, IsInGroup, GetNumGroupMembers, UnitAura | 63 local UnitClass, IsInGroup, GetNumGroupMembers, UnitAura = UnitClass, IsInGroup, GetNumGroupMembers, UnitAura |
65 local GetTalentInfoByID, GetActiveSpecGroup, GetStablePetInfo, GetSpecialization = GetTalentInfoByID, GetActiveSpecGroup, GetStablePetInfo, GetSpecialization | 64 local GetTalentInfoByID, GetActiveSpecGroup, GetStablePetInfo, GetSpecialization = GetTalentInfoByID, GetActiveSpecGroup, GetStablePetInfo, GetSpecialization |
66 M.UpdateBuffStatus = function(aura, filters) | 65 Aura.UpdateBuffStatus = function(aura, filters) |
66 local print = xprint | |
67 if not PlayerBuffStatus[aura] then | 67 if not PlayerBuffStatus[aura] then |
68 PlayerBuffStatus[aura] = {} | 68 PlayerBuffStatus[aura] = {} |
69 end | 69 end |
70 | |
71 | |
72 print(UnitClass('player')) | 70 print(UnitClass('player')) |
73 if IsInGroup() then | 71 if IsInGroup() then |
74 local numBuffed = 0 | 72 local numBuffed = 0 |
75 local partySize = GetNumGroupMembers() | 73 local partySize = GetNumGroupMembers() |
76 local missing = {} | 74 local missing = {} |
97 if test == true then | 95 if test == true then |
98 -- it's a passive effect that is always on | 96 -- it's a passive effect that is always on |
99 return true, true | 97 return true, true |
100 else | 98 else |
101 if c.spec then | 99 if c.spec then |
102 if not (result and c.spec == B.PlayerSpec) then | 100 if not (result and c.spec == vn.PlayerSpec) then |
103 return false | 101 return false |
104 end | 102 end |
105 end | 103 end |
106 | 104 |
107 if c.talent then | 105 if c.talent then |
129 end | 127 end |
130 return true, false | 128 return true, false |
131 end | 129 end |
132 | 130 |
133 --- events: PLAYER_SPECIALIZATION_CHANGED | 131 --- events: PLAYER_SPECIALIZATION_CHANGED |
134 function M:UpdateBuffsTodo (unit) | 132 function Aura:UpdateBuffsTodo (unit) |
135 -- buffs vs. auras | 133 -- buffs vs. auras |
136 if unit ~= 'player' then | 134 if unit ~= 'player' then |
137 -- look for changes in the GIST manifest and sort them out | 135 -- look for changes in the GIST manifest and sort them out |
138 return | 136 return |
139 end | 137 end |
141 local class = UnitClass('player') | 139 local class = UnitClass('player') |
142 local spec = GetSpecialization() | 140 local spec = GetSpecialization() |
143 if not class or | 141 if not class or |
144 not spec or | 142 not spec or |
145 not IsInGroup() or | 143 not IsInGroup() or |
146 not B.PlayerBuffStatus[class] then | 144 not Aura.PlayerBuffStatus[class] then |
147 -- if just logging in, info won't be available for several seconds | 145 -- if just logging in, info won't be available for several seconds |
148 -- if not grouped, don't calc | 146 -- if not grouped, don't calc |
149 -- hide frame | 147 -- hide frame |
150 B.PlayerBuffsActive = function() return false end | 148 Aura.PlayerBuffsActive = function() return false end |
151 return | 149 return |
152 end | 150 end |
153 | 151 |
154 -- verify change | 152 -- verify change |
155 if B.PlayerCurrentSpec == spec or B.PlayerClass == class then | 153 if vn.PlayerCurrentSpec == spec or vn.PlayerClass == class then |
156 return | 154 return |
157 end | 155 end |
158 B.PlayerCurrentSpec = spec | 156 vn.PlayerCurrentSpec = spec |
159 B.PlayerClass = class | 157 vn.PlayerClass = class |
160 | 158 |
161 local test = B.ClassRaidBuffs | 159 local test = vn.ClassRaidBuffs |
162 local buffTypes = {} | 160 local buffTypes = {} |
163 local auraTypes = {} | 161 local auraTypes = {} |
164 for i = 1, NUM_LE_RAID_BUFF_TYPES do | 162 for i = 1, NUM_LE_RAID_BUFF_TYPES do |
165 local name, filters | 163 local name, filters |
166 if test[i] and test[i][class] then | 164 if test[i] and test[i][class] then |
168 else | 166 else |
169 playerBuffs[i] = nil | 167 playerBuffs[i] = nil |
170 end | 168 end |
171 | 169 |
172 if name then | 170 if name then |
173 B.UpdateBuffStatus(name, filters) | 171 vn.UpdateBuffStatus(name, filters) |
174 end | 172 end |
175 end | 173 end |
176 end | 174 end |
177 | 175 |
178 -- Called once to setup the ConsolidatedBuffs stencil | 176 -- Called once to setup the ConsolidatedBuffs stencil |
179 local consolidatedBuffsLoaded | 177 local consolidatedBuffsLoaded, displays |
180 M.SetConsolidatedBuffs = function() | 178 Aura.SetConsolidatedBuffs = function() |
181 local displays = M.displays | |
182 local print = fprint() | 179 local print = fprint() |
180 displays = Aura.displays | |
183 c = displays.ConsolidatedBuff.conf | 181 c = displays.ConsolidatedBuff.conf |
184 parentFrame = M.guides[c.Parent][c.Position] | 182 parentFrame = Aura.guides[c.Parent][c.Position] |
185 raidbuffsFrame = M.anchors.ConsolidatedBuff | 183 raidbuffsFrame = Aura.anchors.ConsolidatedBuff |
186 | 184 |
187 B.SetConfigLayers(raidbuffsFrame) | 185 vn.SetConfigLayers(raidbuffsFrame) |
188 consolidatedBuffsLoaded = true | 186 consolidatedBuffsLoaded = true |
189 ConsolidatedBuffs:ClearAllPoints() | 187 ConsolidatedBuffs:ClearAllPoints() |
190 ConsolidatedBuffs:SetAllPoints(parentFrame.icon) | 188 ConsolidatedBuffs:SetAllPoints(parentFrame.icon) |
191 if c.Icon then | 189 if c.Icon then |
192 ConsolidatedBuffsIcon:SetAllPoints(parentFrame.icon) | 190 ConsolidatedBuffsIcon:SetAllPoints(parentFrame.icon) |
196 end | 194 end |
197 | 195 |
198 ConsolidatedBuffsCount:Hide() | 196 ConsolidatedBuffsCount:Hide() |
199 end | 197 end |
200 | 198 |
199 local CanShowConsolidated = function() | |
200 return IsInGroup() and GetCVarBool("consolidateBuffs") | |
201 end | |
202 | |
201 local missingTypes = {} | 203 local missingTypes = {} |
202 local raidBuffsInitialized | 204 local raidBuffsInitialized |
203 M.UpdateRaidBuffs = function() | 205 Aura.UpdateRaidBuffs = function() |
204 local print = fprint() | 206 local print = xprint |
205 if not consolidatedBuffsLoaded then | 207 if not consolidatedBuffsLoaded then |
206 M.SetConsolidatedBuffs() | 208 Aura.SetConsolidatedBuffs() |
207 end | 209 end |
208 | 210 |
209 if not M.ShowConsolidated or not parentFrame.contains then | 211 if not CanShowConsolidated() then |
210 print(' hiding raid buffs square') | 212 |
211 if raidBuffsInitialized then | 213 if parentFrame.contains then |
212 for i = 1, 9 do | 214 print((CanShowConsolidated() and '|cFF88FF88' or '|cFF444444')..'showConsolidated|r', (parentFrame.contains and '|cFF88FF88' or '|cFF444444') .. 'parent.contains|r') |
213 if raidBuffs[i] then | 215 if raidBuffsInitialized then |
214 raidBuffs[i]:Hide() | 216 for i = 1, 9 do |
217 if raidBuffs[i] then | |
218 raidBuffs[i]:Hide() | |
219 end | |
215 end | 220 end |
216 end | 221 raidBuffsInitialized = nil |
217 raidBuffsInitialized = nil | 222 end |
218 end | 223 if parentFrame then |
219 if parentFrame then | 224 print(c.Parent, c.Position) |
220 print(c.Parent, c.Position) | 225 print('de-flagging parent') |
221 print('de-flagging parent') | 226 parentFrame.contains = nil |
222 parentFrame.contains = nil | 227 end |
223 end | 228 raidbuffsFrame:Hide() |
224 raidbuffsFrame:Hide() | 229 end |
225 return | 230 |
226 end | 231 return |
227 | 232 --- ENDS HERE IF NOT SHOWING CONSOLIDATED FRAME |
228 local c = B.displays.ConsolidatedBuff.conf | 233 end |
229 if parentFrame and not parentFrame.contains then | 234 |
235 local c = Aura.displays.ConsolidatedBuff.conf | |
236 if CanShowConsolidated() and not parentFrame.contains then | |
230 raidBuffsInitialized = true | 237 raidBuffsInitialized = true |
231 print('re-flagging parent', parentFrame:GetName()) | 238 print('re-flagging parent', parentFrame:GetName()) |
232 parentFrame.contains = parentFrame | 239 parentFrame.contains = parentFrame |
233 B.decors[c.Parent][c.Position]:Hide() | 240 Aura.decors[c.Parent][c.Position]:Hide() |
241 raidbuffsFrame:SetPoint('TOPRIGHT', parentFrame, 'TOPRIGHT') | |
234 raidbuffsFrame:Show() | 242 raidbuffsFrame:Show() |
235 | 243 |
236 -- make sure parent icon is updated | 244 -- make sure parent icon is updated |
237 local w = c.Size*c.PerRow+c.Spacing*(c.PerRow-1)+c.Border*2 | 245 local w = c.Size*c.PerRow+c.Spacing*(c.PerRow-1)+c.Border*2 |
238 parentFrame:SetSize(w, w) | 246 parentFrame:SetSize(w, w) |
239 parentFrame.icon:SetSize(w - c.Border*2, w - c.Border*2) | 247 parentFrame.icon:SetSize(w - c.Border*2, w - c.Border*2) |
240 parentFrame.contains = raidbuffsFrame | 248 parentFrame.contains = raidbuffsFrame |
241 | 249 |
242 M.UpdateBuffs(c.Parent) | 250 Aura.UpdateBuffs(c.Parent) |
243 end | 251 end |
244 | 252 |
245 -- have to loop again due to tainting restrictions | 253 -- have to loop again due to tainting restrictions |
246 -- could compare the tooltip font object pointers, but that may change | 254 -- could compare the tooltip font object pointers, but that may change |
247 local buffStack = GetRaidBuffInfo() | 255 local buffStack = GetRaidBuffInfo() |
248 print(GetRaidBuffInfo()) | 256 print(GetRaidBuffInfo()) |
249 local guides = B.guides.ConsolidatedBuff | 257 local guides = vn.guides.ConsolidatedBuff |
250 local numBuffs = 0 | 258 local numBuffs = 0 |
251 local numAvailable = 0 | 259 local numAvailable = 0 |
252 local mask = 1 | 260 local mask = 1 |
253 if buffStack == nil then | 261 if buffStack == nil then |
254 return -- discard | 262 return -- discard |
294 icon = '' | 302 icon = '' |
295 end | 303 end |
296 end | 304 end |
297 mask = lshift(mask, 1) | 305 mask = lshift(mask, 1) |
298 | 306 |
299 M.UpdateBuffStyle(buff, buffStyle, icon) | 307 Aura.UpdateBuffStyle(buff, buffStyle, icon) |
300 end | 308 end |
301 | 309 |
302 -- todo: filter by castable and suppress for non-overlapping auras | 310 -- todo: filter by castable and suppress for non-overlapping auras |
303 | 311 |
304 raidbuffsFrame.label:SetText(numBuffs..'/'..numAvailable) | 312 raidbuffsFrame.label:SetText(numBuffs..'/'..numAvailable) |
305 print(parentFrame:GetName(), parentFrame:GetSize()) | 313 print(parentFrame:GetName(), parentFrame:GetSize()) |
306 | 314 |
307 if B.ShowMissingBuffs then | 315 if vn.ShowMissingBuffs then |
308 B.UpdateMissingBuffs() | 316 vn.UpdateMissingBuffs() |
309 elseif missingBuffsAnchor and missingBuffsAnchor:IsVisible() then | 317 elseif missingBuffsAnchor and missingBuffsAnchor:IsVisible() then |
310 for i = 1, NUM_LE_MISSING_RAID_BUFFS do | 318 for i = 1, NUM_LE_MISSING_RAID_BUFFS do |
311 missingBuffs[i]:Hide() | 319 missingBuffs[i]:Hide() |
312 end | 320 end |
313 end | 321 end |
314 end | 322 end |
315 | 323 |
316 B.UpdateMissingBuffs = function() | 324 vn.UpdateMissingBuffs = function() |
317 local print = B.fprint() | 325 local print = vn.fprint() |
318 local numMissing = 0 | 326 local numMissing = 0 |
319 | 327 |
320 local firstMissing, lastMissing | 328 local firstMissing, lastMissing |
321 for i = 1, NUM_LE_RAID_BUFF_TYPES do | 329 for i = 1, NUM_LE_RAID_BUFF_TYPES do |
322 local name, _, icon, start, duration, spellID, slot = GetRaidBuffTrayAuraInfo(i) | 330 local name, _, icon, start, duration, spellID, slot = GetRaidBuffTrayAuraInfo(i) |
323 | 331 |
324 if not name then | 332 if not name then |
325 numMissing = numMissing + 1 | 333 numMissing = numMissing + 1 |
326 | 334 |
327 print('missing buff', i, numMissing) | 335 print('missing buff', i, numMissing) |
328 B.UpdateBuffStyle(raidBuffs[i].icon, 'missing', "") | 336 vn.UpdateBuffStyle(raidBuffs[i].icon, 'missing', "") |
329 | 337 |
330 missingBuffs[numMissing] = missingBuffs[numMissing] or CreateFrame('Button', 'VeneerMissingBuff' .. numMissing, raidbuffsFrame, 'VeneerMissingBuffTemplate') | 338 missingBuffs[numMissing] = missingBuffs[numMissing] or CreateFrame('Button', 'VeneerMissingBuff' .. numMissing, raidbuffsFrame, 'VeneerMissingBuffTemplate') |
331 | 339 |
332 local missing = missingBuffs[numMissing] | 340 local missing = missingBuffs[numMissing] |
333 | 341 |