Update .toc 90005, zz2

This commit is contained in:
rilgamon 2021-03-23 10:41:28 +01:00
parent 8f131726fc
commit 94b5ea2836
8 changed files with 231 additions and 537 deletions

3
.gitmodules vendored
View File

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

1
Common

@ -1 +0,0 @@
Subproject commit a4f1483ece050607772176aed8b46a565df60458

347
core.lua
View File

@ -1,30 +1,25 @@
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 addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local events = child['events']
local db
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
local defcolor = "ffffff"
local defaults = {
LibStub("zzHelper"):Embed(child)
local function prepareDB()
db = addon['db']['profile'][childName]
child['db'] = db
addon['callbacks']:Fire(format("Init%s", childName))
end
child['specs'] = {
['name'] = childName,
['sv'] = true,
['cfg'] = true,
['cfgReset'] = prepareDB,
['ldb'] = child['ldb'],
['defaults'] = {
['profile'] = {
[childName] = {
["showClock"] = true,
["showLatency"] = true,
["showFPS"] = true,
@ -38,302 +33,8 @@ local defaults = {
['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)
}
}
}
child:NewAddOn(...)

0
icon2.tga Normal file → Executable file
View File

28
locale_deDE.lua Normal file → Executable file
View File

@ -1,9 +1,9 @@
local addonname, tab = ...
local name = "zz_Infoclock"
local L = LibStub("AceLocale-3.0"):NewLocale(name, "deDE", false)
local addonname, addon = ...
local childName = addon['childName']
local L = LibStub("AceLocale-3.0"):NewLocale(childName, "deDE", false)
if L then
L[name] = name
L[name..' Settings'] = name..' Einstellungen'
L[childName] = childName
L[format('%s Settings', childName)] = format('%s Einstellungen', childName)
L['Sunday'] = "Sonntag"
L['Monday'] = "Montag"
L['Tuesday'] = "Dienstag"
@ -73,15 +73,15 @@ if L then
%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."
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

View File

@ -1,9 +1,9 @@
local addonname, tab = ...
local name = "zz_Infoclock"
local L = LibStub("AceLocale-3.0"):NewLocale(name, "enUS", true)
local addonname, addon = ...
local childName = addon['childName']
local L = LibStub("AceLocale-3.0"):NewLocale(childName, "enUS", true)
if L then
L[name] = name
L[name..' Settings'] = name..' Settings'
L[childName] = childName
L[format('%s Settings', childName)] = format('%s Settings', childName)
L['Sunday'] = true
L['Monday'] = true
L['Tuesday'] = true
@ -80,6 +80,6 @@ if L then
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."
L['total'] = 'Total'
L["CPU setting changed. Please Reload UI."] = "CPU setting changed. Please Reload UI."
end

View File

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

View File

@ -1,16 +1,10 @@
## Interface: 90002
## X-Repository: https://svn.grml.de/zz_Infoclock
## Interface: 90005
## X-Repository: https://git.grml.de/rilgamon/zz_Infoclock.git
## 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
## OptionalDeps: zzLib, Ace3, BrokerPack
## SavedVariables: zz_InfoclockDB
## LoadManagers: AddonLoader
## X-LoadOn-Always: delayed
## OptionalDeps: Ace3,BrokerPack,zzLibCommon
Common\common.xml
Libs\embeds.xml
pack.xml