From 6a315f9e41c4edf2989c81f00e181a1ebf8fe80c Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 29 Sep 2018 02:16:52 +0200 Subject: [PATCH] itemclick: move click handler into seperate module --- api/tbc.lua | 3 ++- modules/bags.lua | 27 --------------------------- modules/itemclick.lua | 31 +++++++++++++++++++++++++++++++ pfUI.toc | 1 + 4 files changed, 34 insertions(+), 28 deletions(-) create mode 100644 modules/itemclick.lua diff --git a/api/tbc.lua b/api/tbc.lua index 80ad29dc..8695873f 100644 --- a/api/tbc.lua +++ b/api/tbc.lua @@ -42,8 +42,9 @@ end -- blacklist unrequired modules pfUI.module.autoshift = true +pfUI.module.itemclick = true --- keyring returns +-- the function GetContainerNumSlots returns numbers for keyrings in tbc function pfUI.api.GetContainerNumSlots(bag) if bag == -2 and pfUI.bag and not pfUI.bag.showKeyring then return 0 diff --git a/modules/bags.lua b/modules/bags.lua index 9d7c9692..7c2cd6e0 100644 --- a/modules/bags.lua +++ b/modules/bags.lua @@ -45,33 +45,6 @@ pfUI:RegisterModule("bags", function () return end - local pfHookUseContainerItem = _G.UseContainerItem - function _G.UseContainerItem(bag,slot) - if TradeFrame:IsShown() then - PickupContainerItem(bag,slot) - local slot = TradeFrame_GetAvailableSlot() - if slot then ClickTradeButton(slot) end - if CursorHasItem() then - ClearCursor() - end - elseif AuctionFrame and AuctionFrame:IsShown() and - AuctionFrameBrowse and AuctionFrameBrowse:IsShown() then - local link = GetContainerItemLink(bag,slot) - local name = link and string.sub(link, string.find(link, "%[")+1, string.find(link, "%]")-1) or "" - BrowseName:SetText(name) - AuctionFrameBrowse_Search() - elseif AuctionFrame and AuctionFrame:IsShown() and - AuctionFrameAuctions and AuctionFrameAuctions:IsShown() then - PickupContainerItem(bag,slot) - AuctionsItemButton:Click() - if CursorHasItem() then - ClearCursor() - end - else - pfHookUseContainerItem(bag,slot) - end - end - -- hide blizzard's bankframe BankFrame:SetScale(0.001) BankFrame:SetPoint("TOPLEFT", 0,0) diff --git a/modules/itemclick.lua b/modules/itemclick.lua new file mode 100644 index 00000000..cc5bcb79 --- /dev/null +++ b/modules/itemclick.lua @@ -0,0 +1,31 @@ +pfUI:RegisterModule("itemclick", function () + -- small module that tries to decide if an item should be used or dropped into + -- the auctionhouse search or trade window + + local pfHookUseContainerItem = _G.UseContainerItem + function _G.UseContainerItem(bag,slot) + if TradeFrame:IsShown() then + PickupContainerItem(bag,slot) + local slot = TradeFrame_GetAvailableSlot() + if slot then ClickTradeButton(slot) end + if CursorHasItem() then + ClearCursor() + end + elseif AuctionFrame and AuctionFrame:IsShown() and + AuctionFrameBrowse and AuctionFrameBrowse:IsShown() then + local link = GetContainerItemLink(bag,slot) + local name = link and string.sub(link, string.find(link, "%[")+1, string.find(link, "%]")-1) or "" + BrowseName:SetText(name) + AuctionFrameBrowse_Search() + elseif AuctionFrame and AuctionFrame:IsShown() and + AuctionFrameAuctions and AuctionFrameAuctions:IsShown() then + PickupContainerItem(bag,slot) + AuctionsItemButton:Click() + if CursorHasItem() then + ClearCursor() + end + else + pfHookUseContainerItem(bag,slot) + end + end +end) diff --git a/pfUI.toc b/pfUI.toc index 6617714f..51caced0 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -82,6 +82,7 @@ modules\xpbar.lua modules\autoshift.lua modules\autovendor.lua modules\bags.lua +modules\itemclick.lua modules\cooldown.lua modules\tooltip.lua modules\thirdparty.lua