Skip to content

Commit 133977a

Browse files
committed
Move UpdateUpgradeIcon to ItemButton
Move UpdateUpgradeIcon to ItemButton.lua Call UpdateUpgradeIcon in the OnEnabled in core.lua for handling profile changing Set the Setter function on the option group that is inherited by the Anchor and Offset options instead of using a setter for each option. Fix Whitespaces Remove the whitespace in Options.lua to minimize changes with the master branch Add a whitespace in Core.lua to minimize changes with the master branch
1 parent 58e21a1 commit 133977a

3 files changed

Lines changed: 19 additions & 23 deletions

File tree

config/Options.lua

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -269,25 +269,6 @@ local function GetOptions()
269269
bagList[module.bagName] = L[module.bagName]
270270
end
271271
end
272-
273-
local function UpdateUpgradeIcon()
274-
local db = addon.db.profile
275-
for button, _ in addon:GetPool("ItemButton"):IterateActiveObjects() do
276-
button.UpgradeIcon:ClearAllPoints()
277-
button.UpgradeIcon:SetPoint(db.upgradeIconAnchor, button, db.upgradeIconOffsetX, db.upgradeIconOffsetY)
278-
end
279-
for button, _ in addon:GetPool("BankItemButton"):IterateActiveObjects() do
280-
button.UpgradeIcon:ClearAllPoints()
281-
button.UpgradeIcon:SetPoint(db.upgradeIconAnchor, button, db.upgradeIconOffsetX, db.upgradeIconOffsetY)
282-
end
283-
end
284-
285-
local function SetOptionAndUpdateUpgradeIcon(info, value, ...)
286-
local db = addon.db.profile
287-
db[info[#info]] = value
288-
UpdateUpgradeIcon()
289-
end
290-
291272
options = {
292273
--@debug@
293274
name = addonName..' DEV',
@@ -665,6 +646,11 @@ local function GetOptions()
665646
type = 'group',
666647
inline = true,
667648
order = 400,
649+
set = function(info, value, ...)
650+
local db = addon.db.profile
651+
db[info[#info]] = value
652+
addon:UpdateUpgradeIcon()
653+
end,
668654
args = {
669655
upgradeIconAnchor = {
670656
name = L['Anchor'],
@@ -693,7 +679,6 @@ local function GetOptions()
693679
[9] = "BOTTOMRIGHT",
694680
},
695681
order = 10,
696-
set = SetOptionAndUpdateUpgradeIcon,
697682
},
698683
upgradeIconOffsetX = {
699684
name = L["X Offset"],
@@ -704,7 +689,6 @@ local function GetOptions()
704689
step = 1,
705690
bigStep = 1,
706691
order = 20,
707-
set = SetOptionAndUpdateUpgradeIcon,
708692
},
709693
upgradeIconOffsetY = {
710694
name = L["Y Offset"] ,
@@ -715,7 +699,6 @@ local function GetOptions()
715699
step = 1,
716700
bigStep = 1,
717701
order = 30,
718-
set = SetOptionAndUpdateUpgradeIcon,
719702
},
720703
},
721704
},

core/Core.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ function addon:OnEnable()
170170
self.bagFont:ApplySettings()
171171
self.sectionFont:ApplySettings()
172172
self:UpdatePositionMode()
173-
173+
self:UpdateUpgradeIcon()
174+
174175
self:Debug('Enabled')
175176
end
176177

widgets/ItemButton.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ hooksecurefunc(addon, 'OnInitialize', function()
176176
containerButtonPool:PreSpawn(160)
177177
end)
178178

179+
function addon:UpdateUpgradeIcon()
180+
local db = addon.db.profile
181+
for button, _ in addon:GetPool("ItemButton"):IterateActiveObjects() do
182+
button.UpgradeIcon:ClearAllPoints()
183+
button.UpgradeIcon:SetPoint(db.upgradeIconAnchor, button, db.upgradeIconOffsetX, db.upgradeIconOffsetY)
184+
end
185+
for button, _ in addon:GetPool("BankItemButton"):IterateActiveObjects() do
186+
button.UpgradeIcon:ClearAllPoints()
187+
button.UpgradeIcon:SetPoint(db.upgradeIconAnchor, button, db.upgradeIconOffsetX, db.upgradeIconOffsetY)
188+
end
189+
end
190+
179191
--------------------------------------------------------------------------------
180192
-- Model data
181193
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)