This commit is contained in:
Robin 2021-01-13 16:15:33 +01:00
commit 7c306ad881
9 changed files with 546 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Common"]
path = Common
url = https://git.grml.de/rilgamon/Common.git

1
Common Submodule

@ -0,0 +1 @@
Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed

339
core.lua Normal file
View File

@ -0,0 +1,339 @@
local name, addon = ...
local parentName = addon['parentName'] or "BrokerPack"
local childName = "zz_Infoclock"
local replaces = {
['Sunday'] = true,
['Monday'] = true,
['Tuesday'] = true,
['Wednesday'] = true,
['Thursday'] = true,
['Friday'] = true,
['Saturday'] = true,
['January'] = true,
['February'] = true,
['March'] = true,
['April'] = true,
['May'] = true,
['June'] = true,
['July'] = true,
['August'] = true,
['September'] = true,
['October'] = true,
['November'] = true,
['December'] = true,
}
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
local defcolor = "ffffff"
local defaults = {
["showClock"] = true,
["showLatency"] = true,
["showFPS"] = true,
["update"] = 2,
["clockstring"] = "%H:%M",
["datestring"] = "%A, %d.%B",
["latencystring"] = "%world ms",
["fpsstring"] = "%fps "..L['FPS'],
["ldbstring"] = "%clock %latency %fps",
['datecolor'] = defcolor,
['fpscolor'] = defcolor,
['clockcolor'] = defcolor,
['latencycolor'] = "ffff00",
}
local options = {}
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local ldbicon = LibStub("LibDBIcon-1.0")
local cols = {
['datecolor'] = true,
['fpscolor'] = true,
['clockcolor'] = true,
['latencycolor'] = true,
}
local ainfo = {}
local GetNumAddOns = GetNumAddOns
local GetAddOnInfo = GetAddOnInfo
local GetAddOnMemoryUsage = GetAddOnMemoryUsage
local GetAddOnCPUUsage = GetAddOnCPUUsage
local IsAddOnLoaded = IsAddOnLoaded
local line
-- Fix Classic
local C_CVar = C_CVar or {
GetCVarBool = function(value)
return GetCVar(value) and true or false
end
}
local GameTimeFrame_OnClick = GameTimeFrame_OnClick or function(self) TimeManagerClockButton:Click() end
-- End of Fix Classic
local nextUpdate = GetTime()
local db = {}
local function toggleColor(col,col1,col2)
return col == col1 and col2 or col1
end
local function compute()
local c = date(db['clockstring'])
local d = date(db['datestring'])
for k in pairs(replaces) do
if(k ~= L[k]) then
d = d:gsub(k, L[k])
end
end
local h, w = select(3,GetNetStats())
local l = db['latencystring']
l = l:gsub("%%world", w)
l = l:gsub("%%local", h)
local f = db['fpsstring']
f = f:gsub("%%fps",floor(GetFramerate()))
return c,d,l,f
end
local function sortTab(a,b)
return a['mem'] > b['mem']
end
local function sortTab2(a,b)
return a['cpu'] > b['cpu']
end
local ainfodelay, lastainfo = 2, GetTime()
local function updateainfo()
wipe(ainfo)
UpdateAddOnMemoryUsage()
UpdateAddOnCPUUsage()
local name, enabled, security, mem, cpu, _
for i=1, GetNumAddOns() do
mem = 0
cpu = 0
name, _, _, enabled, _, _, security = GetAddOnInfo(i)
if(name and enabled and IsAddOnLoaded(i)) then
mem = GetAddOnMemoryUsage(i)
cpu = GetAddOnCPUUsage(i)
ainfo[#ainfo+1] = {
['name'] = name,
['mem'] = mem,
['cpu'] = cpu,
}
end
end
end
local function OnTooltip(tip)
if(GetTime() > lastainfo) then
updateainfo()
lastainfo = GetTime() + ainfodelay
end
local c,d,l,f = compute()
tip:AddLine(childName)
local col = "00ff00"
if(db['expert']) then
tip:AddLine(addon:colorize(d,col))
else
tip:AddLine(addon:colorize(format("%s, %s.%s",L[date("%A")],date("%d"),L[date("%B")]),col))
end
col = toggleColor(col,"ffffff","00ff00")
if(db["12-Hours"]) then
tip:AddDoubleLine(addon:colorize(L['Time'],col),addon:colorize(date("%I:%M:%S"),toggleColor(col,"ffffff","00ff00")))
else
tip:AddDoubleLine(addon:colorize(L['Time'],col),addon:colorize(date("%H:%M:%S"),toggleColor(col,"ffffff","00ff00")))
end
col = toggleColor(col,"ffffff","00ff00")
tip:AddDoubleLine(addon:colorize(L['Latency'],col),addon:colorize(format("%s ms",select(3,GetNetStats())),toggleColor(col,"ffffff","00ff00")))
col = toggleColor(col,"ffffff","00ff00")
tip:AddDoubleLine(addon:colorize(L['FPS'],col),addon:colorize(format("%i fps",floor(GetFramerate())),toggleColor(col,"ffffff","00ff00")))
col = toggleColor(col,"ffffff","00ff00")
tip:AddDoubleLine(addon:colorize(L['AddOn Memory'],col),addon:colorize(format("%i MB",floor(collectgarbage('count')/1024)),toggleColor(col,"ffffff","00ff00")))
tip:AddLine(" ")
tip:AddLine(L["AddOns"])
sort(ainfo,sortTab)
local sum,cnt = 0,0
for _, v in ipairs(ainfo) do
if(cnt<9) then
tip:AddDoubleLine(addon:colorize(v['name'],"00ffff"),format(L["%i kB"],v['mem']))
cnt = cnt + 1
end
sum = sum + v['mem']
end
tip:AddDoubleLine(L['total'],format(L["%i kB"],format("%.2f",sum)))
local pCPU = C_CVar.GetCVarBool("scriptProfile")
if(pCPU) then
tip:AddLine(" ")
tip:AddLine(L["CPU"])
sort(ainfo,sortTab2)
sum,cnt = 0,0
for _, v in ipairs(ainfo) do
if(cnt<5) then
tip:AddDoubleLine(addon:colorize(v['name'],"00ffff"),format(L["%i ms"],v['cpu']))
cnt = cnt + 1
end
sum = sum + v['cpu']
end
tip:AddDoubleLine(L['total'],format(L["%i ms"],format("%.2f",sum)))
end
tip:AddLine(" ")
tip:AddLine(L['HINT4'])
tip:AddLine(L["garbagecollect"])
tip:AddLine(L['HINT3'])
tip:AddLine(L['HINT5'])
end
local function OnText(message)
addon:OnText(childName, message)
end
local function OnButton(self, button)
if(button == 'RightButton') then
InterfaceOptionsFrame_OpenToCategory(childName)
InterfaceOptionsFrame_OpenToCategory(childName) -- twice needed
elseif(button == 'MiddleButton') then
local pCPU = C_CVar.GetCVarBool("scriptProfile")
if(pCPU) then
pCPU = 0
else
pCPU = 1
end
C_CVar.SetCVar("scriptProfile", pCPU)
addon:Print(L["CPU setting changed. Please Reload UI."])
updateainfo()
else
if(IsShiftKeyDown()) then
local db = addon['db']['global']['ldbicons']
db[childName]['hide'] = not db[childName]['hide']
if(ldbicon) then
if(db[childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
elseif(IsControlKeyDown()) then
addon:Print(L["garbagecollected"])
collectgarbage("collect")
else
GameTimeFrame_OnClick(_G["GameTimeFrame"])
end
end
end
local function OnDataUpdate()
if(db['expert']) then
local c,d,l,f = compute()
line = db['ldbstring']
line = line:gsub("%%clock", addon:colorize(c,db['clockcolor']))
line = line:gsub("%%date", addon:colorize(d,db['datecolor']))
line = line:gsub("%%fps", addon:colorize(f,db['fpscolor']))
line = line:gsub("%%latency", addon:colorize(l,db['latencycolor']))
else
line = ''
if(db["showClock"]) then
line = format("%s%s ", line, db["12-Hours"] and date("%I:%M") or date("%H:%M"))
end
if(db["showLatency"]) then
line = format("%s%s",line,addon:colorize(format("%s ms ",select(3,GetNetStats())),"ffff00"))
end
if(db["showFPS"]) then
line = format("%s%s fps", line, floor(GetFramerate()))
end
end
if(line ~= '') then
OnText(line)
else
OnText(childName)
end
C_Timer.After(db['update'], OnDataUpdate)
end
local function getPref(pref)
if(cols[pref[#pref]]) then
local r,g,b = addon:Hex2RGB(db[pref[#pref]])
return r/255,g/255,b/255,1
end
return db[pref[#pref]]
end
local function setPref(pref,value,g,b)
db[pref[#pref]] = cols[pref[#pref]] and addon:RGB2Hex(value*255,g*255,b*255) or value
end
local function expertMode()
return not db['expert']
end
local function init()
options = addon:InitConfig(childName, true, {
['name'] = childName,
['type'] = "data source",
['OnTooltipShow'] = OnTooltip,
['OnClick'] = OnButton,
}, getPref, setPref)
db = addon['db']['profile'][childName]
db["update"] = db["update"] or 1
db["clockstring"] = db["clockstring"] or (db["12-Hours"] and "%I:%M" or "%H:%M")
db["datestring"] = db["datestring"] or "%A, %d.%B"
db["latencystring"] = db["latencystring"] or "%world ms"
db["fpsstring"] = db["fpsstring"] or "%fps "..L['FPS']
db["ldbstring"] = db["ldbstring"] or "%clock %latency %fps"
for k in pairs(cols) do
db[k] = db[k] or defcolor
end
local menu = addon:AddConfigMenu({
['name'] = L['Clock'],
['order'] = 3,
['menuGet'] = getPref,
['menuSet'] = setPref,
['disabled'] = expertMode,
}, options)
addon:AddConfigEntry(childName,"input","clockstring",L['Clock'],nil,1,nil,nil,nil,nil,menu)
addon:AddConfigEntry(childName,"color","clockcolor",L['Clock'],nil,2,nil,nil,nil,nil,menu)
addon:AddConfigEntry(childName,"description","dateinfo",L['dateinfo'],nil,100,nil,nil,nil,nil,menu)
local menu2 = addon:AddConfigMenu({
['name'] = L['Date'],
['order'] = 4,
['menuGet'] = getPref,
['menuSet'] = setPref,
['disabled'] = expertMode,
}, options)
addon:AddConfigEntry(childName,"input","datestring",L['Date'],nil,1,nil,nil,nil,nil,menu2)
addon:AddConfigEntry(childName,"color","datecolor",L['Date'],nil,2,nil,nil,nil,nil,menu2)
addon:AddConfigEntry(childName,"description","dateinfo",L['dateinfo'],nil,100,nil,nil,nil,nil,menu2)
local menu3 = addon:AddConfigMenu({
['name'] = L['Latency'],
['order'] = 5,
['menuGet'] = getPref,
['menuSet'] = setPref,
['disabled'] = expertMode,
}, options)
addon:AddConfigEntry(childName,"input","latencystring",L['Latency'],nil,1,nil,nil,nil,nil,menu3)
addon:AddConfigEntry(childName,"color","latencycolor",L['Latency'],nil,2,nil,nil,nil,nil,menu3)
addon:AddConfigEntry(childName,"description","latencyinfo",L['Latencystring'],nil,100,nil,nil,nil,nil,menu3)
local menu4 = addon:AddConfigMenu({
['name'] = L['FPS'],
['order'] = 6,
['menuGet'] = getPref,
['menuSet'] = setPref,
['disabled'] = expertMode,
}, options)
addon:AddConfigEntry(childName,"input","fpsstring",L['FPS'],nil,1,nil,nil,nil,nil,menu4)
addon:AddConfigEntry(childName,"color","fpscolor",L['FPS'],nil,2,nil,nil,nil,nil,menu4)
addon:AddConfigEntry(childName,"description","fpsinfo",L['fpsstring'],nil,100,nil,nil,nil,nil,menu4)
local menu5 = addon:AddConfigMenu({
['name'] = L['LDB'],
['order'] = 7,
['menuGet'] = getPref,
['menuSet'] = setPref,
['disabled'] = expertMode,
}, options)
addon:AddConfigEntry(childName,"input","ldbstring",L['LDB'],nil,1,nil,nil,nil,nil,menu5)
addon:AddConfigEntry(childName,"description","ldbinfo",L['ldbstring'],nil,100,nil,nil,nil,nil,menu5)
addon:AddConfigEntry(childName,"toggle","showClock",L['Show Clock'],nil,2,nil,nil,nil,nil,options)
addon:AddConfigEntry(childName,"toggle","showLatency",L['Show Latency'],nil,3,nil,nil,nil,nil,options)
addon:AddConfigEntry(childName,"toggle","showFPS",L['Show FPS'],nil,4,nil,nil,nil,nil,options)
addon:AddConfigEntry(childName,"toggle","12-Hours",L['12-Hours'],nil,5,nil,nil,nil,nil,options)
addon:AddConfigEntry(childName,"toggle","expert",L['Expert'],nil,6,nil,nil,nil,nil,options)
C_Timer.After(db['update'], OnDataUpdate)
end
addon:startup(name, childName, init, true, defaults)

BIN
icon2.tga Normal file

Binary file not shown.

6
license.txt Normal file
View File

@ -0,0 +1,6 @@
The following license excludes the libraries (Libs) included. See the libraries directory or website.
This AddOn is public domain. That means you can change it, rename it or paint it yellow.
My name (Rilgamon) is valid only for WoWInterface.com and curse.com.
If you use/offer this addon on another website please remove my name.
If you want to give me credit you can replace it with a link to my profile on WoWInterface.com.

91
locale_deDE.lua Normal file
View File

@ -0,0 +1,91 @@
local addonname, tab = ...
local name = "zz_Infoclock"
local L = LibStub("AceLocale-3.0"):NewLocale(name, "deDE", false)
if L then
L[name] = name
L[name..' Settings'] = name..' Einstellungen'
L['Sunday'] = "Sonntag"
L['Monday'] = "Montag"
L['Tuesday'] = "Dienstag"
L['Wednesday'] = "Mittwoch"
L['Thursday'] = "Donnerstag"
L['Friday'] = "Freitag"
L['Saturday'] = "Samstag"
L['January'] = "Januar"
L['February'] = "Februar"
L['March'] = "M\195\164rz"
L['April'] = "April"
L['May'] = "Mai"
L['June'] = "Juni"
L['July'] = "Juli"
L['August'] = "August"
L['September'] = "September"
L['October'] = "Oktober"
L['November'] = "November"
L['December'] = "Dezember"
L['Show Clock'] = "Zeige Uhrzeit"
L['Show Latency'] = "Zeige Latenz"
L['Show FPS'] = "Zeige FPS"
L['Time'] = "Uhrzeit"
L['FPS'] = "FPS"
L['Latency'] = "Latenz"
L["garbagecollect"] = "|c0000ff00Strg-Linksklick|r |c00fffffferzwingt Garbage-Collect|r"
L['HINT3'] = "|c0000ff00Shift-Linksklick|r |c00ffffffschaltet Minimapicon an/aus|r"
L['HINT4'] = "|c0000ff00Linksklick|r |c00ffffffschaltet Kalender an/aus|r"
L['HINT5'] = "|c0000ff00Mittelklick|r |c00ffffffCPU Profiling \195\164ndern|r"
L['AddOn Memory'] = "AddOn Speicher"
L["garbagecollected"] = "Garbage-Collect erzwungen"
L["12-Hours"] = "12-Stunden"
L['Clock'] = "Uhr"
L['Date'] = "Datum"
L['Expert'] = "Expertenmodus"
L['LDB'] = "LDB"
L['dateinfo'] = [=[%a is replaced by the locales abbreviated weekday name.
%A is replaced by the locales full weekday name.
%b is replaced by the locales abbreviated month name.
%B is replaced by the locales full month name.
%c is replaced by the locales appropriate date and time representation.
%C is replaced by the century number the year divided by 100 and truncated to an integer as a decimal number 00-99.
%d is replaced by the day of the month as a decimal number 01,31.
%D same as %m/%d/%y.
%e is replaced by the day of the month as a decimal number 1,31; a single digit is preceded by a space.
%h same as %b.
%H is replaced by the hour 24-hour clock as a decimal number 00,23.
%I is replaced by the hour 12-hour clock as a decimal number 01,12.
%j is replaced by the day of the year as a decimal number 001,366.
%m is replaced by the month as a decimal number 01,12.
%M is replaced by the minute as a decimal number 00,59.
%n is replaced by a newline character.
%p is replaced by the locales equivalent of either a.m. or p.m.
%r is replaced by the time in a.m. and p.m. notation; in the POSIX locale this is equivalent to %I:%M:%S %p.
%R is replaced by the time in 24 hour notation %H:%M.
%S is replaced by the second as a decimal number 00,61.
%t is replaced by a tab character.
%T is replaced by the time %H:%M:%S.
%u is replaced by the weekday as a decimal number 1,7 , with 1 representing Monday.
%U is replaced by the week number of the year Sunday as the first day of the week as a decimal number 00,53.
%V is replaced by the week number of the year Monday as the first day of the week as a decimal number 01,53. If the week containing 1 January has four or more days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1.
%w is replaced by the weekday as a decimal number 0,6 , with 0 representing Sunday.
%W is replaced by the week number of the year Monday as the first day of the week as a decimal number 00,53. All days in a new year preceding the first Monday are considered to be in week 0.
%x is replaced by the locales appropriate date representation.
%X is replaced by the locales appropriate time representation.
%y is replaced by the year without century as a decimal number 00,99.
%Y is replaced by the year with century as a decimal number.
%Z is replaced by the timezone name or abbreviation, or by no bytes if no timezone information exists.
%% is replaced by %.]=]
L["Latencystring"] = "%world %local"
L['fpsstring'] = "%fps"
L['ldbstring'] = "%clock %date %fps %latency"
L["%i kB"] = "%i kB"
L["%i ms"] = "%i ms"
L["AddOns"] = "AddOns"
L['CPU'] = 'CPU'
L['total'] = 'Gesamt'
L["CPU setting changed. Please Reload UI."] = "CPU Einstellung ge\195\164ndert. Bitte UI neu laden."
end
-- ö \195\182 ß \195\159
-- ü \195\188 ä \195\164
-- Ä \195\132
-- ö \195\182
-- Ü \195\156

85
locale_enUS.lua Normal file
View File

@ -0,0 +1,85 @@
local addonname, tab = ...
local name = "zz_Infoclock"
local L = LibStub("AceLocale-3.0"):NewLocale(name, "enUS", true)
if L then
L[name] = name
L[name..' Settings'] = name..' Settings'
L['Sunday'] = true
L['Monday'] = true
L['Tuesday'] = true
L['Wednesday'] = true
L['Thursday'] = true
L['Friday'] = true
L['Saturday'] = true
L['January'] = true
L['February'] = true
L['March'] = true
L['April'] = true
L['May'] = true
L['June'] = true
L['July'] = true
L['August'] = true
L['September'] = true
L['October'] = true
L['November'] = true
L['December'] = true
L['Show Clock'] = true
L['Show Latency'] = true
L['Show FPS'] = true
L['Time'] = true
L['FPS'] = true
L['Latency'] = true
L["garbagecollect"] = "|c0000ff00Ctrl-Leftclick|r |c00ffffffforces a garbage collect.|r"
L['HINT3'] = "|c0000ff00Shift-Leftclick|r |c00fffffftoggles minimap icon|r"
L['HINT4'] = "|c0000ff00Leftclick|r |c00fffffftoggles calendar|r"
L['HINT5'] = "|c0000ff00Middleclick|r |c00ffffffToggle CPU profiling|r"
L['AddOn Memory'] = true
L["garbagecollected"] = "Forced garbage collect"
L["12-Hours"] = true
L['Clock'] = "Clock"
L['Date'] = "Date"
L['Expert'] = "Expert mode"
L['LDB'] = "LDB"
L['dateinfo'] = [=[%a is replaced by the locales abbreviated weekday name.
%A is replaced by the locales full weekday name.
%b is replaced by the locales abbreviated month name.
%B is replaced by the locales full month name.
%c is replaced by the locales appropriate date and time representation.
%C is replaced by the century number the year divided by 100 and truncated to an integer as a decimal number 00-99.
%d is replaced by the day of the month as a decimal number 01,31.
%D same as %m/%d/%y.
%e is replaced by the day of the month as a decimal number 1,31; a single digit is preceded by a space.
%h same as %b.
%H is replaced by the hour 24-hour clock as a decimal number 00,23.
%I is replaced by the hour 12-hour clock as a decimal number 01,12.
%j is replaced by the day of the year as a decimal number 001,366.
%m is replaced by the month as a decimal number 01,12.
%M is replaced by the minute as a decimal number 00,59.
%n is replaced by a newline character.
%p is replaced by the locales equivalent of either a.m. or p.m.
%r is replaced by the time in a.m. and p.m. notation; in the POSIX locale this is equivalent to %I:%M:%S %p.
%R is replaced by the time in 24 hour notation %H:%M.
%S is replaced by the second as a decimal number 00,61.
%t is replaced by a tab character.
%T is replaced by the time %H:%M:%S.
%u is replaced by the weekday as a decimal number 1,7 , with 1 representing Monday.
%U is replaced by the week number of the year Sunday as the first day of the week as a decimal number 00,53.
%V is replaced by the week number of the year Monday as the first day of the week as a decimal number 01,53. If the week containing 1 January has four or more days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1.
%w is replaced by the weekday as a decimal number 0,6 , with 0 representing Sunday.
%W is replaced by the week number of the year Monday as the first day of the week as a decimal number 00,53. All days in a new year preceding the first Monday are considered to be in week 0.
%x is replaced by the locales appropriate date representation.
%X is replaced by the locales appropriate time representation.
%y is replaced by the year without century as a decimal number 00,99.
%Y is replaced by the year with century as a decimal number.
%Z is replaced by the timezone name or abbreviation, or by no bytes if no timezone information exists.
%% is replaced by %.]=]
L["Latencystring"] = "%world %local"
L['fpsstring'] = "%fps"
L['ldbstring'] = "%clock %date %fps %latency"
L["%i kB"] = "%i kB"
L["%i ms"] = "%i ms"
L["AddOns"] = "AddOns"
L['CPU'] = 'CPU'
L['total'] = 'Total'
L["CPU setting changed. Please Reload UI."] = "CPU setting changed. Please Reload UI."
end

5
pack.xml Normal file
View File

@ -0,0 +1,5 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<script file="locale_deDE.lua"/>
<script file="locale_enUS.lua"/>
<Script file="core.lua"/>
</Ui>

16
zz_Infoclock.toc Normal file
View File

@ -0,0 +1,16 @@
## Interface: 90002
## X-Repository: https://svn.grml.de/zz_Infoclock
## X-WoWI-ID: 15497
## X-Curse-Project-ID: 39074
## X-TOC-Classic: 11302
## Title: Infoclock
## Notes: Broker clock, latency and framerate AddOn
## Notes-deDE: Broker Uhr, Latenz, FPS
## Author: Rilgamon
## SavedVariables: zz_InfoclockDB
## LoadManagers: AddonLoader
## X-LoadOn-Always: delayed
## OptionalDeps: Ace3,BrokerPack,zzLibCommon
Common\common.xml
pack.xml