Quantcast

Added overrides for bag keybind

Brandon Talbot [07-21-16 - 17:45]
Added overrides for bag keybind
Filename
src/lua/controller/bag.lua
src/lua/core.lua
diff --git a/src/lua/controller/bag.lua b/src/lua/controller/bag.lua
index 677fe22..e904af1 100644
--- a/src/lua/controller/bag.lua
+++ b/src/lua/controller/bag.lua
@@ -40,13 +40,21 @@ function controller:Update()
     DJBagsBagContainer:Arrange()
 end

+function controller:Toggle()
+    if DJBagsBagContainer:IsVisible() then
+        self:Close()
+    else
+        self:Open()
+    end
+end
+
 function controller:Open()
     self:Update()
     DJBagsBagContainer:Show()
 end

 function controller:Close()
-
+    DJBagsBagContainer:Hide()
 end

 function controller:BAG_UPDATE(bag)
diff --git a/src/lua/core.lua b/src/lua/core.lua
index b45c8d0..02dc9c6 100644
--- a/src/lua/core.lua
+++ b/src/lua/core.lua
@@ -13,6 +13,40 @@ end

 ADDON.events:Add('ADDON_LOADED', core)

+--region Bag commands
+
+ToggleAllBags = function()
+    ADDON.bagController:Toggle()
+end
+
+ToggleBag = function(id)
+    if id < 5 and id > -1 then
+        ADDON.bagController:Toggle()
+    end
+end
+
+ToggleBackpack = function()
+    ADDON.bagController:Toggle()
+end
+
+OpenAllBags = function()
+    ADDON.bagController:Open()
+end
+
+OpenBackpack = function()
+    ADDON.bagController:Open()
+end
+
+CloseAllBags = function()
+    ADDON.bagController:Close()
+end
+
+CloseBackpack = function()
+    ADDON.bagController:Close()
+end
+
+--endregion
+
 SLASH_DJBAGS1 = '/djb';
 function SlashCmdList.DJBAGS(msg, editbox)
     ADDON.bagController:Open()