Skip to content

Commit

Permalink
fix taint issues related to the multi action bars
Browse files Browse the repository at this point in the history
this time in hopefully a better way
  • Loading branch information
Tuller committed Dec 16, 2018
1 parent 9cee290 commit e087673
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 27 deletions.
3 changes: 2 additions & 1 deletion Dominos/Dominos.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Title: Dominos
## Notes: A main actionbar replacement
## Author: Tuller
## Version: 8.1.2
## Version: 8.1.3
## SavedVariables: DominosDB, DominosVersion
## OptionalDeps: Ace3, LibKeyBound-1.0, LibSharedMedia-3.0, Masque, FlyPaper
embeds.xml
Expand All @@ -27,6 +27,7 @@ bars\menuBar.lua
bars\extraActionBar.lua
bars\vehicleBar.lua
## bars\castBar.lua
plugins\multiActionBarFixer.lua
plugins\slashCommands.lua
plugins\launcher.lua
plugins\blizzardHider.lua
Expand Down
2 changes: 1 addition & 1 deletion Dominos/bars/actionBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,4 @@ end
-- workaround for empty buttons not hiding when dropping a pet action
function ActionBarController:PET_BAR_HIDEGRID()
ActionBar:ForAll("HideGrid", ACTION_BUTTON_SHOW_GRID_REASON_EVENT)
end
end
26 changes: 4 additions & 22 deletions Dominos/bars/actionButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,18 @@ end
local function GetOrCreateActionButton(id)
if id <= 12 then
local b = _G[('ActionButton%d'):format(id)]

b.buttonType = 'ACTIONBUTTON'

return b
elseif id <= 24 then
return CreateActionButton(id - 12)
elseif id <= 36 then
local b = _G[('MultiBarRightButton%d'):format(id - 24)]

b.noGrid = 1

return b
return _G[('MultiBarRightButton%d'):format(id - 24)]
elseif id <= 48 then
local b = _G[('MultiBarLeftButton%d'):format(id - 36)]

b.noGrid = 1

return b
return _G[('MultiBarLeftButton%d'):format(id - 36)]
elseif id <= 60 then
local b = _G[('MultiBarBottomRightButton%d'):format(id - 48)]

b.noGrid = 1

return b
return _G[('MultiBarBottomRightButton%d'):format(id - 48)]
elseif id <= 72 then
local b = _G[('MultiBarBottomLeftButton%d'):format(id - 60)]

b.noGrid = 1

return b
return _G[('MultiBarBottomLeftButton%d'):format(id - 60)]
else
return CreateActionButton(id - 60)
end
Expand Down
3 changes: 0 additions & 3 deletions Dominos/plugins/blizzardHider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,3 @@ hideFrames(
'MicroButtonAndBagsBar',
'MainMenuBarPerformanceBar'
)

-- disable multiactionbar_update to prevent some taint issues
MultiActionBar_Update = Multibar_EmptyFunc
48 changes: 48 additions & 0 deletions Dominos/plugins/multiActionBarFixer.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--[[
This code works around empty action buttons appearing on the multi action
buttons either because the user has set to always show blizzard slots, or
because the user has opened the spellbook
We do this via clearing specific showgrid reasons on all the buttons on
each MultiActionBar whenever the showgrid value changes
--]]

local MultiBarFixer = CreateFrame("Frame", nil, nil, "SecureHandlerBaseTemplate")

MultiBarFixer:Hide()

-- adapted from http://lua-users.org/wiki/BitUtils
MultiBarFixer:SetAttribute("ClearFlags", [[
local set = ...
for i = 2, select("#", ...) do
local flag = select(i, ...)
if set % (2 * flag) >= flag then
set = set - flag
end
end
return set
]])

-- clears the given show grid reasons
local OnAttributeChanged = ([[
if name == "showgrid" and value > 0 then
value = control:RunAttribute("ClearFlags", value, %d, %d)
if self:GetAttribute("showgrid") ~= value then
self:SetAttribute("showgrid", value)
end
end
]]):format(ACTION_BUTTON_SHOW_GRID_REASON_CVAR, ACTION_BUTTON_SHOW_GRID_REASON_SPELLBOOK)

-- apply to every multi bar action button
for _, barName in pairs{'MultiBarBottomLeft', 'MultiBarBottomRight', 'MultiBarLeft', 'MultiBarRight'} do
for i = 1, NUM_MULTIBAR_BUTTONS do
local buttonName = ('%sButton%d'):format(barName, i)
local button = _G[buttonName]

MultiBarFixer:WrapScript(button, "OnAttributeChanged", OnAttributeChanged)
end
end

0 comments on commit e087673

Please sign in to comment.