-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtsm.lua
77 lines (62 loc) · 1.89 KB
/
tsm.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
local Addon = select(2, ...)
local TSM = {}
Addon.TSM = TSM
-- TSM4
local TSM_API = _G.TSM_API
function TSM.IsLoaded()
if TSM_API then
return true
end
return false
end
function TSM.GetItemValue(itemLink, priceSource)
if TSM_API and TSM_API.GetCustomPriceValue then
-- Addon.Debug.Log(format(" TSM_API.ToItemString %s", itemLink))
local tsmItemLink = TSM_API.ToItemString(itemLink)
if not tsmItemLink then
-- Addon.Debug.Log(format(" Cannot create tsmItemLink for %s, skipping", itemLink))
return 0
end
-- Addon.Debug.Log(format(" TSM_API.GetCustomPriceValue() %s %s", priceSource, tsmItemLink))
return TSM_API.GetCustomPriceValue(priceSource, tsmItemLink)
end
return 0
end
function TSM.GetAvailablePriceSources()
-- Addon.Debug.Log("tsm.GetAvailablePriceSources()")
if not TSM.IsLoaded() then
-- Addon.Debug.Log("tsm.GetAvailablePriceSources: TSM not loaded")
return
end
local priceSources = {}
local keys = {}
-- filter
local tsmPriceSources = {}
TSM_API.GetPriceSourceKeys(tsmPriceSources)
-- TSM registers price sources from other addons
-- so lets filter to only the ones we should
-- know about
local validSources = {
["DBHistorical"] = true,
["DBMarket"] = true,
["DBMinBuyout"] = true,
["DBRegionHistorical"] = true,
["DBRegionMarketAvg"] = true,
["DBRegionMinBuyoutAvg"] = true,
["DBRegionSaleAvg"] = true,
["DBRecent"] = true,
["VendorSell"] = true,
}
for k, v in pairs(tsmPriceSources) do
if Addon.CONST.PRICE_SOURCE[k] and validSources[k] then
table.insert(keys, k)
elseif Addon.CONST.PRICE_SOURCE[v] and validSources[v] then
table.insert(keys, v)
end
end
sort(keys)
for _, v in ipairs(keys) do
priceSources[v] = Addon.CONST.PRICE_SOURCE[v]
end
return priceSources
end