diff --git a/Modules/ExtraActionBar.lua b/Modules/ExtraActionBar.lua index 73da492..7d6f15c 100644 --- a/Modules/ExtraActionBar.lua +++ b/Modules/ExtraActionBar.lua @@ -23,7 +23,7 @@ end local function UpdateSize(button) button = button or _G[BUTTON_NAME] if button then - local size = E.db.CoA.extraActionButtonSize or 52 + local size = E.global.CoA.extraActionButtonSize or 52 button:SetSize(size, size) end end diff --git a/Modules/LayerPicker.lua b/Modules/LayerPicker.lua index 81b4e86..2e937ef 100644 --- a/Modules/LayerPicker.lua +++ b/Modules/LayerPicker.lua @@ -1,7 +1,27 @@ local E, L, V, P, G = unpack(ElvUI) +local LSM = E.Libs.LSM local CoA = E:GetModule("CoA") local BUTTON_NAME = "LayerPickerFrame" +local MIN_WIDTH, MIN_HEIGHT = 66, 14 +local PAD_X, PAD_Y = 10, 10 + +local function UpdateFont(button) + button = button or _G[BUTTON_NAME] + local text = button and _G[button:GetName().."Text"] + if not text then return end + + text:FontTemplate(LSM:Fetch("font", E.global.CoA.instanceButtonFont), E.global.CoA.instanceButtonFontSize, E.global.CoA.instanceButtonFontOutline) + + button:SetSize( + math.max(MIN_WIDTH, text:GetStringWidth() + PAD_X), + math.max(MIN_HEIGHT, text:GetStringHeight() + PAD_Y) + ) +end + +function CoA:UpdateInstanceButtonFont() + UpdateFont() +end do local orig_AddButton = UIDropDownMenu_AddButton @@ -60,16 +80,11 @@ local function SkinButton(button) if button.CoASkinned then return end button.CoASkinned = true - local name = button:GetName() - local text = _G[name.."Text"] - button:StripTextures(true) button:CreateBackdrop("Default") button:StyleButton() - if text then - text:FontTemplate() - end + UpdateFont(button) end local function TryHook() diff --git a/core.lua b/core.lua index ef4bae3..64c42df 100644 --- a/core.lua +++ b/core.lua @@ -1,5 +1,6 @@ local E, L, V, P, G = unpack(ElvUI) local EP = E.Libs.EP +local ACH = LibStub("LibAceConfigHelper") local AddOnName = ... @@ -10,8 +11,11 @@ E.CoA = CoA V.CoA = {} -P.CoA = { +G.CoA = { extraActionButtonSize = 52, + instanceButtonFont = "PT Sans Narrow", + instanceButtonFontSize = 12, + instanceButtonFontOutline = "OUTLINE", } local function getOptions() @@ -39,9 +43,9 @@ local function getOptions() min = 30, max = 100, step = 1, - get = function() return E.db.CoA.extraActionButtonSize end, + get = function() return E.global.CoA.extraActionButtonSize end, set = function(_, value) - E.db.CoA.extraActionButtonSize = value + E.global.CoA.extraActionButtonSize = value if CoA.UpdateExtraActionButtonSize then CoA:UpdateExtraActionButtonSize() @@ -60,6 +64,40 @@ local function getOptions() type = "header", name = "Instance Swap", }, + font = ACH:SharedMediaFont("Font", nil, 2, nil, + function() return E.global.CoA.instanceButtonFont end, + function(_, value) + E.global.CoA.instanceButtonFont = value + + if CoA.UpdateInstanceButtonFont then + CoA:UpdateInstanceButtonFont() + end + end), + fontSize = { + order = 3, + type = "range", + name = "Font Size", + min = 8, + max = 32, + step = 1, + get = function() return E.global.CoA.instanceButtonFontSize end, + set = function(_, value) + E.global.CoA.instanceButtonFontSize = value + + if CoA.UpdateInstanceButtonFont then + CoA:UpdateInstanceButtonFont() + end + end, + }, + fontOutline = ACH:FontFlags("Font Outline", nil, 4, nil, + function() return E.global.CoA.instanceButtonFontOutline end, + function(_, value) + E.global.CoA.instanceButtonFontOutline = value + + if CoA.UpdateInstanceButtonFont then + CoA:UpdateInstanceButtonFont() + end + end), }, }, },