public
Description: WoW Addon - Fast alt-click item trading
Homepage: http://www.tekkub.net/
Clone URL: git://github.com/tekkub/daytrader.git
Click here to lend your support to: daytrader and make a donation at www.pledgie.com !
daytrader / DayTrader.lua
100644 48 lines (37 sloc) 1.351 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- Most of this code is grennon's from AltClickToAddItem, I just removed the dependancy on AceHooks
-- AltClickToAddItem based on GMail 1.x which was ported from CT_MailMod pre-1.5
 
local targ, bag, slot
 
 
local orig1 = ContainerFrameItemButton_OnModifiedClick
ContainerFrameItemButton_OnModifiedClick = function(self, button, ...)
  if button == "LeftButton" and IsAltKeyDown() and not CursorHasItem() then
    bag, slot = this:GetParent():GetID(), this:GetID()
if TradeFrame:IsVisible() then
      for i=1,6 do
        if not GetTradePlayerItemLink(i) then
PickupContainerItem(bag, slot)
          ClickTradeButton(i)
bag, slot = nil, nil
return
        end
      end
    elseif not CursorHasItem() and UnitExists("target") and UnitIsFriend("player", "target") and UnitIsPlayer("target") and CheckInteractDistance("target", 2) then
      targ = UnitName("target")
      InitiateTrade("target")
      return
    end
  end
  orig1(self, button, ...)
end
 
 
local function posthook(...)
  if targ and not CursorHasItem() and UnitName("target") == targ then
    PickupContainerItem(bag, slot)
    ClickTradeButton(1)
  end
  targ, bag, slot = nil, nil, nil
 
return ...
end
 
 
local orig2 = TradeFrame:GetScript("OnShow")
TradeFrame:SetScript("OnShow", function(...)
if orig2 then return posthook(orig2(...))
else posthook() end
end)