更新发送到功能

更新仇恨计算方式 还在开发
更新其他细节
This commit is contained in:
rucky
2026-03-23 10:26:31 +08:00
commit 5c3f2243c4
26 changed files with 6080 additions and 0 deletions

132
BarDisplay.lua Normal file
View File

@@ -0,0 +1,132 @@
local NanamiDPS = NanamiDPS
local DataStore = NanamiDPS.DataStore
local L = NanamiDPS.L
local BarDisplay = {}
NanamiDPS.BarDisplay = BarDisplay
local BAR_POOL = {}
function BarDisplay:CreateBar(parent, index)
local cfg = NanamiDPS.config or {}
local barHeight = cfg.barHeight or 16
local barSpacing = cfg.barSpacing or 1
local fontSize = cfg.fontSize or 10
local A = SFrames.ActiveTheme
local bar = CreateFrame("StatusBar", "NanamiDPSBar" .. parent:GetID() .. "_" .. index, parent)
bar:SetStatusBarTexture(SFrames:GetTexture())
bar:SetHeight(barHeight)
bar:SetMinMaxValues(0, 1)
bar:SetValue(0)
bar:SetFrameLevel(parent:GetFrameLevel() + 3)
bar.bg = bar:CreateTexture(nil, "BACKGROUND")
bar.bg:SetTexture(SFrames:GetTexture())
bar.bg:SetAllPoints(bar)
if A and A.barBg then
bar.bg:SetVertexColor(A.barBg[1], A.barBg[2], A.barBg[3], A.barBg[4] or 0.6)
else
bar.bg:SetVertexColor(0.15, 0.15, 0.15, 0.6)
end
if cfg.showClassIcons and SFrames.CreateClassIcon then
bar.classIcon = SFrames:CreateClassIcon(bar, barHeight - 2)
bar.classIcon.overlay:SetPoint("LEFT", bar, "LEFT", 2, 0)
end
local textOffset = (cfg.showClassIcons and barHeight + 2) or 4
bar.textLeft = SFrames:CreateFontString(bar, fontSize, "LEFT")
bar.textLeft:SetPoint("LEFT", bar, "LEFT", textOffset, 0)
bar.textLeft:SetPoint("RIGHT", bar, "RIGHT", -130, 0)
bar.textRight = SFrames:CreateFontString(bar, fontSize, "RIGHT")
bar.textRight:SetPoint("RIGHT", bar, "RIGHT", -4, 0)
bar.textRight:SetWidth(126)
bar:EnableMouse(true)
bar:SetScript("OnEnter", function()
if this.onEnter then this.onEnter(this) end
end)
bar:SetScript("OnLeave", function()
if this.onLeave then this.onLeave(this) end
end)
bar:SetScript("OnMouseUp", function()
if this.onClick then this.onClick(this, arg1) end
end)
bar.index = index
return bar
end
function BarDisplay:LayoutBars(window)
local cfg = NanamiDPS.config or {}
local barHeight = cfg.barHeight or 16
local barSpacing = cfg.barSpacing or 1
local headerHeight = 22
for i, bar in ipairs(window.bars) do
bar:ClearAllPoints()
bar:SetPoint("TOPLEFT", window.content, "TOPLEFT", 1, -((i - 1) * (barHeight + barSpacing)))
bar:SetPoint("TOPRIGHT", window.content, "TOPRIGHT", -1, -((i - 1) * (barHeight + barSpacing)))
bar:SetHeight(barHeight)
end
end
function BarDisplay:UpdateBar(bar, data, maxVal, rank)
if not data then
bar:Hide()
return
end
bar:Show()
bar:SetMinMaxValues(0, maxVal > 0 and maxVal or 1)
bar:SetValue(data.value or 0)
local r, g, b = data.r or 0.6, data.g or 0.6, data.b or 0.6
bar:SetStatusBarColor(r, g, b, 1)
bar.bg:SetVertexColor(r * 0.25, g * 0.25, b * 0.25, 0.6)
local nameStr = rank .. ". " .. (data.name or L["Unknown"])
bar.textLeft:SetText(nameStr)
local valStr
if data.valueText then
valStr = data.valueText
else
valStr = NanamiDPS.formatNumber(data.value or 0)
if data.percent then
valStr = valStr .. " (" .. NanamiDPS.round(data.percent, 1) .. "%)"
end
end
bar.textRight:SetText(valStr)
if bar.classIcon and data.class and NanamiDPS.validClasses[data.class] then
SFrames:SetClassIcon(bar.classIcon, data.class)
elseif bar.classIcon then
bar.classIcon:Hide()
if bar.classIcon.overlay then bar.classIcon.overlay:Hide() end
end
bar.barData = data
end
function BarDisplay:SetBarCallbacks(bar, onEnter, onLeave, onClick)
bar.onEnter = onEnter
bar.onLeave = onLeave
bar.onClick = onClick
end
function BarDisplay:GetMaxBars(window)
local cfg = NanamiDPS.config or {}
local barHeight = cfg.barHeight or 16
local barSpacing = cfg.barSpacing or 1
local contentHeight = 200
if window.content then
local h = window.content:GetHeight()
if h and h > 10 then contentHeight = h end
end
local maxBars = math.floor(contentHeight / (barHeight + barSpacing))
return math.max(maxBars, 1)
end