forked from cdmichaelb/Outfitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OutfitterQuickSlots.lua
63 lines (54 loc) · 2.61 KB
/
OutfitterQuickSlots.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
--[[----------------------------------------
Outfitter._FlyoutQuickSlots = {}
----------------------------------------
function Outfitter._FlyoutQuickSlots:Construct()
for _, vSlotName in ipairs(Outfitter.cSlotNames) do
local vSlotButton = _G["Character"..vSlotName]
if vSlotButton then
Outfitter:HookScript(vSlotButton, "PreClick", function (...) self:PreClick(...) end)
Outfitter:HookScript(vSlotButton, "PostClick", function (...) self:PostClick(...) end)
end
end
local vFlyoutSettings = PaperDollItemsFrame.flyoutSettings
local vOrigGetItemsFunc = vFlyoutSettings.getItemsFunc
vFlyoutSettings.getItemsFunc = function (pSlotID, pItemTable, ...)
vOrigGetItemsFunc(pSlotID, pItemTable, ...)
-- Remove items on the player from the choices
for vLocation, vItemID in next, pItemTable do
local vOnPlayer = bit.band(vLocation, ITEM_INVENTORY_LOCATION_PLAYER + ITEM_INVENTORY_LOCATION_BAGS + ITEM_INVENTORY_LOCATION_BANK) == ITEM_INVENTORY_LOCATION_PLAYER
if vOnPlayer then pItemTable[vLocation] = nil end
end
end
local vOrigPostGetItemsFunc = vFlyoutSettings.postGetItemsFunc
vFlyoutSettings.postGetItemsFunc = function (pItemSlotButton, pItemDisplayTable, pNumItems)
local vNumItems = vOrigPostGetItemsFunc(pItemSlotButton, pItemDisplayTable, pNumItems)
-- If the first item is the PLACEINBAGS item, then move it to the end
if vNumItems > 0 and (pItemDisplayTable[1] == EQUIPMENTFLYOUT_PLACEINBAGS_LOCATION) then
table.remove(pItemDisplayTable, 1)
table.insert(pItemDisplayTable, EQUIPMENTFLYOUT_PLACEINBAGS_LOCATION)
end
return vNumItems
end
end
function Outfitter._FlyoutQuickSlots:PreClick(pButton, ...)
self.CurrentInventorySlot = Outfitter.cSlotIDToInventorySlot[pButton:GetID()]
end
function Outfitter._FlyoutQuickSlots:PostClick(pButton, ...)
local vSlotItemLink = Outfitter:GetInventorySlotIDLink(pButton.id or pButton:GetID())
if EquipmentFlyoutFrame:IsVisible() and EquipmentFlyoutFrame.button == pButton then
EquipmentFlyoutFrame:Hide()
-- If there's an item on the cursor after clicking or the slot is empty then open the flyout
else
if CursorHasItem() or not vSlotItemLink then
pButton.popoutButton.flyoutLocked = true
EquipmentFlyout_Show(pButton)
EquipmentFlyoutPopoutButton_SetReversed(pButton.popoutButton, true)
end
end
----------------------------------------
----------------------------------------
function Outfitter:InitializeQuickSlots()
Outfitter.QuickSlots = Outfitter:New(Outfitter._FlyoutQuickSlots)
end
Outfitter:RegisterOutfitEvent("OUTFITTER_INIT", function () Outfitter:InitializeQuickSlots() end)
--]]