Skip to content

Commit

Permalink
- Now showing stat text instead of gem name for prismatic Gems
Browse files Browse the repository at this point in the history
- Now Sorting Quality[Legendary->Common] > Name[A->Z]
  • Loading branch information
Larsj02 committed May 18, 2024
1 parent 10b6eb6 commit f684868
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local Private = select(2, ...)
---@class CacheItemInfo
---@field name string
---@field link string
---@field quality string
---@field icon number
---@field type number
---@field subType number
Expand Down
10 changes: 8 additions & 2 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,17 @@ local function createFrame()
for itemIndex, itemInfo in ipairs(socketTypeData) do
local cachedInfo = cache:GetItemInfo(itemInfo.itemID)
if not cachedInfo then return end
local txt = cachedInfo.name
if itemInfo.gemType == "Prismatic" then
txt = gemUtil:GetGemStats(cachedInfo.description)
end
dataProvider:Insert({
id = itemInfo.itemID,
icon = cachedInfo.icon,
text = cachedInfo.name,
text = txt or "",
index = itemIndex,
info = itemInfo
info = itemInfo,
cachedInfo = cachedInfo,
})
end
end
Expand Down Expand Up @@ -338,6 +343,7 @@ end

local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
---@diagnostic disable-next-line: param-type-mismatch
eventFrame:RegisterEvent("SCRAPPING_MACHINE_ITEM_ADDED")
eventFrame:SetScript("OnEvent", function(_, event)
if event == "SCRAPPING_MACHINE_ITEM_ADDED" then
Expand Down
8 changes: 8 additions & 0 deletions GemUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,11 @@ function gemUtil:GetFilteredGems(socketTypeFilter, nameFilter)
end
return validGems
end

function gemUtil:GetGemStats(description)
local stat = ""
if description and type(description) == "string" then
stat = description:match("%++[^\n]+")
end
return stat
end
3 changes: 3 additions & 0 deletions Misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ end
function misc.ItemSorting(a, b)
local cachedA = cache:GetItemInfo(a.itemID)
local cachedB = cache:GetItemInfo(b.itemID)
if cachedA.quality ~= cachedB.quality then
return cachedA.quality > cachedB.quality
end
return cachedA.name < cachedB.name
end
5 changes: 5 additions & 0 deletions UIElements.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ end

function uiElements:CreateCheckButton(parent, data)
local checkButton = CreateFrame("CheckButton", nil, parent, "ChatConfigCheckButtonTemplate")
---@diagnostic disable-next-line: deprecated
checkButton:SetPoint(unpack(data.point))
checkButton.Text:SetText(data.text)
checkButton.tooltip = data.tooltip
Expand Down Expand Up @@ -121,6 +122,7 @@ function uiElements:CreateDropdown(parent, data)
dropDown.selectionCallback = data.selectionCallback
dropDown.selection = nil
for _, point in ipairs(data.points) do
---@diagnostic disable-next-line: deprecated
dropDown:SetPoint(unpack(point))
end

Expand All @@ -135,6 +137,9 @@ function uiElements:CreateDropdown(parent, data)
end
end
dropDown.SetValue = function (selectionValue, selectionIndex)
---@class dropdownRow
---@field value number
---@cast selectionValue dropdownRow
dropDown:UpdateSelection(selectionIndex, selectionValue.value)
end

Expand Down

0 comments on commit f684868

Please sign in to comment.