fix: enable stance/state bars for CoA custom classes with shapeshift forms
Vanilla Bartender4 assumes only DRUID/WARRIOR/WARLOCK/PRIEST/ROGUE/HERO have
shapeshift forms. CoA custom classes (Witchdoctor, Templar, …) can register
forms late at runtime and aren't in the whitelist, so the stance/state bar
never came up for them.
StanceBar.lua:
- ApplyConfig() no longer Disable()s the module when GetNumShapeshiftForms()
is 0 at config time. A disabled module never re-enables on
UPDATE_SHAPESHIFT_FORMS, so late-registered forms were lost. We now just
hide the bar frame.
- Register UPDATE_SHAPESHIFT_FORMS and PLAYER_ENTERING_WORLD on the module
itself and re-Enable() / show the bar when forms appear after the fact.
Options/Bar.lua:
- The 'Hide in Stance/Form' visibility option was gated by a hard-coded
stanceClasses whitelist. Add an OR-fallback on GetNumShapeshiftForms() > 0
so CoA classes with forms get the UI.
StateBar.lua:
- DefaultStanceMap only had vanilla entries. For unknown classes with live
forms, synthesise a generic { id="formN", index=N } map at runtime so
UpdateStates() can wire stance-based action bar swaps.
This commit is contained in:
@@ -344,7 +344,10 @@ function Bar:GetOptionObject()
|
|||||||
name = L["Hide in Stance/Form"],
|
name = L["Hide in Stance/Form"],
|
||||||
desc = L["Hide this bar in a specific Stance or Form."],
|
desc = L["Hide this bar in a specific Stance or Form."],
|
||||||
values = getStanceTable,
|
values = getStanceTable,
|
||||||
hidden = function() return (not stanceClasses[class]) end,
|
-- CoA: custom classes (Witchdoctor, Templar, …) may have forms
|
||||||
|
-- but aren't in the vanilla stanceClasses whitelist. Show the
|
||||||
|
-- option whenever the player currently has any form available.
|
||||||
|
hidden = function() return (not (stanceClasses[class] or GetNumShapeshiftForms() > 0)) end,
|
||||||
disabled = customEnabled,
|
disabled = customEnabled,
|
||||||
},
|
},
|
||||||
customNl = {
|
customNl = {
|
||||||
|
|||||||
@@ -48,18 +48,43 @@ function StanceBarMod:OnEnable()
|
|||||||
self.bar:RegisterEvent("PLAYER_REGEN_ENABLED")
|
self.bar:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||||
self.bar:RegisterEvent("ACTIONBAR_PAGE_CHANGED")
|
self.bar:RegisterEvent("ACTIONBAR_PAGE_CHANGED")
|
||||||
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
|
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
|
||||||
|
-- CoA: re-enable / refresh when forms appear late (custom classes)
|
||||||
|
self:RegisterEvent("UPDATE_SHAPESHIFT_FORMS", "OnShapeshiftFormsUpdate")
|
||||||
|
self:RegisterEvent("PLAYER_ENTERING_WORLD", "OnShapeshiftFormsUpdate")
|
||||||
self:ReassignBindings()
|
self:ReassignBindings()
|
||||||
self:ApplyConfig()
|
self:ApplyConfig()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function StanceBarMod:OnShapeshiftFormsUpdate()
|
||||||
|
-- CoA: if the module is disabled but forms now exist (custom class form
|
||||||
|
-- registered after login), bring it back online.
|
||||||
|
if not self:IsEnabled() and GetNumShapeshiftForms() > 0 then
|
||||||
|
self:Enable()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self:IsEnabled() and self.bar then
|
||||||
|
if GetNumShapeshiftForms() > 0 then
|
||||||
|
if self.bar.Show then self.bar:Show() end
|
||||||
|
else
|
||||||
|
if self.bar.Hide then self.bar:Hide() end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
StanceBarMod.button_count = 10
|
StanceBarMod.button_count = 10
|
||||||
|
|
||||||
function StanceBarMod:ApplyConfig()
|
function StanceBarMod:ApplyConfig()
|
||||||
if not self:IsEnabled() then return end
|
if not self:IsEnabled() then return end
|
||||||
self.bar:ApplyConfig(self.db.profile)
|
self.bar:ApplyConfig(self.db.profile)
|
||||||
|
|
||||||
|
-- CoA: custom classes (Witchdoctor, Templar, …) may register forms late.
|
||||||
|
-- Don't Disable() the module if there are 0 forms right now — once disabled
|
||||||
|
-- we'd never come back when UPDATE_SHAPESHIFT_FORMS arrives. Just hide the bar
|
||||||
|
-- frame; UpdateStanceButtons() will re-show it when forms appear.
|
||||||
if GetNumShapeshiftForms() == 0 then
|
if GetNumShapeshiftForms() == 0 then
|
||||||
self:Disable()
|
if self.bar.Hide then self.bar:Hide() end
|
||||||
|
else
|
||||||
|
if self.bar.Show then self.bar:Show() end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+23
-1
@@ -116,12 +116,34 @@ local DefaultStanceMap = setmetatable({}, { __index = function(t,k)
|
|||||||
end})
|
end})
|
||||||
Bartender4.StanceMap = DefaultStanceMap
|
Bartender4.StanceMap = DefaultStanceMap
|
||||||
|
|
||||||
|
-- CoA: build a generic runtime stance map for classes the addon doesn't know
|
||||||
|
-- about (Witchdoctor, Templar, …). We don't have spell-id metadata for them,
|
||||||
|
-- so synthesise { id = "formN", index = N } entries based on live form count.
|
||||||
|
local function BuildGenericStanceMap()
|
||||||
|
local num = GetNumShapeshiftForms()
|
||||||
|
if not num or num == 0 then return nil end
|
||||||
|
local map = {}
|
||||||
|
for i = 1, num do
|
||||||
|
map[i] = { id = ("form%d"):format(i), name = ("Form %d"):format(i), index = i }
|
||||||
|
end
|
||||||
|
return map
|
||||||
|
end
|
||||||
|
|
||||||
local stancemap
|
local stancemap
|
||||||
function StateBar:UpdateStates(returnOnly)
|
function StateBar:UpdateStates(returnOnly)
|
||||||
if not self.buttons then return end
|
if not self.buttons then return end
|
||||||
self.statebutton = {}
|
self.statebutton = {}
|
||||||
if not stancemap and DefaultStanceMap[playerclass] then
|
-- CoA: rebuild generic stance maps each call so late-registered forms get
|
||||||
|
-- picked up; vanilla classes keep their cached DefaultStanceMap entry.
|
||||||
|
if not stancemap then
|
||||||
|
if DefaultStanceMap[playerclass] then
|
||||||
stancemap = DefaultStanceMap[playerclass]
|
stancemap = DefaultStanceMap[playerclass]
|
||||||
|
elseif GetNumShapeshiftForms() > 0 then
|
||||||
|
stancemap = BuildGenericStanceMap()
|
||||||
|
end
|
||||||
|
elseif not DefaultStanceMap[playerclass] then
|
||||||
|
-- generic map: refresh on every call in case form count changed
|
||||||
|
stancemap = BuildGenericStanceMap()
|
||||||
end
|
end
|
||||||
|
|
||||||
local statedriver
|
local statedriver
|
||||||
|
|||||||
Reference in New Issue
Block a user