/
local dataobj, elapsed = LibStub:GetLibrary('LibDataBroker-1.1'):NewDataObject('Stats', {text = '2.0 MiB', icon = [=[Interface\AddOns\pStats\icon]=]}), 0.5 |
CreateFrame('Frame'):SetScript('OnUpdate', function(self, al) |
elapsed = elapsed + al |
if(elapsed > 0.5) then |
dataobj.text = formats(gcinfo()) |
elapsed = 0 |
end |
end) |
function dataobj.OnLeave() |
GameTooltip:SetClampedToScreen(true) |
GameTooltip:Hide() |
end |
function dataobj.OnEnter(self) |
local db = pStatsDB or {colors = {0, 1, 1}, sorted = true} |
local db = pStatsDB |
local r, g, b = unpack(db.colors) |
local down, up, latency = GetNetStats() |
local fps = format('%.1f fps', GetFramerate()) |
MiniMapTrackingButton:SetScript('OnMouseWheel', OnMouseWheel) |
MiniMapTrackingButton:SetScript('OnClick', dataobj.OnClick) |
MiniMapTrackingButton:SetScript('OnEnter', dataobj.OnEnter) |
MiniMapTrackingButton:SetScript('OnLeave', dataobj.OnLeave) |
CreateFrame('Frame'):SetScript('OnUpdate', function(self, al) |
elapsed = elapsed + al |
if(elapsed > 0.5) then |
dataobj.text = formats(gcinfo()) |
elapsed = 0 |
end |
end) |
SlashCmdList['PSTATS'] = function() |
if(not IsAddOnLoaded('pStats_Config')) then |
LoadAddOn('pStats_Config') |
end |
InterfaceOptionsFrame_OpenToCategory('pStats') |
end |
SLASH_PSTATS1 = '/pstats' |
## Version: 30000.wowi:revision |
## Title: |cffff6000p|rStats |
## Notes: Replaces the tooltip on MinimapTracking with a more informative one. Also supports LDB |
## OptionalDeps: LibStub, CallbackHandler-1.0, LibSimpleOptions-1.0, LibDataBroker-1.1 |
## SavedVariablesPerCharacter: pStatsDB |
Libs\CallbackHandler\LibStub\LibStub.lua |
Libs\CallbackHandler\CallBackHandler-1.0\CallbackHandler-1.0.lua |
Libs\LibSimpleOptions\LibStub\LibStub.lua |
Libs\LibSimpleOptions\LibSimpleOptions-1.0.lua |
Libs\CallbackHandler\CallbackHandler-1.0.lua |
Libs\LibDataBroker\LibDataBroker-1.1.lua |
pStats.lua |
local function CreateOptions(self, db) |
local title, sub = self:MakeTitleTextAndSubText('pStats', 'These options allow you to customize the looks of pStats.') |
self:MakeButton( |
'name', 'Class Color', |
'description', 'Set text color based on player class', |
'func', function() |
local l, class = UnitClass('player') |
local c = RAID_CLASS_COLORS[class] |
db.colors[1], db.colors[2], db.colors[3] = c.r, c.g, c.b |
self:Refresh() |
end |
):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -16) |
self:MakeColorPicker( |
'name', 'Custom Color', |
'description', 'Set custom text colors with a palette', |
'hasAlpha', false, |
'defaultR', 0, 'defaultG', 1, 'defaultB', 1, |
'getFunc', function() return unpack(db.colors) end, |
'setFunc', function(r, g, b) |
db.colors[1], db.colors[2], db.colors[3] = r, g, b |
end |
):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -46) |
self:MakeToggle( |
'name', 'Toggle sorting method', |
'description', 'Check to sort by memory.\nUn-check to sort by name', |
'default', true, |
'current', db.sorted, |
'setFunc', function(value) |
db.sorted = value |
end |
):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -76) |
end |
local function OnEvent(self, event) |
local db = pStatsDB or {colors = {0, 1, 1}, sorted = true} |
LibStub('LibSimpleOptions-1.0').AddOptionsPanel('pStats', function(self) CreateOptions(self, db) end) |
LibStub('LibSimpleOptions-1.0').AddSlashCommand('pStats', '/pstats') |
self:UnregisterEvent(event) |
pStatsDB = db |
end |
local addon = CreateFrame('Frame') |
addon:RegisterEvent('PLAYER_ENTERING_WORLD') |
addon:SetScript('OnEvent', OnEvent) |