Skip to content

Commit

Permalink
Fix some mindfuck code, and prevent :LoadBindings() from niling out o…
Browse files Browse the repository at this point in the history
…ur state condition.
  • Loading branch information
haste committed Apr 2, 2010
1 parent 3cc886b commit 0b88d39
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions bindings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,12 @@ local createButton = function(key)
return btn
end

local clearButton = function(key)
local btn = _BUTTONS[key]
if(btn) then
for key in next, states do
if(key ~= 'possess') then
btn:SetAttribute(string.format('ob-%s-type', key), nil)
key = (key == 'macro' and 'macrotext') or key
btn:SetAttribute(string.format('ob-%s-attribute', key), nil)
end
local clearButton = function(btn)
for key in next, states do
if(key ~= 'possess') then
btn:SetAttribute(string.format('ob-%s-type', key), nil)
key = (key == 'macro' and 'macrotext') or key
btn:SetAttribute(string.format('ob-%s-attribute', key), nil)
end
end
end
Expand All @@ -125,13 +122,14 @@ local typeTable = {
}

local bindKey = function(key, action, mod)
local modKey
if(mod and (mod == 'alt' or mod == 'ctrl' or mod == 'shift')) then
key = mod:upper() .. '-' .. key
modKey = mod:upper() .. '-' .. key
end

local ty, action = string.split('|', action)
if(not action) then
SetBinding(key, ty)
SetBinding(modKey or key, ty)
else
local btn = createButton(key)
ty = typeTable[ty]
Expand All @@ -140,7 +138,7 @@ local bindKey = function(key, action, mod)
ty = (ty == 'macro' and 'macrotext') or ty
btn:SetAttribute(string.format('ob-%s-attribute', mod or 'base'), ty .. ',' .. action)

SetBindingClick(key, btn:GetName())
SetBindingClick(modKey or key, btn:GetName())
end
end

Expand All @@ -166,14 +164,14 @@ function _NS:LoadBindings(name)
end
end
end
end

RegisterStateDriver(_STATE, "page", _states .. states.possess .. 'possess;' .. _BASE)
_STATE:Execute(([[
local state = '%s'
control:ChildUpdate('state-changed', state)
control:CallMethod('Callbacks', state)
]]):format(_STATE:GetAttribute'state-page'))
RegisterStateDriver(_STATE, "page", _states .. states.possess .. 'possess;' .. _BASE)
_STATE:Execute(([[
local state = '%s'
control:ChildUpdate('state-changed', state)
control:CallMethod('Callbacks', state)
]]):format(_STATE:GetAttribute'state-page'))
end
end

_NS:SetScript('OnEvent', function(self, event, ...)
Expand Down

0 comments on commit 0b88d39

Please sign in to comment.