ExperimentalGear/scripts/titlescreen/fields/service/inputbuttonfield.lua

36 lines
816 B
Lua

require("common.class")
local Dim = require("common.dimensions")
local ServiceField = require("titlescreen.fields.service.servicefield")
---@class InputButtonField: ServiceField
---@field button integer
local InputButtonField = {
__tostring = function() return "InputButtonField" end,
}
function InputButtonField:new(o)
o = o or {}
o.button = o.button or nil
return Inherit(self, o, ServiceField)
end
function InputButtonField:activate() end
function InputButtonField:focus() end
function InputButtonField:deactivate() end
function InputButtonField:drawValue(deltaTime)
local buttonState = game.GetButton(self.button)
local posX = Dim.design.width / 2
self.value = buttonState and "ON" or "OFF"
gfx.BeginPath()
gfx.Text(self.value, posX, 0)
end
return InputButtonField