diff --git a/Changelog and Notes.txt b/Changelog and Notes.txt index c5254f6..e39a00c 100644 --- a/Changelog and Notes.txt +++ b/Changelog and Notes.txt @@ -185,3 +185,5 @@ A feature that would automatically show you the location of the nearest mailbox. Right Click totems to destroy them Show best gold value for quest reward. + +Open all bag user config option at merchant. \ No newline at end of file diff --git a/Leatrix_Plus.lua b/Leatrix_Plus.lua index 082dd4c..0615802 100644 --- a/Leatrix_Plus.lua +++ b/Leatrix_Plus.lua @@ -1753,7 +1753,46 @@ ---------------------------------------------------------------------- if LeaPlusLC["NoBagAutomation"] == "On" and not LeaLockList["NoBagAutomation"] then - RunScript("hooksecurefunc('OpenAllBags', CloseAllBags)") + local function ManageBackpack(event) + if event == "MERCHANT_SHOW" then + BACKPACK_WAS_OPEN = IsBagOpen(0) + if OpenBackpack ~= nil then + CloseBackpack() + end + elseif event == "MERCHANT_CLOSED" and not BACKPACK_WAS_OPEN then + CloseBackpack() + end + end + + local frame = CreateFrame("Frame") + frame:RegisterEvent("MERCHANT_SHOW") + frame:RegisterEvent("MERCHANT_CLOSED") + frame:SetScript("OnEvent", function(self, event) + ManageBackpack(event) + end) + + local function CustomCloseBackpack(closeFunction) + return function() + if not MERCHANT_FRAME_ACTIVE then + closeFunction() + end + end + end + + hooksecurefunc("CloseBackpack", CustomCloseBackpack(CloseBackpack)) + + local function MerchantFrame_Active_OnShow() + MERCHANT_FRAME_ACTIVE = true + end + + local function MerchantFrame_Active_OnHide() + MERCHANT_FRAME_ACTIVE = false + end + + hooksecurefunc("MerchantFrame_OnShow", MerchantFrame_Active_OnShow) + hooksecurefunc("MerchantFrame_OnHide", MerchantFrame_Active_OnHide) + + end ----------------------------------------------------------------------