Mercurial > wow > reaction
diff main.lua @ 12:2735edcf9ab7
Version 0.34
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Wed, 21 Mar 2007 00:13:27 +0000 |
parents | f3a7bfebc283 |
children | 639282f3a0e0 |
line wrap: on
line diff
--- a/main.lua Tue Mar 20 21:38:47 2007 +0000 +++ b/main.lua Wed Mar 21 00:13:27 2007 +0000 @@ -9,7 +9,7 @@ local L = AceLibrary("AceLocale-2.2"):new("ReAction") local dewdrop = AceLibrary("Dewdrop-2.0") local tablet = AceLibrary("Tablet-2.0") -local ReBound = AceLibrary("ReBound-1.0") +local ReBound = AceLibrary("ReBound-1.0"):new("REACTION") -- private functions local function tcopy(t) @@ -54,21 +54,31 @@ self:RegisterEvent("PLAYER_ENTERING_WORLD","HideDefaultBars") self:DisableDefaultKeybindings() + -- create update function for keybinding frame + ReActionKeybindDialog:SetScript("OnHide", function(frame) + main:SetKeybindMode(false) + if frame.save then + ReBound:SaveBindings() + else + ReBound:RevertBindings() + end + frame.save = false + end ) + -- initial non-persistent state self.locked = true self.bars = { } end --- OnEnable is called at startup (startup = true, oldConfig = nil), --- and when the profile is changed (startup = false, oldConfig ~= nil ) -function main:OnEnable( startup, oldConfig ) +-- OnEnable is called at startup and when the profile is changed (via OnProfileEnable) +function main:OnEnable( ) if self.db.profile.firstRunDone ~= true then self.db.profile.bars = tcopy(ReAction_DefaultBlizzardBars) end self:DestroyAllBars() self:SetupBars() self:UpgradeProfile() - self:SetupKeybindings( oldConfig and oldConfig.bindings ) + self:SetupKeybindings() if self.db.profile.firstRunDone ~= true then self:Unlock() end @@ -81,7 +91,10 @@ -- OnProfileEnable() is only called when switching profiles, NOT for the initial profile at load time. function main:OnProfileEnable( oldName, oldData ) - self:OnEnable(false, oldData) + self:UnregisterEvent("REBOUND_BIND") + self:UnregisterEvent("REBOUND_UNBIND") + ReBound:ClearRegisteredBindings() + self:OnEnable() end function main:UpgradeProfile() @@ -164,22 +177,18 @@ BINDING_NAME_PREVIOUSACTIONPAGE = label end -function main:SetupKeybindings( previous ) - if previous then - self:UnregisterEvent("REBOUND_BIND") - self:UnregisterEvent("REBOUND_UNBIND") - for key, binding in pairs(previous) do - ReBound:ClearBinding(key, getglobal(binding.target), binding.button, true) - end - end +function main:SetupKeybindings() if self.db.profile.firstRunDone ~= true then self:StealKeyBindings() else for key, binding in pairs(self.db.profile.bindings) do - ReBound:SetBinding(key, getglobal(binding.target), binding.button) + local target = getglobal(binding.target) + if target then + ReBound:SetBinding(key, target, binding.button) + end end end - SaveBindings(GetCurrentBindingSet()) + ReBound:SaveBindings() self:RegisterEvent("REBOUND_BIND") self:RegisterEvent("REBOUND_UNBIND") end @@ -193,17 +202,17 @@ ReBound:SetBinding(key, self.bars[1].buttons[i]:GetActionFrame(), "LeftButton") end end - SaveBindings(GetCurrentBindingSet()) + ReBound:SaveBindings() end -function main:REBOUND_BIND(key, target, button) - if key and target then +function main:REBOUND_BIND(id, key, target, button) + if id == "REACTION" and key and target then self.db.profile.bindings[key] = { target = target, button = button } end end -function main:REBOUND_UNBIND(key) - if key then +function main:REBOUND_UNBIND(id, key) + if id == "REACTION" and key then self.db.profile.bindings[key] = nil end end @@ -227,10 +236,10 @@ end end if enabled then - ReBound:ShowAll() + ReBound:ShowFrames() ReActionKeybindDialog:Show() else - ReBound:HideAll() + ReBound:HideFrames() if ReActionKeybindDialog:IsShown() then ReActionKeybindDialog:Hide() end @@ -468,6 +477,10 @@ end ) + -- register page up/down buttons with ReBound for keybinding + ReBound:Register(bar.upArrow) + ReBound:Register(bar.downArrow) + if not self.locked then bar:ShowControls() end