ExperimentalGear/scripts/titlescreen/service/servicefield.lua

48 lines
1.2 KiB
Lua
Raw Normal View History

require("common.class")
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)
o = Inherit(self, Field, o)
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