/Tukui/modules/databars/fps.lua

http://github.com/Asphyxia/Tukui · Lua · 41 lines · 35 code · 6 blank · 0 comment · 7 complexity · 506128ee39eaafc0ac0d7c57c856fd23 MD5 · raw file

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