require("common.class") local dim = require("common.dimensions") local ServicePage = require("titlescreen.service.servicepage") ---@class ScreenCheckPage: ServicePage local ScreenCheckPage = { BG_COLOR = {255, 255, 255, 255}, STROKE_COLOR = {255, 0, 0, 255}, SQUARE_BG_COLOR = {128, 128, 128, 255}, SQUARE_STROKE_COLOR = {0, 0, 0, 255}, STROKE_WIDTH = 6, SQUARE_COUNT = {18, 32} } ---Create a new ScreenCheckPage instance --- ---Inherits from ServicePage ---@param o ServicePage ---@return ScreenCheckPage function ScreenCheckPage:new(o) o = Inherit(self, ServicePage, o) o.title = o.title or "SCREEN CHECK" o.footer = o.footer or { "START BUTTON = EXIT", "BACK BUTTON = EXIT" } return o end function ScreenCheckPage:handleButtonInput(button) if button == game.BUTTON_BCK or button == game.BUTTON_STA then if self.viewHandler then self.viewHandler:back() end end end function ScreenCheckPage:drawBackground(deltaTime) --background fill gfx.BeginPath() gfx.Rect(0, 0, dim.design.width, dim.design.height) gfx.FillColor(table.unpack(self.BG_COLOR)) gfx.Fill() --draw square array gfx.BeginPath() local squareSize = dim.design.width / self.SQUARE_COUNT[1] - 2 * self.STROKE_WIDTH local squareSpacing = 2 * self.STROKE_WIDTH for j = 0, self.SQUARE_COUNT[2] - 1 do local posY = self.STROKE_WIDTH + j * (squareSize + squareSpacing) for i = 0, self.SQUARE_COUNT[1] - 1 do local posX = self.STROKE_WIDTH + i * (squareSize + squareSpacing) gfx.Rect(posX, posY, squareSize, squareSize) end end gfx.FillColor(table.unpack(self.SQUARE_BG_COLOR)) gfx.StrokeColor(table.unpack(self.SQUARE_STROKE_COLOR)) gfx.StrokeWidth(self.STROKE_WIDTH) gfx.Fill() gfx.Stroke() --draw crosshairs gfx.BeginPath() --frame gfx.Rect(self.STROKE_WIDTH / 2, self.STROKE_WIDTH / 2, dim.design.width - self.STROKE_WIDTH, dim.design.height - self.STROKE_WIDTH) --center lines gfx.MoveTo(dim.design.width / 2, 0) gfx.LineTo(dim.design.width / 2, dim.design.height) gfx.MoveTo(0, dim.design.height / 2) gfx.LineTo(dim.design.width, dim.design.height / 2) --corners local cornerW = dim.design.width * 4 / 18 local cornerH = dim.design.height * 4 / 32 gfx.MoveTo(0, cornerH) gfx.LineTo(cornerW, cornerH) gfx.LineTo(cornerW, 0) gfx.MoveTo(dim.design.width - cornerW, 0) gfx.LineTo(dim.design.width - cornerW, cornerH) gfx.LineTo(dim.design.width, cornerH) gfx.MoveTo(0, dim.design.height - cornerH) gfx.LineTo(cornerW, dim.design.height - cornerH) gfx.LineTo(cornerW, dim.design.height) gfx.MoveTo(dim.design.width - cornerW, dim.design.height) gfx.LineTo(dim.design.width - cornerW, dim.design.height - cornerH) gfx.LineTo(dim.design.width, dim.design.height - cornerH) --center square local centerX = dim.design.width * 4 / 18 local centerY = dim.design.height * 11 / 32 local centerW = dim.design.width * 10 / 18 local centerH = dim.design.height * 10 / 32 gfx.Rect(centerX, centerY, centerW, centerH) gfx.StrokeColor(table.unpack(self.STROKE_COLOR)) gfx.StrokeWidth(self.STROKE_WIDTH) gfx.Stroke() end return ScreenCheckPage