feat(inferium-gui): centered title

This commit is contained in:
Guillaume ARM 2024-05-23 22:54:16 +02:00
parent 598bf7bfa5
commit bd843779e2

View File

@ -2,19 +2,26 @@ local CountersSelector = require('libs/ui/CountersSelector')
local counterMax = 8
local function centerString(str, width)
local padding = (width / 2) - (#str / 2)
return string.rep(' ', padding) .. str
end
local titleFn = function(countersMap)
local total = 0;
for _, counterPayload in pairs(countersMap) do
if counterPayload and counterPayload.count then
total = total + counterPayload.count
end
end
return centerString("" .. total .. '/' .. counterMax .. ' used farmlands' .. "")
end
local config = {
counterMax = counterMax,
titleFn = function(countersMap)
local total = 0;
for _, counterPayload in pairs(countersMap) do
if counterPayload and counterPayload.count then
total = total + counterPayload.count
end
end
return "| " .. total .. '/' .. counterMax .. ' used farmlands' .. " |"
end
titleFn = titleFn
}
local countersMap = {