Skip to content

Commit

Permalink
2.5.4
Browse files Browse the repository at this point in the history
Added support for RECrystallize
Localized global functions to improve performance
  • Loading branch information
Noshei committed Oct 1, 2024
1 parent 5082a06 commit 027a52f
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 44 deletions.
15 changes: 15 additions & 0 deletions Bindings.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")

-- Localize global functions
local ipairs = ipairs
local math = math
local max = max
local next = next
local pairs = pairs
local select = select
local string = string
local table = table
local time = time
local tonumber = tonumber
local tostring = tostring
local type = type
local unpack = unpack

function GT:ToggleGatheringTracker()
GT.Debug("Toggle Gathering Tracker", 1, GT.db.profile.General.enable)
local key = not GT.db.profile.General.enable
Expand Down
15 changes: 15 additions & 0 deletions Broker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")
local ldb = LibStub("LibDataBroker-1.1")
local LibDBIcon = LibStub("LibDBIcon-1.0")

-- Localize global functions
local ipairs = ipairs
local math = math
local max = max
local next = next
local pairs = pairs
local select = select
local string = string
local table = table
local time = time
local tonumber = tonumber
local tostring = tostring
local type = type
local unpack = unpack

function GT:InitializeBroker()
GT.Debug("InitializeBroker", 1)
-- Create LibDataBroker data object
Expand Down
141 changes: 113 additions & 28 deletions Config.lua

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions DisplayCollapse.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")

-- Localize global functions
local ipairs = ipairs
local math = math
local max = max
local next = next
local pairs = pairs
local select = select
local string = string
local table = table
local time = time
local tonumber = tonumber
local tostring = tostring
local type = type
local unpack = unpack

function GT:CollapseDisplay()
GT.Debug("CollapseDisplay", 1)
for itemID, itemFrame in pairs(GT.Display.Frames) do
Expand Down
15 changes: 15 additions & 0 deletions DisplayCreation.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")
local media = LibStub:GetLibrary("LibSharedMedia-3.0")

-- Localize global functions
local ipairs = ipairs
local math = math
local max = max
local next = next
local pairs = pairs
local select = select
local string = string
local table = table
local time = time
local tonumber = tonumber
local tostring = tostring
local type = type
local unpack = unpack

local function FramePool_Resetter(framePool, frame)
frame:Hide()
frame:ClearAllPoints()
Expand Down
15 changes: 15 additions & 0 deletions FilterButton.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")

-- Localize global functions
local ipairs = ipairs
local math = math
local max = max
local next = next
local pairs = pairs
local select = select
local string = string
local table = table
local time = time
local tonumber = tonumber
local tostring = tostring
local type = type
local unpack = unpack

function GT:ToggleFilterButton(show)
if show then
GT.Debug("Show Filters Button", 1)
Expand Down
37 changes: 26 additions & 11 deletions GatheringTracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ GT.Notifications = {}
GT.NotificationPause = true
GT.GlobalStartTime = 0

-- Localize global functions
local ipairs = ipairs
local math = math
local max = max
local next = next
local pairs = pairs
local select = select
local string = string
local table = table
local time = time
local tonumber = tonumber
local tostring = tostring
local type = type
local unpack = unpack

