2022-04-11 18:47:26 +02:00
|
|
|
require("common.class")
|
2022-04-15 04:54:30 +02:00
|
|
|
require("common.filereader")
|
2022-04-11 18:47:26 +02:00
|
|
|
local Dim = require("common.dimensions")
|
|
|
|
local Version = require("common.version")
|
|
|
|
local Page = require("components.pager.page")
|
2022-04-24 01:39:48 +02:00
|
|
|
local CheckUpdatePage = require("titlescreen.pages.boot.checkupdatepage")
|
2022-04-11 18:47:26 +02:00
|
|
|
local ServiceField = require("titlescreen.fields.service.servicefield")
|
2022-04-15 04:54:30 +02:00
|
|
|
local ListField = require("titlescreen.fields.service.listfield")
|
|
|
|
local SelfTestField = require("titlescreen.fields.boot.selftestfield")
|
|
|
|
|
2022-04-11 18:47:26 +02:00
|
|
|
---@class BootPage: Page
|
|
|
|
local BootPage = {
|
|
|
|
__tostring = function() return "BootPage" end,
|
|
|
|
}
|
|
|
|
|
|
|
|
---Create a new BootPage instance
|
2022-04-12 23:45:28 +02:00
|
|
|
---@param o? table # initial parameters
|
2022-04-11 18:47:26 +02:00
|
|
|
---@return BootPage
|
2022-04-27 02:40:22 +02:00
|
|
|
function BootPage.new(o)
|
2022-04-11 18:47:26 +02:00
|
|
|
o = o or {}
|
|
|
|
|
2022-04-27 02:40:22 +02:00
|
|
|
local this = CreateInstance(BootPage, o, Page)
|
2022-04-11 18:47:26 +02:00
|
|
|
|
2022-04-24 01:39:48 +02:00
|
|
|
this._networkResult = {}
|
|
|
|
|
2022-04-27 02:40:22 +02:00
|
|
|
this:addField(ServiceField.new{posX = 32, posY = 32, label = Version.getLongVersion(), value = ""})
|
|
|
|
this:addField(ServiceField.new{posX = 64, posY = 64, label = "UNNAMED SDVX CLONE STARTUP...", value = ""})
|
2022-04-15 04:54:30 +02:00
|
|
|
|
|
|
|
local valueOffX = 220
|
2022-04-27 02:40:22 +02:00
|
|
|
this._mainIoTestField = SelfTestField.new{label = "MAIN I/O", VALUE_OFFSETX = valueOffX}
|
2022-04-24 01:39:48 +02:00
|
|
|
this._mainIoTestField.checkTask = function(obj)
|
|
|
|
return SelfTestStatusEnum.OK
|
|
|
|
end
|
|
|
|
this._mainIoTestField.onStatusChange = function(status)
|
|
|
|
if status == SelfTestStatusEnum.OK then
|
|
|
|
this._skinConfigTestField:activate()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-27 02:40:22 +02:00
|
|
|
this._skinConfigTestField = SelfTestField.new{label = "SKIN CONFIG", VALUE_OFFSETX = valueOffX}
|
2022-04-24 01:39:48 +02:00
|
|
|
this._skinConfigTestField.checkTask = function(obj)
|
|
|
|
local crewpath = "skins/" .. game.GetSkin() .. "/textures/crew/anim/" .. game.GetSkinSetting("single_idol")
|
|
|
|
if not IsDir(crewpath) then
|
|
|
|
return SelfTestStatusEnum.ERROR
|
|
|
|
end
|
|
|
|
return SelfTestStatusEnum.OK
|
|
|
|
end
|
|
|
|
this._skinConfigTestField.onStatusChange = function(status)
|
|
|
|
if status == SelfTestStatusEnum.OK then
|
|
|
|
this._networkTestField:activate()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-27 02:40:22 +02:00
|
|
|
this._networkTestField = SelfTestField.new{label = "NETWORK", VALUE_OFFSETX = valueOffX}
|
2022-04-24 01:39:48 +02:00
|
|
|
-- set up async network check
|
|
|
|
this._networkTestField.checkTask = function(obj)
|
|
|
|
local status = SelfTestStatusEnum.INPROGRESS
|
|
|
|
|
|
|
|
if not IRData.Active then
|
|
|
|
return SelfTestStatusEnum.PASS
|
|
|
|
end
|
|
|
|
|
|
|
|
while status == SelfTestStatusEnum.INPROGRESS do
|
|
|
|
if this._networkResult.statusCode == IRData.States.Success then
|
|
|
|
status = SelfTestStatusEnum.OK
|
|
|
|
elseif this._networkResult.statusCode then
|
|
|
|
status = SelfTestStatusEnum.ERROR -- there's a response, but it's not success
|
|
|
|
end
|
|
|
|
|
|
|
|
coroutine.yield(status)
|
|
|
|
end
|
|
|
|
|
|
|
|
return status
|
|
|
|
end
|
|
|
|
this._networkTestField.onStatusChange = function(status)
|
|
|
|
if status == SelfTestStatusEnum.INPROGRESS then
|
|
|
|
IR.Heartbeat(function(res) this._networkResult = res end) -- IR doesn't like being called in a coroutine
|
|
|
|
elseif status == SelfTestStatusEnum.PASS or status == SelfTestStatusEnum.OK then
|
|
|
|
if this.viewHandler then
|
2022-04-27 02:40:22 +02:00
|
|
|
this.viewHandler:navigate(CheckUpdatePage.new())
|
2022-04-24 01:39:48 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-27 02:40:22 +02:00
|
|
|
local list = ListField.new{posX = 64, posY = 96}
|
2022-04-24 01:39:48 +02:00
|
|
|
list:addField(this._mainIoTestField)
|
|
|
|
list:addField(this._skinConfigTestField)
|
|
|
|
list:addField(this._networkTestField)
|
2022-04-15 04:54:30 +02:00
|
|
|
this:addField(list)
|
|
|
|
|
|
|
|
return this
|
2022-04-11 18:47:26 +02:00
|
|
|
end
|
|
|
|
|
2022-04-12 23:45:28 +02:00
|
|
|
---@param deltaTime number # frametime in seconds
|
2022-04-11 18:47:26 +02:00
|
|
|
function BootPage:drawBackground(deltaTime)
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.FillColor(0, 0, 0)
|
|
|
|
gfx.Rect(0, 0, Dim.design.width, Dim.design.height)
|
|
|
|
gfx.Fill()
|
|
|
|
end
|
|
|
|
|
2022-04-24 01:39:48 +02:00
|
|
|
local first = true
|
2022-04-15 04:54:30 +02:00
|
|
|
function BootPage:render(deltaTime)
|
2022-04-24 01:39:48 +02:00
|
|
|
if first then
|
|
|
|
self._mainIoTestField:activate()
|
|
|
|
first = false
|
|
|
|
end
|
2022-04-15 04:54:30 +02:00
|
|
|
Page.render(self, deltaTime)
|
|
|
|
end
|
|
|
|
|
2022-04-11 18:47:26 +02:00
|
|
|
return BootPage
|