feat(inferium-gui): centered title
This commit is contained in:
parent
598bf7bfa5
commit
bd843779e2
@ -2,19 +2,26 @@ local CountersSelector = require('libs/ui/CountersSelector')
|
|||||||
|
|
||||||
local counterMax = 8
|
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 = {
|
local config = {
|
||||||
counterMax = counterMax,
|
counterMax = counterMax,
|
||||||
titleFn = function(countersMap)
|
titleFn = titleFn
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local countersMap = {
|
local countersMap = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user