完成焦点等开发
This commit is contained in:
126
ActionBars.lua
126
ActionBars.lua
@@ -26,6 +26,7 @@ local DEFAULTS = {
|
||||
showHotkey = true,
|
||||
showMacroName = false,
|
||||
rangeColoring = true,
|
||||
behindGlow = true,
|
||||
showPetBar = true,
|
||||
showStanceBar = true,
|
||||
showRightBars = true,
|
||||
@@ -1149,6 +1150,91 @@ local function GetOrCreateRangeOverlay(b)
|
||||
return ov
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Behind-skill glow: highlight skills that require being behind the target
|
||||
--------------------------------------------------------------------------------
|
||||
-- Icon texture substrings (lowercase) that identify "must be behind" skills.
|
||||
-- Matching by texture is the most reliable method in Vanilla (no GetActionInfo).
|
||||
local BEHIND_SKILL_ICONS = {
|
||||
-- Rogue
|
||||
"ability_backstab", -- 背刺 (Backstab)
|
||||
"ability_rogue_ambush", -- 伏击 (Ambush)
|
||||
"ability_ambush", -- 伏击 (Ambush, alternate icon)
|
||||
-- Druid (cat form)
|
||||
"spell_shadow_vampiricaura",-- 撕碎 (Shred)
|
||||
"ability_shred", -- 撕碎 (Shred, alternate)
|
||||
"ability_druid_ravage", -- 突袭 (Ravage)
|
||||
}
|
||||
|
||||
-- Build a fast lookup set (lowercased)
|
||||
local behindIconSet = {}
|
||||
for _, v in ipairs(BEHIND_SKILL_ICONS) do
|
||||
behindIconSet[string.lower(v)] = true
|
||||
end
|
||||
|
||||
-- Check if an action slot's icon matches a behind-only skill
|
||||
local function IsBehindSkillAction(action)
|
||||
if not action or not HasAction(action) then return false end
|
||||
local tex = GetActionTexture(action)
|
||||
if not tex then return false end
|
||||
tex = string.lower(tex)
|
||||
for pattern, _ in pairs(behindIconSet) do
|
||||
if string.find(tex, pattern) then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Create / retrieve the green glow overlay for behind-skill highlighting
|
||||
local function GetOrCreateBehindGlow(b)
|
||||
if b.sfBehindGlow then return b.sfBehindGlow end
|
||||
local inset = b.sfIconInset or 2
|
||||
|
||||
-- Outer glow frame (slightly larger than button)
|
||||
local glow = CreateFrame("Frame", nil, b)
|
||||
glow:SetFrameLevel(b:GetFrameLevel() + 3)
|
||||
glow:SetPoint("TOPLEFT", b, "TOPLEFT", -2, 2)
|
||||
glow:SetPoint("BOTTOMRIGHT", b, "BOTTOMRIGHT", 2, -2)
|
||||
|
||||
-- Green border textures (4 edges)
|
||||
local thickness = 2
|
||||
local r, g, a = 0.2, 1.0, 0.7
|
||||
|
||||
local top = glow:CreateTexture(nil, "OVERLAY")
|
||||
top:SetTexture("Interface\\Buttons\\WHITE8X8")
|
||||
top:SetPoint("TOPLEFT", glow, "TOPLEFT", 0, 0)
|
||||
top:SetPoint("TOPRIGHT", glow, "TOPRIGHT", 0, 0)
|
||||
top:SetHeight(thickness)
|
||||
top:SetVertexColor(r, g, 0.3, a)
|
||||
|
||||
local bot = glow:CreateTexture(nil, "OVERLAY")
|
||||
bot:SetTexture("Interface\\Buttons\\WHITE8X8")
|
||||
bot:SetPoint("BOTTOMLEFT", glow, "BOTTOMLEFT", 0, 0)
|
||||
bot:SetPoint("BOTTOMRIGHT", glow, "BOTTOMRIGHT", 0, 0)
|
||||
bot:SetHeight(thickness)
|
||||
bot:SetVertexColor(r, g, 0.3, a)
|
||||
|
||||
local left = glow:CreateTexture(nil, "OVERLAY")
|
||||
left:SetTexture("Interface\\Buttons\\WHITE8X8")
|
||||
left:SetPoint("TOPLEFT", glow, "TOPLEFT", 0, 0)
|
||||
left:SetPoint("BOTTOMLEFT", glow, "BOTTOMLEFT", 0, 0)
|
||||
left:SetWidth(thickness)
|
||||
left:SetVertexColor(r, g, 0.3, a)
|
||||
|
||||
local right = glow:CreateTexture(nil, "OVERLAY")
|
||||
right:SetTexture("Interface\\Buttons\\WHITE8X8")
|
||||
right:SetPoint("TOPRIGHT", glow, "TOPRIGHT", 0, 0)
|
||||
right:SetPoint("BOTTOMRIGHT", glow, "BOTTOMRIGHT", 0, 0)
|
||||
right:SetWidth(thickness)
|
||||
right:SetVertexColor(r, g, 0.3, a)
|
||||
|
||||
glow:Hide()
|
||||
b.sfBehindGlow = glow
|
||||
return glow
|
||||
end
|
||||
|
||||
-- Cached behind state, updated by the range-check timer
|
||||
local isBehindTarget = false
|
||||
|
||||
function AB:SetupRangeCheck()
|
||||
local rangeFrame = CreateFrame("Frame", "SFramesActionBarRangeCheck", UIParent)
|
||||
rangeFrame.timer = 0
|
||||
@@ -1160,7 +1246,18 @@ function AB:SetupRangeCheck()
|
||||
this.timer = 0
|
||||
|
||||
local db = AB:GetDB()
|
||||
if not db.rangeColoring then return end
|
||||
|
||||
-- Update behind state (shared with behind-glow logic)
|
||||
local behindGlowEnabled = db.behindGlow ~= false
|
||||
local hasEnemy = UnitExists("target") and UnitCanAttack("player", "target")
|
||||
and not UnitIsDead("target")
|
||||
if behindGlowEnabled and hasEnemy
|
||||
and type(UnitXP) == "function" then
|
||||
local ok, val = pcall(UnitXP, "behind", "player", "target")
|
||||
isBehindTarget = ok and val and true or false
|
||||
else
|
||||
isBehindTarget = false
|
||||
end
|
||||
|
||||
local function CheckRange(buttons, idFunc)
|
||||
local getID = idFunc or ActionButton_GetPagedID
|
||||
@@ -1168,15 +1265,30 @@ function AB:SetupRangeCheck()
|
||||
for _, b in ipairs(buttons) do
|
||||
local ok, action = pcall(getID, b)
|
||||
if ok and action and HasAction(action) then
|
||||
local inRange = IsActionInRange(action)
|
||||
local ov = GetOrCreateRangeOverlay(b)
|
||||
if inRange == 0 then
|
||||
ov:Show()
|
||||
else
|
||||
ov:Hide()
|
||||
-- Range coloring
|
||||
if db.rangeColoring then
|
||||
local inRange = IsActionInRange(action)
|
||||
local ov = GetOrCreateRangeOverlay(b)
|
||||
if inRange == 0 then
|
||||
ov:Show()
|
||||
else
|
||||
ov:Hide()
|
||||
end
|
||||
end
|
||||
-- Behind-skill glow
|
||||
if behindGlowEnabled and IsBehindSkillAction(action) then
|
||||
local glow = GetOrCreateBehindGlow(b)
|
||||
if isBehindTarget then
|
||||
glow:Show()
|
||||
else
|
||||
glow:Hide()
|
||||
end
|
||||
elseif b.sfBehindGlow then
|
||||
b.sfBehindGlow:Hide()
|
||||
end
|
||||
else
|
||||
if b.sfRangeOverlay then b.sfRangeOverlay:Hide() end
|
||||
if b.sfBehindGlow then b.sfBehindGlow:Hide() end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user