|
|
|
|
@ -126,6 +126,7 @@ function TSM:RegisterModule()
|
|
|
|
|
{ key = "avgSell", label = L["Avg Sell Price"], callback = "GetAvgSellPrice" }, |
|
|
|
|
{ key = "avgBuy", label = L["Avg Buy Price"], callback = "GetAvgBuyPrice" }, |
|
|
|
|
{ key = "smartAvgBuy", label = L["Smart Avg Buy Price"], callback = "GetSmartAvgBuyPrice" }, |
|
|
|
|
{ key = "lastBuy", label = L["Last Buy Price"], callback = "GetLastBuyPrice" }, |
|
|
|
|
{ key = "maxSell", label = L["Max Sell Price"], callback = "GetMaxSellPrice" }, |
|
|
|
|
{ key = "maxBuy", label = L["Max Buy Price"], callback = "GetMaxBuyPrice" }, |
|
|
|
|
{ key = "minSell", label = L["Min Sell Price"], callback = "GetMinSellPrice" }, |
|
|
|
|
@ -188,6 +189,7 @@ function TSM:GetTooltip(itemString)
|
|
|
|
|
|
|
|
|
|
if TSM.db.realm.tooltip.purchase and TSM.items[itemString] and #TSM.items[itemString].buys > 0 then |
|
|
|
|
local lastPurchased = TSM.items[itemString].buys[#TSM.items[itemString].buys].time |
|
|
|
|
local lastBuyPrice = TSM:GetLastBuyPrice(itemString) |
|
|
|
|
local totalPrice, totalNum = 0, 0 |
|
|
|
|
for _, record in ipairs(TSM.items[itemString].buys) do |
|
|
|
|
totalNum = totalNum + record.quantity |
|
|
|
|
@ -220,6 +222,13 @@ function TSM:GetTooltip(itemString)
|
|
|
|
|
if lastPurchased then |
|
|
|
|
local timeDiff = SecondsToTime(time() - lastPurchased) |
|
|
|
|
tinsert(text, { left = " " .. L["Last Purchased:"], right = "|cffffffff" .. format(L["%s ago"], timeDiff) }) |
|
|
|
|
if lastBuyPrice then |
|
|
|
|
if moneyCoinsTooltip then |
|
|
|
|
tinsert(text, { left = " " .. L["Last Buy Price:"], right = (TSMAPI:FormatTextMoneyIcon(lastBuyPrice, "|cffffffff", true) or ("|cffffffff" .. "?")) }) |
|
|
|
|
else |
|
|
|
|
tinsert(text, { left = " " .. L["Last Buy Price:"], right = (TSMAPI:FormatTextMoney(lastBuyPrice, "|cffffffff", true) or ("|cffffffff" .. "?")) }) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@ -575,6 +584,19 @@ function TSM:GetMinBuyPrice(itemString)
|
|
|
|
|
return TSM.cache[itemString].minBuyPrice |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function TSM:GetLastBuyPrice(itemString) |
|
|
|
|
itemString = TSMAPI:GetItemString(select(2, TSMAPI:GetSafeItemInfo(itemString))) |
|
|
|
|
if not (itemString and TSM.items[itemString] and #TSM.items[itemString].buys > 0) then return end |
|
|
|
|
TSM.cache[itemString] = TSM.cache[itemString] or {} |
|
|
|
|
|
|
|
|
|
if not TSM.cache[itemString].lastBuyPrice then |
|
|
|
|
local lastRecord = TSM.items[itemString].buys[#TSM.items[itemString].buys] |
|
|
|
|
TSM.cache[itemString].lastBuyPrice = lastRecord and lastRecord.copper or nil |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return TSM.cache[itemString].lastBuyPrice |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function TSM:Round(value, sig) |
|
|
|
|
sig = sig or 1 |
|
|
|
|
local gold = value / sig |
|
|
|
|
|