sStats_lat:SetScript("OnUpdate", function(self, elapsed) |
lattimer = lattimer + elapsed |
if lattimer >= 1 then |
local _,_,latency = GetNetStats() |
sStats:SetModuleText(sStats_latText, latency, " ms") |
_,_,hlatency,wlatency = GetNetStats() |
sStats:SetModuleText(sStats_latText, wlatency, " ms") |
lattimer = 0 |
end |
end) |
|
|
--tooltips |
local tt = GameTooltip |
local tips |
sStats_lat:SetScript("OnEnter", function(self) |
if sStatsPCDB.charSpec then |
tips = sStatsPCDB.sStats_lat.tooltip |
else |
tips = sStatsDB.sStats_lat.tooltip |
end |
if tips then |
tt:SetOwner(self, "ANCHOR_TOPRIGHT") |
tt:AddLine("Latency Stats") |
tt:AddDoubleLine("UI latency:", hlatency.." ms", 1,1,1,1,1,1) |
tt:AddDoubleLine("World latency:", wlatency.." ms", 1,1,1,1,1,1) |
GameTooltip:Show() |
end |
end) |
sStats_lat:SetScript("OnLeave", function() if tips then tt:Hide() end end) |
|
--adding custom options and saved variables |
sStatsDB.sStats_lat.tooltip = sStatsDB.sStats_lat.tooltip or true |
if sStatsPCDB.charSpec then |
sStatsPCDB.sStats_lat.tooltip = sStatsPCDB.sStats_lat.tooltip or true |
end |
|
sStatsOptionsTable.args.sStats_lat.args.tooltip = { |
name = "Show tooltip", |
desc = "Display the tooltip for this module.", |
type = "toggle", |
get = function() |
if sStatsPCDB.charSpec then |
return sStatsPCDB.sStats_lat.tooltip |
else |
return sStatsDB.sStats_lat.tooltip |
end |
end, |
set = function() |
if sStatsPCDB.charSpec then |
sStatsPCDB.sStats_lat.tooltip = not sStatsPCDB.sStats_lat.tooltip |
else |
sStatsDB.sStats_lat.tooltip = not sStatsDB.sStats_lat.tooltip |
end |
end, |
} |
|
end) |