From 7ea4fa8521354e7b25b652558be8c9058f5c06f0 Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 30 Jun 2020 20:08:09 +0200 Subject: [PATCH] panel: add colors to the fps and latency display --- api/config.lua | 2 ++ modules/gui.lua | 1 + modules/panel.lua | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/api/config.lua b/api/config.lua index 9776efa9..01fb3b4e 100644 --- a/api/config.lua +++ b/api/config.lua @@ -520,6 +520,8 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("panel", "right", "right", "gold") pfUI:UpdateConfig("panel", "other", "minimap", "zone") pfUI:UpdateConfig("panel", "micro", "enable", "0") + pfUI:UpdateConfig("panel", nil, "fpscolors", "1") + pfUI:UpdateConfig("panel", "bag", "ignorespecial", "1") pfUI:UpdateConfig("panel", "xp", "xp_always", "0") pfUI:UpdateConfig("panel", "xp", "xp_display", "XPFLEX") diff --git a/modules/gui.lua b/modules/gui.lua index 39baadf4..482f21e4 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1945,6 +1945,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () CreateConfig(nil, T["Enable Micro Bar"], C.panel.micro, "enable", "checkbox") CreateConfig(nil, T["Enable 24h Clock"], C.global, "twentyfour", "checkbox") CreateConfig(nil, T["Servertime"], C.global, "servertime", "checkbox") + CreateConfig(U["panel"], T["Show FPS and Latency Colors"], C.panel, "fpscolors", "checkbox") CreateConfig(nil, T["Auto Hide"], nil, nil, "header") CreateConfig(nil, T["Enable Autohide For Left Chat Panel"], C.panel, "hide_leftchat", "checkbox") diff --git a/modules/panel.lua b/modules/panel.lua index 803ca325..56dec8d0 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -138,6 +138,7 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function() do -- FPS & Lag local widget = CreateFrame("Frame", "pfPanelWidgetLag", UIParent) + local lag, fps, laghex, fpshex, _ widget.Tooltip = function() local active = 0 GameTooltip:ClearLines() @@ -179,8 +180,17 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function() widget:SetScript("OnUpdate",function() if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end - local _, _, lag = GetNetStats() - pfUI.panel:OutputPanel("fps", floor(GetFramerate()) .. " " .. T["fps"] .. " & " .. lag .. " " .. T["ms"], widget.Tooltip, widget.Click) + fps = floor(GetFramerate()) + _, _, lag = GetNetStats() + + if C.panel.fpscolors == "1" then + _, _, _, fpshex = GetColorGradient(fps/60) + _, _, _, laghex = GetColorGradient(60/lag) + fps = fpshex .. fps .. "|r" + lag = laghex .. lag .. "|r" + end + + pfUI.panel:OutputPanel("fps", fps .. " " .. T["fps"] .. " & " .. lag .. " " .. T["ms"], widget.Tooltip, widget.Click) end) end