mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-18 10:40:48 +00:00
actionbar: assign scripts only once per bar
This commit is contained in:
+32
-27
@@ -791,6 +791,7 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
local realsize = size+border*2
|
local realsize = size+border*2
|
||||||
|
|
||||||
-- create frame
|
-- create frame
|
||||||
|
local init = not bars[i]
|
||||||
bars[i] = bars[i] or CreateFrame("Frame", "pfActionBar" .. barnames[i], UIParent, ACTIONBAR_SECURE_TEMPLATE_BAR)
|
bars[i] = bars[i] or CreateFrame("Frame", "pfActionBar" .. barnames[i], UIParent, ACTIONBAR_SECURE_TEMPLATE_BAR)
|
||||||
bars[i]:SetID(i)
|
bars[i]:SetID(i)
|
||||||
|
|
||||||
@@ -813,17 +814,19 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- show/hide petbar on petbar updates
|
-- show/hide petbar on petbar updates
|
||||||
bars[i]:RegisterEvent("PET_BAR_UPDATE")
|
if init then
|
||||||
bars[i]:SetScript("OnEvent", function()
|
bars[i]:RegisterEvent("PET_BAR_UPDATE")
|
||||||
-- hide obsolete buttons
|
bars[i]:SetScript("OnEvent", function()
|
||||||
for i=1, NUM_PET_ACTION_SLOTS do
|
-- hide obsolete buttons
|
||||||
if not PetHasActionBar() and bars[12][i] then
|
for i=1, NUM_PET_ACTION_SLOTS do
|
||||||
bars[12][i]:Hide()
|
if not PetHasActionBar() and bars[12][i] then
|
||||||
end
|
bars[12][i]:Hide()
|
||||||
end
|
end
|
||||||
-- refresh layout
|
end
|
||||||
CreateActionBar(12)
|
-- refresh layout
|
||||||
end)
|
CreateActionBar(12)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
-- handle shapeshift bar
|
-- handle shapeshift bar
|
||||||
elseif i == 11 then
|
elseif i == 11 then
|
||||||
@@ -835,25 +838,27 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- update shapeshift bar when amount of spells changes
|
-- update shapeshift bar when amount of spells changes
|
||||||
bars[i]:RegisterEvent("PLAYER_ENTERING_WORLD")
|
if init then
|
||||||
bars[i]:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
|
bars[i]:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
bars[i]:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
|
bars[i]:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
|
||||||
bars[i]:SetScript("OnEvent", function()
|
bars[i]:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
|
||||||
local count = GetNumShapeshiftForms()
|
bars[i]:SetScript("OnEvent", function()
|
||||||
if count ~= this.lastCount then
|
local count = GetNumShapeshiftForms()
|
||||||
this.lastCount = count
|
if count ~= this.lastCount then
|
||||||
|
this.lastCount = count
|
||||||
|
|
||||||
-- hide obsolete buttons
|
-- hide obsolete buttons
|
||||||
for i=1, NUM_SHAPESHIFT_SLOTS do
|
for i=1, NUM_SHAPESHIFT_SLOTS do
|
||||||
if i > GetNumShapeshiftForms() and bars[11][i] then
|
if i > GetNumShapeshiftForms() and bars[11][i] then
|
||||||
bars[11][i]:Hide()
|
bars[11][i]:Hide()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- create new buttons and refresh layout
|
-- create new buttons and refresh layout
|
||||||
CreateActionBar(11)
|
CreateActionBar(11)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
-- regular bars
|
-- regular bars
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user