PageRenderTime 102ms CodeModel.GetById 41ms app.highlight 2ms RepoModel.GetById 58ms app.codeStats 0ms

/Tukui/modules/databars/fps.lua

http://github.com/Asphyxia/Tukui
Lua | 41 lines | 35 code | 6 blank | 0 comment | 4 complexity | 506128ee39eaafc0ac0d7c57c856fd23 MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2local ADDON_NAME, ns = ...
 3local oUF = ns.oUF or oUF
 4
 5ns._Objects = {}
 6ns._Headers = {}
 7
 8if not C["databars"].framerate or C["databars"].framerate == 0 then return end
 9local barNum = C["databars"].framerate
10
11T.databars[barNum]:Show()
12
13local Stat = CreateFrame("Frame", nil, T.databars[barNum])
14Stat:EnableMouse(true)
15Stat:SetFrameStrata("BACKGROUND")
16Stat:SetFrameLevel(4)
17
18local StatusBar = T.databars[barNum].statusbar
19local Text = T.databars[barNum].text
20
21local int = 1
22local function Update(self, t)
23	int = int - t
24	if int < 0 then
25		local fps = floor(GetFramerate())
26		Text:SetText(fps..T.datacolor.." FPS")
27		StatusBar:SetMinMaxValues(0, GetCVar("maxFPS"))
28		StatusBar:SetValue(fps)
29		self:SetAllPoints(T.databars[barNum])
30		if fps > 50 then
31			StatusBar:SetStatusBarColor( 30 / 255, 1, 30 / 255 , .8 )
32		elseif fps > 45 then
33			StatusBar:SetStatusBarColor( 1, 180 / 255, 0, .8 )
34		else
35			StatusBar:SetStatusBarColor( 1, 75 / 255, 75 / 255, 0.5, .8 )
36		end
37		int = 1
38	end	
39end
40Stat:SetScript("OnUpdate", Update) 
41Update(Stat, 10)