UPDATE: Added latency functionality and a new scale friendly backdrop.
Hello everyone. This is the development topic to go along with the uploaded addon in the beta category. Here I will post the most recent code, developments and general information. If you would like to get involved I appreciate any tips, suggestions or ideas for general improvement.
For the current release 0.1 I worked on mimicing the default UI's Framerate indicator. This isn't exactly a ground breaking feature but it was a starting point for a beginner. As I move along I will be adding comments to the code to make things easier to understand if you are new like me or maybe give the experienced guys an idea of what I was trying to do so they can suggest a better way.
The code here will most likely be more up to date than the uploaded addon.
Txt Code:
;nmSystemBar ESO AddOn by NuMotiv. Visit the ESOUI Wiki for references: "http://wiki.esoui.com/Main_Page"
;Defines the current API Version
## APIVersion: 100011
;Defines the AddOn name, displayed in AddOn Manager
## Title: NuMotiv System Bar |c6b96340.2
;Defines the AddOn description, displayed in AddOn Manager
## Description: |caaaaaaCurrently mimics the built in framerate and latency meters. |cd5c859Next Release: Add local time clock.
;Defines the current version
## Version: 0.2
;Defines the author's name
## Author: |c8625c4NuMotiv
;Defines the saved variables file
## SavedVariables: nmSystemBarSavedVariables
;Defines the files loaded by the AddOn
nmSystemBar.xml
nmSystemBar.lua
Xml Code:
<!--nmSystemBar ESO AddOn by NuMotiv. Visit the ESOUI Wiki for references: "http://wiki.esoui.com/Main_Page"-->
<!--Creates the container for the AddOn XML code-->
<GuiXml>
<Controls>
<!--Create the top-level level control for the frame called "nmSystemBarWin"-->
<TopLevelControl name="nmSystemBarWin" movable="true" mouseEnabled="true" clampedToScreen="true" hidden="false">
<Dimensions x="168" y="68"/>
<ClampedToScreenInsets top="20" bottom="-20" left="20" right="-20"/>
<Anchor point="BOTTOMLEFT" relativeTo="GuiRoot" relativePoint="BOTTOMLEFT" offsetX="0" offsetY="0"/>
<Controls>
<!--Sets the backdrop of the frame-->
<Backdrop name="$(parent)Backdrop" integralWrapping="true">
<Anchor point="TOPLEFT"/>
<Anchor point="BOTTOMRIGHT"/>
<Edge file="EsoUI/Art/ChatWindow/chat_BG_edge.dds" edgeFileWidth="256" edgeFileHeight="256" edgeSize="32"/>
<Center file="EsoUI/Art/ChatWindow/chat_BG_center.dds"/>
<Insets left="32" top="32" right="-32" bottom="-32"/>
</Backdrop>
<!--Create a control for the framerate meter-->
<Control name="$(parent)FPS" mouseEnabled="true">
<Dimensions x="65" y="40"/>
<Anchor point="RIGHT" relativeTo="$(parent)" relativePoint="CENTER"/>
<Controls>
<!--Set the label for the framerate-->
<Label name="$(parent)Label" font="ZoFontWinT2" color="c5c29e" horizontalAlignment="CENTER" verticalAlignment="CENTER">
<AnchorFill/>
</Label>
</Controls>
<!--Tells the framerate meter to move with the frame-->
<OnMouseDown>
self:GetParent():StartMoving()
</OnMouseDown>
<!--Tells it to stop moving with the frame-->
<OnMouseUp>
self:GetParent():StopMovingOrResizing()
</OnMouseUp>
<!--Tells the framerate meter to display a tooltip when mousing over-->
<OnMouseEnter>
nmSystemBar.FPSTooltip(self)
</OnMouseEnter>
<!--Tells it to hide the tooltip when the mouse leaves the frame-->
<OnMouseExit>
nmSystemBar.HideTooltip(self)
</OnMouseExit>
</Control>
<!--Create a control for the latency meter-->
<Control name="$(parent)Latency" mouseEnabled="true">
<Dimensions x="65" y="40"/>
<Anchor point="LEFT" relativeTo="$(parent)" relativePoint="CENTER"/>
<Controls>
<!--Draws the latency meter bars-->
<Texture name="$(parent)Bars" textureFile="ESOUI/art/campaign/campaignbrowser_hipop.dds">
<Dimensions x="26" y="26"/>
<Anchor point="LEFT" relativeTo="$(parent)" relativePoint="LEFT"/>
</Texture>
<!--Set the label for the latency level-->
<Label name="$(parent)Label" font="ZoFontWinT2" horizontalAlignment="LEFT" verticalAlignment="CENTER">
<Anchor point="LEFT" relativeTo="$(parent)Bars" relativePoint="RIGHT"/>
</Label>
</Controls>
<!--Tells the latency meter to move with the frame-->
<OnMouseDown>
self:GetParent():StartMoving()
</OnMouseDown>
<!--Tells it to stop moving with the frame-->
<OnMouseUp>
self:GetParent():StopMovingOrResizing()
</OnMouseUp>
<!--Tells the latency meter to display a tooltip when mousing over-->
<OnMouseEnter>
nmSystemBar.LatencyTooltip(self)
</OnMouseEnter>
<!--Tells it to hide the tooltip when the mouse leaves the frame-->
<OnMouseExit>
nmSystemBar.HideTooltip(self)
</OnMouseExit>
</Control>
</Controls>
<!--Save the position when the frame stops moving-->
<OnMoveStop>
nmSystemBar.OnMoveStop()
</OnMoveStop>
</TopLevelControl>
</Controls>
</GuiXml>
Lua Code:
--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)