2022-04-03 19:43:50 +02:00
|
|
|
require("common.class")
|
2022-04-03 04:59:43 +02:00
|
|
|
local dim = require("common.dimensions")
|
|
|
|
local Field = require("components.pager.field")
|
|
|
|
|
|
|
|
---@class ServiceField: Field
|
|
|
|
---@field label string
|
|
|
|
---@field value any
|
|
|
|
---@field footer string|string[]
|
|
|
|
local ServiceField = {
|
|
|
|
SERVICE_DEFAULT_FONT_SIZE = 24,
|
|
|
|
SERVICE_DEFAULT_FONT_FACE = "dfmarugoth.ttf",
|
|
|
|
SERVICE_DEFAULT_FONT_COLOR = {255, 255, 255, 255}, --{r, g, b, a}
|
|
|
|
}
|
|
|
|
|
|
|
|
function ServiceField:new(o)
|
2022-04-03 19:43:50 +02:00
|
|
|
o = Inherit(self, Field, o)
|
2022-04-03 04:59:43 +02:00
|
|
|
|
|
|
|
o.label = o.label or "<UNDEFINED>"
|
|
|
|
o.value = o.value or nil
|
|
|
|
o.footer = o.footer or nil
|
|
|
|
|
|
|
|
return o
|
|
|
|
end
|
|
|
|
|
|
|
|
function ServiceField:drawValue(deltaTime)
|
|
|
|
gfx.Save()
|
|
|
|
gfx.Text("N/A", dim.design.width / 2, 0)
|
|
|
|
gfx.Restore()
|
|
|
|
end
|
|
|
|
|
|
|
|
function ServiceField:render(deltaTime)
|
|
|
|
gfx.Save()
|
|
|
|
|
|
|
|
gfx.Translate(self.posX, self.posY)
|
|
|
|
|
|
|
|
gfx.FontSize(ServiceField.SERVICE_DEFAULT_FONT_SIZE)
|
|
|
|
gfx.LoadSkinFont(ServiceField.SERVICE_DEFAULT_FONT_FACE)
|
|
|
|
gfx.FillColor(table.unpack(ServiceField.SERVICE_DEFAULT_FONT_COLOR))
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT | gfx.TEXT_ALIGN_TOP)
|
|
|
|
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.Text(self.label, 0, 0)
|
|
|
|
self:drawValue(deltaTime)
|
|
|
|
|
|
|
|
gfx.Restore()
|
|
|
|
end
|
|
|
|
|
|
|
|
return ServiceField
|