Skip to content

Commit 07ef0ed

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 Fix whitespaces Fix whitespaces ../core/Core.lua:174 ../config/Options.lua:668 Actually fix whitespaces this time perhaps it is time I installed a linter...
1 parent 58e21a1 commit 07ef0ed

3 files changed

Lines changed: 18 additions & 23 deletions

File tree

config/Options.lua

Lines changed: 5 additions & 23 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'],
@@ -679,7 +665,6 @@ local function GetOptions()
679665
BOTTOMLEFT = L['Bottom Left'],
680666
BOTTOM = L['Bottom'],
681667
BOTTOMRIGHT = L['Bottom Right'],
682-
683668
},
684669
sorting = {
685670
[1] = "TOPLEFT",
@@ -693,7 +678,6 @@ local function GetOptions()
693678
[9] = "BOTTOMRIGHT",
694679
},
695680
order = 10,
696-
set = SetOptionAndUpdateUpgradeIcon,
697681
},
698682
upgradeIconOffsetX = {
699683
name = L["X Offset"],
@@ -704,7 +688,6 @@ local function GetOptions()
704688
step = 1,
705689
bigStep = 1,
706690
order = 20,
707-
set = SetOptionAndUpdateUpgradeIcon,
708691
},
709692
upgradeIconOffsetY = {
710693
name = L["Y Offset"] ,
@@ -715,7 +698,6 @@ local function GetOptions()
715698
step = 1,
716699
bigStep = 1,
717700
order = 30,
718-
set = SetOptionAndUpdateUpgradeIcon,
719701
},
720702
},
721703
},

core/Core.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ function addon:OnEnable()
170170
self.bagFont:ApplySettings()
171171
self.sectionFont:ApplySettings()
172172
self:UpdatePositionMode()
173+
self:UpdateUpgradeIcon()
173174

174175
self:Debug('Enabled')
175176
end

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)