50 lines
1.2 KiB
Lua
50 lines
1.2 KiB
Lua
|
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)
|
||
|
self.__index = self
|
||
|
setmetatable(self, {__index = Field})
|
||
|
o = Field:new(o)
|
||
|
setmetatable(o, self)
|
||
|
|
||
|
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
|