2022-04-24 01:39:48 +02:00
|
|
|
require("common.class")
|
|
|
|
local Dim = require("common.dimensions")
|
2022-04-27 12:29:54 +02:00
|
|
|
local Page = require("api.page.page")
|
2022-07-12 01:43:14 +02:00
|
|
|
local CheckUpdateField = require("titlescreen.boot.checkupdatefield")
|
|
|
|
local DialogField = require("titlescreen.boot.dialogfield")
|
2022-04-24 01:39:48 +02:00
|
|
|
|
|
|
|
---@class CheckUpdatePage: Page
|
2022-04-24 15:07:52 +02:00
|
|
|
---@field _focusedField CheckUpdateField
|
2022-04-24 01:39:48 +02:00
|
|
|
local CheckUpdatePage = {
|
2022-05-06 01:02:30 +02:00
|
|
|
__name = "CheckUpdatePage",
|
2022-04-24 01:39:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
---Create a new CheckUpdatePage instance
|
2022-05-06 01:02:30 +02:00
|
|
|
---@param params? CheckUpdatePage # initial parameters
|
2022-04-24 01:39:48 +02:00
|
|
|
---@return CheckUpdatePage
|
2022-05-06 01:02:30 +02:00
|
|
|
function CheckUpdatePage.new(params)
|
|
|
|
local self = CreateInstance(CheckUpdatePage, params, Page)
|
2022-04-24 01:39:48 +02:00
|
|
|
|
2022-04-24 15:07:52 +02:00
|
|
|
local width = DialogField.DEFAULT_WIDTH
|
|
|
|
local height = DialogField.DEFAULT_HEIGHT
|
|
|
|
local posX = (Dim.design.width - width) / 2
|
|
|
|
local posY = (Dim.design.height - height) / 2
|
2022-05-06 01:02:30 +02:00
|
|
|
self._updateDialogField = DialogField.new{
|
2022-04-24 15:07:52 +02:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-06 01:02:30 +02:00
|
|
|
self._updateDialogField.handleButtonInput = function (_, button)
|
|
|
|
if not self.viewHandler then
|
2022-04-24 15:07:52 +02:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
if button == game.BUTTON_BCK then
|
2022-06-29 00:35:52 +02:00
|
|
|
self:onInvalidation() -- Cancel update, close screen
|
2022-04-24 15:07:52 +02:00
|
|
|
return true
|
|
|
|
elseif button == game.BUTTON_STA then
|
2022-06-29 00:35:52 +02:00
|
|
|
self:onInvalidation(true)
|
2022-04-24 15:07:52 +02:00
|
|
|
return true
|
|
|
|
end
|
2022-04-27 02:40:22 +02:00
|
|
|
|
|
|
|
return false
|
2022-04-24 15:07:52 +02:00
|
|
|
end
|
|
|
|
|
2022-05-06 01:02:30 +02:00
|
|
|
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
|
2022-04-24 01:39:48 +02:00
|
|
|
end
|
2022-04-24 15:07:52 +02:00
|
|
|
|
2022-05-06 01:02:30 +02:00
|
|
|
self:addField(self._checkUpdateField)
|
2022-04-24 01:39:48 +02:00
|
|
|
|
2022-05-06 01:02:30 +02:00
|
|
|
self._focusedField = self._checkUpdateField
|
2022-04-24 15:07:52 +02:00
|
|
|
|
2022-05-06 01:02:30 +02:00
|
|
|
return self
|
2022-04-24 01:39:48 +02:00
|
|
|
end
|
|
|
|
|
2022-04-24 15:07:52 +02:00
|
|
|
function CheckUpdatePage:handleButtonInput(button)
|
|
|
|
if self._focusedField and self._focusedField:handleButtonInput(button) then
|
|
|
|
return -- stop processing input
|
|
|
|
end
|
|
|
|
|
|
|
|
if button == game.BUTTON_BCK then
|
2022-06-29 00:35:52 +02:00
|
|
|
self:onInvalidation()
|
2022-04-24 15:07:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-24 01:39:48 +02:00
|
|
|
---@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
|