Skip to content

Commit

Permalink
Reapply "Work-around issues with the PetBar not accepting modified ke…
Browse files Browse the repository at this point in the history
…ybinding

The issue with modified petbar keybinds is still there, so I was a bit overhasty with my previous commit. I tried to improve the issue that the workaround breakes the keybinds when on a vehicle or drake. In these cases the keybinds of the petbar do not work.
  • Loading branch information
zahnom committed Feb 8, 2023
1 parent 3171d18 commit e88510d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ read_globals = {
"SetBindingClick",
"SetCVar",
"SetModifiedClick",
"SetOverrideBinding",
"SetOverrideBindingClick",
"UnitClass",
"UnitFactionGroup",
Expand Down
33 changes: 28 additions & 5 deletions PetBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,26 @@ function PetBarMod:ReassignBindings()
if InCombatLockdown() then return end
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)

if not WoWRetail then
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))
if self:IsKeybindWithModifier(key) then
SetOverrideBinding(self.bar, false, key, button)
else
SetOverrideBindingClick(self.bar, false, key, real_button)
end
end
end
else
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
end
Expand Down Expand Up @@ -151,3 +166,11 @@ function PetBar:ApplyConfig(config)
self:ForAll("Update")
self:ForAll("ApplyStyle", self.config.style)
end

function PetBarMod:IsKeybindWithModifier(key)
if key:find('^' .. "ALT") ~= nil then return true
elseif key:find('^' .. "CTRL") ~= nil then return true
elseif key:find('^' .. "SHIFT") ~= nil then return true
else return false
end
end

0 comments on commit e88510d

Please sign in to comment.