coa: dynamic PopulateListFrame buttons for 21 CoA custom classes

Closes the deferred UI piece from 32324ff. The 11 vanilla class buttons
in Dcr_lists.xml stay hardcoded so this fork keeps working on stock
clients with no CoA extras (DC.ClassNumToUName produces 0 entries at
idx >= 22 there, builder returns early).

D:BuildPopulateExtraClassButtons(frame) walks DC.ClassNumToUName for
keys 22+, sorted, and creates one GameMenuButtonTemplate per class:
  - First extra fills row 6's empty right column (beside Hero)
  - Remaining alternate left/right, chained off Hero / Deathknight
  - Frame grows by ceil((n-1)/2) * 20 px so the existing BOTTOM-anchored
    Close button slides down with it
Idempotent via frame.coa_extras_built.

Wired from DecursivePopulateListFrame OnShow with a Dcr.BuildPopulateExtraClassButtons
nil-guard so an out-of-order load doesn't break the frame.

Bumped toc to Asc-1.1.1-coa.
This commit is contained in:
2026-05-10 22:06:53 +02:00
parent 32324ff732
commit 26abb6d513
3 changed files with 52 additions and 1 deletions
+50
View File
@@ -598,4 +598,54 @@ function D:PopulateButtonPress(frame) --{{{
end --}}} end --}}}
-- CoA: append PopulateListFrame buttons for class indices 22+ (CoA custom
-- classes added in Dcr_Raid.lua). The vanilla 11 buttons stay hardcoded in
-- Dcr_lists.xml so this fork keeps working on stock clients with no extras.
function D:BuildPopulateExtraClassButtons(frame) --{{{
if frame.coa_extras_built then return end
local extras = {}
for k in pairs(DC.ClassNumToUName) do
if k >= 22 then extras[#extras + 1] = k end
end
table.sort(extras)
if #extras == 0 then
frame.coa_extras_built = true
return
end
-- Each row added below the existing 6-row class grid is 20px tall. The
-- first extra slots into row 6's empty right column, so only ceil((n-1)/2)
-- new rows are needed.
local newRows = math.ceil((#extras - 1) / 2)
frame:SetHeight(frame:GetHeight() + newRows * 20)
local frameName = frame:GetName()
local prevLeft = _G[frameName .. "Hero"]
local prevRight = _G[frameName .. "Deathknight"]
for i, classIdx in ipairs(extras) do
local class = DC.ClassNumToUName[classIdx]
local btn = CreateFrame("Button", frameName .. "Coa" .. classIdx, frame, "GameMenuButtonTemplate")
btn:SetSize(80, 20)
btn.ClassType = class
btn:SetText(D:ColorText(LC[class] or class, "FF" .. D:GetClassHexColor(class)))
btn:SetScript("OnClick", function(b) D:PopulateButtonPress(b) end)
if i == 1 then
btn:SetPoint("TOP", prevRight, "BOTTOM", 0, 0)
prevRight = btn
elseif i % 2 == 0 then
btn:SetPoint("TOP", prevLeft, "BOTTOM", 0, 0)
prevLeft = btn
else
btn:SetPoint("TOP", prevRight, "BOTTOM", 0, 0)
prevRight = btn
end
end
frame.coa_extras_built = true
end --}}}
T._LoadedFiles["Dcr_lists.lua"] = "2.5.1-6-gd3885c5"; T._LoadedFiles["Dcr_lists.lua"] = "2.5.1-6-gd3885c5";
+1
View File
@@ -440,6 +440,7 @@
<Scripts> <Scripts>
<OnShow> <OnShow>
_G[self:GetName().."Title"]:SetText(Dcr.L["STR_QUICK_POP"]); _G[self:GetName().."Title"]:SetText(Dcr.L["STR_QUICK_POP"]);
if Dcr.BuildPopulateExtraClassButtons then Dcr:BuildPopulateExtraClassButtons(self); end
</OnShow> </OnShow>
</Scripts> </Scripts>
<Layers> <Layers>
+1 -1
View File
@@ -18,7 +18,7 @@
## SavedVariables: DecursiveDB ## SavedVariables: DecursiveDB
## Version: Asc-1.1.0-coa (orig 2.5.1-6-gd3885c5) ## Version: Asc-1.1.1-coa (orig 2.5.1-6-gd3885c5)
## Author: Archarodim ## Author: Archarodim
## X-License: All Rights Reserved ## X-License: All Rights Reserved