-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.lua
74 lines (62 loc) · 1.72 KB
/
Utils.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
assert(LibStub("AceAddon-3.0"):GetAddon("BetterBags"), "BetterBags_SnipersFilters requires BetterBags")
---@type string, AddonNS
local _, addon = ...
local Utils = {
Item = {}
}
-- Used for Debugging
local function GetItemTooltipLines(itemID)
local tooltip = C_TooltipInfo.GetItemByID(itemID)
return tooltip.lines
end
local function SSF_ItemHasText(itemID, text)
local hasText = false
local tooltip = C_TooltipInfo.GetItemByID(itemID)
for k,v in pairs(tooltip.lines) do
if v.leftText ~= nil then
if v.leftText:match(text) then
hasText = true
return true
end
end
if v.rightText ~= nil then
if v.rightText:match(text) then
hasText = true
return true
end
end
end
return hasText
end
local function GetCurrentExpansion()
return GetExpansionLevel()
end
local function PrefixFromExpacID(expacID)
local patchId = expacID + 1
if patchId < 10 then
return "0" .. patchId .. "."
end
return patchId .. "."
end
-- Neck/Ring/Cloak
local function IsJewelry(itemInfo)
if itemInfo.itemType == "Armor" then
if itemInfo.itemEquipLoc == "INVTYPE_FINGER" then
return true
end
if itemInfo.itemEquipLoc == "INVTYPE_NECK" then
return true
end
if itemInfo.itemEquipLoc == "INVTYPE_TRINKET" then
return true
end
else
return false
end
end
Utils.Item.HasText = SSF_ItemHasText
Utils.Item.IsJewelry = IsJewelry
Utils.GetCurrentExpansion = GetCurrentExpansion
Utils.GetItemTooltipLines = GetItemTooltipLines
Utils.PrefixFromExpacID = PrefixFromExpacID
addon.Utils = Utils