Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
solocommand committed Oct 16, 2022
1 parent 5107ff6 commit 84e4444
Show file tree
Hide file tree
Showing 48 changed files with 11,394 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
21 changes: 21 additions & 0 deletions .github/workflows/deploy-packager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Deploy via BigWigs Packager

on:
push:
branches:
- main
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest
env:
CF_API_KEY: ${{ secrets.CF_API_KEY }}
WAGO_API_TOKEN: ${{ secrets.WAGO_API_TOKEN }}
GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Package and Release
uses: BigWigsMods/packager@master
1 change: 1 addition & 0 deletions .pkgmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-as: PerformanceMonitor
174 changes: 174 additions & 0 deletions PerformanceMonitor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
local addonName, addon = ...
local L = addon.L
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local ldbi = LibStub:GetLibrary('LibDBIcon-1.0')
local AceTimer = LibStub("AceTimer-3.0")
local timer = nil;

local function showConfig()
InterfaceOptionsFrame_OpenToCategory(addonName)
InterfaceOptionsFrame_OpenToCategory(addonName)
end

local function normal(text)
if not text then return "" end
return NORMAL_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE;
end

local function red(text)
if not text then return "" end
return RED_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE;
end

local function yellow(text)
if not text then return "" end
return YELLOW_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE;
end

local function green(text)
if not text then return "" end
return GREEN_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE;
end

local function highlight(text)
if not text then return "" end
return HIGHLIGHT_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE;
end

local function muted(text)
if not text then return "" end
return DISABLED_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE;
end


-- Init & config panel
do
local eventFrame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
eventFrame:SetScript("OnEvent", function(self, event, loadedAddon)
if loadedAddon ~= addonName then return end
self:UnregisterEvent("ADDON_LOADED")

if type(PerformanceMonitorSettings) ~= "table" then PerformanceMonitorSettings = {currencies={},minimap={hide=false}} end
local sv = PerformanceMonitorSettings
if type(sv.minimap) ~= "table" then sv.minimap = {hide=false} end
if type(sv.showFPS) ~= "boolean" then sv.showFPS = true end
if type(sv.showLatency) ~= "boolean" then sv.showLatency = true end
if type(sv.showLatencyWorld) ~= "boolean" then sv.showLatencyWorld = false end
if type(sv.showMem) ~= "boolean" then sv.showMem = true end
addon.db = sv

ldbi:Register(addonName, addon.dataobj, addon.db.minimap)
self:SetScript("OnEvent", nil)
end)
eventFrame:RegisterEvent("ADDON_LOADED")
addon.frame = eventFrame
end

-- data text
do
local f = CreateFrame("frame")
local text = "..loading.."
local tooltip = ""
local dataobj = ldb:NewDataObject("PerformanceMonitor", {
type = "data source",
icon = "Interface\\AddOns\\PerformanceMonitor\\PerformanceMonitor",
text = text,
OnEnter = function(frame)
GameTooltip:SetOwner(frame, "ANCHOR_NONE")
GameTooltip:SetPoint("TOPLEFT", frame, "BOTTOMLEFT")
GameTooltip:ClearLines()
addon:updateTooltip(frame)
GameTooltip:Show()
end,
OnLeave = function()
GameTooltip:Hide()
end,
OnClick = function(self, button)
showConfig()
end,
})

addon.dataobj = dataobj

local function fmtLabel(text)
if not text then return "" end
text = normal(text);
return " "..normal(text)..": ";
end

local function updateText()
local fps = GetFramerate();
local _, _, latencyHome, latencyWorld = GetNetStats();
local memory, gcThreshold = gcinfo();

local function getFPS()
local function color(v)
if (v >= 60) then
return green(format('%2.1f', v))
elseif (v >= 30) then
return yellow(format('%2.1f', v))
end
return red(format('%2.1f', v))
end
return fmtLabel(L.labelFPS)..color(fps)
end

