require("common.class") local Dim = require("scripts.graphics.dimensions") local Page = require("api.page.page") local CheckUpdateField = require("titlescreen.boot.checkupdatefield") local DialogField = require("titlescreen.boot.dialogfield") ---@class CheckUpdatePage: Page ---@field _focusedField CheckUpdateField local CheckUpdatePage = { __name = "CheckUpdatePage", } ---Create a new CheckUpdatePage instance ---@param params? CheckUpdatePage # initial parameters ---@return CheckUpdatePage function CheckUpdatePage.new(params) local self = CreateInstance(CheckUpdatePage, params, Page) local width = DialogField.DEFAULT_WIDTH local height = DialogField.DEFAULT_HEIGHT local posX = (Dim.design.width - width) / 2 local posY = (Dim.design.height - height) / 2 self._updateDialogField = DialogField.new{ posX = posX, posY = posY, aabbW = width, aabbH = height, HEADER = { title = "Updates found", code = "0-1000-0000" }, TEXT = { "An update is available to Unnamed SDVX Clone,", "please update to receive the latest features." }, LEGEND = { { label = "BACK BUTTON", text = "ABORT UPDATE/START GAME" }, { label = "START BUTTON", text = "GO TO SERVICE PAGE" } } } self._updateDialogField.handleButtonInput = function (_, button) if not self.viewHandler then return false end if button == game.BUTTON_BCK then self:onInvalidation() -- Cancel update, close screen return true elseif button == game.BUTTON_STA then self:onInvalidation(true) return true end return false end self._checkUpdateField = CheckUpdateField.new{posX = 32, posY = 64, label = "update check"} self._checkUpdateField.onUpdateAvailable = function(url, version) self:addField(self._updateDialogField) self._focusedField = self._updateDialogField end self:addField(self._checkUpdateField) self._focusedField = self._checkUpdateField return self end function CheckUpdatePage:handleButtonInput(button) if self._focusedField and self._focusedField:handleButtonInput(button) then return -- stop processing input end if button == game.BUTTON_BCK then self:onInvalidation() end end ---@param deltaTime number # frametime in seconds function CheckUpdatePage:drawBackground(deltaTime) gfx.BeginPath() gfx.FillColor(0, 0, 0) gfx.Rect(0, 0, Dim.design.width, Dim.design.height) gfx.Fill() end return CheckUpdatePage