From ef1fadf665374a63b2a7b5f9991070c4d0476755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20H=C3=BCskes?= Date: Sun, 27 Nov 2022 22:26:40 +0100 Subject: [PATCH] Add local fps for ldb Add colored numbers instead of full string --- broker.lua | 76 ++++++++++++++++++++++++------------------------- locale_deDE.lua | 2 +- locale_enUS.lua | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/broker.lua b/broker.lua index 5eaa9bc..e50b894 100755 --- a/broker.lua +++ b/broker.lua @@ -114,24 +114,45 @@ end local function toggleColor(col,col1,col2) return col == col1 and col2 or col1 end -local function computelatency() - return select(3,GetNetStats()) +local function compute_colorpick(name, val) + local color = db[format('%scolor', name)] + if(db[format('%slow', name)] and tonumber(db[format('%slow', name)]) > 0 and val <= tonumber(db[format('%slow', name)])) then + color = db[format('%slowcolor', name)] + end + if(db[format('%smedium', name)] and tonumber(db[format('%smedium', name)]) > 0 and val >= tonumber(db[format('%smedium', name)])) then + color = db[format('%smediumcolor', name)] + end + if(db[format('%shigh', name)] and tonumber(db[format('%shigh', name)]) > 0 and val >= tonumber(db[format('%shigh', name)])) then + color = db[format('%shighcolor', name)] + end + return color end local function compute() - local c = date(db['clockstring']) local d = date(db['datestring']) for k in pairs(replaces) do if(k ~= L[k]) then d = d:gsub(k, L[k]) end end - local h, w = computelatency() + local h, w = select(3,GetNetStats()) local l = db['latencystring'] l = l:gsub("%%world", w) l = l:gsub("%%local", h) local f = db['fpsstring'] - f = f:gsub("%%fps",floor(GetFramerate())) - return c,d,l,f + local fr = floor(GetFramerate()) + f = f:gsub("%%fps", fr) + return { + ['clockstring'] = date(db['clockstring']), + ['datestring'] = d, + ['latencystring'] = l, + ['latencycolor'] = compute_colorpick('latency', w), + ['latencyvalue'] = w, + ['latencyhomevalue'] = h, + ['latencyhomecolor'] = compute_colorpick('latency', h), + ['fpscolor'] = compute_colorpick('fps', fr), + ['fpsstring'] = f, + ['fpsvalue'] = fr + } end local function sortTab(a,b) return a['mem'] > b['mem'] @@ -147,13 +168,13 @@ local function OnTooltipShow(tip) child['lastainfo'] = GetTime() + ainfodelay end local ainfo = child['ainfo'] - local c,d,l,f = compute() + local com = compute() tip:AddLine(childName) local col = "00ff00" if(db['expert']) then - tip:AddLine(child:colorize(d,col)) + tip:AddLine(child:colorize(com['datestring'], col)) else - tip:AddLine(child:colorize(format("%s, %s.%s",L[date("%A")],date("%d"),L[date("%B")]),col)) + tip:AddLine(child:colorize(format("%s, %s.%s",L[date("%A")],date("%d"),L[date("%B")]), col)) end col = toggleColor(col,"ffffff","00ff00") if(db["12-Hours"]) then @@ -162,9 +183,9 @@ local function OnTooltipShow(tip) tip:AddDoubleLine(child:colorize(L['Time'],col),child:colorize(date("%H:%M:%S"),toggleColor(col,"ffffff","00ff00"))) end col = toggleColor(col,"ffffff","00ff00") - tip:AddDoubleLine(child:colorize(L['Latency'],col),child:colorize(format("%s ms",select(3,GetNetStats())),toggleColor(col,"ffffff","00ff00"))) + tip:AddDoubleLine(child:colorize(L['Latency'],col),child:colorize(format("%s ms", com['latencyvalue']), toggleColor(col,"ffffff","00ff00"))) col = toggleColor(col,"ffffff","00ff00") - tip:AddDoubleLine(child:colorize(L['FPS'],col),child:colorize(format("%i fps",floor(GetFramerate())),toggleColor(col,"ffffff","00ff00"))) + tip:AddDoubleLine(child:colorize(L['FPS'],col),child:colorize(format("%i fps",com['fpsvalue']),toggleColor(col,"ffffff","00ff00"))) col = toggleColor(col,"ffffff","00ff00") tip:AddDoubleLine(child:colorize(L['AddOn Memory'],col),child:colorize(format("%i MB",floor(collectgarbage('count')/1024)),toggleColor(col,"ffffff","00ff00"))) tip:AddLine(" ") @@ -203,34 +224,13 @@ end local function OnDataUpdate() local line = childName if(db['expert']) then - local c,d,l,f = compute() + local com = compute() line = db['ldbstring'] - line = line:gsub("%%clock", child:colorize(c,db['clockcolor'])) - line = line:gsub("%%date", child:colorize(d,db['datecolor'])) - local fpscolor = db['fpscolor'] - local fr = floor(GetFramerate()) - if(db['fpslow'] and tonumber(db['fpslow']) > 0 and tonumber(fr) <= tonumber(db['fpslow'])) then - fpscolor = db['fpslowcolor'] - end - if(db['fpsmedium'] and tonumber(db['fpsmedium']) > 0 and tonumber(fr) >= tonumber(db['fpsmedium'])) then - fpscolor = db['fpsmediumcolor'] - end - if(db['fpshigh'] and tonumber(db['fpshigh']) > 0 and tonumber(fr) >= tonumber(db['fpshigh'])) then - fpscolor = db['fpshighcolor'] - end - line = line:gsub("%%fps", child:colorize(f,fpscolor)) - local latencycolor = db['latencycolor'] - local h, w = computelatency() - if(db['latencylow'] and tonumber(db['latencylow']) > 0 and tonumber(w) <= tonumber(db['latencylow'])) then - latencycolor = db['latencylowcolor'] - end - if(db['latencymedium'] and tonumber(db['latencymedium']) > 0 and tonumber(w) >= tonumber(db['latencymedium'])) then - latencycolor = db['latencymediumcolor'] - end - if(db['latencyhigh'] and tonumber(db['latencyhigh']) > 0 and tonumber(w) >= tonumber(db['latencyhigh'])) then - latencyscolor = db['latencyhighcolor'] - end - line = line:gsub("%%latency", child:colorize(l,latencycolor)) + line = line:gsub("%%clock", child:colorize(com['clockstring'], db['clockcolor'])) + line = line:gsub("%%date", child:colorize(com['datestring'], db['datecolor'])) + line = line:gsub("%%fps", child:colorize(com['fpsvalue'], com['fpscolor'])) + line = line:gsub("%%latency", child:colorize(com['latencyvalue'], com['latencycolor'])) + line = line:gsub("%%home", child:colorize(com['latencyhomevalue'], com['latencyhomecolor'])) else line = '' if(db["showClock"]) then diff --git a/locale_deDE.lua b/locale_deDE.lua index b78eb1a..68f6a47 100755 --- a/locale_deDE.lua +++ b/locale_deDE.lua @@ -75,7 +75,7 @@ if L then %% is replaced by %.]=] L["Latencystring"] = "%world %local" L['fpsstring'] = "%fps" - L['ldbstring'] = "%clock %date %fps %latency" + L['ldbstring'] = "%clock %date %fps %latency %home" L["%i kB"] = "%i kB" L["%i ms"] = "%i ms" L["AddOns"] = "AddOns" diff --git a/locale_enUS.lua b/locale_enUS.lua index 074500f..27bf94f 100755 --- a/locale_enUS.lua +++ b/locale_enUS.lua @@ -75,7 +75,7 @@ if L then %% is replaced by %.]=] L["Latencystring"] = "%world %local" L['fpsstring'] = "%fps" - L['ldbstring'] = "%clock %date %fps %latency" + L['ldbstring'] = "%clock %date %fps %latency %home" L["%i kB"] = "%i kB" L["%i ms"] = "%i ms" L["AddOns"] = "AddOns"