Skip to content

Commit

Permalink
2.6.2
Browse files Browse the repository at this point in the history
Added Item Tooltip option
Removed unnecessary function
Replaced depreciated functions
Started adding annotations to functions
Fixed notification trigger error
Cleaned up miscellaneous code warnings
  • Loading branch information
Noshei committed Oct 21, 2024
1 parent f107826 commit 3ab7277
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 72 deletions.
1 change: 1 addition & 0 deletions Bindings.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@class GT
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")

-- Localize global functions
Expand Down
1 change: 1 addition & 0 deletions Broker.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@class GT
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")
local ldb = LibStub("LibDataBroker-1.1")
local LibDBIcon = LibStub("LibDBIcon-1.0")
Expand Down
70 changes: 42 additions & 28 deletions Config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---@class GT : AceAddon-3.0, AceEvent-3.0, AceConfigRegistry-3.0, AceConfigDialog-3.0
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")
local Config = GT:NewModule("Config", "AceEvent-3.0")
local AceConfigRegistry = LibStub("AceConfigRegistry-3.0")
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
local media = LibStub:GetLibrary("LibSharedMedia-3.0")
Expand Down Expand Up @@ -63,6 +63,7 @@ GT.defaults = {
collapseTime = 2,
sessionItems = false,
sessionOnly = false,
itemTooltip = false,
},
Notifications = {
Count = {
Expand Down Expand Up @@ -422,14 +423,27 @@ local generalOptions = {
end,
order = 320
},
itemTooltip = {
type = "toggle",
name = "Display Item Tooltip",
desc =
"When selected the item tooltip will be displayed when mousing over an items icon.",
width = 1.70,
get = function() return GT.db.profile.General.itemTooltip end,
set = function(_, key)
GT.db.profile.General.itemTooltip = key
GT:RebuildDisplay("Item Tooltip Option Changed")
end,
order = 321
},
},
},
LookandFeel = {
type = "group",
name = "Look and Feel",
order = 2,
args = {
header2 = {
header3 = {
type = "header",
name = "Display Options",
order = 200
Expand Down Expand Up @@ -648,7 +662,7 @@ local generalOptions = {
end,
order = 257
},
header3 = {
header4 = {
type = "header",
name = "Columns",
order = 300
Expand Down Expand Up @@ -688,7 +702,7 @@ local generalOptions = {
end,
order = 302
},
header4 = {
header5 = {
type = "header",
name = "Icon",
order = 400
Expand Down Expand Up @@ -747,7 +761,7 @@ local generalOptions = {
for itemID, itemFrame in pairs(GT.Display.Frames) do
if itemID > 2 and itemID < 9999999998 then
local iconRarity = C_Item.GetItemQualityByID(itemID)
GT:CreateRarityBorder(itemFrame, iconRarity)
GT:DisplayFrameRarity(itemFrame, iconRarity)
end
end
else
Expand All @@ -762,7 +776,7 @@ local generalOptions = {
end,
order = 403
},
header5 = {
header6 = {
type = "header",
name = "Text",
order = 500
Expand Down Expand Up @@ -1299,7 +1313,7 @@ for expansion, expansionData in pairs(GT.ItemData) do
if itemData.id <= #GT.ItemData.Other.Other then
return itemData.icon
else
return GetItemIcon(tonumber(itemData.id))
return C_Item.GetItemIconByID(itemData.id)
end
end,
imageCoords = function()
Expand All @@ -1314,7 +1328,7 @@ for expansion, expansionData in pairs(GT.ItemData) do
borderColor = nil
overlay = nil
else
local rarity = C_Item.GetItemQualityByID(tonumber(itemData.id)) or 1
local rarity = C_Item.GetItemQualityByID(itemData.id) or 1
if rarity <= 1 then
border = { "Interface\\Common\\WhiteIconFrame", "texture" }
else
Expand Down Expand Up @@ -1433,7 +1447,7 @@ local aliasOptions = {
end
if exists > 0 then
if tempAliasName == "Reset This Alias" then
table.remove(GT.db.profile.Aliases, index)
table.remove(GT.db.profile.Aliases, exists)
GT:UpdateAliases(tempAliasCharacter)
else
GT.db.profile.Aliases[exists].alias = tempAliasName
Expand Down Expand Up @@ -1496,7 +1510,7 @@ function GT:CreateCustomFilterOptions()
end
for id, value in pairs(GT.db.profile.CustomFiltersTable) do
--Create a local item to get data from the server
local itemID = tonumber(id)
local itemID = tonumber(id) or 1
local item = Item:CreateFromItemID(itemID)
GT.Debug("Create Custom Filter Options", 2, itemID)
--Waits for the data to be returned from the server
Expand All @@ -1507,7 +1521,7 @@ function GT:CreateCustomFilterOptions()
type = "toggle",
dialogControl = "NW_CheckBox",
name = itemName,
image = function() return GetItemIcon(tonumber(id)) end,
image = function() return C_Item.GetItemIconByID(id) end,
get = function() return GT.db.profile.CustomFiltersTable[id] end,
set = function(_, key)
if key then
Expand All @@ -1526,12 +1540,12 @@ function GT:CreateCustomFilterOptions()
local borderColor = {}
local overlay = {}

if tonumber(id) <= #GT.ItemData.Other.Other then
if id <= #GT.ItemData.Other.Other then
border = nil
borderColor = nil
overlay = nil
else
local rarity = C_Item.GetItemQualityByID(tonumber(id)) or 1
local rarity = C_Item.GetItemQualityByID(id) or 1
if rarity <= 1 then
border = { "Interface\\Common\\WhiteIconFrame", "texture" }
else
Expand Down Expand Up @@ -1632,13 +1646,13 @@ local function InitializePriceSource()
end

if next(priceSourcesLoaded) == nil then
priceSourcesLoaded = false
priceSourcesLoaded = nil
end

return priceSourcesLoaded
end

function Config:OnInitialize()
function GT:OnInitialize()
--have to check if tsm is loaded before we create the options so that we can use that variable in the options.
GT.priceSources = InitializePriceSource()

Expand Down Expand Up @@ -1693,18 +1707,18 @@ function Config:OnInitialize()

--register font and sound with LSM
media:Register("font", "Fira Mono Medium", "Interface\\Addons\\GatheringTracker\\Media\\Fonts\\FiraMono-Medium.ttf", media.LOCALE_BIT_western + media.LOCALE_BIT_ruRU)
media:Register("sound", "Auction Window Open", 567482)
media:Register("sound", "Auction Window Close", 567499)
media:Register("sound", "Auto Quest Complete", 567476)
media:Register("sound", "Level Up", 567431)
media:Register("sound", "Player Invite", 567451)
media:Register("sound", "Raid Warning", 567397)
media:Register("sound", "Ready Check", 567409)
media:Register("sound", "Murloc Aggro", 556000)
media:Register("sound", "Map Ping", 567416)
media:Register("sound", "Bonk 1", 568956)
media:Register("sound", "Bonk 2", 569179)
media:Register("sound", "Bonk 3", 569569)
media:Register("sound", "Auction Window Open", "567482")
media:Register("sound", "Auction Window Close", "567499")
media:Register("sound", "Auto Quest Complete", "567476")
media:Register("sound", "Level Up", "567431")
media:Register("sound", "Player Invite", "567451")
media:Register("sound", "Raid Warning", "567397")
media:Register("sound", "Ready Check", "567409")
media:Register("sound", "Murloc Aggro", "556000")
media:Register("sound", "Map Ping", "567416")
media:Register("sound", "Bonk 1", "568956")
media:Register("sound", "Bonk 2", "569179")
media:Register("sound", "Bonk 3", "569569")

GT.Enabled = GT.db.profile.General.enable
if not GT.Enabled then
Expand All @@ -1719,5 +1733,5 @@ function Config:OnInitialize()
GT.NotificationPause = true

GT:RebuildIDTables()
GT:CreateBaseFrame("Config:OnInitialize")
GT:CreateBaseFrame()
end
1 change: 1 addition & 0 deletions Constants.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@class GT
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")

local expansions = {
Expand Down
1 change: 1 addition & 0 deletions DisplayCollapse.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@class GT
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")

-- Localize global functions
Expand Down
57 changes: 54 additions & 3 deletions DisplayCreation.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@class GT
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")
local media = LibStub:GetLibrary("LibSharedMedia-3.0")

Expand All @@ -20,6 +21,10 @@ local function FramePool_Resetter(framePool, frame)
frame:Hide()
frame:ClearAllPoints()
if frame.icon then
frame.icon:SetScript("OnEnter", nil)
frame.icon:SetScript("OnLeave", nil)
frame.icon:SetMouseClickEnabled(false)
frame.icon:SetMouseMotionEnabled(false)
GT.Pools.texturePool:Release(frame.icon)
frame.icon = nil
end
Expand Down Expand Up @@ -100,15 +105,17 @@ function GT:CreateDisplayFrame(id, iconId, iconQuality, iconRarity, displayText,

GT.Display.Frames[id] = frame

GT:DisplayFrameIcon(frame, iconId)
--GT:DisplayFrameHighlight(frame)

GT:DisplayFrameIcon(frame, iconId, id)

if iconQuality then
GT:DisplayFrameQuality(frame, iconQuality)
end

GT:DisplayFrameRarity(frame, iconRarity)

frameHeight = frame:GetHeight()
local frameHeight = frame:GetHeight()
frame.text = {}

GT:DisplayFrameCounts(frame, id, displayText)
Expand Down Expand Up @@ -150,7 +157,7 @@ function GT:DisplayFrameBase(id)
return frame
end

function GT:DisplayFrameIcon(frame, iconId)
function GT:DisplayFrameIcon(frame, iconId, id)
frame.icon = GT.Pools.texturePool:Acquire()
frame.icon:SetParent(frame)
frame.icon:SetDrawLayer("BACKGROUND", 0)
Expand All @@ -159,6 +166,33 @@ function GT:DisplayFrameIcon(frame, iconId)
frame.icon:SetWidth(GT.db.profile.General.iconWidth)
frame.icon:SetHeight(GT.db.profile.General.iconHeight)
frame.icon:Show()

if id <= #GT.ItemData.Other.Other and id >= 9999999998 then
return
end
if not GT.db.profile.General.itemTooltip then
return
end

frame.icon:SetScript("OnEnter", function(self, motion)
if motion then
GameTooltip:SetOwner(self, self:GetTooltipAnchor())
GameTooltip:SetItemByID(id)
GameTooltip:Show()
end
end)

frame.icon:SetScript("OnLeave", function(self)
if GameTooltip:GetOwner() == self then
GameTooltip:Hide()
end
end)

function frame.icon:GetTooltipAnchor()
local x = self:GetRight() / GetScreenWidth() > 0.8
return x and 'ANCHOR_LEFT' or 'ANCHOR_RIGHT'
end
frame.icon:SetMouseClickEnabled(false)
end

function GT:DisplayFrameQuality(frame, iconQuality)
Expand Down Expand Up @@ -196,6 +230,23 @@ 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, displayText)
for i, text in ipairs(displayText) do
local anchor = frame.icon
Expand Down
9 changes: 5 additions & 4 deletions FilterButton.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@class GT
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")

-- Localize global functions
Expand Down Expand Up @@ -226,7 +227,7 @@ function GT:GenerateFiltersMenu(frame)
if itemData.icon then
leftTexture:SetTexture(itemData.icon)
else
leftTexture:SetTexture(GetItemIcon(tonumber(itemData.id)))
leftTexture:SetTexture(C_Item.GetItemIconByID(itemData.id))
end

text.fontString:SetPoint("LEFT", leftTexture, "RIGHT", 7, 1)
Expand Down Expand Up @@ -331,15 +332,15 @@ end
function GT:CreateCustomFiltersList(frame, rootDescription)
local customFiltersList = {}
for id, data in pairs(GT.db.profile.CustomFiltersTable) do
local itemID = tonumber(id)
local itemID = tonumber(id) or 1
local item = Item:CreateFromItemID(itemID)
--Waits for the data to be returned from the server
if not item:IsItemEmpty() then
item:ContinueOnItemLoad(function()
local itemDetails = {
id = tonumber(id),
text = item:GetItemName(),
icon = tostring(GetItemIcon(itemID) or "")
icon = tostring(C_Item.GetItemIconByID(itemID) or "")
}
table.insert(customFiltersList, itemDetails)
end)
Expand Down Expand Up @@ -427,7 +428,7 @@ function GT:CreateProfilesList(frame, rootDescription)
end

local function SetSelected_Profile()
GT.Debug("Profile Button Clicked", 2, name, key)
GT.Debug("Profile Button Clicked", 2, name)
--this closes the menu when the profile is changed
--ToggleDropDownMenu(1, nil, GT.baseFrame.menu, "cursor", 0, 0, GT.baseFrame.filterMenu, nil)
GT.db:SetProfile(name)
Expand Down
Loading

0 comments on commit 3ab7277

Please sign in to comment.