From 6bf635e8af9f4ac8140ef94991d26c72705ba772 Mon Sep 17 00:00:00 2001 From: Sattva Date: Sun, 17 Sep 2023 02:12:50 +0300 Subject: [PATCH] Rewrite NoBagAutomation module for 3.3.5 Generally because it wouldn't let me open bags by "Open All Bags" keybind. --- Changelog and Notes.txt | 2 ++ Leatrix_Plus.lua | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) 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 ----------------------------------------------------------------------