From 26abb6d513e5d924ba87af21e3bb27f53fd5cbf7 Mon Sep 17 00:00:00 2001 From: Florian Berthold Date: Sun, 10 May 2026 22:06:53 +0200 Subject: [PATCH] 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. --- Decursive/Dcr_lists.lua | 50 +++++++++++++++++++++++++++++++++++++++++ Decursive/Dcr_lists.xml | 1 + Decursive/Decursive.toc | 2 +- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Decursive/Dcr_lists.lua b/Decursive/Dcr_lists.lua index fde4fe5..746c7b8 100644 --- a/Decursive/Dcr_lists.lua +++ b/Decursive/Dcr_lists.lua @@ -598,4 +598,54 @@ function D:PopulateButtonPress(frame) --{{{ 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"; diff --git a/Decursive/Dcr_lists.xml b/Decursive/Dcr_lists.xml index 26b957d..948018f 100644 --- a/Decursive/Dcr_lists.xml +++ b/Decursive/Dcr_lists.xml @@ -440,6 +440,7 @@ _G[self:GetName().."Title"]:SetText(Dcr.L["STR_QUICK_POP"]); + if Dcr.BuildPopulateExtraClassButtons then Dcr:BuildPopulateExtraClassButtons(self); end diff --git a/Decursive/Decursive.toc b/Decursive/Decursive.toc index 86bf006..ca09301 100644 --- a/Decursive/Decursive.toc +++ b/Decursive/Decursive.toc @@ -18,7 +18,7 @@ ## 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 ## X-License: All Rights Reserved