2018-08-05 11:22:07 -04:00
|
|
|
local M = {}
|
|
|
|
|
2021-07-05 23:27:43 -04:00
|
|
|
local Common = require 'Common'
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2019-10-10 22:52:49 -04:00
|
|
|
local __string_match = string.match
|
|
|
|
local __string_gmatch = string.gmatch
|
|
|
|
|
2017-07-19 00:36:15 -04:00
|
|
|
local _TEXT_SPACING_ = 20
|
|
|
|
|
2021-07-05 23:27:43 -04:00
|
|
|
local header = Common.Header(
|
|
|
|
_G_INIT_DATA_.RIGHT_X,
|
|
|
|
_G_INIT_DATA_.TOP_Y,
|
|
|
|
_G_INIT_DATA_.SECTION_WIDTH,
|
|
|
|
'PACMAN'
|
|
|
|
)
|
|
|
|
|
|
|
|
local rows = Common.initTextRows(
|
|
|
|
_G_INIT_DATA_.RIGHT_X,
|
|
|
|
header.bottom_y,
|
|
|
|
_G_INIT_DATA_.SECTION_WIDTH,
|
|
|
|
_TEXT_SPACING_,
|
|
|
|
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
|
|
|
|
)
|
2017-07-19 00:36:15 -04:00
|
|
|
|
|
|
|
_TEXT_SPACING_ = nil
|
|
|
|
|
2019-10-11 21:52:10 -04:00
|
|
|
local update = function(cr, pacman_stats)
|
|
|
|
local stats = __string_match(pacman_stats, '%d+%s+[^%s]+%s+[^%s]+%s+(.*)$')
|
2019-10-10 22:52:49 -04:00
|
|
|
if stats then
|
|
|
|
local i = 1
|
2019-10-11 21:52:10 -04:00
|
|
|
for v in __string_gmatch(stats, '%d+') do
|
2021-07-05 23:27:43 -04:00
|
|
|
Common.text_rows_set(rows, cr, i, v)
|
2019-10-10 22:52:49 -04:00
|
|
|
i = i + 1
|
|
|
|
end
|
|
|
|
else
|
2021-07-05 23:27:43 -04:00
|
|
|
for i=1, 5 do
|
|
|
|
Common.text_rows_set(rows, cr, i, 'N/A')
|
2019-10-10 22:52:49 -04:00
|
|
|
end
|
|
|
|
end
|
2017-07-19 00:36:15 -04:00
|
|
|
end
|
|
|
|
|
2021-07-05 23:27:43 -04:00
|
|
|
M.draw_static = function(cr)
|
|
|
|
Common.drawHeader(cr, header)
|
|
|
|
Common.text_rows_draw_static(rows, cr)
|
2018-08-05 11:22:07 -04:00
|
|
|
end
|
|
|
|
|
2021-07-05 23:27:43 -04:00
|
|
|
M.draw_dynamic = function(cr, pacman_stats)
|
2019-10-11 21:52:10 -04:00
|
|
|
update(cr, pacman_stats)
|
2021-07-05 23:27:43 -04:00
|
|
|
Common.text_rows_draw_dynamic(rows, cr)
|
2017-07-19 00:36:15 -04:00
|
|
|
end
|
|
|
|
|
2018-08-05 11:22:07 -04:00
|
|
|
return M
|