-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGH_CharacterFrame.lua
More file actions
executable file
·186 lines (163 loc) · 6.28 KB
/
GH_CharacterFrame.lua
File metadata and controls
executable file
·186 lines (163 loc) · 6.28 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
local slotConverter = {
-- Left
[1] = "HeadSlotFrame",
[2] = "NeckSlotFrame",
[3] = "ShoulderSlotFrame",
[15] = "BackSlotFrame",
[5] = "ChestSlotFrame",
[4] = "ShirtSlotFrame",
[19] = "TabardSlotFrame",
[9] = "WristSlotFrame",
--- Right
[10] = "HandsSlotFrame",
[6] = "WaistSlotFrame",
[7] = "LegsSlotFrame",
[8] = "FeetSlotFrame",
[11] = "Finger0SlotFrame",
[12] = "Finger1SlotFrame",
[13] = "Trinket0SlotFrame",
[14] = "Trinket1SlotFrame",
-- Bottom
[16] = "MainHandSlotFrame",
[17] = "SecondaryHandSlotFrame"
}
-- ! ////////// ////////// Character Frame \\\\\\\\\\ \\\\\\\\\\ ! --
local function CharFrameShow(_)
if not GearHelper.db.profile.ilvlCharFrame then
do
return
end
end
table.foreach(
GearHelperVars.charInventory,
function(slotID, item, number)
if (item ~= -1) then
local xOffset = 0
local yOffset = -2
local parentAnchor = ""
local childAnchor = ""
if (slotID < 6 or slotID == 9 or slotID == 15 or slotID == 19) then
xOffset = 5
yOffset = 0
parentAnchor = "RIGHT"
childAnchor = "LEFT"
elseif (slotID < 16) then
xOffset = -5
yOffset = 0
parentAnchor = "LEFT"
childAnchor = "RIGHT"
else
xOffset = 0
yOffset = 5
parentAnchor = "TOP"
childAnchor = "BOTTOM"
end
local name = "Character" .. slotConverter[slotID]
local pFrame = _G[name]
local button = _G["charIlvlSlotFrame" .. slotID] or CreateFrame("Frame", "charIlvlSlotFrame" .. slotID, CharacterFrame) -- Our frame
button:SetPoint(childAnchor, pFrame, parentAnchor, xOffset, yOffset)
button:SetSize(50, 25)
button:SetFrameStrata("HIGH")
-- FontStrings only need a position set. By default, they size automatically according to the text shown.
local text = _G["charIlvlSlotText" .. slotID] or button:CreateFontString("charIlvlSlotText" .. slotID, "OVERLAY", "GameFontNormal") -- Our text area
text:SetPoint(childAnchor, pFrame, parentAnchor, xOffset, yOffset)
local itemScan = GHItem:Create(item.itemLink)
local itemLink, iR, itemLevel, itemEquipLoc = itemScan.itemLink, itemScan.rarity, itemScan.iLvl, itemScan.equipLoc
if (itemLevel > 0) then
text:SetText(itemLevel)
local r, g, b = GetItemQualityColor(iR and iR or 0)
text:SetTextColor(r, g, b, 1)
text:Show()
end
button:Show()
end
end
)
end
local function CharFrameHide()
table.foreach(
GearHelperVars.charInventory,
function(slotID, _)
if (_G["charIlvlSlotFrame" .. slotID]) then
_G["charIlvlSlotFrame" .. slotID]:Hide()
end
end
)
end
function GearHelper:AddIlvlOnCharFrame()
PaperDollItemsFrame:HookScript("OnShow", CharFrameShow)
PaperDollItemsFrame:HookScript("OnHide", CharFrameHide)
end
function GearHelper:ResetIlvlOnCharFrame()
CharFrameHide()
if (PaperDollItemsFrame:IsVisible()) then
CharFrameShow()
end
end
-- ! ////////// ////////// Inspect Frame \\\\\\\\\\ \\\\\\\\\\ ! --
local function InspectFrameShow()
if not GearHelper.db.profile.ilvlInspectFrame then
do
return
end
end
-- For ids in slotConverter
for slotID, slotName in pairs(slotConverter) do
local itemLink = GetInventoryItemLink("target", slotID)
if (itemLink) and (itemLink ~= -1) then
local xOffset = 0
local yOffset = -2
local parentAnchor = ""
local childAnchor = ""
if (slotID < 6 or slotID == 9 or slotID == 15 or slotID == 19) then
xOffset = 5
yOffset = 0
parentAnchor = "RIGHT"
childAnchor = "LEFT"
elseif (slotID < 16) then
xOffset = -5
yOffset = 0
parentAnchor = "LEFT"
childAnchor = "RIGHT"
else
xOffset = 0
yOffset = 5
parentAnchor = "TOP"
childAnchor = "BOTTOM"
end
local name = "Inspect" .. slotConverter[slotID]
local pFrame = _G[name]
local button = _G["inspectIlvlSlotFrame" .. slotID] or CreateFrame("Frame", "inspectIlvlSlotFrame" .. slotID, InspectPaperDollItemsFrame) -- Our frame
button:SetPoint(childAnchor, pFrame, parentAnchor, xOffset, yOffset)
button:SetSize(50, 25)
button:SetFrameStrata("TOOLTIP")
-- FontStrings only need a position set. By default, they size automatically according to the text shown.
local text = _G["inspectIlvlSlotText" .. slotID] or button:CreateFontString("inspectIlvlSlotText" .. slotID, "OVERLAY", "GameFontNormal") -- Our text area
text:SetPoint(childAnchor, pFrame, parentAnchor, xOffset, yOffset)
local itemScan = GHItem:Create(itemLink)
local itemLink, iR, itemLevel, itemEquipLoc = itemScan.itemLink, itemScan.rarity, itemScan.iLvl, itemScan.equipLoc
if (itemLevel > 0) then
text:SetText(itemLevel)
local r, g, b = GetItemQualityColor(iR and iR or 0)
text:SetTextColor(r, g, b, 1)
text:Show()
end
button:Show()
end
end
end
local function InspectFrameHide()
table.foreach(
slotConverter,
function(slotID, _)
if (_G["inspectIlvlSlotFrame" .. slotID]) then
_G["inspectIlvlSlotFrame" .. slotID]:Hide()
end
end
)
GearHelperVars.unitInspected = nil
end
function GearHelper:HookInspectFrame()
InspectPaperDollItemsFrame:HookScript("OnShow", InspectFrameShow)
InspectPaperDollItemsFrame:HookScript("OnHide", InspectFrameHide)
end