GT.metaData = {
name = C_AddOns.GetAddOnMetadata("GatheringTracker", "Title"),
version = C_AddOns.GetAddOnMetadata("GatheringTracker", "Version"),
Expand Down Expand Up @@ -526,7 +541,7 @@ function GT:PrepareDataForDisplay(event, wait)

GT:SetupTotalsRow()

if GT.db.profile.General.characterValue and GT:GroupDisplayCheck() and GT.tsmLoaded then
if GT.db.profile.General.characterValue and GT:GroupDisplayCheck() and GT.priceSources then
local playerPriceTotals = {}
for senderIndex, senderData in ipairs(GT.sender) do
local playerTotal, playerPrice = GT:CalculateTotals(senderIndex, true)
Expand Down Expand Up @@ -577,8 +592,8 @@ function GT:SetupItemRows()
else
local totalItemCount, priceTotalItem = GT:CalculateTotals(nil, nil, itemID, true)
local pricePerItem = nil
if GT.tsmLoaded then
pricePerItem = (TSM_API.GetCustomPriceValue(GT.TSM, "i:" .. itemID) or 0) / 10000
if GT.priceSources then
pricePerItem = GT:GetItemPrice(itemID)
end
local itemsPerHour = GT:CalculateItemsPerHour(itemID)
local goldPerHour = itemsPerHour * (pricePerItem or 0)
Expand Down Expand Up @@ -624,8 +639,8 @@ function GT:CalculateItemsPerHourTotal(playerTotals)
startAmount = startAmount + itemData.startTotal

local itemPerHour = GT:CalculateItemsPerHour(itemID)
if itemPerHour and GT.tsmLoaded then
pricePerHour = pricePerHour + (itemPerHour * ((TSM_API.GetCustomPriceValue(GT.TSM, "i:" .. itemID) or 0) / 10000))
if itemPerHour and GT.priceSources then
pricePerHour = pricePerHour + (itemPerHour * GT:GetItemPrice(itemID))
end
end
end
Expand Down Expand Up @@ -688,8 +703,8 @@ function GT:RefreshPerHourDisplay(stop, wait)
local itemsPerHour = 0
local goldPerHour = 0
local pricePerItem = nil
if GT.tsmLoaded then
pricePerItem = (TSM_API.GetCustomPriceValue(GT.TSM, "i:" .. itemID) or 0) / 10000
if GT.priceSources then
pricePerItem = GT:GetItemPrice(itemID)
end

if itemFrame.itemsPerHour and GT.db.profile.General.itemsPerHour then
Expand Down Expand Up @@ -1034,8 +1049,8 @@ function GT:CalculatePlayerTotals(senderIndex, calcSenderValue)
for itemID, itemCount in pairs(GT.sender[senderIndex].inventoryData) do
if itemID > #GT.ItemData.Other.Other and itemCount - GT.db.profile.General.ignoreAmount > 0 then
total = total + itemCount
if calcSenderValue and GT.tsmLoaded then
value = value + (itemCount * (TSM_API.GetCustomPriceValue(GT.TSM, "i:" .. itemID) or 0) / 10000)
if calcSenderValue and GT.priceSources then
value = value + (itemCount * GT:GetItemPrice(itemID))
end
end
end
Expand All @@ -1052,8 +1067,8 @@ function GT:CalculateItemTotals(itemID, calcItemValue)
total = total + itemCount
end
end
if calcItemValue and GT.tsmLoaded then
value = (total * (TSM_API.GetCustomPriceValue(GT.TSM, "i:" .. itemID) or 0) / 10000)
if calcItemValue and GT.priceSources then
value = (total * GT:GetItemPrice(itemID))
end
GT.InventoryData[itemID].total = total
return total, math.ceil(value - 0.5) --rounds up to whole number
Expand Down
4 changes: 2 additions & 2 deletions GatheringTracker.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
## Title: Gathering Tracker
## Notes: Addon for tracking gathered items, supports solo players and groups
## Author: Noshei
## Version: 2.5.3
## OptionalDeps: TradeSkillMaster
## Version: 2.5.4
## OptionalDeps: TradeSkillMaster, RECrystallize
## SavedVariables: GatheringTrackerDB
## AddonCompartmentFunc: GatheringTracker_OnAddonCompartmentClick
## IconTexture: 3692438
Expand Down
21 changes: 18 additions & 3 deletions NotificationHandler.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")
local media = LibStub:GetLibrary("LibSharedMedia-3.0")

-- Localize global functions
local ipairs = ipairs
local math = math
local max = max
local next = next
local pairs = pairs
local select = select
local string = string
local table = table
local time = time
local tonumber = tonumber
local tostring = tostring
local type = type
local unpack = unpack

function GT:NotificationHandler(mode, id, amount, value)
GT.Debug("Notifications Handler", 5, mode, id, amount, value)

Expand Down Expand Up @@ -110,13 +125,13 @@ function GT:NotificationHandler(mode, id, amount, value)
end
end

if GT.db.profile.Notifications.Gold.enable and GT.tsmLoaded and GT.db.profile.General.tsmPrice > 0 then
if GT.db.profile.Notifications.Gold.enable and GT.priceSources and GT.db.profile.General.tsmPrice > 0 then
if mode == "all" and (GT.db.profile.Notifications.Gold.itemAll == 1 or GT.db.profile.Notifications.Gold.itemAll == 2) then --All Items or Both
NotificationCheck("Gold", false)
end
if mode == "each" and (GT.db.profile.Notifications.Gold.itemAll == 0 or GT.db.profile.Notifications.Gold.itemAll == 2) then --Each Item or Both
if GT.db.profile.General.tsmPrice > 0 then
local eprice = (TSM_API.GetCustomPriceValue(GT.TSM, "i:" .. tostring(id)) or 0) / 10000
local eprice = GT:GetItemPrice(id)
value = math.ceil(eprice * amount)
NotificationCheck("Gold", false)
end
Expand All @@ -135,7 +150,7 @@ function GT:NotificationHandler(mode, id, amount, value)
playerTotal = playerTotal + amount
NotificationCheck("Count", true)
if GT.db.profile.General.tsmPrice > 0 then
local eprice = (TSM_API.GetCustomPriceValue(GT.TSM, "i:" .. tostring(itemID)) or 0) / 10000
local eprice = GT:GetItemPrice(itemID)
value = math.ceil(eprice * amount)
NotificationCheck("Gold", true)
end
Expand Down
34 changes: 34 additions & 0 deletions Utilities.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")

-- Localize global functions
local ipairs = ipairs
local math = math
local max = max
local next = next
local pairs = pairs
local select = select
local string = string
local table = table
local time = time
local tonumber = tonumber
local tostring = tostring
local type = type
local unpack = unpack

function GT:AddComas(str)
return #str % 3 == 0 and str:reverse():gsub("(%d%d%d)", "%1,"):reverse():sub(2) or str:reverse():gsub("(%d%d%d)", "%1,"):reverse()
end
Expand Down Expand Up @@ -246,3 +261,22 @@ function GT:CheckColumnSize(index, frame)
return
end
end

function GT:GetItemPrice(itemID)
if not GT.priceSources then
return
end
if GT.db.profile.General.tsmPrice == 0 then
return 0
end
local itemID = tonumber(itemID)
local price = 0

if GT.priceSources["RECrystallize"] and GT.db.profile.General.tsmPrice == 10 then
price = (RECrystallize_PriceCheckItemID(itemID) or 0) / 10000
end
if GT.priceSources["TradeSkillMaster"] then
price = (TSM_API.GetCustomPriceValue(GT.TSM, "i:" .. itemID) or 0) / 10000
end
return price
end

0 comments on commit 027a52f

Please sign in to comment.