diff --git a/config/Options.lua b/config/Options.lua index 59a9593a..b04642ee 100644 --- a/config/Options.lua +++ b/config/Options.lua @@ -641,6 +641,66 @@ local function GetOptions() }, } }, + ItemUpgrade = { + name = ITEM_UPGRADE, + type = 'group', + inline = true, + order = 400, + set = function(info, value, ...) + local db = addon.db.profile + db[info[#info]] = value + addon:UpdateUpgradeIcon() + end, + args = { + upgradeIconAnchor = { + name = L['Anchor'], + type = 'select', + values = { + TOPLEFT = L['Top Left'], + TOP = L['Top'], + TOPRIGHT = L['Top Right'], + LEFT = L['Left'], + CENTER = L['Center'], + RIGHT = L['Right'], + BOTTOMLEFT = L['Bottom Left'], + BOTTOM = L['Bottom'], + BOTTOMRIGHT = L['Bottom Right'], + }, + sorting = { + [1] = "TOPLEFT", + [2] = "TOP", + [3] = "TOPRIGHT", + [4] = "LEFT", + [5] = "CENTER", + [6] = "RIGHT", + [7] = "BOTTOMLEFT", + [8] = "BOTTOM", + [9] = "BOTTOMRIGHT", + }, + order = 10, + }, + upgradeIconOffsetX = { + name = L["X Offset"], + desc = L["Offset in X direction (horizontal) from the given anchor point."], + type = 'range', + min = -20, + max = 20, + step = 1, + bigStep = 1, + order = 20, + }, + upgradeIconOffsetY = { + name = L["Y Offset"] , + desc = L["Offset in Y direction (vertical) from the given anchor point."], + type = 'range', + min = -20, + max = 20, + step = 1, + bigStep = 1, + order = 30, + }, + }, + }, }, }, filters = { diff --git a/core/Constants.lua b/core/Constants.lua index 6da9b3fb..81b9991b 100644 --- a/core/Constants.lua +++ b/core/Constants.lua @@ -158,6 +158,9 @@ addon.DEFAULT_SETTINGS = { hideAnchor = false, autoDeposit = false, compactLayout = false, + upgradeIconAnchor = "TOPLEFT", + upgradeIconOffsetX = 0, + upgradeIconOffsetY = 0, }, char = { collapsedSections = { diff --git a/core/Core.lua b/core/Core.lua index 495c36d8..c6338780 100644 --- a/core/Core.lua +++ b/core/Core.lua @@ -170,6 +170,7 @@ function addon:OnEnable() self.bagFont:ApplySettings() self.sectionFont:ApplySettings() self:UpdatePositionMode() + self:UpdateUpgradeIcon() self:Debug('Enabled') end diff --git a/widgets/ItemButton.lua b/widgets/ItemButton.lua index 5c33308f..18440708 100644 --- a/widgets/ItemButton.lua +++ b/widgets/ItemButton.lua @@ -79,6 +79,8 @@ function buttonProto:OnCreate() self.NewItemTexture:Hide() end self.SplitStack = nil -- Remove the function set up by the template + self.UpgradeIcon:ClearAllPoints() + self.UpgradeIcon:SetPoint(addon.db.profile.upgradeIconAnchor, self, addon.db.profile.upgradeIconOffsetX, addon.db.profile.upgradeIconOffsetY) end function buttonProto:OnAcquire(container, bag, slot) @@ -121,6 +123,13 @@ end local bankButtonClass, bankButtonProto = addon:NewClass("BankItemButton", "ItemButton") bankButtonClass.frameTemplate = "BankItemButtonGenericTemplate" +function bankButtonProto:OnCreate() + self.UpgradeIcon = self:CreateTexture(nil, "OVERLAY", nil, 1) + self.UpgradeIcon:SetAtlas("bags-greenarrow", true) + self.UpgradeIcon:Hide() + buttonProto.OnCreate(self) +end + function bankButtonProto:OnAcquire(container, bag, slot) self.GetInventorySlot = nil -- Remove the method added by the template self.inventorySlot = bag == REAGENTBANK_CONTAINER and ReagentBankButtonIDToInvSlotID(slot) or BankButtonIDToInvSlotID(slot) @@ -140,7 +149,7 @@ function bankButtonProto:GetInventorySlot() end function bankButtonProto:UpdateUpgradeIcon() - if self.bag ~= BANK_CONTAINER and self.bag ~= REAGENTBANK_CONTAINER then + if self.bag ~= REAGENTBANK_CONTAINER then buttonProto.UpdateUpgradeIcon(self) end end @@ -167,6 +176,18 @@ hooksecurefunc(addon, 'OnInitialize', function() containerButtonPool:PreSpawn(160) end) +function addon:UpdateUpgradeIcon() + local db = addon.db.profile + for button, _ in addon:GetPool("ItemButton"):IterateAllObjects() do + button.UpgradeIcon:ClearAllPoints() + button.UpgradeIcon:SetPoint(db.upgradeIconAnchor, button, db.upgradeIconOffsetX, db.upgradeIconOffsetY) + end + for button, _ in addon:GetPool("BankItemButton"):IterateAllObjects() do + button.UpgradeIcon:ClearAllPoints() + button.UpgradeIcon:SetPoint(db.upgradeIconAnchor, button, db.upgradeIconOffsetX, db.upgradeIconOffsetY) + end +end + -------------------------------------------------------------------------------- -- Model data --------------------------------------------------------------------------------