local function getLatency()
local t = fmtLabel(L.labelLatency)
local function color(v)
if (v <= 300) then
return green(format('%d', v)..'ms')
elseif (v <= 600) then
return yellow(format('%d', v)..'ms')
end
return red(format('%d', v)..'ms')
end
if (addon.db.showLatency) then
t = t..color(latencyHome)
end
if (addon.db.showLatency and addon.db.showLatencyWorld) then
t = t.." "
end
if (addon.db.showLatencyWorld) then
t = t..color(latencyWorld)
end
return t
end
local function getMemoryUsage()
local function color(v)
-- @todo thresholds?
return highlight(format('%.3f', v / 1024).." MB")
end
return fmtLabel(L.labelMem)..color(memory)
end


local text = "";
if (addon.db.showFPS) then text = text..getFPS() end
if (addon.db.showLatency or addon.db.showLatencyWorld) then
text = text..getLatency()
end
if (addon.db.showMem) then text = text..getMemoryUsage() end

dataobj.text = text;
end

function addon:updateTooltip()

GameTooltip:AddLine(L["PerformanceMonitor"].."\n")

end

function addon:setDB(key, value)
addon.db[key] = value
updateText()
end

f:RegisterEvent("PLAYER_ENTERING_WORLD");
f:SetScript("OnEvent", function(self, event)
if not timer then
-- @todo should this only run when the datatext is displayed?
timer = AceTimer.ScheduleRepeatingTimer("PerformanceMonitor", updateText, 1.5 )
end
end)
end
Binary file added PerformanceMonitor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PerformanceMonitor.tga
Binary file not shown.
17 changes: 17 additions & 0 deletions PerformanceMonitor.toc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Interface: 90200
## Title: PerformanceMonitor
## Notes: A customizable data broker for displaying player currencies
## Author: solocommand
## SavedVariables: PerformanceMonitorSettings
## Version: @project-version@
## X-ReleaseDate: @project-date-iso@
## X-License: MIT
## X-Wago-ID: RqGZzoGd
## OptionalDeps: Ace3

embeds.xml

i18n\enUS.lua

PerformanceMonitor.lua
config.lua
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# PerformanceMonitor
PerformanceMonitor
===========
![Project logo, red/green gauge](PerformanceMonitor.png)

A World of Warcraft LDB addon to display your current FPS, latency, and memory utilization
64 changes: 64 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
local addonName, addon = ...
local L = addon.L
local ldbi = LibStub('LibDBIcon-1.0', true)

