Skip to content

Commit

Permalink
3.0.4
Browse files Browse the repository at this point in the history
Added Session Timer (under Other Filters)
Fixed error on first login
  • Loading branch information
Noshei committed Nov 13, 2024
1 parent ef815ba commit a62204a
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 99 deletions.
97 changes: 57 additions & 40 deletions Config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ local unpack = unpack
GT.defaults = {
profile = {
General = {
fixSettings = 0,
enable = true,
unlock = false,
filtersButton = false,
Expand Down Expand Up @@ -664,6 +665,7 @@ local generalOptions = {
set = function(_, key)
GT.db.profile.General.multiColumn = key
GT:AllignRows()
GT:AllignColumns()
end,
order = 301
},
Expand All @@ -680,6 +682,7 @@ local generalOptions = {
GT.db.profile.General.numRows = key
if not GT.db.profile.General.collapseDisplay then
GT:AllignRows()
GT:AllignColumns()
end
end,
disabled = function()
Expand Down Expand Up @@ -807,14 +810,14 @@ local generalOptions = {
if itemID < 9999999998 then
for textIndex, textFrame in ipairs(itemFrame.text) do
textFrame:SetFont(media:Fetch("font", GT.db.profile.General.textFont), GT.db.profile.General.textSize, "OUTLINE")
GT:CheckColumnSize(textIndex, textFrame)
GT:CheckColumnSize(textIndex, textFrame, itemID)
end

local frameHeight = math.max(GT.db.profile.General.iconHeight, key)
itemFrame:SetHeight(frameHeight + 3)
else
for textIndex, textFrame in ipairs(itemFrame.text) do
GT:CheckColumnSize(textIndex, textFrame)
GT:CheckColumnSize(textIndex, textFrame, itemID)
end
end
end
Expand All @@ -836,11 +839,11 @@ local generalOptions = {
if itemID < 9999999998 then
for textIndex, textFrame in ipairs(itemFrame.text) do
textFrame:SetFont(media:Fetch("font", GT.db.profile.General.textFont), GT.db.profile.General.textSize, "OUTLINE")
GT:CheckColumnSize(textIndex, textFrame)
GT:CheckColumnSize(textIndex, textFrame, itemID)
end
else
for textIndex, textFrame in ipairs(itemFrame.text) do
GT:CheckColumnSize(textIndex, textFrame)
GT:CheckColumnSize(textIndex, textFrame, itemID)
end
end
end
Expand Down Expand Up @@ -885,14 +888,14 @@ local generalOptions = {
if itemID >= 9999999998 then
for textIndex, textFrame in ipairs(itemFrame.text) do
textFrame:SetFont(media:Fetch("font", GT.db.profile.General.totalFont), GT.db.profile.General.totalSize, "OUTLINE")
GT:CheckColumnSize(textIndex, textFrame)
GT:CheckColumnSize(textIndex, textFrame, itemID)
end

local frameHeight = math.max(GT.db.profile.General.iconHeight, key)
itemFrame:SetHeight(frameHeight + 3)
else
for textIndex, textFrame in ipairs(itemFrame.text) do
GT:CheckColumnSize(textIndex, textFrame)
GT:CheckColumnSize(textIndex, textFrame, itemID)
end
end
end
Expand All @@ -914,11 +917,11 @@ local generalOptions = {
if itemID >= 9999999998 then
for textIndex, textFrame in ipairs(itemFrame.text) do
textFrame:SetFont(media:Fetch("font", GT.db.profile.General.totalFont), GT.db.profile.General.totalSize, "OUTLINE")
GT:CheckColumnSize(textIndex, textFrame)
GT:CheckColumnSize(textIndex, textFrame, itemID)
end
else
for textIndex, textFrame in ipairs(itemFrame.text) do
GT:CheckColumnSize(textIndex, textFrame)
GT:CheckColumnSize(textIndex, textFrame, itemID)
end
end
end
Expand Down Expand Up @@ -1441,6 +1444,49 @@ function GT:CreateCustomFilterOptions()
end
end

function GatheringTracker_OnAddonCompartmentClick(addonName, button)
if (button == "LeftButton") then
GT:ToggleGatheringTracker()
elseif (button == "RightButton") then
Settings.OpenToCategory(GT.metaData.name, true)
end
end

local function UpdateChangedorRemovedSavedVariables()
-- Increment when adding anything to function
local fixConstant = 1
if GT.db.profile.General.fixSettings < fixConstant then
--Change debug to int instead of bool
if type(GT.db.profile.General.debugOption) == "boolean" then
GT.db.profile.General.debugOption = 0
end

if GT.db.profile.Filters["gold"] then
GT.db.profile.Filters["gold"] = nil
GT.db.profile.Filters[1] = true
end

if GT.db.profile.Filters["bag"] then
GT.db.profile.Filters["bag"] = nil
GT.db.profile.Filters[2] = true
end

local tempFilterTable = {}
for itemID in string.gmatch(GT.db.profile.CustomFilters, "[%d]+") do
itemID = tonumber(itemID) or 0
if GT.db.profile.CustomFiltersTable[itemID] then
tempFilterTable[itemID] = GT.db.profile.CustomFiltersTable[itemID]
else
tempFilterTable[itemID] = true
end
GT:RemoveItemData(tempFilterTable[itemID], itemID)
end
GT.db.profile.CustomFiltersTable = tempFilterTable

GT.db.profile.General.fixSettings = fixConstant
end
end

function GT:RefreshConfig(event, db, profile)
GT.Debug("Refresh Config", 1, event, profile, db.profile.General.enable, GT.Enabled)
if db.profile.General.enable and not GT.Enabled and event == "OnProfileChanged" then
Expand All @@ -1451,6 +1497,9 @@ function GT:RefreshConfig(event, db, profile)
GT.Enabled = false
GT:OnDisable()
end
if event == "OnProfileChanged" then
UpdateChangedorRemovedSavedVariables()
end

GT.baseFrame.backdrop:ClearAllPoints()
GT.baseFrame.backdrop:SetPoint(
Expand All @@ -1468,38 +1517,6 @@ function GT:RefreshConfig(event, db, profile)
GT:CreateCustomFilterOptions()
end

function GatheringTracker_OnAddonCompartmentClick(addonName, button)
if (button == "LeftButton") then
GT:ToggleGatheringTracker()
elseif (button == "RightButton") then
Settings.OpenToCategory(GT.metaData.name, true)
end
end

local function UpdateChangedorRemovedSavedVariables()
--Change debug to int instead of bool
if type(GT.db.profile.General.debugOption) == "boolean" then
GT.db.profile.General.debugOption = 0
end

if GT.db.profile.Filters["gold"] then
GT.db.profile.Filters["gold"] = nil
GT.db.profile.Filters[1] = true
end

if GT.db.profile.Filters["bag"] then
GT.db.profile.Filters["bag"] = nil
GT.db.profile.Filters[2] = true
end

for id, value in pairs(GT.db.profile.CustomFiltersTable) do
if type(id) ~= "number" then
GT.db.profile.CustomFiltersTable[id] = nil
GT.db.profile.CustomFiltersTable[tonumber(id)] = value
end
end
end

local function InitializePriceSource()
local priceSources = { "TradeSkillMaster", "RECrystallize", "Auctionator" }
local priceSourcesLoaded = {}
Expand Down
1 change: 1 addition & 0 deletions Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,7 @@ local ItemData = {
-- Other
{ id = 1, name = "Current Gold", order = 1, icon = "Interface\\Addons\\GatheringTracker\\Media\\Ability_Racial_PackHobgoblin", desc = "Displays the current Gold on the character, rounded to the nearest whole number.", retail = true, classic = true, era = true, season = true, expansion = "Other", category = "Other" },
{ id = 2, name = "Open Bag Space", order = 2, icon = "Interface\\Addons\\GatheringTracker\\Media\\Garrison_Building_Storehouse", desc = "Displays the number of open bag space.", retail = true, classic = true, era = true, season = true, expansion = "Other", category = "Other" },
{ id = 3, name = "Session Timer", order = 3, icon = 134377, desc = "Displays a timer starting from the first gather after being enabled.", retail = true, classic = true, era = true, season = true, expansion = "Other", category = "Other" },
}

GT.ItemData = {}
Expand Down
59 changes: 27 additions & 32 deletions DisplayCreation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ local function FramePool_Resetter(framePool, frame)
if frame.priceTotalItem then
frame.priceTotalItem = nil
end
if frame.timer then
frame.timer = nil
end
frame:SetScript("OnEnter", nil)
frame:SetMouseClickEnabled(false)
frame:SetMouseMotionEnabled(false)
Expand Down Expand Up @@ -85,8 +88,15 @@ local function CreateTextDisplay(frame, id, text, type, height, anchor)

string:SetPoint("LEFT", anchor, "RIGHT", offset, 0)
string:SetJustifyH("LEFT") --add option for this?
string:SetText(text)
if id ~= 3 then
string:SetText(text)
end
string:Show()
if id == 3 then
frame.timer = true
string:SetText("00:00:00")
GT:UpdateTimer(frame)
end
return string
end

Expand All @@ -101,12 +111,8 @@ function GT:CreateDisplayFrame(id, iconId, iconQuality, iconRarity, displayText,

local frame = GT:DisplayFrameBase(id)

--frame.displayedCharacters = #displayText

GT.Display.Frames[id] = frame

--GT:DisplayFrameHighlight(frame)

GT:DisplayFrameIcon(frame, iconId, id)

if iconQuality then
Expand All @@ -126,10 +132,6 @@ function GT:CreateDisplayFrame(id, iconId, iconQuality, iconRarity, displayText,
GT:DisplayFrameCounts(frame, id, displayText)
end

--[[if totalItemCount and GT:GroupDisplayCheck() then
GT:DisplayFrameTotal(frame, id, totalItemCount)
end]]

if pricePerItem and GT.db.profile.General.perItemPrice then
GT:DisplayFramePricePer(frame, id, pricePerItem)
end
Expand Down Expand Up @@ -238,23 +240,6 @@ function GT:DisplayFrameRarity(frame, iconRarity)
frame.iconRarity:Show()
end

function GT:DisplayFrameHighlight(frame)
frame.highlight = GT.Pools.texturePool:Acquire()
frame.highlight:SetParent(frame)
frame.highlight:SetDrawLayer("BACKGROUND", 7)
frame.highlight:SetAtlas("communities-create-avatar-border-hover")
frame.highlight:SetAllPoints(frame)
frame.highlight:Hide()
end
--[[
Possible textures to use for the highlight:
Looting_ItemCard_HighlightState (best option as it is visible and colors well)
ClickCastList-ButtonHighlight (good option, but less visible)
Adventures_MissionList_Highlight
communitiesfinder_card_highlight
search-highlight-largeNumber
]]

function GT:DisplayFrameCounts(frame, id, text, index)
index = index or 1
local anchor = frame.icon
Expand All @@ -267,12 +252,22 @@ function GT:DisplayFrameCounts(frame, id, text, index)
text = text
end
frame.text[index] = CreateTextDisplay(frame, id, text, "count", frame:GetHeight(), anchor)
GT:CheckColumnSize(index, frame.text[index])

if id <= #GT.ItemData.Other.Other then
-- 3 is the offset from the icon, 8 is the offset to the next column
local offset = GT.db.profile.General.iconWidth + 3 + 8
local parentWidth = frame:GetWidth()
local width = parentWidth - offset
local stringWidth = frame.text[index]:GetUnboundedStringWidth()
frame.text[index]:SetWidth(stringWidth)
end

GT:CheckColumnSize(index, frame.text[index], id)
end

function GT:DisplayFrameTotal(frame, id, totalItemCount)
frame.text[#frame.text + 1] = CreateTextDisplay(frame, id, "[" .. math.ceil(totalItemCount - 0.5) .. "]", "totalItemCount", frame:GetHeight(), frame.text[#frame.text])
GT:CheckColumnSize(#frame.text, frame.text[#frame.text])
GT:CheckColumnSize(#frame.text, frame.text[#frame.text], id)
frame.totalItemCount = #frame.text
end

Expand All @@ -284,24 +279,24 @@ function GT:DisplayFramePricePer(frame, id, pricePerItem)
text = ""
end
frame.text[#frame.text + 1] = CreateTextDisplay(frame, id, text, "pricePerItem", frame:GetHeight(), frame.text[#frame.text])
GT:CheckColumnSize(#frame.text, frame.text[#frame.text])
GT:CheckColumnSize(#frame.text, frame.text[#frame.text], id)
frame.pricePerItem = #frame.text
end

function GT:DisplayFramePriceTotal(frame, id, priceTotalItem)
frame.text[#frame.text + 1] = CreateTextDisplay(frame, id, "(" .. math.ceil(priceTotalItem - 0.5) .. "g)", "priceTotalItem", frame:GetHeight(), frame.text[#frame.text])
GT:CheckColumnSize(#frame.text, frame.text[#frame.text])
GT:CheckColumnSize(#frame.text, frame.text[#frame.text], id)
frame.priceTotalItem = #frame.text
end

function GT:DisplayFrameItemsPerHour(frame, id, itemsPerHour)
frame.text[#frame.text + 1] = CreateTextDisplay(frame, id, math.ceil(itemsPerHour - 0.5) .. "/h", "itemsPerHour", frame:GetHeight(), frame.text[#frame.text])
GT:CheckColumnSize(#frame.text, frame.text[#frame.text])
GT:CheckColumnSize(#frame.text, frame.text[#frame.text], id)
frame.itemsPerHour = #frame.text
end

function GT:DisplayFrameGoldPerHour(frame, id, goldPerHour)
frame.text[#frame.text + 1] = CreateTextDisplay(frame, id, math.ceil(goldPerHour - 0.5) .. "g/h", "goldPerHour", frame:GetHeight(), frame.text[#frame.text])
GT:CheckColumnSize(#frame.text, frame.text[#frame.text])
GT:CheckColumnSize(#frame.text, frame.text[#frame.text], id)
frame.goldPerHour = #frame.text
end
Loading

0 comments on commit a62204a

Please sign in to comment.