Add Extra Action Button keybind with hotkey text, resizable size slider, and recentered anchor
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
<Bindings>
|
||||||
|
<Binding name="CLICK ExtraActionBarPoolFrameExtraActionButtonTemplate1:LeftButton" header="BINDING_HEADER_COA"/>
|
||||||
|
</Bindings>
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
## RequiredDeps: ElvUI
|
## RequiredDeps: ElvUI
|
||||||
## X-IconTexture: Interface\AddOns\ElvUI\Media\ElvUILogo
|
## X-IconTexture: Interface\AddOns\ElvUI\Media\ElvUILogo
|
||||||
|
|
||||||
|
Bindings.xml
|
||||||
core.lua
|
core.lua
|
||||||
Modules\ExtraActionBar.lua
|
Modules\ExtraActionBar.lua
|
||||||
Modules\LayerPicker.lua
|
Modules\LayerPicker.lua
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
local E, L, V, P, G = unpack(ElvUI)
|
local E, L, V, P, G = unpack(ElvUI)
|
||||||
|
local LSM = E.Libs.LSM
|
||||||
local CoA = E:GetModule("CoA")
|
local CoA = E:GetModule("CoA")
|
||||||
|
|
||||||
local CONTAINER_NAME = "ExtraActionBar"
|
local CONTAINER_NAME = "ExtraActionBar"
|
||||||
local BUTTON_NAME = "ExtraActionBarPoolFrameExtraActionButtonTemplate1"
|
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 function SkinGlow(button, name)
|
||||||
local glow = _G[name.."SpellActivationAlert"]
|
local glow = _G[name.."SpellActivationAlert"]
|
||||||
@@ -16,10 +20,49 @@ local function SkinGlow(button, name)
|
|||||||
end
|
end
|
||||||
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
|
if button.CoASkinned then return end
|
||||||
button.CoASkinned = true
|
button.CoASkinned = true
|
||||||
|
|
||||||
|
RecenterAnchor(button, container)
|
||||||
|
UpdateSize(button)
|
||||||
|
|
||||||
local name = button:GetName()
|
local name = button:GetName()
|
||||||
local icon = _G[name.."Icon"]
|
local icon = _G[name.."Icon"]
|
||||||
local hotkey = _G[name.."HotKey"]
|
local hotkey = _G[name.."HotKey"]
|
||||||
@@ -59,12 +102,18 @@ local function SkinButton(button)
|
|||||||
rim:SetFrameLevel(button.backdrop:GetFrameLevel() + 10)
|
rim:SetFrameLevel(button.backdrop:GetFrameLevel() + 10)
|
||||||
rim:SetBackdrop({edgeFile = E.media.blankTex, edgeSize = 6})
|
rim:SetBackdrop({edgeFile = E.media.blankTex, edgeSize = 6})
|
||||||
rim:SetBackdropBorderColor(unpack(E.media.bordercolor))
|
rim:SetBackdropBorderColor(unpack(E.media.bordercolor))
|
||||||
|
|
||||||
|
button:SetFrameLevel(rim:GetFrameLevel() + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if hotkey then
|
if hotkey then
|
||||||
hotkey:ClearAllPoints()
|
hotkey:ClearAllPoints()
|
||||||
hotkey:Point("TOPRIGHT", 0, 0)
|
hotkey:Point("TOPRIGHT", -8, -8)
|
||||||
hotkey:FontTemplate()
|
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
|
end
|
||||||
|
|
||||||
if macroText then
|
if macroText then
|
||||||
@@ -129,7 +178,7 @@ local function TryHook()
|
|||||||
|
|
||||||
if container and button then
|
if container and button then
|
||||||
SetupMover(container, button)
|
SetupMover(container, button)
|
||||||
SkinButton(button)
|
SkinButton(button, container)
|
||||||
end
|
end
|
||||||
|
|
||||||
return container ~= nil and button ~= nil
|
return container ~= nil and button ~= nil
|
||||||
|
|||||||
@@ -3,11 +3,17 @@ local EP = E.Libs.EP
|
|||||||
|
|
||||||
local AddOnName = ...
|
local AddOnName = ...
|
||||||
|
|
||||||
|
BINDING_HEADER_COA = "Conquest of Azeroth"
|
||||||
|
|
||||||
local CoA = E:NewModule("CoA", "AceEvent-3.0", "AceTimer-3.0")
|
local CoA = E:NewModule("CoA", "AceEvent-3.0", "AceTimer-3.0")
|
||||||
E.CoA = CoA
|
E.CoA = CoA
|
||||||
|
|
||||||
V.CoA = {}
|
V.CoA = {}
|
||||||
|
|
||||||
|
P.CoA = {
|
||||||
|
extraActionButtonSize = 52,
|
||||||
|
}
|
||||||
|
|
||||||
local function getOptions()
|
local function getOptions()
|
||||||
local options = {
|
local options = {
|
||||||
order = 55,
|
order = 55,
|
||||||
@@ -19,13 +25,42 @@ local function getOptions()
|
|||||||
order = 1,
|
order = 1,
|
||||||
type = "group",
|
type = "group",
|
||||||
name = "Extra Action Button",
|
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 = {
|
instanceSwap = {
|
||||||
order = 2,
|
order = 2,
|
||||||
type = "group",
|
type = "group",
|
||||||
name = "Instance Swap",
|
name = "Instance Swap",
|
||||||
args = {},
|
args = {
|
||||||
|
header = {
|
||||||
|
order = 1,
|
||||||
|
type = "header",
|
||||||
|
name = "Instance Swap",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user