完成多出修改

修复拾取界面点击无效问题
修复宠物训练界面不显示训练点问题
新增天赋分享到聊天界面
修复飞行界面无法关闭问题
修复术士宠物的显示问题
为天赋界面添加默认数据库支持
框架现在也可自主选择是否启用
玩家框架和目标框架可取消显示3D头像以及透明度修改
背包和银行也添加透明度自定义支持
优化tooltip性能和背包物品显示方式
修复布局模式在ui缩放后不能正常定位的问题
添加硬核模式危险和死亡的工会通报
添加拾取和已拾取的框体
等等
This commit is contained in:
rucky
2026-03-23 10:25:25 +08:00
parent 63337b14d2
commit ec9e3c29d6
34 changed files with 13897 additions and 578 deletions

View File

@@ -11,6 +11,10 @@ local function Clamp(value, minValue, maxValue)
return value
end
local DIST_BASE_WIDTH = 80
local DIST_BASE_HEIGHT = 24
local DIST_BASE_FONTSIZE = 14
function SFrames.Target:GetDistance(unit)
if not UnitExists(unit) then return nil end
if UnitIsUnit(unit, "player") then return "0 码" end
@@ -69,27 +73,60 @@ function SFrames.Target:ApplyConfig()
local cfg = self:GetConfig()
local f = self.frame
local db = SFramesDB or {}
local showPortrait = db.targetShowPortrait ~= false
local frameAlpha = tonumber(db.targetFrameAlpha) or 1
frameAlpha = Clamp(frameAlpha, 0.1, 1.0)
f:SetScale(cfg.scale)
f:SetWidth(cfg.width)
f:SetHeight(cfg.height)
f:SetAlpha(frameAlpha)
if f.portrait then
f.portrait:SetWidth(cfg.portraitWidth)
f.portrait:SetHeight(cfg.height - 2)
end
if f.portraitBG then
f.portraitBG:ClearAllPoints()
f.portraitBG:SetPoint("TOPLEFT", f.portrait, "TOPLEFT", -1, 0)
f.portraitBG:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 0, 0)
end
if f.health then
f.health:ClearAllPoints()
f.health:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1)
f.health:SetPoint("TOPRIGHT", f.portrait, "TOPLEFT", -1, 0)
f.health:SetHeight(cfg.healthHeight)
if showPortrait then
if f.portrait then
f.portrait:SetWidth(cfg.portraitWidth)
f.portrait:SetHeight(cfg.height - 2)
f.portrait:Show()
end
if f.portraitBG then
f.portraitBG:ClearAllPoints()
f.portraitBG:SetPoint("TOPLEFT", f.portrait, "TOPLEFT", -1, 0)
f.portraitBG:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 0, 0)
f.portraitBG:Show()
end
if f.health then
f.health:ClearAllPoints()
f.health:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1)
f.health:SetPoint("TOPRIGHT", f.portrait, "TOPLEFT", -1, 0)
f.health:SetHeight(cfg.healthHeight)
end
if f.classIcon and f.classIcon.overlay then
f.classIcon.overlay:ClearAllPoints()
f.classIcon.overlay:SetPoint("CENTER", f.portrait, "TOPRIGHT", 0, 0)
end
if f.comboText then
f.comboText:ClearAllPoints()
f.comboText:SetPoint("CENTER", f.portrait, "CENTER", 0, 0)
end
else
if f.portrait then f.portrait:Hide() end
if f.portraitBG then f.portraitBG:Hide() end
if f.health then
f.health:ClearAllPoints()
f.health:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1)
f.health:SetPoint("TOPRIGHT", f, "TOPRIGHT", -1, -1)
f.health:SetHeight(cfg.healthHeight)
end
if f.classIcon and f.classIcon.overlay then
f.classIcon.overlay:ClearAllPoints()
f.classIcon.overlay:SetPoint("CENTER", f, "TOPRIGHT", -8, 0)
end
if f.comboText then
f.comboText:ClearAllPoints()
f.comboText:SetPoint("RIGHT", f.health, "RIGHT", -4, 0)
end
end
if f.healthBGFrame then
@@ -124,9 +161,20 @@ function SFrames.Target:ApplyConfig()
f.powerText:SetFont(fontPath, cfg.valueFont, outline)
end
if f.castbar then
f.castbar:ClearAllPoints()
if showPortrait then
f.castbar:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 6)
f.castbar:SetPoint("BOTTOMRIGHT", f.portrait, "TOPRIGHT", -(SFrames.Config.castbarHeight + 6), 6)
else
f.castbar:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 6)
f.castbar:SetPoint("BOTTOMRIGHT", f, "TOPRIGHT", -(SFrames.Config.castbarHeight + 6), 6)
end
end
if self.distanceFrame then
local dScale = tonumber(SFramesDB and SFramesDB.targetDistanceScale) or 1
self.distanceFrame:SetScale(Clamp(dScale, 0.7, 1.8))
self:ApplyDistanceScale(dScale)
end
if UnitExists("target") then
@@ -134,22 +182,36 @@ function SFrames.Target:ApplyConfig()
end
end
function SFrames.Target:ApplyDistanceScale(scale)
local f = self.distanceFrame
if not f then return end
scale = Clamp(tonumber(scale) or 1, 0.7, 1.8)
f:SetWidth(DIST_BASE_WIDTH * scale)
f:SetHeight(DIST_BASE_HEIGHT * scale)
if f.text then
local fontPath = SFrames:GetFont()
local outline = (SFrames.Media and SFrames.Media.fontOutline) or "OUTLINE"
local fontSize = math.max(8, math.floor(DIST_BASE_FONTSIZE * scale + 0.5))
f.text:SetFont(fontPath, fontSize, outline)
end
end
function SFrames.Target:InitializeDistanceFrame()
local f = CreateFrame("Button", "SFramesTargetDistanceFrame", UIParent)
f:SetWidth(80)
f:SetHeight(24)
f:SetFrameStrata("HIGH")
local frameScale = (SFramesDB and type(SFramesDB.targetDistanceScale) == "number") and SFramesDB.targetDistanceScale or 1
f:SetScale(frameScale)
local dScale = (SFramesDB and type(SFramesDB.targetDistanceScale) == "number") and SFramesDB.targetDistanceScale or 1
dScale = Clamp(dScale, 0.7, 1.8)
f:SetWidth(DIST_BASE_WIDTH * dScale)
f:SetHeight(DIST_BASE_HEIGHT * dScale)
if SFramesDB and SFramesDB.Positions and SFramesDB.Positions["TargetDistanceFrame"] then
local pos = SFramesDB.Positions["TargetDistanceFrame"]
f:SetPoint(pos.point, UIParent, pos.relativePoint, pos.xOfs, pos.yOfs)
else
-- Default position: Center of screen for visibility if first time
f:SetPoint("CENTER", UIParent, "CENTER", 0, 100)
end
f:SetMovable(true)
f:EnableMouse(true)
f:RegisterForDrag("LeftButton")
@@ -161,29 +223,29 @@ function SFrames.Target:InitializeDistanceFrame()
local point, relativeTo, relativePoint, xOfs, yOfs = this:GetPoint()
SFramesDB.Positions["TargetDistanceFrame"] = { point = point, relativePoint = relativePoint, xOfs = xOfs, yOfs = yOfs }
end)
SFrames:CreateUnitBackdrop(f)
f:SetBackdrop(nil) -- Remove border and background for natural look
f.text = SFrames:CreateFontString(f, 14, "CENTER")
f:SetBackdrop(nil)
local fontSize = math.max(8, math.floor(DIST_BASE_FONTSIZE * dScale + 0.5))
f.text = SFrames:CreateFontString(f, fontSize, "CENTER")
f.text:SetPoint("CENTER", f, "CENTER", 0, 0)
f.text:SetTextColor(1, 0.8, 0.2)
f.text:SetShadowColor(0, 0, 0, 1)
f.text:SetShadowOffset(1, -1)
SFrames.Target.distanceFrame = f
f:Hide()
-- Distance Updater on the frame itself
f.timer = 0
f:SetScript("OnUpdate", function()
if SFramesDB and SFramesDB.targetDistanceEnabled == false then
if this:IsShown() then this:Hide() end
return
end
if not UnitExists("target") then
if not UnitExists("target") then
if this:IsShown() then this:Hide() end
return
return
end
this.timer = this.timer + (arg1 or 0)
if this.timer >= 0.4 then
@@ -391,7 +453,13 @@ function SFrames.Target:Initialize()
SFrames:RegisterEvent("UNIT_MAXRAGE", function() if arg1 == "target" then self:UpdatePower() end end)
SFrames:RegisterEvent("PLAYER_COMBO_POINTS", function() self:UpdateComboPoints() end)
SFrames:RegisterEvent("UNIT_DISPLAYPOWER", function() if arg1 == "target" then self:UpdatePowerType() end end)
SFrames:RegisterEvent("UNIT_PORTRAIT_UPDATE", function() if arg1 == "target" then self.frame.portrait:SetUnit("target") self.frame.portrait:SetCamera(0) self.frame.portrait:SetPosition(-1.0, 0, 0) end end)
SFrames:RegisterEvent("UNIT_PORTRAIT_UPDATE", function()
if arg1 == "target" and self.frame.portrait and not (SFramesDB and SFramesDB.targetShowPortrait == false) then
self.frame.portrait:SetUnit("target")
self.frame.portrait:SetCamera(0)
self.frame.portrait:SetPosition(-1.0, 0, 0)
end
end)
SFrames:RegisterEvent("UNIT_DYNAMIC_FLAGS", function() if arg1 == "target" then self:UpdateAll() end end)
SFrames:RegisterEvent("UNIT_FACTION", function() if arg1 == "target" then self:UpdateAll() end end)
SFrames:RegisterEvent("RAID_TARGET_UPDATE", function() self:UpdateRaidIcon() end)
@@ -413,7 +481,15 @@ function SFrames.Target:Initialize()
-- If target already exists on load (e.g. after /reload), show and update it immediately
self:OnTargetChanged()
-- Distance Updater removed from target frame
-- Register movers
if SFrames.Movers and SFrames.Movers.RegisterMover then
SFrames.Movers:RegisterMover("TargetFrame", f, "目标",
"CENTER", "UIParent", "CENTER", 200, -100)
if SFrames.Target.distanceFrame then
SFrames.Movers:RegisterMover("TargetDistanceFrame", SFrames.Target.distanceFrame, "目标距离",
"CENTER", "UIParent", "CENTER", 0, 100)
end
end
end
function SFrames.Target:OnTargetChanged()
@@ -444,11 +520,14 @@ function SFrames.Target:UpdateAll()
self:UpdateRaidIcon()
self:UpdateAuras()
self.frame.portrait:SetUnit("target")
self.frame.portrait:SetCamera(0)
self.frame.portrait:Hide()
self.frame.portrait:Show()
self.frame.portrait:SetPosition(-1.0, 0, 0)
local showPortrait = not (SFramesDB and SFramesDB.targetShowPortrait == false)
if showPortrait and self.frame.portrait then
self.frame.portrait:SetUnit("target")
self.frame.portrait:SetCamera(0)
self.frame.portrait:Hide()
self.frame.portrait:Show()
self.frame.portrait:SetPosition(-1.0, 0, 0)
end
local name = UnitName("target") or ""
local level = UnitLevel("target")
@@ -901,11 +980,11 @@ function SFrames.Target:UpdateAuras()
if texture then
b.icon:SetTexture(texture)
-- Scrape tooltip for duration
SFrames.Tooltip:SetOwner(UIParent, "ANCHOR_NONE")
SFrames.Tooltip:ClearLines()
SFrames.Tooltip:SetUnitBuff("target", i)
local timeLeft = SFrames:GetAuraTimeLeft("target", i, true)
SFrames.Tooltip:Hide()
if timeLeft and timeLeft > 0 then
b.expirationTime = GetTime() + timeLeft
b.cdText:SetText(SFrames:FormatTime(timeLeft))
@@ -974,6 +1053,7 @@ function SFrames.Target:UpdateAuras()
SFrames.Tooltip:ClearLines()
SFrames.Tooltip:SetUnitDebuff("target", i)
timeLeft = SFrames:GetAuraTimeLeft("target", i, false)
SFrames.Tooltip:Hide()
end
if timeLeft and timeLeft > 0 then