Skip to content

Commit fa5ba16

Browse files
committed
Fix layout-indicator switch
1 parent 11429e2 commit fa5ba16

8 files changed

Lines changed: 133 additions & 63 deletions

File tree

.kanban

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@
152152
"comments": []
153153
},
154154
{
155-
"id": "65017c0e-525a-42ed-adf7-7a396547406c",
155+
"id": "49fa23b6-7197-45c5-b107-97210fb53fde",
156156
"listId": "fc9baa7c-c3e7-49a4-8526-816c794e5ed9",
157-
"title": "Bars and max duration option",
157+
"title": "Use ObjectPool to create indicators",
158158
"description": "",
159159
"labels": [],
160160
"checkboxes": [],
@@ -166,6 +166,15 @@
166166
"id": "7b0c4654-92fe-4b4e-9566-15e8c706d9c9",
167167
"title": "DONE",
168168
"cards": [
169+
{
170+
"id": "65017c0e-525a-42ed-adf7-7a396547406c",
171+
"listId": "7b0c4654-92fe-4b4e-9566-15e8c706d9c9",
172+
"title": "Bars and max duration option",
173+
"description": "",
174+
"labels": [],
175+
"checkboxes": [],
176+
"comments": []
177+
},
169178
{
170179
"id": "dd2e1868-482f-4f16-9755-ab54c171f9b3",
171180
"listId": "7b0c4654-92fe-4b4e-9566-15e8c706d9c9",

Indicators/Custom.lua

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Cell.snippetVars.enabledIndicators = enabledIndicators
1616
Cell.snippetVars.customIndicators = customIndicators
1717

1818
--! init enabledIndicators & customIndicators
19-
local function UpdateTablesForIndicator(indicatorTable)
19+
function I.UpdateIndicatorTable(indicatorTable)
2020
local indicatorName = indicatorTable["indicatorName"]
2121
local auraType = indicatorTable["auraType"]
2222

@@ -53,6 +53,7 @@ local function UpdateTablesForIndicator(indicatorTable)
5353
end
5454

5555
customIndicators[auraType][indicatorName]["name"] = indicatorTable["name"]
56+
customIndicators[auraType][indicatorName]["type"] = indicatorTable["type"]
5657

5758
if auraType == "buff" then
5859
customIndicators[auraType][indicatorName]["castBy"] = indicatorTable["castBy"]
@@ -61,7 +62,7 @@ local function UpdateTablesForIndicator(indicatorTable)
6162
end
6263
end
6364

64-
function I.CreateIndicator(parent, indicatorTable, noTableUpdate)
65+
function I.CreateIndicator(parent, indicatorTable)
6566
local indicatorName = indicatorTable["indicatorName"]
6667
local indicator
6768
if indicatorTable["type"] == "icon" then
@@ -93,10 +94,6 @@ function I.CreateIndicator(parent, indicatorTable, noTableUpdate)
9394
end
9495
parent.indicators[indicatorName] = indicator
9596

96-
if not noTableUpdate then
97-
UpdateTablesForIndicator(indicatorTable)
98-
end
99-
10097
return indicator
10198
end
10299

@@ -136,7 +133,7 @@ function I.ResetCustomIndicatorTables()
136133

137134
-- update customs
138135
for i = Cell.defaults.builtIns + 1, #Cell.vars.currentLayoutTable.indicators do
139-
UpdateTablesForIndicator(Cell.vars.currentLayoutTable.indicators[i])
136+
I.UpdateIndicatorTable(Cell.vars.currentLayoutTable.indicators[i])
140137
end
141138
end
142139

Indicators/Custom_Classic.lua

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ local I = Cell.iFuncs
66
-------------------------------------------------
77
-- custom indicators
88
-------------------------------------------------
9-
local currentLayout
109
local enabledIndicators = {}
1110
local customIndicators = {
1211
["buff"] = {},
@@ -17,7 +16,7 @@ Cell.snippetVars.enabledIndicators = enabledIndicators
1716
Cell.snippetVars.customIndicators = customIndicators
1817

1918
--! init enabledIndicators & customIndicators
20-
local function UpdateTablesForIndicator(indicatorTable)
19+
function I.UpdateIndicatorTable(indicatorTable)
2120
local indicatorName = indicatorTable["indicatorName"]
2221
local auraType = indicatorTable["auraType"]
2322

@@ -54,6 +53,7 @@ local function UpdateTablesForIndicator(indicatorTable)
5453
end
5554

5655
customIndicators[auraType][indicatorName]["name"] = indicatorTable["name"]
56+
customIndicators[auraType][indicatorName]["type"] = indicatorTable["type"]
5757

5858
if auraType == "buff" then
5959
customIndicators[auraType][indicatorName]["castBy"] = indicatorTable["castBy"]
@@ -62,7 +62,7 @@ local function UpdateTablesForIndicator(indicatorTable)
6262
end
6363
end
6464

65-
function I.CreateIndicator(parent, indicatorTable, noTableUpdate)
65+
function I.CreateIndicator(parent, indicatorTable)
6666
local indicatorName = indicatorTable["indicatorName"]
6767
local indicator
6868
if indicatorTable["type"] == "icon" then
@@ -94,10 +94,6 @@ function I.CreateIndicator(parent, indicatorTable, noTableUpdate)
9494
end
9595
parent.indicators[indicatorName] = indicator
9696

97-
if not noTableUpdate then
98-
UpdateTablesForIndicator(indicatorTable)
99-
end
100-
10197
return indicator
10298
end
10399

@@ -137,11 +133,8 @@ function I.ResetCustomIndicatorTables()
137133

138134
-- update customs
139135
for i = Cell.defaults.builtIns + 1, #Cell.vars.currentLayoutTable.indicators do
140-
UpdateTablesForIndicator(Cell.vars.currentLayoutTable.indicators[i])
136+
I.UpdateIndicatorTable(Cell.vars.currentLayoutTable.indicators[i])
141137
end
142-
143-
-- update currentLayout
144-
currentLayout = Cell.vars.currentLayout
145138
end
146139

147140
local function UpdateCustomIndicators(layout, indicatorName, setting, value, value2)
@@ -283,7 +276,7 @@ local function comparator(a, b)
283276
end
284277

285278
function I.ShowCustomIndicators(unitButton, auraType)
286-
if Cell.vars.currentLayout ~= currentLayout then return end
279+
if not unitButton._indicatorsReady then return end
287280

288281
local unit = unitButton.states.displayedUnit
289282
for indicatorName, indicatorTable in pairs(customIndicators[auraType]) do

Modules/Indicators.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ local function UpdateIndicators(layout, indicatorName, setting, value, value2)
602602
I.RemoveAllCustomIndicators(previewButton)
603603

604604
for i, t in pairs(currentLayoutTable["indicators"]) do
605-
local indicator = previewButton.indicators[t["indicatorName"]] or I.CreateIndicator(previewButton, t, true)
605+
local indicator = previewButton.indicators[t["indicatorName"]] or I.CreateIndicator(previewButton, t)
606606
indicator.configs = t
607607

608608
InitIndicator(t["indicatorName"])
@@ -970,7 +970,7 @@ local function UpdateIndicators(layout, indicatorName, setting, value, value2)
970970
indicator:EnableSmooth(value2)
971971
end
972972
elseif setting == "create" then
973-
indicator = I.CreateIndicator(previewButton, value, true)
973+
indicator = I.CreateIndicator(previewButton, value)
974974
indicator.configs = value
975975

976976
-- update position

RaidFrames/UnitButton.lua

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ local barAnimationType, highlightEnabled, predictionEnabled
6767
local shieldEnabled, overshieldEnabled, overshieldReverseFillEnabled
6868
local absorbEnabled, absorbInvertColor
6969

70+
local CheckCLEURequired
71+
7072
-------------------------------------------------
7173
-- unit button func declarations
7274
-------------------------------------------------
@@ -105,6 +107,8 @@ local function ResetIndicators()
105107
wipe(enabledIndicators)
106108
wipe(indicatorNums)
107109

110+
CheckCLEURequired()
111+
108112
for _, t in pairs(Cell.vars.currentLayoutTable["indicators"]) do
109113
-- update enabled
110114
if t["enabled"] then
@@ -398,17 +402,25 @@ local queue = {}
398402
updater:SetScript("OnUpdate", function()
399403
local b = queue[1]
400404
if b then
401-
if not b._status then
402-
-- print("processing", GetTime(), b:GetName())
405+
if b._status == "waiting_for_init" then
406+
-- print("processing_init", GetTime(), b:GetName())
403407
b._status = "processing"
404408
HandleIndicators(b)
405-
UnitButton_UpdateAll(b)
406-
b._status = "finished"
407-
elseif b._status == "finished" then
409+
UnitButton_UpdateAuras(b)
410+
b._status = "done"
411+
elseif b._status == "waiting_for_update" then
412+
-- print("processing_update", GetTime(), b:GetName())
413+
b._indicatorsReady = true
414+
b._status = "processing"
415+
UnitButton_UpdateAuras(b)
416+
b._status = "done"
417+
elseif b._status == "done" then
408418
CellLoadingBar.current = (CellLoadingBar.current or 0) + 1
409419
CellLoadingBar:SetValue(CellLoadingBar.current)
410420
tremove(queue, 1)
411421
b._status = nil
422+
elseif b._status ~= "processing" then -- re-queue
423+
b._status = "waiting_for_init"
412424
end
413425
else
414426
CellLoadingBar:Hide()
@@ -424,8 +436,15 @@ hooksecurefunc(updater, "Show", function()
424436
CellLoadingBar:Show()
425437
end)
426438

427-
local function AddToQueue(b)
439+
local function AddToInitQueue(b)
440+
b._indicatorsReady = nil
441+
b._status = "waiting_for_init"
442+
tinsert(queue, b)
443+
end
444+
445+
local function AddToUpdateQueue(b)
428446
b._indicatorsReady = nil
447+
b._status = "waiting_for_update"
429448
tinsert(queue, b)
430449
end
431450

@@ -462,9 +481,10 @@ local function UpdateIndicators(layout, indicatorName, setting, value, value2)
462481
F:Debug("NO UPDATE: only reset custom indicator tables")
463482
I.ResetCustomIndicatorTables()
464483
ResetIndicators()
484+
--! update main _indicatorsReady
485+
F:IterateAllUnitButtons(AddToUpdateQueue, true, nil, true)
465486
--! update shared buttons: npcs, spotlights
466-
-- F:IterateSharedUnitButtons(HandleIndicators)
467-
F:IterateSharedUnitButtons(AddToQueue)
487+
F:IterateSharedUnitButtons(AddToInitQueue)
468488
updater:Show()
469489
return
470490
end
@@ -482,7 +502,7 @@ local function UpdateIndicators(layout, indicatorName, setting, value, value2)
482502
-- update all when indicators update finished
483503
F:IterateAllUnitButtons(UnitButton_UpdateAll, true)
484504
else
485-
F:IterateAllUnitButtons(AddToQueue, true)
505+
F:IterateAllUnitButtons(AddToInitQueue, true)
486506
updater:Show()
487507
end
488508
indicatorsInitialized = true
@@ -850,6 +870,7 @@ local function UpdateIndicators(layout, indicatorName, setting, value, value2)
850870
indicatorBooleans[indicatorName] = value2
851871
end
852872
elseif setting == "create" then
873+
I.UpdateIndicatorTable(value)
853874
F:IterateAllUnitButtons(function(b)
854875
local indicator = I.CreateIndicator(b, value)
855876
indicator.configs = value
@@ -1461,15 +1482,27 @@ end
14611482
-- check auras using CLEU
14621483
-------------------------------------------------
14631484
local cleu = CreateFrame("Frame")
1464-
cleu:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
1485+
1486+
function CheckCLEURequired()
1487+
if (Cell.vars.currentLayoutTable.indicators[Cell.defaults.indicatorIndices.externalCooldowns].enabled
1488+
or Cell.vars.currentLayoutTable.indicators[Cell.defaults.indicatorIndices.defensiveCooldowns].enabled
1489+
or Cell.vars.currentLayoutTable.indicators[Cell.defaults.indicatorIndices.allCooldowns].enabled)
1490+
and (I.IsDefensiveCooldown(55342) or I.IsExternalCooldown(414660)) then
1491+
cleu:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
1492+
else
1493+
cleu:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
1494+
end
1495+
end
14651496

14661497
local function UpdateMirrorImage(b, event)
14671498
if event == "SPELL_AURA_APPLIED" then
14681499
b._mirror_image = GetTime()
14691500
elseif event == "SPELL_AURA_REMOVED" then
14701501
b._mirror_image = nil
14711502
end
1472-
UnitButton_UpdateBuffs(b)
1503+
if b._indicatorsReady then
1504+
UnitButton_UpdateBuffs(b)
1505+
end
14731506
end
14741507

14751508
local SelfBarriers = {
@@ -1497,7 +1530,9 @@ local function UpdateMassBarrier(b, event)
14971530
b._mass_barrier = nil
14981531
b._mass_barrier_icon = nil
14991532
end
1500-
UnitButton_UpdateBuffs(b)
1533+
if b._indicatorsReady then
1534+
UnitButton_UpdateBuffs(b)
1535+
end
15011536
end
15021537

15031538
cleu:SetScript("OnEvent", function()

RaidFrames/UnitButton_Cata_Wrath.lua

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,17 +395,25 @@ local queue = {}
395395
updater:SetScript("OnUpdate", function()
396396
local b = queue[1]
397397
if b then
398-
if not b._status then
399-
-- print("processing", GetTime(), b:GetName())
398+
if b._status == "waiting_for_init" then
399+
-- print("processing_init", GetTime(), b:GetName())
400400
b._status = "processing"
401401
HandleIndicators(b)
402-
UnitButton_UpdateAll(b)
403-
b._status = "finished"
404-
elseif b._status == "finished" then
402+
UnitButton_UpdateAuras(b)
403+
b._status = "done"
404+
elseif b._status == "waiting_for_update" then
405+
-- print("processing_update", GetTime(), b:GetName())
406+
b._indicatorsReady = true
407+
b._status = "processing"
408+
UnitButton_UpdateAuras(b)
409+
b._status = "done"
410+
elseif b._status == "done" then
405411
CellLoadingBar.current = (CellLoadingBar.current or 0) + 1
406412
CellLoadingBar:SetValue(CellLoadingBar.current)
407413
tremove(queue, 1)
408414
b._status = nil
415+
elseif b._status ~= "processing" then -- re-queue
416+
b._status = "waiting_for_init"
409417
end
410418
else
411419
CellLoadingBar:Hide()
@@ -421,8 +429,15 @@ hooksecurefunc(updater, "Show", function()
421429
CellLoadingBar:Show()
422430
end)
423431

424-
local function AddToQueue(b)
432+
local function AddToInitQueue(b)
433+
b._indicatorsReady = nil
434+
b._status = "waiting_for_init"
435+
tinsert(queue, b)
436+
end
437+
438+
local function AddToUpdateQueue(b)
425439
b._indicatorsReady = nil
440+
b._status = "waiting_for_update"
426441
tinsert(queue, b)
427442
end
428443

@@ -459,9 +474,10 @@ local function UpdateIndicators(layout, indicatorName, setting, value, value2)
459474
F:Debug("NO UPDATE: only reset custom indicator tables")
460475
I.ResetCustomIndicatorTables()
461476
ResetIndicators()
477+
--! update main _indicatorsReady
478+
F:IterateAllUnitButtons(AddToUpdateQueue, true, nil, true)
462479
--! update shared buttons: npcs, spotlights
463-
-- F:IterateSharedUnitButtons(HandleIndicators)
464-
F:IterateSharedUnitButtons(AddToQueue)
480+
F:IterateSharedUnitButtons(AddToInitQueue)
465481
updater:Show()
466482
return
467483
end
@@ -479,7 +495,7 @@ local function UpdateIndicators(layout, indicatorName, setting, value, value2)
479495
-- update all when indicators update finished
480496
F:IterateAllUnitButtons(UnitButton_UpdateAll, true)
481497
else
482-
F:IterateAllUnitButtons(AddToQueue, true)
498+
F:IterateAllUnitButtons(AddToInitQueue, true)
483499
updater:Show()
484500
end
485501
indicatorsInitialized = true
@@ -845,6 +861,7 @@ local function UpdateIndicators(layout, indicatorName, setting, value, value2)
845861
indicatorBooleans[indicatorName] = value2
846862
end
847863
elseif setting == "create" then
864+
I.UpdateIndicatorTable(value)
848865
F:IterateAllUnitButtons(function(b)
849866
local indicator = I.CreateIndicator(b, value)
850867
indicator.configs = value

0 commit comments

Comments
 (0)