--nmSystemBar ESO AddOn by NuMotiv. Visit the ESOUI Wiki for references: "http://wiki.esoui.com/Main_Page"
--Create a top-level table called "nmSystemBar"
nmSystemBar = {}
--Register the name "nmSystemBar" to the AddOn
nmSystemBar.name = "nmSystemBar"
--Define local variables
local MaxFPS = 999
local MaxLatency = 999
local HighLatency = 350
local MidLatency = 150
local LowLatency = 0
--Create a table for the default values "nmSystemBar.PositionDefaults"
nmSystemBar.PositionDefaults = {x = -20, y = 20}
--Create a local function that gathers and displays the current framerate
local function OnUpdate()
--Set "FPS" to the current framerate
local FPS = GetFramerate()
--Set "Latency" to the current latency level
local Latency = GetLatency()
--If the current framerate is higher than the maximum allowed value 999 set it to 999
if FPS > MaxFPS then
FPS = MaxFPS
end
--If the current latency is higher than the maximum allowed value 999 set it to 999
if Latency > MaxLatency then
Latency = MaxLatency
end
--Set the latency icon and color based on value
if Latency >= HighLatency then
nmSystemBarWinLatencyBars:SetTexture("ESOUI/art/campaign/campaignbrowser_lowpop.dds")
nmSystemBarWinLatencyBars:SetColor(1,0,0,1)
nmSystemBarWinLatencyLabel:SetColor(1,0,0,1)
elseif Latency >= MidLatency then
nmSystemBarWinLatencyBars:SetTexture("ESOUI/art/campaign/campaignbrowser_medpop.dds")
elseif Latency >= LowLatency then
nmSystemBarWinLatencyBars:SetTexture("ESOUI/art/campaign/campaignbrowser_hipop.dds")
end
--Set the framerate label to whatever the current value is
nmSystemBarWinFPSLabel:SetText("FPS: |cffffff"..zo_round(FPS))
nmSystemBarWinLatencyLabel:SetText(Latency)
end
--Save the new position values
function nmSystemBar.OnMoveStop()
nmSystemBar.SavedPosition.x = nmSystemBarWin:GetLeft()
nmSystemBar.SavedPosition.y = nmSystemBarWin:GetTop()
end
--Create a function to initialize the AddOn
function nmSystemBar.OnAddOnLoaded(event, name)
--Check for our AddOn
if name == nmSystemBar.name then
--Once the AddOn is loaded unregister the event
EVENT_MANAGER:UnregisterForEvent(nmSystemBar.name, EVENT_ADD_ON_LOADED)
--Create a new saved variables file in "Documents\Elder Scrolls Online\live\SavedVariables"
nmSystemBar.SavedPosition = ZO_SavedVars:New("nmSystemBarSavedVariables", 1, nil, nmSystemBar.PositionDefaults)
--Load the values from the saved variables
nmSystemBarWin:ClearAnchors()
nmSystemBarWin:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, nmSystemBar.SavedPosition.x, nmSystemBar.SavedPosition.y)
--Register the event "OnUpdate" and set its interval to 1000 milliseconds or 1 second
EVENT_MANAGER:RegisterForUpdate("UpdateFPS", 1000, OnUpdate)
end
end
--When mousing over framerate label display the tooltip
function nmSystemBar.FPSTooltip(self)
InitializeTooltip(InformationTooltip, self, BOTTOM, 0, 0)
SetTooltipText(InformationTooltip, "Frames per second. Higher values indicate a smoother experience.")
end
function nmSystemBar.LatencyTooltip(self)
InitializeTooltip(InformationTooltip, self, BOTTOM, 0, 0)
SetTooltipText(InformationTooltip, "Your latency to the server in milliseconds. Higher values can result in decreased responsiveness while playing.")
end
--When mouse leaves framerate label hide the tooltip
function nmSystemBar.HideTooltip(self)
ClearTooltip(InformationTooltip)
end
--Register the event OnAddOnLoaded to initialize our AddOn
EVENT_MANAGER:RegisterForEvent(nmSystemBar.name, EVENT_ADD_ON_LOADED, nmSystemBar.OnAddOnLoaded)