local function build()
local t = {
name = "PerformanceMonitor",
handler = PerformanceMonitor,
type = 'group',
args = {
showFPS = {
type = 'toggle',
order = 1,
get = function(info) return addon.db[info[#info]] end,
set = function(info, value) return addon:setDB(info[#info], value) end,
name = L.showFPS,
desc = L.showFPSDescription,
},
showLatency = {
type = 'toggle',
order = 1,
get = function(info) return addon.db[info[#info]] end,
set = function(info, value) return addon:setDB(info[#info], value) end,
name = L.showLatency,
desc = L.showLatencyDescription,
},
showLatencyWorld = {
type = 'toggle',
order = 1,
get = function(info) return addon.db[info[#info]] end,
set = function(info, value) return addon:setDB(info[#info], value) end,
name = L.showLatencyWorld,
desc = L.showLatencyWorldDescription,
},
showMem = {
type = 'toggle',
order = 1,
get = function(info) return addon.db[info[#info]] end,
set = function(info, value) return addon:setDB(info[#info], value) end,
name = L.showMem,
desc = L.showMemDescription,
},
showMinimapIcon = {
type = 'toggle',
name = L.showMinimapIcon,
desc = L.showMinimapIconDescription,
order = 0,
get = function(info) return not addon.db.minimap.hide end,
set = function(info, value)
local config = addon.db.minimap
config.hide = not value
addon:setDB("minimap", config)
ldbi:Refresh(addonName)
end,
},
}
}

-- return our new table
return t
end

LibStub("AceConfig-3.0"):RegisterOptionsTable("PerformanceMonitor", build, nil)
addon.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(addonName, "PerformanceMonitor")
13 changes: 13 additions & 0 deletions embeds.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<Script file="vendor\LibStub\LibStub.lua"/>
<!--@no-lib-strip@-->
<Include file="vendor\AceGUI-3.0\AceGUI-3.0.xml"/>
<Include file="vendor\AceConfig-3.0\AceConfig-3.0.xml"/>
<Include file="vendor\AceTimer-3.0\AceTimer-3.0.xml"/>
<!--@end-no-lib-strip@-->
<Script file="vendor\LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
<!--@no-lib-strip@-->
<Script file="vendor\LibDBIcon-1.0\LibDBIcon-1.0.lua"/>
<!--@end-no-lib-strip@-->
</Ui>
52 changes: 52 additions & 0 deletions i18n/enUS.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

local addonName, addon = ...

local L = {}

L.PerformanceMonitor = 'PerformanceMonitor'

L.showMinimapIcon = 'Show minimap button'
L.showMinimapIconDescription = 'Show the PerformanceMonitor minimap button'
L.showFPS = 'Show FPS'
L.showFPSDescription = 'Show the frames per second in the data text'
L.showLatency = 'Show ping'
L.showLatencyDescription = 'Show the ping (latency) to the home server in the data text.'
L.showLatencyWorld = 'Show ping (world)'
L.showLatencyWorldDescription = 'Show the ping (latency) to the world server in the data text.'
L.showMem = 'Show memory usage'
L.showMemDescription = 'Show the addon memory usage in the data text.'

L.labelFPS = 'FPS'
L.labelLatency = 'Latency'
L.labelMem = 'Memory'

L["TITAN_FPS_FORMAT"] = "%.1f";
L["TITAN_FPS_BUTTON_LABEL"] = "FPS: ";
L["TITAN_FPS_MENU_TEXT"] = "FPS";
L["TITAN_FPS_TOOLTIP_CURRENT_FPS"] = "Current FPS: ";
L["TITAN_FPS_TOOLTIP_AVG_FPS"] = "Average FPS: ";
L["TITAN_FPS_TOOLTIP_MIN_FPS"] = "Minimum FPS: ";
L["TITAN_FPS_TOOLTIP_MAX_FPS"] = "Maximum FPS: ";
L["TITAN_FPS_TOOLTIP"] = "Frames Per Second";

L["TITAN_LATENCY_FORMAT"] = "%d".."ms";
L["TITAN_LATENCY_BANDWIDTH_FORMAT"] = "%.3f ".."KB/s";
L["TITAN_LATENCY_BUTTON_LABEL"] = "Latency: ";
L["TITAN_LATENCY_TOOLTIP"] = "Network Status";
L["TITAN_LATENCY_TOOLTIP_LATENCY_HOME"] = "Realm Latency (home): ";
L["TITAN_LATENCY_TOOLTIP_LATENCY_WORLD"] = "Game Latency (world): ";
L["TITAN_LATENCY_TOOLTIP_BANDWIDTH_IN"] = "Bandwidth In: ";
L["TITAN_LATENCY_TOOLTIP_BANDWIDTH_OUT"] = "Bandwidth Out: ";
L["TITAN_LATENCY_MENU_TEXT"] = "Latency";

L["TITAN_MEMORY_FORMAT"] = "%.3f".."MB";
L["TITAN_MEMORY_FORMAT_KB"] = "%d".."KB";
L["TITAN_MEMORY_RATE_FORMAT"] = "%.3f".."KB/s";
L["TITAN_MEMORY_BUTTON_LABEL"] = "Memory: ";
L["TITAN_MEMORY_TOOLTIP"] = "Memory Usage";
L["TITAN_MEMORY_TOOLTIP_CURRENT_MEMORY"] = "Current: ";
L["TITAN_MEMORY_TOOLTIP_INITIAL_MEMORY"] = "Initial: ";
L["TITAN_MEMORY_TOOLTIP_INCREASING_RATE"] = "Increasing Rate: ";
L["TITAN_MEMORY_KBMB_LABEL"] = "KB/MB";

addon.L = L
Loading

0 comments on commit 84e4444

Please sign in to comment.