From b4640dc24855cb3b45ac40d101cb2dfba0a835dc Mon Sep 17 00:00:00 2001 From: DarthKsane <73148573+DarthKsane@users.noreply.github.com> Date: Wed, 21 Oct 2020 18:43:00 +0300 Subject: [PATCH 1/6] Update Scoreboard.lua --- Scoreboard.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Scoreboard.lua b/Scoreboard.lua index c7296d9..65dfa46 100644 --- a/Scoreboard.lua +++ b/Scoreboard.lua @@ -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 @@ -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 @@ -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"); From 0886f1ea617f2bc0a79591af05b91f6b32087911 Mon Sep 17 00:00:00 2001 From: DarthKsane <73148573+DarthKsane@users.noreply.github.com> Date: Wed, 21 Oct 2020 18:43:43 +0300 Subject: [PATCH 2/6] Update config.lua --- config.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config.lua b/config.lua index ed50570..6eeb9c2 100644 --- a/config.lua +++ b/config.lua @@ -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] = { @@ -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 From 1cc25740375d983e5fa3183eb534b32f8f8c8d20 Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Wed, 21 Oct 2020 11:20:56 -0500 Subject: [PATCH 3/6] Update Scoreboard.lua Update to use id instead of passing the link around --- Scoreboard.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Scoreboard.lua b/Scoreboard.lua index 65dfa46..44ab548 100644 --- a/Scoreboard.lua +++ b/Scoreboard.lua @@ -81,8 +81,11 @@ do addon.dataobj = dataobj - -- Remove any non-word characters that cause issues saving in other locales - local function getCurrencyKeyID(ilink) return C_CurrencyInfo.GetCurrencyIDFromLink(ilink) end + -- Returns the currency id from the currency index + function addon:getCurrencyIdFromIndex(i) + local ilink = C_CurrencyInfo.GetCurrencyListLink(i) + return C_CurrencyInfo.GetCurrencyIDFromLink(ilink) + end local function fmtIcon(icon) local text @@ -115,9 +118,9 @@ do for i=1, size do local c = C_CurrencyInfo.GetCurrencyListInfo(i) - local li = C_CurrencyInfo.GetCurrencyListLink(i) + local id = addon:getCurrencyIdFromIndex(i); if (not c.isHeader) then - if (addon:getCurrency(li) and not c.isTypeUnused) then + if (addon:getCurrency(id) and not c.isTypeUnused) then text = text..renderItem(c.name, c.quantity, c.iconFileID, c.maxQuantity) if (i ~= size) then text = text.." " end end @@ -188,15 +191,13 @@ do updateText() end - function addon:setCurrency(ilink, value) - local nk = getCurrencyKeyID(ilink) - addon.db.currencies[nk] = value + function addon:setCurrency(id, value) + addon.db.currencies[id] = value updateText() end - function addon:getCurrency(ilink) - local nk = getCurrencyKeyID(ilink) - return addon.db.currencies[nk] == true + function addon:getCurrency(id) + return addon.db.currencies[id] == true end f:RegisterEvent("PLAYER_ENTERING_WORLD"); From 729b50fefa56eae223a46eeebb1b0c88c595cb63 Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Wed, 21 Oct 2020 11:22:36 -0500 Subject: [PATCH 4/6] Update config.lua --- config.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.lua b/config.lua index 6eeb9c2..f56f637 100644 --- a/config.lua +++ b/config.lua @@ -80,7 +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) + local id = addon:getCurrencyIdFromIndex(i) if c.isHeader then if c.isHeaderExpanded and c.name ~= "Unused" then t.args[c.name] = { @@ -95,8 +95,8 @@ local function build() type = 'toggle', order = 20 + i, name = c.name, - get = function() return addon:getCurrency(li) end, - set = function(i, v) return addon:setCurrency(li, v) end, + get = function() return addon:getCurrency(id) end, + set = function(i, v) return addon:setCurrency(id, v) end, } end end From 43554b77ba1d09207043acb907e24387e592a58d Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Wed, 21 Oct 2020 12:17:53 -0500 Subject: [PATCH 5/6] Revert "Update Scoreboard.lua" This reverts commit 1cc25740375d983e5fa3183eb534b32f8f8c8d20. --- Scoreboard.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Scoreboard.lua b/Scoreboard.lua index 44ab548..65dfa46 100644 --- a/Scoreboard.lua +++ b/Scoreboard.lua @@ -81,11 +81,8 @@ do addon.dataobj = dataobj - -- Returns the currency id from the currency index - function addon:getCurrencyIdFromIndex(i) - local ilink = C_CurrencyInfo.GetCurrencyListLink(i) - return C_CurrencyInfo.GetCurrencyIDFromLink(ilink) - end + -- Remove any non-word characters that cause issues saving in other locales + local function getCurrencyKeyID(ilink) return C_CurrencyInfo.GetCurrencyIDFromLink(ilink) end local function fmtIcon(icon) local text @@ -118,9 +115,9 @@ do for i=1, size do local c = C_CurrencyInfo.GetCurrencyListInfo(i) - local id = addon:getCurrencyIdFromIndex(i); + local li = C_CurrencyInfo.GetCurrencyListLink(i) if (not c.isHeader) then - if (addon:getCurrency(id) 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 @@ -191,13 +188,15 @@ do updateText() end - function addon:setCurrency(id, value) - addon.db.currencies[id] = value + function addon:setCurrency(ilink, value) + local nk = getCurrencyKeyID(ilink) + addon.db.currencies[nk] = value updateText() end - function addon:getCurrency(id) - return addon.db.currencies[id] == true + function addon:getCurrency(ilink) + local nk = getCurrencyKeyID(ilink) + return addon.db.currencies[nk] == true end f:RegisterEvent("PLAYER_ENTERING_WORLD"); From ff2f366f900e5f2bd8dfe9310be0641a1e358197 Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Wed, 21 Oct 2020 12:17:53 -0500 Subject: [PATCH 6/6] Revert "Update config.lua" This reverts commit 729b50fefa56eae223a46eeebb1b0c88c595cb63. --- config.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.lua b/config.lua index f56f637..6eeb9c2 100644 --- a/config.lua +++ b/config.lua @@ -80,7 +80,7 @@ local function build() -- add currencies for i=1, C_CurrencyInfo.GetCurrencyListSize() do local c = C_CurrencyInfo.GetCurrencyListInfo(i) - local id = addon:getCurrencyIdFromIndex(i) + local li = C_CurrencyInfo.GetCurrencyListLink(i) if c.isHeader then if c.isHeaderExpanded and c.name ~= "Unused" then t.args[c.name] = { @@ -95,8 +95,8 @@ local function build() type = 'toggle', order = 20 + i, name = c.name, - get = function() return addon:getCurrency(id) end, - set = function(i, v) return addon:setCurrency(id, v) end, + get = function() return addon:getCurrency(li) end, + set = function(i, v) return addon:setCurrency(li, v) end, } end end