2022-04-03 19:43:50 +02:00
|
|
|
require("common.class")
|
|
|
|
|
2022-04-03 01:35:41 +02:00
|
|
|
---@class Field
|
|
|
|
---@field parent Page
|
|
|
|
---@field posX number
|
|
|
|
---@field posY number
|
|
|
|
local Field = {
|
2022-04-03 19:43:50 +02:00
|
|
|
---@type nil|fun(button: integer): boolean
|
|
|
|
---returns true if further button input processing should be stopped, otherwise false
|
|
|
|
handleButtonInput = nil,
|
|
|
|
---@type nil|fun(knob: integer, delta: number): boolean
|
|
|
|
---returns true if further button input processing should be stopped, otherwise false
|
|
|
|
handleKnobInput = nil,
|
2022-04-03 01:35:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
---Create a new Field instance
|
|
|
|
---@param o table
|
|
|
|
---@return Field
|
|
|
|
function Field:new(o)
|
2022-04-03 19:43:50 +02:00
|
|
|
o = Base(self, o)
|
2022-04-03 01:35:41 +02:00
|
|
|
|
|
|
|
--set instance members
|
|
|
|
|
|
|
|
o.parent = o.parent or nil
|
|
|
|
o.posX = o.posX or 0
|
|
|
|
o.posY = o.posY or 0
|
|
|
|
|
|
|
|
return o
|
|
|
|
end
|
|
|
|
|
2022-04-03 19:51:56 +02:00
|
|
|
function Field:activate() end
|
|
|
|
|
|
|
|
function Field:focus() end
|
|
|
|
|
|
|
|
function Field:deactivate() end
|
|
|
|
|
2022-04-03 01:35:41 +02:00
|
|
|
function Field:render(deltaTime)
|
|
|
|
gfx.Save()
|
|
|
|
|
|
|
|
gfx.Translate(self.posX, self.posY)
|
|
|
|
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.FillColor(255, 0, 128, 192)
|
|
|
|
gfx.StrokeColor(0, 0, 0)
|
|
|
|
gfx.StrokeWidth(2)
|
|
|
|
gfx.Rect(-50, -50, 100, 100)
|
|
|
|
gfx.Fill()
|
|
|
|
gfx.Stroke()
|
|
|
|
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.MoveTo(-50, 0)
|
|
|
|
gfx.LineTo(50, 0)
|
|
|
|
gfx.MoveTo(0, -50)
|
|
|
|
gfx.LineTo(0, 50)
|
|
|
|
gfx.StrokeColor(0, 0, 0, 64)
|
|
|
|
gfx.StrokeWidth(2)
|
|
|
|
gfx.Stroke()
|
|
|
|
|
|
|
|
local fontSize = 18
|
|
|
|
local fontMargin = 4
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.FontSize(fontSize)
|
|
|
|
gfx.LoadSkinFont("dfmarugoth.ttf")
|
|
|
|
gfx.FillColor(0, 0, 0)
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER | gfx.TEXT_ALIGN_MIDDLE)
|
|
|
|
gfx.Text("TEXTURE", 0, -fontSize / 2 - fontMargin)
|
|
|
|
gfx.Text("MISSING", 0, fontSize / 2 + fontMargin)
|
|
|
|
|
|
|
|
gfx.Restore()
|
|
|
|
end
|
|
|
|
|
|
|
|
return Field
|