mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-25 21:40:49 +00:00
itemclick: hold shift to use item
This commit is contained in:
+44
-10
@@ -2,30 +2,64 @@ pfUI:RegisterModule("itemclick", "vanilla", function ()
|
|||||||
-- small module that tries to decide if an item should be used or dropped into
|
-- small module that tries to decide if an item should be used or dropped into
|
||||||
-- the auctionhouse search or trade window
|
-- the auctionhouse search or trade window
|
||||||
|
|
||||||
|
-- helper functions
|
||||||
|
local IsTrading = function()
|
||||||
|
return TradeFrame:IsShown()
|
||||||
|
end
|
||||||
|
|
||||||
|
local IsAuctionBrowsing = function()
|
||||||
|
return AuctionFrame and AuctionFrame:IsShown() and AuctionFrameBrowse and AuctionFrameBrowse:IsShown()
|
||||||
|
end
|
||||||
|
|
||||||
|
local IsAuctionSelling = function()
|
||||||
|
return AuctionFrame and AuctionFrame:IsShown() and AuctionFrameAuctions and AuctionFrameAuctions:IsShown()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- overwrite use/trade logic unless shift is pressed
|
||||||
local pfHookUseContainerItem = _G.UseContainerItem
|
local pfHookUseContainerItem = _G.UseContainerItem
|
||||||
function _G.UseContainerItem(bag,slot)
|
function _G.UseContainerItem(bag, slot)
|
||||||
if TradeFrame:IsShown() then
|
if IsTrading() and not IsShiftKeyDown() then
|
||||||
PickupContainerItem(bag,slot)
|
-- move item to trade window
|
||||||
|
PickupContainerItem(bag, slot)
|
||||||
local slot = TradeFrame_GetAvailableSlot()
|
local slot = TradeFrame_GetAvailableSlot()
|
||||||
if slot then ClickTradeButton(slot) end
|
if slot then ClickTradeButton(slot) end
|
||||||
if CursorHasItem() then
|
if CursorHasItem() then
|
||||||
ClearCursor()
|
ClearCursor()
|
||||||
end
|
end
|
||||||
elseif AuctionFrame and AuctionFrame:IsShown() and
|
elseif IsAuctionBrowsing() and not IsShiftKeyDown() then
|
||||||
AuctionFrameBrowse and AuctionFrameBrowse:IsShown() then
|
-- search item in auction house
|
||||||
local link = GetContainerItemLink(bag,slot)
|
local link = GetContainerItemLink(bag, slot)
|
||||||
local name = link and string.sub(link, string.find(link, "%[")+1, string.find(link, "%]")-1) or ""
|
local name = link and string.sub(link, string.find(link, "%[")+1, string.find(link, "%]")-1) or ""
|
||||||
BrowseName:SetText(name)
|
BrowseName:SetText(name)
|
||||||
AuctionFrameBrowse_Search()
|
AuctionFrameBrowse_Search()
|
||||||
elseif AuctionFrame and AuctionFrame:IsShown() and
|
elseif IsAuctionSelling() and not IsShiftKeyDown() then
|
||||||
AuctionFrameAuctions and AuctionFrameAuctions:IsShown() then
|
-- sell item to auction house
|
||||||
PickupContainerItem(bag,slot)
|
PickupContainerItem(bag, slot)
|
||||||
AuctionsItemButton:Click()
|
AuctionsItemButton:Click()
|
||||||
if CursorHasItem() then
|
if CursorHasItem() then
|
||||||
ClearCursor()
|
ClearCursor()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
pfHookUseContainerItem(bag,slot)
|
-- default action
|
||||||
|
pfHookUseContainerItem(bag, slot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- detect bag button tooltips
|
||||||
|
local showHelperNextTooltip = false
|
||||||
|
local pfHookSetBagItem = GameTooltip.SetBagItem
|
||||||
|
function GameTooltip.SetBagItem(self, container, slot)
|
||||||
|
showHelperNextTooltip = IsTrading() or IsAuctionBrowsing() or IsAuctionSelling()
|
||||||
|
return pfHookSetBagItem(self, container, slot)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- add helper text to tooltips
|
||||||
|
local tooltip = CreateFrame("Frame", "pfItemClickHelpMessage", GameTooltip)
|
||||||
|
tooltip:SetScript("OnShow", function()
|
||||||
|
if showHelperNextTooltip then
|
||||||
|
GameTooltip:AddLine(T["Hold [Shift] to use item."], 0.50, 0.75, 1.00)
|
||||||
|
GameTooltip:Show()
|
||||||
|
showHelperNextTooltip = false
|
||||||
|
end
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user