完成焦点等开发
This commit is contained in:
175
Units/Raid.lua
175
Units/Raid.lua
@@ -71,6 +71,17 @@ function SFrames.Raid:ApplyFrameStyle(frame, metrics)
|
||||
frame.healthBGFrame:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT", 1, -1)
|
||||
end
|
||||
|
||||
local bgA = (SFramesDB and type(SFramesDB.raidBgAlpha) == "number") and SFramesDB.raidBgAlpha or 0.9
|
||||
local A = SFrames.ActiveTheme
|
||||
if A and A.panelBg and bgA < 0.89 then
|
||||
if frame.healthBGFrame and frame.healthBGFrame.SetBackdropColor then
|
||||
frame.healthBGFrame:SetBackdropColor(A.panelBg[1], A.panelBg[2], A.panelBg[3], bgA)
|
||||
end
|
||||
if frame.powerBGFrame and frame.powerBGFrame.SetBackdropColor then
|
||||
frame.powerBGFrame:SetBackdropColor(A.panelBg[1], A.panelBg[2], A.panelBg[3], bgA)
|
||||
end
|
||||
end
|
||||
|
||||
if frame.power then
|
||||
if metrics.showPower then
|
||||
frame.power:Show()
|
||||
@@ -290,6 +301,10 @@ function SFrames.Raid:EnsureFrames()
|
||||
end)
|
||||
f:SetScript("OnClick", function()
|
||||
if arg1 == "LeftButton" then
|
||||
if IsShiftKeyDown() and SFrames.Focus and SFrames.Focus.SetFromUnit then
|
||||
pcall(SFrames.Focus.SetFromUnit, SFrames.Focus, this.unit)
|
||||
return
|
||||
end
|
||||
if TryDropCursorOnUnit(this.unit) then return end
|
||||
if SpellIsTargeting and SpellIsTargeting() then
|
||||
SpellTargetUnit(this.unit)
|
||||
@@ -375,10 +390,14 @@ function SFrames.Raid:EnsureFrames()
|
||||
end
|
||||
end)
|
||||
f:SetScript("OnEnter", function()
|
||||
if SetMouseoverUnit then SetMouseoverUnit(this.unit) end
|
||||
GameTooltip_SetDefaultAnchor(GameTooltip, this)
|
||||
GameTooltip:SetUnit(this.unit)
|
||||
end)
|
||||
f:SetScript("OnLeave", function() GameTooltip:Hide() end)
|
||||
f:SetScript("OnLeave", function()
|
||||
if SetMouseoverUnit then SetMouseoverUnit() end
|
||||
GameTooltip:Hide()
|
||||
end)
|
||||
f.unit = unit
|
||||
|
||||
-- Health Bar
|
||||
@@ -395,16 +414,24 @@ function SFrames.Raid:EnsureFrames()
|
||||
f.health.bg:SetVertexColor(_A.slotBg[1], _A.slotBg[2], _A.slotBg[3], _A.slotBg[4] or 1)
|
||||
|
||||
-- Heal prediction overlay (incoming heals)
|
||||
f.health.healPredMine = f.health:CreateTexture(nil, "OVERLAY")
|
||||
f.health.healPredMine = f.health:CreateTexture(nil, "ARTWORK")
|
||||
f.health.healPredMine:SetTexture(SFrames:GetTexture())
|
||||
f.health.healPredMine:SetVertexColor(0.4, 1.0, 0.55, 0.78)
|
||||
f.health.healPredMine:SetDrawLayer("ARTWORK", 2)
|
||||
f.health.healPredMine:Hide()
|
||||
|
||||
f.health.healPredOther = f.health:CreateTexture(nil, "OVERLAY")
|
||||
f.health.healPredOther = f.health:CreateTexture(nil, "ARTWORK")
|
||||
f.health.healPredOther:SetTexture(SFrames:GetTexture())
|
||||
f.health.healPredOther:SetVertexColor(0.2, 0.9, 0.35, 0.5)
|
||||
f.health.healPredOther:SetDrawLayer("ARTWORK", 2)
|
||||
f.health.healPredOther:Hide()
|
||||
|
||||
f.health.healPredOver = f.health:CreateTexture(nil, "OVERLAY")
|
||||
f.health.healPredOver:SetTexture(SFrames:GetTexture())
|
||||
f.health.healPredOver:SetVertexColor(1.0, 0.3, 0.3, 0.6)
|
||||
f.health.healPredOver:SetDrawLayer("OVERLAY", 7)
|
||||
f.health.healPredOver:Hide()
|
||||
|
||||
-- Power Bar
|
||||
f.power = SFrames:CreateStatusBar(f, "SFramesRaidFrame"..i.."Power")
|
||||
f.power:SetMinMaxValues(0, 100)
|
||||
@@ -793,14 +820,16 @@ function SFrames.Raid:UpdateHealPrediction(unit)
|
||||
if not frameData then return end
|
||||
|
||||
local f = frameData.frame
|
||||
if not (f.health and f.health.healPredMine and f.health.healPredOther) then return end
|
||||
if not (f.health and f.health.healPredMine and f.health.healPredOther and f.health.healPredOver) then return end
|
||||
|
||||
local predMine = f.health.healPredMine
|
||||
local predOther = f.health.healPredOther
|
||||
local predOver = f.health.healPredOver
|
||||
|
||||
local function HidePredictions()
|
||||
predMine:Hide()
|
||||
predOther:Hide()
|
||||
predOver:Hide()
|
||||
end
|
||||
|
||||
if not UnitExists(unit) or not UnitIsConnected(unit) then
|
||||
@@ -810,14 +839,39 @@ function SFrames.Raid:UpdateHealPrediction(unit)
|
||||
|
||||
local hp = UnitHealth(unit) or 0
|
||||
local maxHp = UnitHealthMax(unit) or 0
|
||||
if maxHp <= 0 or hp >= maxHp then
|
||||
|
||||
if CheckSuperWow then
|
||||
local ok, hasSW = pcall(CheckSuperWow)
|
||||
if ok and hasSW then
|
||||
local ok2, realHp = pcall(UnitHealth, unit)
|
||||
if ok2 then
|
||||
hp = realHp or hp
|
||||
end
|
||||
local ok3, realMaxHp = pcall(UnitHealthMax, unit)
|
||||
if ok3 then
|
||||
maxHp = realMaxHp or maxHp
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if maxHp <= 0 then
|
||||
HidePredictions()
|
||||
return
|
||||
end
|
||||
|
||||
local _, mineIncoming, othersIncoming = GetIncomingHeals(unit)
|
||||
if CheckSuperWow then
|
||||
local ok, hasSW = pcall(CheckSuperWow)
|
||||
if ok and hasSW then
|
||||
local ok2, _, realMine, realOther = pcall(GetIncomingHeals, unit)
|
||||
if ok2 then
|
||||
mineIncoming = realMine or mineIncoming
|
||||
othersIncoming = realOther or othersIncoming
|
||||
end
|
||||
end
|
||||
end
|
||||
local missing = maxHp - hp
|
||||
if missing <= 0 then
|
||||
if missing <= 0 and (mineIncoming <= 0 and othersIncoming <= 0) then
|
||||
HidePredictions()
|
||||
return
|
||||
end
|
||||
@@ -825,41 +879,46 @@ function SFrames.Raid:UpdateHealPrediction(unit)
|
||||
local mineShown = math.min(math.max(0, mineIncoming), missing)
|
||||
local remaining = missing - mineShown
|
||||
local otherShown = math.min(math.max(0, othersIncoming), remaining)
|
||||
if mineShown <= 0 and otherShown <= 0 then
|
||||
if mineIncoming <= 0 and othersIncoming <= 0 then
|
||||
HidePredictions()
|
||||
return
|
||||
end
|
||||
|
||||
local barWidth = f.health:GetWidth() or 0
|
||||
local barWidth = f:GetWidth() - 2
|
||||
if barWidth <= 0 then
|
||||
HidePredictions()
|
||||
return
|
||||
end
|
||||
|
||||
local currentWidth = math.floor((hp / maxHp) * barWidth + 0.5)
|
||||
if currentWidth < 0 then currentWidth = 0 end
|
||||
if currentWidth > barWidth then currentWidth = barWidth end
|
||||
local currentPosition = (hp / maxHp) * barWidth
|
||||
if currentPosition < 0 then currentPosition = 0 end
|
||||
if currentPosition > barWidth then currentPosition = barWidth end
|
||||
|
||||
local availableWidth = barWidth - currentWidth
|
||||
if availableWidth <= 0 then
|
||||
local availableWidth = barWidth - currentPosition
|
||||
if availableWidth <= 0 and (mineIncoming <= 0 and othersIncoming <= 0) then
|
||||
HidePredictions()
|
||||
return
|
||||
end
|
||||
|
||||
local mineWidth = math.floor((mineShown / maxHp) * barWidth + 0.5)
|
||||
local otherWidth = math.floor((otherShown / maxHp) * barWidth + 0.5)
|
||||
if mineWidth < 0 then mineWidth = 0 end
|
||||
if otherWidth < 0 then otherWidth = 0 end
|
||||
if mineWidth > availableWidth then mineWidth = availableWidth end
|
||||
if otherWidth > (availableWidth - mineWidth) then
|
||||
otherWidth = availableWidth - mineWidth
|
||||
local mineWidth = 0
|
||||
local otherWidth = 0
|
||||
if missing > 0 then
|
||||
mineWidth = (mineShown / missing) * availableWidth
|
||||
otherWidth = (otherShown / missing) * availableWidth
|
||||
if mineWidth < 0 then mineWidth = 0 end
|
||||
if otherWidth < 0 then otherWidth = 0 end
|
||||
if mineWidth > availableWidth then mineWidth = availableWidth end
|
||||
if otherWidth > (availableWidth - mineWidth) then
|
||||
otherWidth = availableWidth - mineWidth
|
||||
end
|
||||
end
|
||||
|
||||
if mineWidth > 0 then
|
||||
predMine:ClearAllPoints()
|
||||
predMine:SetPoint("TOPLEFT", f.health, "TOPLEFT", currentWidth, 0)
|
||||
predMine:SetPoint("BOTTOMLEFT", f.health, "BOTTOMLEFT", currentWidth, 0)
|
||||
predMine:SetPoint("TOPLEFT", f.health, "TOPLEFT", currentPosition, 0)
|
||||
predMine:SetPoint("BOTTOMLEFT", f.health, "BOTTOMLEFT", currentPosition, 0)
|
||||
predMine:SetWidth(mineWidth)
|
||||
predMine:SetHeight(f.health:GetHeight())
|
||||
predMine:Show()
|
||||
else
|
||||
predMine:Hide()
|
||||
@@ -867,13 +926,32 @@ function SFrames.Raid:UpdateHealPrediction(unit)
|
||||
|
||||
if otherWidth > 0 then
|
||||
predOther:ClearAllPoints()
|
||||
predOther:SetPoint("TOPLEFT", f.health, "TOPLEFT", currentWidth + mineWidth, 0)
|
||||
predOther:SetPoint("BOTTOMLEFT", f.health, "BOTTOMLEFT", currentWidth + mineWidth, 0)
|
||||
predOther:SetPoint("TOPLEFT", f.health, "TOPLEFT", currentPosition + mineWidth, 0)
|
||||
predOther:SetPoint("BOTTOMLEFT", f.health, "BOTTOMLEFT", currentPosition + mineWidth, 0)
|
||||
predOther:SetWidth(otherWidth)
|
||||
predOther:SetHeight(f.health:GetHeight())
|
||||
predOther:Show()
|
||||
else
|
||||
predOther:Hide()
|
||||
end
|
||||
|
||||
local totalIncoming = mineIncoming + othersIncoming
|
||||
local overHeal = totalIncoming - missing
|
||||
if overHeal > 0 then
|
||||
local overWidth = (overHeal / maxHp) * barWidth
|
||||
if overWidth > 0 then
|
||||
predOver:ClearAllPoints()
|
||||
predOver:SetPoint("TOPLEFT", f.health, "TOPRIGHT", 0, 0)
|
||||
predOver:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT", 0, 0)
|
||||
predOver:SetWidth(overWidth)
|
||||
predOver:SetHeight(f.health:GetHeight())
|
||||
predOver:Show()
|
||||
else
|
||||
predOver:Hide()
|
||||
end
|
||||
else
|
||||
predOver:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function SFrames.Raid:UpdatePower(unit)
|
||||
@@ -1016,15 +1094,51 @@ function SFrames.Raid:UpdateAuras(unit)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Helper: get buff name via SuperWoW aura ID (fast) or tooltip scan (fallback)
|
||||
local hasSuperWoW = SFrames.superwow_active and SpellInfo
|
||||
local function GetBuffName(unit, index)
|
||||
if hasSuperWoW then
|
||||
local texture, auraID = UnitBuff(unit, index)
|
||||
if auraID and SpellInfo then
|
||||
local spellName = SpellInfo(auraID)
|
||||
if spellName and spellName ~= "" then
|
||||
return spellName, texture
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Fallback: tooltip scan
|
||||
SFrames.Tooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
SFrames.Tooltip:SetUnitBuff(unit, index)
|
||||
local buffName = SFramesScanTooltipTextLeft1:GetText()
|
||||
SFrames.Tooltip:Hide()
|
||||
return buffName, UnitBuff(unit, index)
|
||||
end
|
||||
|
||||
local function GetDebuffName(unit, index)
|
||||
if hasSuperWoW then
|
||||
local texture, count, dtype, auraID = UnitDebuff(unit, index)
|
||||
if auraID and SpellInfo then
|
||||
local spellName = SpellInfo(auraID)
|
||||
if spellName and spellName ~= "" then
|
||||
return spellName, texture, count, dtype
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Fallback: tooltip scan
|
||||
SFrames.Tooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
SFrames.Tooltip:SetUnitDebuff(unit, index)
|
||||
local debuffName = SFramesScanTooltipTextLeft1:GetText()
|
||||
SFrames.Tooltip:Hide()
|
||||
local texture, count, dtype = UnitDebuff(unit, index)
|
||||
return debuffName, texture, count, dtype
|
||||
end
|
||||
|
||||
-- Check Buffs
|
||||
for i = 1, 32 do
|
||||
local texture, applications = UnitBuff(unit, i)
|
||||
if not texture then break end
|
||||
|
||||
SFrames.Tooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
SFrames.Tooltip:SetUnitBuff(unit, i)
|
||||
local buffName = SFramesScanTooltipTextLeft1:GetText()
|
||||
SFrames.Tooltip:Hide()
|
||||
local buffName = GetBuffName(unit, i)
|
||||
|
||||
if buffName then
|
||||
for pos, listData in pairs(buffsNeeded) do
|
||||
@@ -1058,10 +1172,7 @@ function SFrames.Raid:UpdateAuras(unit)
|
||||
end
|
||||
end
|
||||
|
||||
SFrames.Tooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
SFrames.Tooltip:SetUnitDebuff(unit, i)
|
||||
local debuffName = SFramesScanTooltipTextLeft1:GetText()
|
||||
SFrames.Tooltip:Hide()
|
||||
local debuffName = GetDebuffName(unit, i)
|
||||
|
||||
if debuffName then
|
||||
for pos, listData in pairs(buffsNeeded) do
|
||||
|
||||
Reference in New Issue
Block a user