set override bindings on Bar1, ShapeshiftBar, PetBar

This commit is contained in:
Hendrik Leppkes
2008-03-10 16:20:58 +00:00
parent 0c0abdbca6
commit 60fa80d401
5 changed files with 61 additions and 7 deletions
+4
View File
@@ -145,6 +145,7 @@ function ActionBar:UpdateButtons(numbuttons)
local buttons = self.buttons or {}
local updateBindings = (numbuttons > #buttons)
-- create more buttons if needed
for i = (#buttons+1), numbuttons do
buttons[i] = Bartender4.Button:Create(i, self)
@@ -166,6 +167,9 @@ function ActionBar:UpdateButtons(numbuttons)
self:UpdateButtonLayout()
self:SetGrid()
if updateBindings and self.id == "1" then
module:ReassignBindings()
end
end
+16 -1
View File
@@ -1,6 +1,6 @@
--[[ $Id$ ]]
local BT4ActionBars = Bartender4:NewModule("ActionBars")
local BT4ActionBars = Bartender4:NewModule("ActionBars", "AceEvent-3.0")
local ActionBar, ActionBar_MT
@@ -79,6 +79,8 @@ function BT4ActionBars:OnEnable()
end
first = nil
end
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
self:ReassignBindings()
end
-- Applys the config in the current profile to all active Bars
@@ -222,6 +224,19 @@ function BT4ActionBars:CreateBarOption(id, options)
self.options.args[id].args = options
end
function BT4ActionBars:ReassignBindings()
if not self.actionbars or not self.actionbars[1] then return end
local frame = self.actionbars[1]
ClearOverrideBindings(frame)
for i = 1,min(#frame.buttons, 12) do
local button, real_button = ("ACTIONBUTTON%d"):format(i), ("BT4Button%d"):format(i)
for k=1, select('#', GetBindingKey(button)) do
local key = select(k, GetBindingKey(button))
SetOverrideBindingClick(frame, false, key, real_button)
end
end
end
-- Creates a new bar object based on the id and the specified config
function BT4ActionBars:Create(id, config)
local id = tostring(id)
+4 -4
View File
@@ -288,10 +288,10 @@ function Button:GetBindings()
binding = "CLICK "..self:GetName()..":LeftButton"
for i = 1, select('#', GetBindingKey(binding)) do
local hotKey = select(i, GetBindingKey(binding))
if keys ~= "" then
keys = keys .. ', '
end
keys = keys .. GetBindingText(hotKey,'KEY_')
if keys ~= "" then
keys = keys .. ', '
end
keys = keys .. GetBindingText(hotKey,'KEY_')
end
return keys
+17 -1
View File
@@ -1,7 +1,7 @@
--[[ $Id: StanceBar.lua 61678 2008-02-17 01:37:33Z nevcairiel $ ]]
-- register module
local PetBarMod = Bartender4:NewModule("PetBar")
local PetBarMod = Bartender4:NewModule("PetBar", "AceEvent-3.0")
-- fetch upvalues
local ActionBars = Bartender4:GetModule("ActionBars")
@@ -57,6 +57,9 @@ function PetBarMod:OnEnable()
self:ApplyConfig()
self:SetupOptions()
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
self:ReassignBindings()
end
function PetBarMod:OnDisable()
@@ -144,9 +147,22 @@ function PetBarMod:SetupOptions()
ActionBars.options.args["Pet"].args = self:IsEnabled() and self.options.table or self.disabledoptions
end
function PetBarMod:ReassignBindings()
if not self.bar or not self.bar.buttons then return end
ClearOverrideBindings(self.bar)
for i = 1, 10 do
local button, real_button = ("BONUSACTIONBUTTON%d"):format(i), ("BT4PetButton%d"):format(i)
for k=1, select('#', GetBindingKey(button)) do
local key = select(k, GetBindingKey(button))
SetOverrideBindingClick(self.bar, false, key, real_button)
end
end
end
function PetBarMod:ApplyConfig()
if not self:IsEnabled() then return end
self.bar:ApplyConfig(self.db.profile)
self:ReassignBindings()
end
function PetButtonPrototype:Update()
+20 -1
View File
@@ -1,7 +1,7 @@
--[[ $Id$ ]]
-- register module
local StanceBarMod = Bartender4:NewModule("StanceBar")
local StanceBarMod = Bartender4:NewModule("StanceBar", "AceEvent-3.0")
-- fetch upvalues
local ActionBars = Bartender4:GetModule("ActionBars")
@@ -41,6 +41,8 @@ function StanceBarMod:OnEnable()
self.bar:RegisterEvent("PLAYER_AURAS_CHANGED")
self.bar:RegisterEvent("PLAYER_REGEN_ENABLED")
self.bar:Show()
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
self:ReassignBindings()
end
function StanceBarMod:OnDisable()
@@ -95,6 +97,18 @@ function StanceBarMod:ApplyConfig()
self.bar:ApplyConfig(self.db.profile)
end
function StanceBarMod:ReassignBindings()
if not self.bar or not self.bar.buttons then return end
ClearOverrideBindings(self.bar)
for i = 1, min(#self.bar.buttons, 10) do
local button, real_button = ("SHAPESHIFTBUTTON%d"):format(i), ("BT4StanceButton%d"):format(i)
for k=1, select('#', GetBindingKey(button)) do
local key = select(k, GetBindingKey(button))
SetOverrideBindingClick(self.bar, false, key, real_button)
end
end
end
function StanceButtonPrototype:Update()
if not self:IsShown() then return end
local id = self:GetID()
@@ -205,6 +219,8 @@ function StanceBar:UpdateStanceButtons()
local num_stances = GetNumShapeshiftForms()
local updateBindings = (num_stances > #buttons)
for i = (#buttons+1), num_stances do
buttons[i] = StanceBarMod:CreateStanceButton(i)
end
@@ -221,6 +237,9 @@ function StanceBar:UpdateStanceButtons()
self.buttons = buttons
self:UpdateButtonLayout()
if updateBindings then
StanceBarMod:ReassignBindings()
end
end
function StanceBar:OnEvent(event, ...)