PageRenderTime 14ms CodeModel.GetById 9ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Tukui/modules/datatext/fps.lua

http://github.com/Asphyxia/Tukui
Lua | 53 lines | 44 code | 6 blank | 3 comment | 3 complexity | 897cb16367b8ad337ebbe89a5af52596 MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2
 3--------------------------------------------------------------------
 4-- FPS
 5--------------------------------------------------------------------
 6
 7if C["datatext"].fps_ms and C["datatext"].fps_ms > 0 then
 8	local Stat = CreateFrame("Frame")
 9  	Stat:EnableMouse(true)
10	Stat:SetFrameStrata("HIGH")
11	Stat:SetFrameLevel(3)
12
13	local Text  = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
14	Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
15	T.PP(C["datatext"].fps_ms, Text)
16
17	local int = 1
18	local function Update(self, t)
19		int = int - t
20		if int < 0 then
21      		fps = floor(GetFramerate())
22      		bw_in, bw_out, ms_home, ms_world = GetNetStats()
23      		ms_combined = ms_home + ms_world
24			Text:SetText( FPS_ABBR .. ": " .. T.datacolor .. fps .. "|r".. " / " .. MILLISECONDS_ABBR .. ": " .. T.datacolor .. ms_home)
25			int = 1
26		end	
27	  
28    		self:SetAllPoints(Text) 
29	end
30
31	Stat:SetScript("OnUpdate", Update) 
32	Stat:SetScript("OnEnter", function(self)
33		if not InCombatLockdown() then
34			local anchor, panel, xoff, yoff = T.DataTextTooltipAnchor(Text)
35			GameTooltip:SetOwner(panel, anchor, xoff, yoff)
36			GameTooltip:ClearLines()
37	      	GameTooltip:AddDoubleLine("Frame rate")
38			GameTooltip:AddDoubleLine("Frame per second", fps .. " " .. FPS_ABBR, 1, 1, 1, 1, 1, 1)
39			GameTooltip:AddLine(" ")
40			GameTooltip:AddDoubleLine("Lag")
41			GameTooltip:AddDoubleLine("Total lag", ms_combined .. " " .. MILLISECONDS_ABBR, 1, 1, 1, 1, 1, 1)
42			GameTooltip:AddDoubleLine("Local lag", ms_home .. " " .. MILLISECONDS_ABBR, 1, 1, 1, 1, 1, 1)
43			GameTooltip:AddDoubleLine("Global lag", ms_world .. " " .. MILLISECONDS_ABBR, 1, 1, 1, 1, 1, 1)
44			GameTooltip:AddLine(" ")
45			GameTooltip:AddLine("Delay")
46			GameTooltip:AddDoubleLine("Incoming", string.format("%.4f", bw_in) .. " kb/s", 1, 1, 1, 1, 1, 1)
47			GameTooltip:AddDoubleLine("Outgoing", string.format("%.4f", bw_out) .. " kb/s", 1, 1, 1, 1, 1, 1)
48			GameTooltip:Show()
49		end
50  	end)	
51  	Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)	
52  	Update(Stat, 10)
53end