Browse Source

show last buy price in tooltips

dev
Jørgen Lien Sellæg 4 months ago
parent
commit
269852a19a
  1. 1
      README.md
  2. 2
      TradeSkillMaster/TradeSkillMaster.toc
  3. 2
      TradeSkillMaster_Accounting/Locale/enUS.lua
  4. 22
      TradeSkillMaster_Accounting/TradeSkillMaster_Accounting.lua
  5. 4
      TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc

1
README.md

@ -44,6 +44,7 @@ TSM price strings can reference built-in data sources and combine them with math
- `avgSell`: Average sell price.
- `avgBuy`: Average buy price.
- `smartAvgBuy`: Smart average buy price (uses current holdings to weight recent buys).
- `lastBuy`: Last buy price (most recent purchase; also shown under Last Purchased in Accounting tooltips).
- `maxSell`: Maximum sell price.
- `maxBuy`: Maximum buy price.
- `minSell`: Minimum sell price.

2
TradeSkillMaster/TradeSkillMaster.toc

@ -2,7 +2,7 @@
## Title: |cff00fe00TradeSkillMaster: Revived|r
## Notes: Core addon for the TradeSkillMaster suite, revived for Wrath of the Lich King. Does nothing without modules installed.
## Author: Sapu94, Bart39, Gnomezilla [Warmane-Icecrown(A)], BlueAo [Warmane], andrew6180, Yoshiyuka, DimaSheiko, and other contributors...
## Version: 2.3.25
## Version: 2.3.27
## SavedVariables: TradeSkillMasterAppDB, AscensionTSMDB
## OptionalDeps: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0, SharedMedia, TheUndermineJournal, TheUndermineJournalGE
## X-Embeds: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0

2
TradeSkillMaster_Accounting/Locale/enUS.lua

@ -24,6 +24,8 @@ L["Average Prices:"] = true
L["Avg Buy Price"] = true
L["Avg Resale Profit"] = true
L["Avg Sell Price"] = true
L["Last Buy Price"] = true
L["Last Buy Price:"] = true
L["Smart Avg Buy Price:"] = true
L["Smart Avg Buy Price"] = true
L["Back to Previous Page"] = true

22
TradeSkillMaster_Accounting/TradeSkillMaster_Accounting.lua

@ -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

4
TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc

@ -2,10 +2,10 @@
## Title: |cff00ff00TradeSkillMaster_AuctionDB|r
## Notes: Stores auction house data and calculates market prices.
## Author: Sapu94, Bart39
## Version: 2.3.25
## Version: 2.3.27
## SavedVariables: AscensionTSM_AuctionDB
## Dependency: TradeSkillMaster
## X-Curse-Packaged-Version: 2.3.25
## X-Curse-Packaged-Version: 2.3.27
## X-Curse-Project-Name: TradeSkillMaster_AuctionDB
## X-Curse-Project-ID: tradeskillmaster_auctiondb
## X-Curse-Repository-ID: wow/tradeskillmaster_auctiondb/mainline

Loading…
Cancel
Save