From ba48ff95ba35076e98d0d496c7214f10ce028c1c Mon Sep 17 00:00:00 2001 From: Anthony Narkevicius Date: Sat, 25 Nov 2023 16:24:10 -0800 Subject: [PATCH] fix error with destroy window in combat (#10) * Fix GetAll scan functionality * fix error with destroy window in combat --- TradeSkillMaster_Destroying/Modules/gui.lua | 39 +++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/TradeSkillMaster_Destroying/Modules/gui.lua b/TradeSkillMaster_Destroying/Modules/gui.lua index d09dd3a..ae5a078 100644 --- a/TradeSkillMaster_Destroying/Modules/gui.lua +++ b/TradeSkillMaster_Destroying/Modules/gui.lua @@ -236,7 +236,18 @@ end function GUI:UNIT_SPELLCAST_INTERRUPTED(_, unit) if unit == "player" and private.frame and private.frame:IsVisible() then TSMAPI:CancelFrame("destroyEnableDelay") - private.frame.destroyBtn:Enable() + if InCombatLockdown() then + TSMAPI:CreateTimeDelay("destroyEnableDelay", 1, + function() + if not UnitCastingInfo("player") + and not LootFrame:IsVisible() + and not InCombatLockdown() then + private.frame.destroyBtn:Enable() + end + end) + else + private.frame.destroyBtn:Enable() + end end end @@ -271,13 +282,35 @@ function private:LootChanged() local quantity = select(2, GetContainerItemInfo(private.tempData.bag, private.tempData.slot)) if quantity == private.tempData.quantity or quantity == private.tempData.perDestroy then TSMAPI:CancelFrame("destroyEnableDelay") - private.frame.destroyBtn:Enable() + if InCombatLockdown() then + TSMAPI:CreateTimeDelay("destroyEnableDelay", 1, + function() + if not UnitCastingInfo("player") + and not LootFrame:IsVisible() + and not InCombatLockdown() then + private.frame.destroyBtn:Enable() + end + end) + else + private.frame.destroyBtn:Enable() + end end end elseif private.highStack and GetNumLootItems() <= 1 then if private.frame and private.frame:IsVisible() then TSMAPI:CancelFrame("destroyEnableDelay") - private.frame.destroyBtn:Enable() + if InCombatLockdown() then + TSMAPI:CreateTimeDelay("destroyEnableDelay", 1, + function() + if not UnitCastingInfo("player") + and not LootFrame:IsVisible() + and not InCombatLockdown() then + private.frame.destroyBtn:Enable() + end + end) + else + private.frame.destroyBtn:Enable() + end end end end \ No newline at end of file