Permalink
Browse files

bindings update work to make things better

  • Loading branch information...
1 parent 99443b3 commit d0207161abdae8ef01212c9f8d11f09ee64151df Tuller committed Dec 3, 2010
Showing with 50 additions and 22 deletions.
  1. +3 −2 Dominos.toc
  2. +2 −14 actionBar.lua
  3. +32 −0 bindingsUpdater.lua
  4. +7 −4 classBar.lua
  5. +6 −2 petBar.lua
View
@@ -2,7 +2,7 @@
## Title: Dominos
## Notes: A main actionbar replacement
## Author: Tuller
-## Version: 1.20.1
+## Version: 1.20.2
## SavedVariables: DominosDB, DominosVersion
## OptionalDeps: Ace3, LibKeyBound-1.0, ButtonFacade, FlyPaper
embeds.xml
@@ -18,4 +18,5 @@ classBar.lua
bagBar.lua
menuBar.lua
vehicleBar.lua
-minimap.lua
+minimap.lua
+bindingsUpdater.lua
View
@@ -466,24 +466,12 @@ function ActionBar:UpdateGrid()
end
end
---keybound support
-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()
-
+function ActionBar:UPDATE_BINDINGS()
for _,b in pairs(self.buttons) do
- b:UnregisterEvent('UPDATE_BINDINGS')
+ b:UpdateHotkey(b.buttonType)
end
end
-
--right click targeting support
function ActionBar:UpdateRightClickUnit()
self.header:SetAttribute('*unit2', Dominos:GetRightClickUnit())
View
@@ -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)
View
@@ -111,16 +111,13 @@ function ClassButton:UpdateEvents()
self:RegisterEvent('SPELL_UPDATE_COOLDOWN')
self:RegisterEvent('SPELL_UPDATE_USABLE')
self:RegisterEvent('UNIT_AURA')
- self:RegisterEvent('UPDATE_BINDINGS')
else
self:UnregisterAllEvents()
end
end
function ClassButton:OnEvent(event, arg1)
- if event == 'UPDATE_BINDINGS' then
- self:UpdateHotkey()
- elseif event == 'UPDATE_SHAPESHIFT_FORMS' and (self:GetID() > GetNumShapeshiftForms()) then
+ if event == 'UPDATE_SHAPESHIFT_FORMS' and (self:GetID() > GetNumShapeshiftForms()) then
self:Hide()
elseif event == 'UNIT_AURA' then
if arg1 == 'player' then
@@ -237,4 +234,10 @@ function ClassBar:UpdateForms()
b:Show()
end
self:SetNumButtons(GetNumShapeshiftForms() or 0)
+end
+
+function ClassBar:UPDATE_BINDINGS()
+ for _,b in pairs(self.buttons) do
+ b:UpdateHotkey(b.buttonType)
+ end
end
View
@@ -125,7 +125,6 @@ function PetBar:KEYBOUND_ENABLED()
self.header:SetAttribute('state-visibility', 'display')
for _,button in pairs(self.buttons) do
- button:RegisterEvent('UPDATE_BINDINGS')
button:Show()
end
end
@@ -135,11 +134,16 @@ function PetBar:KEYBOUND_DISABLED()
local petBarShown = PetHasActionBar()
for _,button in pairs(self.buttons) do
- button:UnregisterEvent('UPDATE_BINDINGS')
if petBarShown and GetPetActionInfo(button:GetID()) then
button:Show()
else
button:Hide()
end
end
+end
+
+function PetBar:UPDATE_BINDINGS()
+ for _,b in pairs(self.buttons) do
+ b:UpdateHotkey(b.buttonType)
+ end
end

0 comments on commit d020716

Please sign in to comment.