2022-04-03 23:24:17 +02:00
|
|
|
require("common.class")
|
2022-06-29 00:35:52 +02:00
|
|
|
local ServicePage = require("api.page.servicepage")
|
2022-07-12 01:43:14 +02:00
|
|
|
local ListField = require("titlescreen.common.listfield")
|
|
|
|
local ColorGradientField = require("titlescreen.service.colorgradientfield")
|
2022-04-03 23:24:17 +02:00
|
|
|
|
|
|
|
---@class ColorCheckPage: ServicePage
|
|
|
|
local ColorCheckPage = {
|
2022-05-06 01:02:30 +02:00
|
|
|
__name = "ColorCheckPage",
|
2022-04-05 23:53:19 +02:00
|
|
|
|
2022-04-15 04:54:30 +02:00
|
|
|
PADDING = {56, 120, 0, 56}, --{left, top, right, bottom}
|
|
|
|
|
|
|
|
GRADIENT_SPACING = 32,
|
2022-04-11 18:47:26 +02:00
|
|
|
SEPARATOR_LINE_COLOR = {255, 255, 255, 255},
|
|
|
|
SEPARATOR_LINE_WIDTH = 4,
|
2022-04-03 23:24:17 +02:00
|
|
|
|
2022-04-11 18:47:26 +02:00
|
|
|
SEPARATOR_ARROW_SIZE = 16,
|
|
|
|
SEPARATOR_ARROW_MARGIN = 2,
|
|
|
|
SEPARATOR_ARROW_LINE_WIDTH = 1
|
2022-04-03 23:24:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
---Create a new ColorCheckPage instance
|
2022-05-06 01:02:30 +02:00
|
|
|
---@param params? ColorCheckPage # initial parameters
|
2022-04-03 23:24:17 +02:00
|
|
|
---@return ColorCheckPage
|
2022-05-06 01:02:30 +02:00
|
|
|
function ColorCheckPage.new(params)
|
|
|
|
params = params or {}
|
2022-04-03 23:24:17 +02:00
|
|
|
|
2022-05-06 01:02:30 +02:00
|
|
|
params.title = params.title or "COLOR CHECK"
|
|
|
|
params.footer = params.footer or {
|
2022-04-03 23:24:17 +02:00
|
|
|
"START BUTTON = EXIT",
|
|
|
|
"BACK BUTTON = EXIT"
|
|
|
|
}
|
|
|
|
|
2022-05-06 01:02:30 +02:00
|
|
|
local self = CreateInstance(ColorCheckPage, params, ServicePage)
|
2022-04-27 02:40:22 +02:00
|
|
|
|
|
|
|
local height = ColorCheckPage.GRADIENT_SPACING
|
|
|
|
local list = ListField.new()
|
|
|
|
list:addField(ColorGradientField.new{label = "RED", value = {255, 0, 0, 255}, aabbH = height})
|
|
|
|
list:addField(ColorGradientField.new{label = "YELLOW", value = {255, 255, 0, 255}, aabbH = height})
|
|
|
|
list:addField(ColorGradientField.new{label = "GREEN", value = {0, 255, 0, 255}, aabbH = height})
|
|
|
|
list:addField(ColorGradientField.new{label = "CYAN", value = {0, 255, 255, 255}, aabbH = height})
|
|
|
|
list:addField(ColorGradientField.new{label = "BLUE", value = {0, 0, 255, 255}, aabbH = height})
|
|
|
|
list:addField(ColorGradientField.new{label = "MAGENTA", value = {255, 0, 255, 255}, aabbH = height})
|
|
|
|
list:addField(ColorGradientField.new{label = "WHITE", value = {255, 255, 255, 255}, aabbH = height})
|
2022-04-15 04:54:30 +02:00
|
|
|
list:refreshFields()
|
|
|
|
|
2022-05-06 01:02:30 +02:00
|
|
|
self:addField(list)
|
|
|
|
self:refreshFields()
|
2022-04-15 04:54:30 +02:00
|
|
|
|
2022-05-06 01:02:30 +02:00
|
|
|
return self
|
2022-04-03 23:24:17 +02:00
|
|
|
end
|
|
|
|
|
2022-04-12 23:45:28 +02:00
|
|
|
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
2022-04-03 23:24:17 +02:00
|
|
|
function ColorCheckPage:handleButtonInput(button)
|
|
|
|
if button == game.BUTTON_BCK or button == game.BUTTON_STA then
|
|
|
|
if self.viewHandler then
|
|
|
|
self.viewHandler:back()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-12 23:45:28 +02:00
|
|
|
---@param deltaTime number # frametime in seconds
|
|
|
|
function ColorCheckPage:_drawSeparator(deltaTime)
|
2022-04-03 23:24:17 +02:00
|
|
|
gfx.BeginPath()
|
2022-04-11 18:47:26 +02:00
|
|
|
gfx.Rect(ColorGradientField.GRADIENT_X_OFFSET, 0,
|
|
|
|
ColorGradientField.GRADIENT_WIDTH, self.SEPARATOR_LINE_WIDTH)
|
|
|
|
gfx.FillColor(table.unpack(self.SEPARATOR_LINE_COLOR))
|
2022-04-03 23:24:17 +02:00
|
|
|
gfx.Fill()
|
2022-04-11 18:47:26 +02:00
|
|
|
end
|
2022-04-03 23:24:17 +02:00
|
|
|
|
2022-04-12 23:45:28 +02:00
|
|
|
---@param deltaTime number # frametime in seconds
|
|
|
|
function ColorCheckPage:_drawArrows(deltaTime)
|
2022-04-03 23:24:17 +02:00
|
|
|
local stepW = ColorGradientField.GRADIENT_WIDTH / ColorGradientField.GRADIENT_STEPS
|
|
|
|
gfx.BeginPath()
|
|
|
|
for i = 0, 3 do
|
2022-04-15 04:54:30 +02:00
|
|
|
local posX = ColorGradientField.GRADIENT_X_OFFSET + i * stepW
|
2022-04-11 18:47:26 +02:00
|
|
|
gfx.MoveTo(posX + self.SEPARATOR_ARROW_MARGIN, self.SEPARATOR_ARROW_SIZE - self.SEPARATOR_ARROW_MARGIN)
|
|
|
|
gfx.LineTo(posX + stepW / 2, self.SEPARATOR_ARROW_MARGIN)
|
|
|
|
gfx.LineTo(posX + stepW - self.SEPARATOR_ARROW_MARGIN, self.SEPARATOR_ARROW_SIZE - self.SEPARATOR_ARROW_MARGIN)
|
2022-04-03 23:24:17 +02:00
|
|
|
end
|
2022-04-11 18:47:26 +02:00
|
|
|
gfx.StrokeColor(table.unpack(self.SEPARATOR_LINE_COLOR))
|
|
|
|
gfx.StrokeWidth(self.SEPARATOR_ARROW_LINE_WIDTH)
|
2022-04-03 23:24:17 +02:00
|
|
|
gfx.Stroke()
|
2022-04-11 18:47:26 +02:00
|
|
|
end
|
2022-04-03 23:24:17 +02:00
|
|
|
|
2022-04-12 23:45:28 +02:00
|
|
|
---@param deltaTime number # frametime in seconds
|
|
|
|
function ColorCheckPage:_drawArrowText(deltaTime)
|
2022-04-11 18:47:26 +02:00
|
|
|
local stepW = ColorGradientField.GRADIENT_WIDTH / ColorGradientField.GRADIENT_STEPS
|
2022-04-03 23:24:17 +02:00
|
|
|
local textCenterX = ColorGradientField.GRADIENT_X_OFFSET + 2 * stepW
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER | gfx.TEXT_ALIGN_TOP)
|
2022-04-11 18:47:26 +02:00
|
|
|
gfx.FontSize(self.FONT_SIZE)
|
|
|
|
gfx.LoadSkinFont(self.FONT_FACE)
|
|
|
|
gfx.FillColor(table.unpack(self.FONT_COLOR))
|
|
|
|
gfx.Text("COLORLESS", textCenterX, 0)
|
|
|
|
end
|
|
|
|
|
2022-04-12 23:45:28 +02:00
|
|
|
---@param deltaTime number # frametime in seconds
|
2022-04-11 18:47:26 +02:00
|
|
|
function ColorCheckPage:drawBackground(deltaTime)
|
2022-04-15 04:54:30 +02:00
|
|
|
ServicePage.drawBackground(self, deltaTime)
|
2022-04-11 18:47:26 +02:00
|
|
|
gfx.Save()
|
2022-04-15 04:54:30 +02:00
|
|
|
gfx.Translate(self.PADDING[1], self.PADDING[2])
|
2022-04-11 18:47:26 +02:00
|
|
|
|
2022-04-15 04:54:30 +02:00
|
|
|
local list = self.content[1]
|
|
|
|
local posX = list.posX
|
|
|
|
local posY = list.posY + list.aabbH
|
|
|
|
gfx.Translate(posX, posY)
|
2022-04-12 23:45:28 +02:00
|
|
|
self:_drawSeparator(deltaTime)
|
2022-04-11 18:47:26 +02:00
|
|
|
gfx.Translate(0, self.SEPARATOR_LINE_WIDTH)
|
2022-04-12 23:45:28 +02:00
|
|
|
self:_drawArrows(deltaTime)
|
2022-04-11 18:47:26 +02:00
|
|
|
gfx.Translate(0, self.SEPARATOR_ARROW_SIZE)
|
2022-04-12 23:45:28 +02:00
|
|
|
self:_drawArrowText(deltaTime)
|
2022-04-03 23:24:17 +02:00
|
|
|
|
|
|
|
gfx.Restore()
|
|
|
|
end
|
|
|
|
|
2022-04-05 23:53:19 +02:00
|
|
|
return ColorCheckPage
|