Skip to content

Commit

Permalink
Merge pull request #21 from DarthKsane/Use-currency-ID
Browse files Browse the repository at this point in the history
Use currency ID
  • Loading branch information
solocommand authored Oct 21, 2020
2 parents a21cafc + ff2f366 commit 7def8db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
17 changes: 9 additions & 8 deletions Scoreboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ do
addon.dataobj = dataobj

-- Remove any non-word characters that cause issues saving in other locales
local function getIconKey(icon) return gsub(icon, "[^%w]", "") end
local function getCurrencyKeyID(ilink) return C_CurrencyInfo.GetCurrencyIDFromLink(ilink) end

local function fmtIcon(icon)
local text
Expand Down Expand Up @@ -115,8 +115,9 @@ do

for i=1, size do
local c = C_CurrencyInfo.GetCurrencyListInfo(i)
local li = C_CurrencyInfo.GetCurrencyListLink(i)
if (not c.isHeader) then
if (addon:getCurrency(c.iconFileID) and not c.isTypeUnused) then
if (addon:getCurrency(li) and not c.isTypeUnused) then
text = text..renderItem(c.name, c.quantity, c.iconFileID, c.maxQuantity)
if (i ~= size) then text = text.." " end
end
Expand Down Expand Up @@ -187,15 +188,15 @@ do
updateText()
end

function addon:setCurrency(icon, value)
local ik = getIconKey(icon)
addon.db.currencies[ik] = value
function addon:setCurrency(ilink, value)
local nk = getCurrencyKeyID(ilink)
addon.db.currencies[nk] = value
updateText()
end

function addon:getCurrency(icon)
local ik = getIconKey(icon)
return addon.db.currencies[ik] == true
function addon:getCurrency(ilink)
local nk = getCurrencyKeyID(ilink)
return addon.db.currencies[nk] == true
end

f:RegisterEvent("PLAYER_ENTERING_WORLD");
Expand Down
5 changes: 3 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ local function build()
-- add currencies
for i=1, C_CurrencyInfo.GetCurrencyListSize() do
local c = C_CurrencyInfo.GetCurrencyListInfo(i)
local li = C_CurrencyInfo.GetCurrencyListLink(i)
if c.isHeader then
if c.isHeaderExpanded and c.name ~= "Unused" then
t.args[c.name] = {
Expand All @@ -94,8 +95,8 @@ local function build()
type = 'toggle',
order = 20 + i,
name = c.name,
get = function() return addon:getCurrency(c.iconFileID) end,
set = function(i, v) return addon:setCurrency(c.iconFileID, v) end,
get = function() return addon:getCurrency(li) end,
set = function(i, v) return addon:setCurrency(li, v) end,
}
end
end
Expand Down

0 comments on commit 7def8db

Please sign in to comment.