From 2e906ea7bf763256ed5c49c171bffc7beba77bf9 Mon Sep 17 00:00:00 2001 From: shagu Date: Thu, 18 Apr 2019 21:09:50 +0200 Subject: [PATCH] castbar: add option to display lag --- api/config.lua | 2 ++ modules/castbar.lua | 15 +++++++++++++++ modules/gui.lua | 2 ++ 3 files changed, 19 insertions(+) diff --git a/api/config.lua b/api/config.lua index cae45788..038c3d79 100644 --- a/api/config.lua +++ b/api/config.lua @@ -767,10 +767,12 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("castbar", "player", "width", "-1") pfUI:UpdateConfig("castbar", "player", "height", "-1") pfUI:UpdateConfig("castbar", "player", "showicon", "0") + pfUI:UpdateConfig("castbar", "player", "showlag", "0") pfUI:UpdateConfig("castbar", "target", "hide_pfui", "0") pfUI:UpdateConfig("castbar", "target", "width", "-1") pfUI:UpdateConfig("castbar", "target", "height", "-1") pfUI:UpdateConfig("castbar", "target", "showicon", "0") + pfUI:UpdateConfig("castbar", "target", "showlag", "0") pfUI:UpdateConfig("castbar", nil, "use_unitfonts", "0") pfUI:UpdateConfig("tooltip", nil, "position", "chat") diff --git a/modules/castbar.lua b/modules/castbar.lua index 23b25c2f..a9f415c4 100644 --- a/modules/castbar.lua +++ b/modules/castbar.lua @@ -62,6 +62,11 @@ pfUI:RegisterModule("castbar", 20400, function () cb.bar.right:SetText("right") cb.bar.right:SetJustifyH("right") + cb.bar.lag = cb.bar:CreateTexture(nil, "OVERLAY") + cb.bar.lag:SetPoint("TOPRIGHT", cb.bar, "TOPRIGHT", 0, 0) + cb.bar.lag:SetPoint("BOTTOMRIGHT", cb.bar, "BOTTOMRIGHT", 0, 0) + cb.bar.lag:SetTexture(1,.2,.2,.2) + cb:SetScript("OnUpdate", function() if this.drag and this.drag:IsShown() then this:SetAlpha(1) @@ -116,6 +121,14 @@ pfUI:RegisterModule("castbar", 20400, function () this.bar:SetPoint("TOPLEFT", this, 0, 0) this.icon:Hide() end + + if this.showlag then + local _, _, lag = GetNetStats() + local width = duration / this:GetWidth() * lag/100 + this.bar.lag:SetWidth(width) + else + this.bar.lag:Hide() + end end if channel then @@ -178,6 +191,7 @@ pfUI:RegisterModule("castbar", 20400, function () if C.castbar.player.hide_pfui == "0" then pfUI.castbar.player = CreateCastbar("pfPlayerCastbar", UIParent, "player") pfUI.castbar.player.showicon = C.castbar.player.showicon == "1" and true or nil + pfUI.castbar.player.showlag = C.castbar.player.showlag == "1" and true or nil if pfUI.uf.player then local pspace = tonumber(C.unitframes.player.pspace) @@ -201,6 +215,7 @@ pfUI:RegisterModule("castbar", 20400, function () if C.castbar.target.hide_pfui == "0" then pfUI.castbar.target = CreateCastbar("pfTargetCastbar", UIParent, "target") pfUI.castbar.target.showicon = C.castbar.target.showicon == "1" and true or nil + pfUI.castbar.target.showlag = C.castbar.target.showlag == "1" and true or nil if pfUI.uf.target then local pspace = tonumber(C.unitframes.target.pspace) diff --git a/modules/gui.lua b/modules/gui.lua index f557c9c8..fcc2829c 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1784,12 +1784,14 @@ pfUI:RegisterModule("gui", 20400, function () CreateConfig(nil, T["Player Castbar"], nil, nil, "header") CreateConfig(nil, T["Show Spell Icon"], C.castbar.player, "showicon", "checkbox") + CreateConfig(nil, T["Show Lag"], C.castbar.player, "showlag", "checkbox") CreateConfig(nil, T["Castbar Width"], C.castbar.player, "width") CreateConfig(nil, T["Castbar Height"], C.castbar.player, "height") CreateConfig(nil, T["Disable Player Castbar"], C.castbar.player, "hide_pfui", "checkbox") CreateConfig(nil, T["Target Castbar"], nil, nil, "header") CreateConfig(nil, T["Show Spell Icon"], C.castbar.target, "showicon", "checkbox") + CreateConfig(nil, T["Show Lag"], C.castbar.target, "showlag", "checkbox") CreateConfig(nil, T["Castbar Width"], C.castbar.target, "width") CreateConfig(nil, T["Castbar Height"], C.castbar.target, "height") CreateConfig(nil, T["Disable Target Castbar"], C.castbar.target, "hide_pfui", "checkbox")