Skip to content

Commit

Permalink
Added a BetterBags native keybind for toggling the bag.
Browse files Browse the repository at this point in the history
Rebound native blizzard keybinds so they use BetterBags' native keybind.

Eliminated all frame rate drops from opening bags.
  • Loading branch information
Cidan committed May 10, 2024
1 parent 1a7fa23 commit d89a84b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Bindings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
<Binding name="BETTERBAGS_TOGGLESEARCH" category="BetterBags">
BetterBags_ToggleSearch()
</Binding>
<Binding name="BETTERBAGS_TOGGLEBAGS" category="BetterBags">
BetterBags_ToggleBags()
</Binding>
</Bindings>
3 changes: 2 additions & 1 deletion core/boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ local addon = LibStub("AceAddon-3.0"):NewAddon(root, addonName, 'AceHook-3.0')

addon:SetDefaultModuleState(false)

BINDING_NAME_BETTERBAGS_TOGGLESEARCH = "Search Bags"
BINDING_NAME_BETTERBAGS_TOGGLESEARCH = "Search Bags"
BINDING_NAME_BETTERBAGS_TOGGLEBAGS = "Toggle Bags"
2 changes: 1 addition & 1 deletion core/hooks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function addon:ToggleAllBags(interactingFrame)
else
addon.backpackShouldOpen = true
end
events:SendMessageLater('bags/OpenClose')
events:SendMessage('bags/OpenClose')
end

function addon:CloseSpecialWindows(interactingFrame)
Expand Down
12 changes: 9 additions & 3 deletions core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ addon.Bags = {}

addon.atBank = false

-- BetterBags_ToggleBags is a wrapper function for the ToggleAllBags function.
function BetterBags_ToggleBags()
addon:ToggleAllBags()
end

local function CheckKeyBindings()
if InCombatLockdown() then
addon._bindingFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
Expand All @@ -80,15 +85,16 @@ local function CheckKeyBindings()
"TOGGLEBAG1",
"TOGGLEBAG2",
"TOGGLEBAG3",
"TOGGLEBAG4"
"TOGGLEBAG4",
"OPENALLBAGS"
}
for _, binding in pairs(bindings) do
local key, otherkey = GetBindingKey(binding)
if key ~= nil then
SetOverrideBinding(addon._bindingFrame, true, key, "OPENALLBAGS")
SetOverrideBinding(addon._bindingFrame, true, key, "BETTERBAGS_TOGGLEBAGS")
end
if otherkey ~= nil then
SetOverrideBinding(addon._bindingFrame, true, otherkey, "OPENALLBAGS")
SetOverrideBinding(addon._bindingFrame, true, otherkey, "BETTERBAGS_TOGGLEBAGS")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion frames/bag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function bagFrame.bagProto:Show()
if self.frame:IsShown() then
return
end
addon.ForceShowBlizzardBags()
--addon.ForceShowBlizzardBags()
PlaySound(self.kind == const.BAG_KIND.BANK and SOUNDKIT.IG_MAINMENU_OPEN or SOUNDKIT.IG_BACKPACK_OPEN)
self.frame:Show()
end
Expand Down

0 comments on commit d89a84b

Please sign in to comment.