Skip to content

Commit

Permalink
bindings update work to make things better
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuller committed Dec 3, 2010
1 parent 99443b3 commit d020716
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 22 deletions.
5 changes: 3 additions & 2 deletions Dominos.toc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Title: Dominos ## Title: Dominos
## Notes: A main actionbar replacement ## Notes: A main actionbar replacement
## Author: Tuller ## Author: Tuller
## Version: 1.20.1 ## Version: 1.20.2
## SavedVariables: DominosDB, DominosVersion ## SavedVariables: DominosDB, DominosVersion
## OptionalDeps: Ace3, LibKeyBound-1.0, ButtonFacade, FlyPaper ## OptionalDeps: Ace3, LibKeyBound-1.0, ButtonFacade, FlyPaper
embeds.xml embeds.xml
Expand All @@ -18,4 +18,5 @@ classBar.lua
bagBar.lua bagBar.lua
menuBar.lua menuBar.lua
vehicleBar.lua vehicleBar.lua
minimap.lua minimap.lua
bindingsUpdater.lua
16 changes: 2 additions & 14 deletions actionBar.lua
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -466,24 +466,12 @@ function ActionBar:UpdateGrid()
end end
end end


--keybound support function ActionBar:UPDATE_BINDINGS()
function ActionBar:KEYBOUND_ENABLED()
self:ShowGrid()

for _,b in pairs(self.buttons) do
b:RegisterEvent('UPDATE_BINDINGS')
end
end

function ActionBar:KEYBOUND_DISABLED()
self:HideGrid()

for _,b in pairs(self.buttons) do for _,b in pairs(self.buttons) do
b:UnregisterEvent('UPDATE_BINDINGS') b:UpdateHotkey(b.buttonType)
end end
end end



--right click targeting support --right click targeting support
function ActionBar:UpdateRightClickUnit() function ActionBar:UpdateRightClickUnit()
self.header:SetAttribute('*unit2', Dominos:GetRightClickUnit()) self.header:SetAttribute('*unit2', Dominos:GetRightClickUnit())
Expand Down
32 changes: 32 additions & 0 deletions bindingsUpdater.lua
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,32 @@
--[[
a frame to update bindings to prevent craziness from happening in crazy town
--]]

local BindingsUpdater = CreateFrame('Frame')

function BindingsUpdater:OnEvent(event, ...)
local a = self[event]
if a then
a(self, event, ...)
end
end

function BindingsUpdater:UPDATE_BINDINGS(event)
self:UpdateFrames()
self:UnregisterEvent('UPDATE_BINDINGS')
end

function BindingsUpdater:UpdateFrames()
for _, frame in Dominos.Frame:GetAll() do
if frame.UPDATE_BINDINGS then
frame:UPDATE_BINDINGS()
end
end
end

hooksecurefunc('SetBinding', BindingsUpdater.UpdateFrames)
hooksecurefunc('SetBindingClick', BindingsUpdater.UpdateFrames)
hooksecurefunc('SetBindingItem', BindingsUpdater.UpdateFrames)
hooksecurefunc('SetBindingMacro', BindingsUpdater.UpdateFrames)
hooksecurefunc('SetBindingSpell', BindingsUpdater.UpdateFrames)
hooksecurefunc('LoadBindings', BindingsUpdater.UpdateFrames)
11 changes: 7 additions & 4 deletions classBar.lua
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -111,16 +111,13 @@ function ClassButton:UpdateEvents()
self:RegisterEvent('SPELL_UPDATE_COOLDOWN') self:RegisterEvent('SPELL_UPDATE_COOLDOWN')
self:RegisterEvent('SPELL_UPDATE_USABLE') self:RegisterEvent('SPELL_UPDATE_USABLE')
self:RegisterEvent('UNIT_AURA') self:RegisterEvent('UNIT_AURA')
self:RegisterEvent('UPDATE_BINDINGS')
else else
self:UnregisterAllEvents() self:UnregisterAllEvents()
end end
end end


function ClassButton:OnEvent(event, arg1) function ClassButton:OnEvent(event, arg1)
if event == 'UPDATE_BINDINGS' then if event == 'UPDATE_SHAPESHIFT_FORMS' and (self:GetID() > GetNumShapeshiftForms()) then
self:UpdateHotkey()
elseif event == 'UPDATE_SHAPESHIFT_FORMS' and (self:GetID() > GetNumShapeshiftForms()) then
self:Hide() self:Hide()
elseif event == 'UNIT_AURA' then elseif event == 'UNIT_AURA' then
if arg1 == 'player' then if arg1 == 'player' then
Expand Down Expand Up @@ -237,4 +234,10 @@ function ClassBar:UpdateForms()
b:Show() b:Show()
end end
self:SetNumButtons(GetNumShapeshiftForms() or 0) self:SetNumButtons(GetNumShapeshiftForms() or 0)
end

function ClassBar:UPDATE_BINDINGS()
for _,b in pairs(self.buttons) do
b:UpdateHotkey(b.buttonType)
end
end end
8 changes: 6 additions & 2 deletions petBar.lua
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ function PetBar:KEYBOUND_ENABLED()
self.header:SetAttribute('state-visibility', 'display') self.header:SetAttribute('state-visibility', 'display')


for _,button in pairs(self.buttons) do for _,button in pairs(self.buttons) do
button:RegisterEvent('UPDATE_BINDINGS')
button:Show() button:Show()
end end
end end
Expand All @@ -135,11 +134,16 @@ function PetBar:KEYBOUND_DISABLED()


local petBarShown = PetHasActionBar() local petBarShown = PetHasActionBar()
for _,button in pairs(self.buttons) do for _,button in pairs(self.buttons) do
button:UnregisterEvent('UPDATE_BINDINGS')
if petBarShown and GetPetActionInfo(button:GetID()) then if petBarShown and GetPetActionInfo(button:GetID()) then
button:Show() button:Show()
else else
button:Hide() button:Hide()
end end
end end
end

function PetBar:UPDATE_BINDINGS()
for _,b in pairs(self.buttons) do
b:UpdateHotkey(b.buttonType)
end
end end

0 comments on commit d020716

Please sign in to comment.