This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
item.lua
executable file
·131 lines (102 loc) · 2.73 KB
/
item.lua
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
--[[
item.lua
A guild item slot button
--]]
local Bagnon = LibStub('AceAddon-3.0'):GetAddon('Bagnon')
local ItemSlot = Bagnon:NewClass('GuildItemSlot', 'Button', Bagnon.ItemSlot)
ItemSlot.GUILDBANK_ITEM_LOCK_CHANGED = ItemSlot.UpdateLocked
ItemSlot.nextID = 0
--[[ Constructor ]]--
function ItemSlot:SetFrame(parent, tab, slot)
self:SetSlot(tab, slot)
self:SetParent(parent)
end
function ItemSlot:Create()
local item = Bagnon.ItemSlot.Create(self)
item:SetScript('OnReceiveDrag', self.OnReceiveDrag)
item:SetScript('OnDragStart', self.OnDragStart)
item:SetScript('OnClick', self.OnClick)
item:RegisterForDrag('LeftButton')
item:RegisterForClicks('anyUp')
return item
end
function ItemSlot:ConstructNewItemSlot(id)
return CreateFrame('Button', 'BagnonGuildItemSlot' .. id, nil, 'ContainerFrameItemButtonTemplate')
end
function ItemSlot:CanReuseBlizzardBagSlots()
return nil
end
--[[ Events ]]--
function ItemSlot:OnClick(button)
if HandleModifiedItemClick(self:GetItem()) then
return
end
if IsModifiedClick('SPLITSTACK') then
if not self:IsLocked() then
self.SplitStack = ItemSlot.SplitStack -- have no idea why is necessary
OpenStackSplitFrame(select(2, self:GetInfo()), self, 'BOTTOMLEFT', 'TOPLEFT')
end
return
end
local type, money = GetCursorInfo()
if type == 'money' then
DepositGuildBankMoney(money)
ClearCursor()
elseif type == 'guildbankmoney' then
DropCursorMoney()
ClearCursor()
elseif button == 'RightButton' then
AutoStoreGuildBankItem(self:GetSlot())
else
PickupGuildBankItem(self:GetSlot())
end
end
function ItemSlot:OnDragStart(button)
PickupGuildBankItem(self:GetSlot())
end
function ItemSlot:OnReceiveDrag(button)
PickupGuildBankItem(self:GetSlot())
end
function ItemSlot:OnShow()
self:RegisterEvent('GUILDBANK_ITEM_LOCK_CHANGED')
self:Update()
end
function ItemSlot:OnEnter()
if self:GetItem() then
self:AnchorTooltip()
self:UpdateTooltip()
end
end
--[[ Updaters ]]--
function ItemSlot:UpdateTooltip()
GameTooltip:SetGuildBankItem(self:GetSlot())
GameTooltip:Show()
end
function ItemSlot:SplitStack(split)
local tab, slot = self:GetSlot()
SplitGuildBankItem(tab, slot, split)
end
function ItemSlot:UpdateCooldown() -- fake method
end
--[[ Accessors ]]--
function ItemSlot:SetSlot(tab, slot)
self.tab = tab
self:SetID(slot)
self:Update()
end
function ItemSlot:GetSlot()
return self.tab, self:GetID()
end
function ItemSlot:GetInfo()
local slot, tab = self:GetSlot()
local link = GetGuildBankItemLink(slot, tab)
local icon, count, locked = GetGuildBankItemInfo(slot, tab)
local quality = link and select(3, GetItemInfo(link))
return icon, count, locked, quality, nil, nil, link
end
function ItemSlot:IsQuestItem()
return false
end
function ItemSlot:IsCached()
return false
end