-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathInspect.lua
90 lines (85 loc) · 2.6 KB
/
Inspect.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
local CM = ClickMorph
if CM.isClassic then return end
local f = CreateFrame("Frame")
local InvSlotsOrder = {
INVSLOT_HEAD, -- 1
INVSLOT_SHOULDER, -- 3
INVSLOT_BODY, -- 4
INVSLOT_CHEST, -- 5
INVSLOT_WAIST, -- 6
INVSLOT_LEGS, -- 7
INVSLOT_FEET, -- 8
INVSLOT_WRIST, -- 9
INVSLOT_HAND, -- 10
INVSLOT_BACK, -- 15
INVSLOT_MAINHAND, -- 16
INVSLOT_OFFHAND, -- 17
INVSLOT_RANGED, -- 18
INVSLOT_TABARD, -- 19
}
function f:OnEvent(event, addon)
if addon == "Blizzard_InspectUI" then
self:InitializeInspect()
self:UnregisterEvent(event)
end
end
if IsAddOnLoaded("Blizzard_InspectUI") then
f:InitializeInspect()
else
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", f.OnEvent)
end
function f:InitializeInspect()
InspectModelFrame:HookScript("OnMouseUp", function()
if IsAltKeyDown() then
local unit = InspectFrame.unit
local items = {}
CM:Undress()
if not CM.isRetail then
for _, slotID in pairs(InvSlotsOrder) do
local itemLink = GetInventoryItemLink(InspectFrame.unit, slotID)
if itemLink then
tinsert(items, {slotID, itemLink})
end
end
else
for _, slotID in pairs(InvSlotsOrder) do
local itemID, itemModID = GetInventoryItemID(InspectFrame.unit, slotID) -- GetInventoryItemID returns the transmogged item
local itemLink = GetInventoryItemLink(InspectFrame.unit, slotID) -- GetInventoryItemLink returns the actual item (link)
if itemID then
local _, sourceID = C_TransmogCollection.GetItemInfo(itemID, itemModID)
if sourceID then
local source = C_TransmogCollection.GetSourceInfo(sourceID)
tinsert(items, {slotID, source})
else
-- some items dont return a sourceID:
-- * some artifacts
-- * items with suffixes like "of the Fireflash", mostly with itemModID 5
-- * class specific gear, like 157685:0 [Spellsculptor's Leggings]
CM:PrintChat(format("Error: Could not find sourceID for inventorySlot %d, itemID %d:%d, %s",
slotID, itemID, itemModID, itemLink), 1, 1, 0)
end
end
end
end
-- sort by Inventory Slot
sort(items, function(a, b)
return a[1] < b[1]
end)
if not CM.isRetail then
for _, v in pairs(items) do
CM:MorphItem("player", v[2], true)
end
else
for _, v in pairs(items) do
CM:MorphItemBySource("player", v[2], true)
end
end
local class = UnitClassBase(unit)
local hex = select(4, GetClassColor(class))
local fullName = GetUnitName(unit, true)
local unitLink = "|c"..TEXT_MODE_A_STRING_DEST_UNIT:format(hex, UnitGUID(unit), fullName, fullName)
CM:PrintChat(format("items -> %s", unitLink))
end
end)
end