diff --git a/Bindings.xml b/Bindings.xml new file mode 100644 index 0000000..bd99479 --- /dev/null +++ b/Bindings.xml @@ -0,0 +1,3 @@ + + + diff --git a/ElvUI_CoA.toc b/ElvUI_CoA.toc index ab95f63..b1b4d5d 100644 --- a/ElvUI_CoA.toc +++ b/ElvUI_CoA.toc @@ -6,6 +6,7 @@ ## RequiredDeps: ElvUI ## X-IconTexture: Interface\AddOns\ElvUI\Media\ElvUILogo +Bindings.xml core.lua Modules\ExtraActionBar.lua Modules\LayerPicker.lua diff --git a/Modules/ExtraActionBar.lua b/Modules/ExtraActionBar.lua index 81e6bd0..73da492 100644 --- a/Modules/ExtraActionBar.lua +++ b/Modules/ExtraActionBar.lua @@ -1,8 +1,12 @@ local E, L, V, P, G = unpack(ElvUI) +local LSM = E.Libs.LSM local CoA = E:GetModule("CoA") local CONTAINER_NAME = "ExtraActionBar" local BUTTON_NAME = "ExtraActionBarPoolFrameExtraActionButtonTemplate1" +local BINDING_ACTION = "CLICK "..BUTTON_NAME..":LeftButton" + +_G["BINDING_NAME_"..BINDING_ACTION] = "Extra Action Button" local function SkinGlow(button, name) local glow = _G[name.."SpellActivationAlert"] @@ -16,10 +20,49 @@ local function SkinGlow(button, name) end end -local function SkinButton(button) +local function UpdateSize(button) + button = button or _G[BUTTON_NAME] + if button then + local size = E.db.CoA.extraActionButtonSize or 52 + button:SetSize(size, size) + end +end + +function CoA:UpdateExtraActionButtonSize() + UpdateSize() +end + +local function UpdateHotkeyText(button) + button = button or _G[BUTTON_NAME] + local hotkey = button and _G[button:GetName().."HotKey"] + if not hotkey then return end + + local key = GetBindingKey(BINDING_ACTION) + if key then + hotkey:SetText(GetBindingText(key, "KEY_")) + hotkey:Show() + else + hotkey:SetText("") + hotkey:Hide() + end +end + +local function RecenterAnchor(button, container) + local x, y = button:GetCenter() + local cx, cy = container:GetCenter() + if not (x and y and cx and cy) then return end + + button:ClearAllPoints() + button:SetPoint("CENTER", container, "CENTER", x - cx, y - cy) +end + +local function SkinButton(button, container) if button.CoASkinned then return end button.CoASkinned = true + RecenterAnchor(button, container) + UpdateSize(button) + local name = button:GetName() local icon = _G[name.."Icon"] local hotkey = _G[name.."HotKey"] @@ -59,12 +102,18 @@ local function SkinButton(button) rim:SetFrameLevel(button.backdrop:GetFrameLevel() + 10) rim:SetBackdrop({edgeFile = E.media.blankTex, edgeSize = 6}) rim:SetBackdropBorderColor(unpack(E.media.bordercolor)) + + button:SetFrameLevel(rim:GetFrameLevel() + 1) end if hotkey then hotkey:ClearAllPoints() - hotkey:Point("TOPRIGHT", 0, 0) - hotkey:FontTemplate() + hotkey:Point("TOPRIGHT", -8, -8) + hotkey:FontTemplate(LSM:Fetch("font", E.db.actionbar.font), E.db.actionbar.fontSize, E.db.actionbar.fontOutline) + hotkey:SetTextColor(1, 1, 1) + + UpdateHotkeyText(button) + CoA:RegisterEvent("UPDATE_BINDINGS", function() UpdateHotkeyText(button) end) end if macroText then @@ -129,7 +178,7 @@ local function TryHook() if container and button then SetupMover(container, button) - SkinButton(button) + SkinButton(button, container) end return container ~= nil and button ~= nil diff --git a/core.lua b/core.lua index 2c3565c..ef4bae3 100644 --- a/core.lua +++ b/core.lua @@ -3,11 +3,17 @@ local EP = E.Libs.EP local AddOnName = ... +BINDING_HEADER_COA = "Conquest of Azeroth" + local CoA = E:NewModule("CoA", "AceEvent-3.0", "AceTimer-3.0") E.CoA = CoA V.CoA = {} +P.CoA = { + extraActionButtonSize = 52, +} + local function getOptions() local options = { order = 55, @@ -19,13 +25,42 @@ local function getOptions() order = 1, type = "group", name = "Extra Action Button", - args = {}, + args = { + header = { + order = 1, + type = "header", + name = "Extra Action Button", + }, + size = { + order = 2, + type = "range", + name = "Size", + desc = "Adjust the width/height of the Extra Action Button, in pixels.", + min = 30, + max = 100, + step = 1, + get = function() return E.db.CoA.extraActionButtonSize end, + set = function(_, value) + E.db.CoA.extraActionButtonSize = value + + if CoA.UpdateExtraActionButtonSize then + CoA:UpdateExtraActionButtonSize() + end + end, + }, + }, }, instanceSwap = { order = 2, type = "group", name = "Instance Swap", - args = {}, + args = { + header = { + order = 1, + type = "header", + name = "Instance Swap", + }, + }, }, }, }