调整dps插件对仇恨的估算方式

优化dps插件
This commit is contained in:
rucky
2026-03-25 00:57:35 +08:00
parent 5c3f2243c4
commit 12c8c55159
16 changed files with 2454 additions and 165 deletions

View File

@@ -17,7 +17,32 @@ local SNAP_THRESHOLD = 12
-----------------------------------------------------------------------
local MAX_DROPDOWN_VISIBLE = 8
local dropdownOverlay = CreateFrame("Button", "NanamiDPS_DropdownOverlay", UIParent)
dropdownOverlay:SetFrameStrata("FULLSCREEN")
dropdownOverlay:SetAllPoints(UIParent)
dropdownOverlay:EnableMouse(true)
dropdownOverlay:Hide()
dropdownOverlay.activeDropdown = nil
dropdownOverlay:SetScript("OnClick", function()
if dropdownOverlay.activeDropdown then
dropdownOverlay.activeDropdown:Hide()
end
dropdownOverlay.activeDropdown = nil
dropdownOverlay:Hide()
end)
local function HideActiveDropdown()
if dropdownOverlay.activeDropdown then
dropdownOverlay.activeDropdown:Hide()
end
dropdownOverlay.activeDropdown = nil
dropdownOverlay:Hide()
end
local function ShowDropdown(parent, items, onClick, anchorPoint, relTo, relPoint, xOff, yOff)
HideActiveDropdown()
if parent.dropdown and parent.dropdown:IsShown() then
parent.dropdown:Hide()
return
@@ -75,7 +100,7 @@ local function ShowDropdown(parent, items, onClick, anchorPoint, relTo, relPoint
btn:SetScript("OnClick", function()
if this.itemData then
dd.onClickFn(this.itemData)
dd:Hide()
HideActiveDropdown()
end
end)
@@ -144,6 +169,8 @@ local function ShowDropdown(parent, items, onClick, anchorPoint, relTo, relPoint
dd.scrollDownIndicator:Hide()
end
dropdownOverlay.activeDropdown = dd
dropdownOverlay:Show()
dd:Show()
end
@@ -384,11 +411,60 @@ function Window:Create(wid)
end)
resetBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
-- Pause button
local pauseBtn = CreateFrame("Button", nil, frame.titleBar)
pauseBtn:SetWidth(16)
pauseBtn:SetHeight(16)
pauseBtn:SetPoint("RIGHT", resetBtn, "LEFT", -1, 0)
local pauseIcon = SFrames:CreateFontString(pauseBtn, 9, "CENTER")
pauseIcon:SetAllPoints()
pauseIcon:SetText("||")
if A and A.text then
pauseIcon:SetTextColor(A.text[1], A.text[2], A.text[3])
end
frame.pauseBtn = pauseBtn
local function UpdatePauseVisual()
if cfg.paused then
if A and A.accent then
pauseIcon:SetTextColor(A.accent[1], A.accent[2], A.accent[3])
else
pauseIcon:SetTextColor(1, 0.5, 0.5)
end
pauseIcon:SetText("|cffff4444>||")
else
if A and A.text then
pauseIcon:SetTextColor(A.text[1], A.text[2], A.text[3])
else
pauseIcon:SetTextColor(1, 1, 1)
end
pauseIcon:SetText("||")
end
end
UpdatePauseVisual()
frame.updatePauseVisual = UpdatePauseVisual
pauseBtn:SetScript("OnClick", function()
cfg.paused = not cfg.paused
Window:UpdatePausedAlpha()
end)
pauseBtn:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
if cfg.paused then
GameTooltip:AddLine(L["Resume"])
else
GameTooltip:AddLine(L["Pause"])
end
GameTooltip:Show()
end)
pauseBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
-- Report button
local reportBtn = CreateFrame("Button", nil, frame.titleBar)
reportBtn:SetWidth(16)
reportBtn:SetHeight(16)
reportBtn:SetPoint("RIGHT", resetBtn, "LEFT", -1, 0)
reportBtn:SetPoint("RIGHT", pauseBtn, "LEFT", -1, 0)
local reportIcon = SFrames:CreateFontString(reportBtn, 9, "CENTER")
reportIcon:SetAllPoints()
reportIcon:SetText("R")
@@ -464,6 +540,7 @@ function Window:Create(wid)
ShowDropdown(frame.btnSegment, items, function(item)
frame.segmentIndex = item.index
frame.btnSegment.text:SetText(item.text)
Window:SavePosition(frame)
Window:RefreshWindow(frame)
end, "TOPLEFT", frame.btnSegment, "BOTTOMLEFT", 0, -2)
end)
@@ -503,6 +580,7 @@ function Window:Create(wid)
frame.activeModuleName = item.moduleName
frame.btnMode.text:SetText(item.text)
frame.scroll = 0
Window:SavePosition(frame)
Window:RefreshWindow(frame)
end, "TOPLEFT", frame.btnMode, "BOTTOMLEFT", 0, -2)
end)
@@ -514,6 +592,32 @@ function Window:Create(wid)
frame.content:SetPoint("TOPLEFT", frame.selectorBar, "BOTTOMLEFT", 0, -1)
frame.content:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -4, 4)
-- Paused overlay text (created after content frame)
frame.pausedOverlay = frame.content:CreateFontString(nil, "OVERLAY")
frame.pausedOverlay:SetFont(STANDARD_TEXT_FONT, 14, "OUTLINE")
frame.pausedOverlay:SetPoint("CENTER", frame.content, "CENTER", 0, 0)
frame.pausedOverlay:SetText("|cffff6666" .. L["Paused"])
frame.pausedOverlay:SetAlpha(0.7)
if cfg.paused then
frame.pausedOverlay:Show()
else
frame.pausedOverlay:Hide()
end
---------------------------------------------------------------
-- Pause alpha: restore on hover, reduce on leave
---------------------------------------------------------------
frame:SetScript("OnEnter", function()
if cfg.paused then
this:SetAlpha(cfg.backdropAlpha or 0.92)
end
end)
frame:SetScript("OnLeave", function()
if cfg.paused and not MouseIsOver(this) then
this:SetAlpha(cfg.pausedAlpha or 0.35)
end
end)
---------------------------------------------------------------
-- Scroll wheel
---------------------------------------------------------------
@@ -672,6 +776,8 @@ function Window:SavePosition(frame)
point = point, relativePoint = relPoint,
xOfs = xOfs, yOfs = yOfs,
w = fw, h = fh,
moduleName = frame.activeModuleName,
segmentIndex = frame.segmentIndex,
}
frame:ClearAllPoints()
@@ -705,6 +811,28 @@ function Window:LoadPosition(frame)
frame:ClearAllPoints()
frame:SetPoint("RIGHT", UIParent, "RIGHT", -80, -50)
end
if pos then
if pos.moduleName and NanamiDPS.modules[pos.moduleName] then
frame.activeModuleName = pos.moduleName
local mod = NanamiDPS.modules[pos.moduleName]
if mod and mod.GetName and frame.btnMode then
frame.btnMode.text:SetText(mod:GetName())
end
end
if pos.segmentIndex ~= nil then
frame.segmentIndex = pos.segmentIndex
if frame.btnSegment then
local segList = DataStore:GetSegmentList()
for _, s in ipairs(segList) do
if s.index == pos.segmentIndex then
frame.btnSegment.text:SetText(s.name)
break
end
end
end
end
end
end
-----------------------------------------------------------------------
@@ -762,6 +890,28 @@ function Window:RefreshWindow(frame, force)
BarDisplay:LayoutBars(frame)
end
function Window:UpdatePausedAlpha()
local cfg = NanamiDPS.config or {}
for _, win in pairs(activeWindows) do
if win and win:IsShown() then
if cfg.paused then
win:SetAlpha(cfg.pausedAlpha or 0.35)
if win.pausedOverlay then
win.pausedOverlay:Show()
end
else
win:SetAlpha(1.0)
if win.pausedOverlay then
win.pausedOverlay:Hide()
end
end
if win.updatePauseVisual then
win.updatePauseVisual()
end
end
end
end
function Window:RefreshAll(force)
for _, win in pairs(activeWindows) do
if win and win:IsShown() then
@@ -774,26 +924,35 @@ end
-- Initialization
-----------------------------------------------------------------------
NanamiDPS:RegisterCallback("INIT", "Window", function()
local win = Window:Create(1)
activeWindows[1] = win
NanamiDPS.windows = activeWindows
NanamiDPS:RegisterCallback("refresh", "WindowRefresh", function()
for _, w in pairs(activeWindows) do
if w then w.needsRefresh = true end
end
end)
Window:LoadPosition(win)
local cfg = NanamiDPS.config or {}
if cfg.visible ~= false then
win:Show()
else
win:Hide()
local savedWindowCount = 1
if NanamiDPS_DB and NanamiDPS_DB.windowPositions then
for wid, _ in pairs(NanamiDPS_DB.windowPositions) do
if type(wid) == "number" and wid > savedWindowCount then
savedWindowCount = wid
end
end
end
Window:RefreshWindow(win, true)
for i = 1, savedWindowCount do
local win = Window:Create(i)
activeWindows[i] = win
Window:LoadPosition(win)
if cfg.visible ~= false then
win:Show()
else
win:Hide()
end
Window:RefreshWindow(win, true)
end
NanamiDPS.windows = activeWindows
end)
-----------------------------------------------------------------------
@@ -828,6 +987,9 @@ function Window:DestroyWindow(wid)
if activeWindows[wid] then
activeWindows[wid]:Hide()
activeWindows[wid] = nil
if NanamiDPS_DB and NanamiDPS_DB.windowPositions then
NanamiDPS_DB.windowPositions[wid] = nil
end
end
end