@@ -11,10 +11,11 @@ L["Timer frequency"] = "Timer frequency"
11
11
L [" Use kill events" ] = " Use kill events"
12
12
L [" Use damage events" ] = " Use damage events"
13
13
L [" Show item level" ] = " Show item level"
14
+ L [" Show item id" ] = " Show item id"
14
15
L [" Server attunement variables not loaded" ] = " Server attunement variables not loaded"
15
16
16
17
local Skada = Skada
17
- SkadaAttunes = Skada :NewModule (L [" Attunements" ])
18
+ SkadaAttunes = Skada :NewModule (L [" Attunements" ], " AceTimer-3.0 " )
18
19
19
20
local function chat (msg )
20
21
DEFAULT_CHAT_FRAME :AddMessage (msg )
@@ -109,13 +110,15 @@ local function addOrUpdatePlayerAttune(player, id, progress)
109
110
110
111
if progress < 100 then
111
112
local name , link , _ , itemLevel , _ , _ , _ , _ , _ , icon = GetItemInfo (id )
113
+ local unknown = false
112
114
113
115
if not itemLevel then
114
116
itemLevel = 0
115
117
end
116
118
117
119
if not name then
118
- name = " Unknown item (" .. id .. " )"
120
+ unknown = true
121
+ name = " Unknown item"
119
122
end
120
123
121
124
if not icon then
@@ -126,6 +129,10 @@ local function addOrUpdatePlayerAttune(player, id, progress)
126
129
name = " [" .. itemLevel .. " ] " .. name
127
130
end
128
131
132
+ if unknown or Skada .db .profile .modules .attuneshowitemid then
133
+ name = name .. ' (' .. id .. ' )'
134
+ end
135
+
129
136
if not player .attunes [id ] then
130
137
player .attunes [id ] = {
131
138
id = id ,
@@ -147,28 +154,43 @@ local function addOrUpdatePlayerAttune(player, id, progress)
147
154
end
148
155
end
149
156
157
+ local function get_player (set , playerId , playerName )
158
+ for _ , player in ipairs (set .players ) do
159
+ if player .id == playerId then
160
+ return player
161
+ end
162
+ end
163
+
164
+ return Skada :get_player (set , playerId , playerName )
165
+ end
166
+
150
167
local function updateAttuneProgress (set , attuneEvent , forceRefresh )
151
168
if not set then
152
169
return
153
170
end
154
171
155
172
-- Get the player.
156
- local player = Skada : get_player (set , attuneEvent .playerId , attuneEvent .playerName )
173
+ local player = get_player (set , attuneEvent .playerId , attuneEvent .playerName )
157
174
if player then
175
+ local changed = false
158
176
local inProgress = getInProgressAttunes (forceRefresh )
159
177
160
178
for _ , attune in ipairs (inProgress ) do
161
- addOrUpdatePlayerAttune (player , attune .id , attune .progress )
179
+ changed = addOrUpdatePlayerAttune (player , attune .id , attune .progress ) or changed
162
180
end
163
181
164
182
for id , _ in pairs (player .attunes ) do
165
183
if not tableContainsProperty (inProgress , " id" , id ) then
166
184
removePlayerAttune (player , id )
185
+ changed = true
167
186
end
168
187
end
169
188
170
- set .numAttunes = player .numAttunes
171
- Skada :UpdateDisplay (true )
189
+ if changed then
190
+ player .last = time ()
191
+ set .numAttunes = player .numAttunes
192
+ Skada :UpdateDisplay (true )
193
+ end
172
194
end
173
195
end
174
196
@@ -186,12 +208,6 @@ local function OnAttuneProgress(timestamp, eventtype, srcGUID, srcName, srcFlags
186
208
attuneProgressEvent .playerId = UnitGUID (" player" )
187
209
attuneProgressEvent .playerName = UnitName (" player" )
188
210
189
- -- Create new set if not exists
190
- if not Skada .total then
191
- Skada .total = {players = {}, name = L [" Total" ], starttime = time (), [" time" ] = 0 , last_action = time ()}
192
- Skada .db .profile .total = Skada .total
193
- end
194
-
195
211
local forceRefresh = false
196
212
if eventtype == ' PLAYER_XP_UPDATE' then
197
213
forceRefresh = true
@@ -248,16 +264,24 @@ local function mod_tooltip(win, id, _, tooltip)
248
264
end
249
265
end
250
266
251
- function SkadaAttunes :Update (win ,set )
252
- local max = 0
267
+ function SkadaAttunes :Update (win , set )
268
+ -- Only update the total/current segments
269
+ if set ~= Skada .total and set ~= Skada .current then
270
+ return
271
+ end
272
+
273
+ win .metadata .maxvalue = 100
253
274
254
275
-- Aggregate the data.
255
276
local tmp = {}
256
- for i , player in ipairs (set .players ) do
277
+ for _ , player in ipairs (set .players ) do
257
278
if player .numAttunes > 0 then
258
279
for id , attune in pairs (player .attunes ) do
259
280
if not tmp [id ] then
260
- tmp [id ] = {id = attune .id , progress = attune .progress , name = attune .name , icon = attune .icon , link = attune .link }
281
+ -- Extra check to remove old attunes
282
+ if ItemAttuneHas [id ] or 0 < 100 then
283
+ tmp [id ] = {id = attune .id , progress = attune .progress , name = attune .name , icon = attune .icon , link = attune .link }
284
+ end
261
285
else
262
286
tmp [id ].progress = attune .progress
263
287
end
@@ -276,20 +300,20 @@ function SkadaAttunes:Update(win,set)
276
300
d .id = id
277
301
d .icon = attune .icon
278
302
279
- if attune .progress > max then
280
- max = attune .progress
281
- end
282
303
nr = nr + 1
283
304
end
284
305
285
- win .metadata .maxvalue = 100
306
+ -- Clean up old stuff
307
+ --[[ for i = nr, #win.dataset, 1 do
308
+ win.dataset[i].id = nil
309
+ end ]]
286
310
end
287
311
288
312
289
313
function SkadaAttunes :OnEnable ()
290
- SkadaAttunes .metadata = {tooltip = mod_tooltip }
314
+ SkadaAttunes .metadata = {tooltip = mod_tooltip , wipestale = 1 }
291
315
292
- updateTimer = Skada :ScheduleRepeatingTimer (OnTimerTick , 1 )
316
+ updateTimer = self :ScheduleRepeatingTimer (OnTimerTick , 1 )
293
317
294
318
Skada :RegisterForCL (OnAttuneProgress , ' PLAYER_XP_UPDATE' , {src_is_interesting = true })
295
319
@@ -338,7 +362,6 @@ function SkadaAttunes:AddSetAttributes(set)
338
362
set .numAttunes = 0
339
363
340
364
local inProgress = getInProgressAttunes ()
341
- -- Also add to set total damage taken.
342
365
set .numAttunes = # inProgress
343
366
end
344
367
end
@@ -367,6 +390,14 @@ local opts = {
367
390
set = function () Skada .db .profile .modules .attuneshowitemlevel = not Skada .db .profile .modules .attuneshowitemlevel end ,
368
391
order = 1
369
392
},
393
+
394
+ showitemid = {
395
+ type = " toggle" ,
396
+ name = L [" Show item id" ],
397
+ get = function () return Skada .db .profile .modules .attuneshowitemid end ,
398
+ set = function () Skada .db .profile .modules .attuneshowitemid = not Skada .db .profile .modules .attuneshowitemid end ,
399
+ order = 2
400
+ },
370
401
},
371
402
},
372
403
@@ -473,6 +504,10 @@ function SkadaAttunes:OnInitialize()
473
504
Skada .db .profile .modules .attuneshowitemlevel = true
474
505
end
475
506
507
+ if Skada .db .profile .modules .attuneshowitemid == nil then
508
+ Skada .db .profile .modules .attuneshowitemid = false
509
+ end
510
+
476
511
if Skada .db .profile .modules .attuneblocklist == nil then
477
512
Skada .db .profile .modules .attuneblocklist = {}
478
513
end
0 commit comments