diff --git a/Localization.lua b/Localization.lua index ae6b03d6..fa9fe035 100644 --- a/Localization.lua +++ b/Localization.lua @@ -284,6 +284,12 @@ L["Related to player level"] = true L["Same as InventoryItemLevels"] = true L["Use SyLevel"] = true L["Which color scheme should be used to display the item level ?"] = true +L['Text Position'] = true +L["Anchor"] = true +L["X Offset"] = true +L["Offset in X direction (horizontal) from the given anchor point."] = true +L["Y Offset"] = true +L["Offset in Y direction (vertical) from the given anchor point."] = true -- modules/Junk.lua L["Alt-right-click to configure the Junk module."] = true @@ -625,6 +631,11 @@ L["When checked, right-clicking on an empty space of a bag opens the configurati L["When ctrl is held down"] = "Quand CONTROL est enfoncé" L["When shift is held down"] = "Quand MAJ est enfoncé" L["Which color scheme should be used to display the item level ?"] = "Quel thème de couleur doit être utilisé pour afficher le niiveau d'objet ?" -- Needs review +L["Anchor"] = "Ancre" +L["X Offset"] = "Décalage en X" +L["Offset in X direction (horizontal) from the given anchor point."] = "Le décalage en X (horizontal) par rapport au point d'ancrage donné." +L["Y Offset"] = "Décalage en Y" +L["Offset in Y direction (vertical) from the given anchor point."] = "Le décalage en Y (vertical) par rapport au point d'ancrage donné." ------------------------ deDE ------------------------ elseif locale == 'deDE' then @@ -792,6 +803,11 @@ L["When alt is held down"] = "Wenn Alt gedrückt ist" L["When any modifier key is held down"] = "Wenn irgendeine Modifizierungstase gedrückt ist" L["When ctrl is held down"] = "Wenn Strg gedrückt ist" L["When shift is held down"] = "Wenn Umschalt gedrückt ist" +L["Anchor"] = "Anker" +L["X Offset"] = "X-Verschiebung" +L["Offset in X direction (horizontal) from the given anchor point."] = "Verschiebung in Richtung X (horizontal) vom gegebenen Ankerpunkt aus." +L["Y Offset"] = "Y-Verschiebung" +L["Offset in Y direction (vertical) from the given anchor point."] = "Verschiebung in Richtung Y (vertikal) vom gegebenen Ankerpunkt aus." ------------------------ esMX ------------------------ -- no translation @@ -966,6 +982,11 @@ L["When alt is held down"] = "Когда кнопка Alt нажата" L["When any modifier key is held down"] = "Когда какая-либо клавиша модификатора нажата" L["When ctrl is held down"] = "Когда кнопка Ctrl нажата" L["When shift is held down"] = "Когда кнопка Shift нажата" +L["Anchor"] = "Якорь" +L["X Offset"] = "Сдвиг по Х" +L["Offset in X direction (horizontal) from the given anchor point."] = "Сдвиг по оси Х (горизонтально) от заданной точки привязки." +L["Y Offset"] = "Сдвиг по Y" +L["Offset in Y direction (vertical) from the given anchor point."] = "Сдвиг по оси Y (вертикально) от заданной точки привязки." ------------------------ esES ------------------------ elseif locale == 'esES' then @@ -1062,6 +1083,11 @@ L["Unlock anchor"] = "desbloquear anclaje - desanclar." L["Use this to adjust the bag scale."] = "Usa esto para ajustar la escala de la bolsa." L["Use this to adjust the quality-based border opacity. 100% means fully opaque."] = [=[Usa esto para ajustar la opacidad del borde basado en la calidad. 100% significa opaco. ]=] +L["Anchor"] = "Anclar" +L["X Offset"] = "Desplazamiento X" +L["Offset in X direction (horizontal) from the given anchor point."] = "Desplazado en la dirección X (horizontal) desde el punto de anclaje dado." +L["Y Offset"] = "Desplazamiento Y" +L["Offset in Y direction (vertical) from the given anchor point."] = "Desplazado en la dirección Y (vertical) desde el punto de anclaje dado." ------------------------ zhTW ------------------------ elseif locale == 'zhTW' then @@ -1319,6 +1345,11 @@ L["When checked, right-clicking on an empty space of a bag opens the configurati L["When ctrl is held down"] = "當 ctrl 按住" L["When shift is held down"] = "當 shift 按住" L["Which color scheme should be used to display the item level ?"] = "應該使用哪種顏色設定顯示物品的等級?" -- Needs review +L["Anchor"] = "錨點" +L["X Offset"] = "X 偏移量" +L["Offset in X direction (horizontal) from the given anchor point."] = "X 方向(水平)給定的錨點偏移量。" +L["Y Offset"] = "Y 偏移量" +L["Offset in Y direction (vertical) from the given anchor point."] = "Y 方向(垂直)給定的錨點偏移量。" ------------------------ zhCN ------------------------ elseif locale == 'zhCN' then @@ -1573,6 +1604,11 @@ L["When checked, right-clicking on an empty space of a bag opens the configurati L["When ctrl is held down"] = "当CTRL键被按下" -- Needs review L["When shift is held down"] = "当SHIFT键被按下" -- Needs review L["Which color scheme should be used to display the item level ?"] = "应该使用哪种颜色设定显示物品的等级?" -- Needs review +L["Anchor"] = "锚点" +L["X Offset"] = "X 偏移量" +L["Offset in X direction (horizontal) from the given anchor point."] = "X 方向(水平)给定的锚点偏移量。" +L["Y Offset"] = "Y 偏移量" +L["Offset in Y direction (vertical) from the given anchor point."] = "Y 方向(垂直)给定的锚点偏移量。" ------------------------ koKR ------------------------ elseif locale == 'koKR' then @@ -1849,6 +1885,11 @@ L["When ctrl is held down"] = "Ctrl키를 누르고 있을 때" L["When shift is held down"] = "Shift키를 누르고 있을 때" L["Which color scheme should be used to display the item level ?"] = "아이템 레벨에 어떤 색상화 방식을 사용할까요 ?" L["You can block auto-deposit ponctually by pressing a modified key while talking to the banker."] = "은행원과 대화할 때 보조 키를 누르고 있으면 자동 보관 기능을 방지할 수 있습니다." +L["Anchor"] = "앵커" +L["X Offset"] = "X 좌표" +L["Offset in X direction (horizontal) from the given anchor point."] = "주어진 앵커를 기준으로 X 방향(수평)의 좌표를 설정합니다." +L["Y Offset"] = "Y 좌표" +L["Offset in Y direction (vertical) from the given anchor point."] = "주어진 앵커를 기준으로 Y 방향(수직)의 좌표를 설정합니다." ------------------------ ptBR ------------------------ elseif locale == 'ptBR' then @@ -2106,6 +2147,11 @@ L["When checked, right-clicking on an empty space of a bag opens the configurati L["When ctrl is held down"] = "Quando CTRL é pressionado" L["When shift is held down"] = "Quando SHIFT é pressionado" L["Which color scheme should be used to display the item level ?"] = "Qual esquema de cores deve ser usado para mostrar o nível do item?" +L["Anchor"] = "Ancorar" +L["X Offset"] = "Posição de X" +L["Offset in X direction (horizontal) from the given anchor point."] = "Posição da direção X (horizontal) do ponto de ancora dado" +L["Y Offset"] = "Posição de Y" +L["Offset in Y direction (vertical) from the given anchor point."] = "Posição da direção Y (vertical) do ponto de ancora dado" end -- @noloc]] diff --git a/modules/ItemLevel.lua b/modules/ItemLevel.lua index c68d5736..5c81e44d 100644 --- a/modules/ItemLevel.lua +++ b/modules/ItemLevel.lua @@ -43,7 +43,7 @@ mod.uiName = L['Item level'] mod.uiDesc = L['Display the level of equippable item in the top left corner of the button.'] local colorSchemes = { - none = function() return 1, 1 ,1 end + none = function() return mod.db.profile.text.r, mod.db.profile.text.g, mod.db.profile.text.b end } local texts = {} @@ -56,6 +56,16 @@ else function SyLevelBypass() return false end end +local function UpdateFont() + local fontName, fontSize = mod.font:GetFont() + mod.font:SetFont(fontName, fontSize, "OUTLINE") + if mod.db.profile.colorScheme == "none" then + for button, text in pairs(texts) do + text:SetTextColor(colorSchemes[mod.db.profile.colorScheme]()) + end + end +end + function mod:OnInitialize() self.db = addon.db:RegisterNamespace(self.moduleName, { profile = { @@ -65,8 +75,18 @@ function mod:OnInitialize() minLevel = 1, ignoreJunk = true, ignoreHeirloom = true, + anchor = 'BOTTOMLEFT', + offsetX = 2, + offsetY = 1, + text = addon:GetFontDefaults(NumberFontNormalLarge), }, }) + self.font = addon:CreateFont( + self.name..'Font', + NumberFontNormalLarge, + function() return self.db.profile.text end + ) + self.font.SettingHook = UpdateFont if self.db.profile.colored == true then self.db.profile.colorScheme = 'original' self.db.profile.colored = nil @@ -87,12 +107,25 @@ function mod:OnInitialize() end end +local function UpdateTextLocation() + local anchor = mod.db.profile.anchor or mod.db.defaults.profile.anchor + local offsetX = mod.db.profile.offsetX or mod.db.defaults.profile.offsetX + local offsetY = mod.db.profile.offsetY or mod.db.defaults.profile.offsetY + for button, text in pairs(texts) do + text:ClearAllPoints() + text:SetPoint(anchor, button, offsetX, offsetY) + end +end + function mod:OnEnable() self:RegisterMessage('AdiBags_UpdateButton', 'UpdateButton') if SyLevel and self.db.profile.useSyLevel and not SyLevel:IsPipeEnabled('Adibags') then SyLevel:EnablePipe('Adibags') end self:SendMessage('AdiBags_UpdateAllButtons') + self.font:ApplySettings() + UpdateFont() + UpdateTextLocation() end function mod:OnDisable() @@ -103,7 +136,11 @@ end local function CreateText(button) local text = button:CreateFontString(nil, "OVERLAY", "NumberFontNormal") - text:SetPoint("TOPLEFT", button, 3, -1) + local anchor = mod.db.profile.anchor or mod.db.defaults.profile.anchor + local offsetX = mod.db.profile.offsetX or mod.db.defaults.profile.offsetX + local offsetY = mod.db.profile.offsetY or mod.db.defaults.profile.offsetY + text:SetPoint(anchor, button, offsetX, offsetY) + text:SetFontObject(mod.font) text:Hide() texts[button] = text return text @@ -152,7 +189,8 @@ end function mod:GetOptions() - return { + local options = + { useSyLevel = SyLevel and { name = L['Use SyLevel'], desc = L['Let SyLevel handle the the display.'], @@ -171,7 +209,7 @@ function mod:GetOptions() type = 'select', hidden = SyLevelBypass, values = { - none = L['None'], + none = L['Manual'], original = L['Same as InventoryItemLevels'], level = L['Related to player level'], }, @@ -199,7 +237,66 @@ function mod:GetOptions() type = 'toggle', order = 50, }, - }, addon:GetOptionHandler(self) + positionHeader = { + name = L['Text Position'], + type = 'header', + order = 70, + }, + anchor = { + name = L['Anchor'], + type = 'select', + values = { + TOPLEFT = "TOPLEFT", + TOP = "TOP", + TOPRIGHT = "TOPRIGHT", + LEFT = "LEFT", + CENTER = "CENTER", + RIGHT = "RIGHT", + BOTTOMLEFT = "BOTTOMLEFT", + BOTTOM = "BOTTOM", + BOTTOMRIGHT = "BOTTOMRIGHT", + }, + sorting = { + [1] = "TOPLEFT", + [2] = "TOP", + [3] = "TOPRIGHT", + [4] = "LEFT", + [5] = "CENTER", + [6] = "RIGHT", + [7] = "BOTTOMLEFT", + [8] = "BOTTOM", + [9] = "BOTTOMRIGHT", + }, + order = 71, + set = function(info,value) mod.db.profile[info[#info]] = value; UpdateTextLocation() end, + }, + offsetX = { + 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 = 72, + set = function(info,value) mod.db.profile[info[#info]] = value; UpdateTextLocation() end, + }, + offsetY = { + 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 = 73, + set = function(info,value) mod.db.profile[info[#info]] = value; UpdateTextLocation() end, + }, + text = addon:CreateFontOptions(self.font, nil, 80), + } + options.text.args.size.step = 1 + options.text.args.color.disabled = function() return mod.db.profile.colorScheme ~= "none" end + return options, addon:GetOptionHandler(self) end -- Color scheme inspired from InventoryItemLevels