code cleanup
instead of implementing __tostring, set __name use variable name 'params' instead of 'o' use 'self' for indicating instance instead of 'this' move private members under self instead of params set doc type of 'params' as the object created (helps IDE autocomplete)
This commit is contained in:
parent
be9a1f9408
commit
e68fcd5bfe
|
@ -8,19 +8,21 @@ local exclusiveAudioSample = nil
|
||||||
---@field exclusive boolean
|
---@field exclusive boolean
|
||||||
---@field loop boolean
|
---@field loop boolean
|
||||||
---@field playing boolean
|
---@field playing boolean
|
||||||
local AudioSample = {}
|
local AudioSample = {
|
||||||
|
__name = "AudioSample"
|
||||||
|
}
|
||||||
|
|
||||||
---Create new AudioSample instance
|
---Create new AudioSample instance
|
||||||
---@param o AudioSample
|
---@param params AudioSample
|
||||||
---@return AudioSample
|
---@return AudioSample
|
||||||
function AudioSample.new(o)
|
function AudioSample.new(params)
|
||||||
assert(o.path, "AudioSample.new() did not receive path to audio sample")
|
assert(params.path, "AudioSample.new() did not receive path to audio sample")
|
||||||
o.exclusive = o.exclusive or false
|
params.exclusive = params.exclusive or false
|
||||||
o.loop = o.loop or false
|
params.loop = params.loop or false
|
||||||
|
|
||||||
game.LoadSkinSample(o.path)
|
game.LoadSkinSample(params.path)
|
||||||
|
|
||||||
return CreateInstance(AudioSample, o)
|
return CreateInstance(AudioSample, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
function AudioSample:play()
|
function AudioSample:play()
|
||||||
|
|
|
@ -4,24 +4,24 @@ local Field = require("api.page.field")
|
||||||
---@class ContainerField: Field
|
---@class ContainerField: Field
|
||||||
---@field content Field[]
|
---@field content Field[]
|
||||||
local ContainerField = {
|
local ContainerField = {
|
||||||
__tostring = function() return "ContainerField" end,
|
__name = "ContainerField"
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new ContainerField instance
|
---Create a new ContainerField instance
|
||||||
---@param o? table # initial parameters
|
---@param params? ContainerField # initial parameters
|
||||||
---@return ContainerField
|
---@return ContainerField
|
||||||
function ContainerField.new(o)
|
function ContainerField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
--set instance members
|
--set instance members
|
||||||
|
|
||||||
o.content = o.content or {}
|
params.content = params.content or {}
|
||||||
|
|
||||||
local this = CreateInstance(ContainerField, o, Field)
|
local self = CreateInstance(ContainerField, params, Field)
|
||||||
|
|
||||||
this:refreshFields()
|
self:refreshFields()
|
||||||
|
|
||||||
return this
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Add content to container
|
---Add content to container
|
||||||
|
|
|
@ -7,24 +7,24 @@ require("common.class")
|
||||||
---@field aabbW number
|
---@field aabbW number
|
||||||
---@field aabbH number
|
---@field aabbH number
|
||||||
local Field = {
|
local Field = {
|
||||||
__tostring = function() return "Field" end,
|
__name = "Field"
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new Field instance
|
---Create a new Field instance
|
||||||
---@param o? table # initial parameters
|
---@param params? Field # initial parameters
|
||||||
---@return Field
|
---@return Field
|
||||||
function Field.new(o)
|
function Field.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
--set instance members
|
--set instance members
|
||||||
|
|
||||||
o.parent = o.parent or nil
|
params.parent = params.parent or nil
|
||||||
o.posX = o.posX or 0
|
params.posX = params.posX or 0
|
||||||
o.posY = o.posY or 0
|
params.posY = params.posY or 0
|
||||||
o.aabbW = o.aabbW or 0
|
params.aabbW = params.aabbW or 0
|
||||||
o.aabbH = o.aabbH or 0
|
params.aabbH = params.aabbH or 0
|
||||||
|
|
||||||
return CreateInstance(Field, o)
|
return CreateInstance(Field, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Get the containing top-level parent page
|
---Get the containing top-level parent page
|
||||||
|
|
|
@ -4,18 +4,18 @@ local Field = require("api.page.field")
|
||||||
---@class LinkField: Field
|
---@class LinkField: Field
|
||||||
---@field link Page
|
---@field link Page
|
||||||
local LinkField = {
|
local LinkField = {
|
||||||
__tostring = function() return "LinkField" end
|
__name = "LinkField"
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new LinkField instance
|
---Create a new LinkField instance
|
||||||
---@param o? table # initial parameters
|
---@param params? LinkField # initial parameters
|
||||||
---@return LinkField
|
---@return LinkField
|
||||||
function LinkField.new(o)
|
function LinkField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.link = o.link or nil
|
params.link = params.link or nil
|
||||||
|
|
||||||
return CreateInstance(LinkField, o, Field)
|
return CreateInstance(LinkField, params, Field)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
||||||
|
|
|
@ -5,11 +5,11 @@ require("common.class")
|
||||||
---@field content Field[]
|
---@field content Field[]
|
||||||
---@field viewHandler nil|PageView
|
---@field viewHandler nil|PageView
|
||||||
local Page = {
|
local Page = {
|
||||||
__tostring = function() return "Page" end,
|
__name = "Page",
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new Page instance
|
---Create a new Page instance
|
||||||
---@param params? table # initial parameters
|
---@param params? Page # initial parameters
|
||||||
---@return Page
|
---@return Page
|
||||||
function Page.new(params)
|
function Page.new(params)
|
||||||
params = params or {}
|
params = params or {}
|
||||||
|
|
|
@ -3,7 +3,7 @@ require("common.class")
|
||||||
---@class PageView
|
---@class PageView
|
||||||
---@field pageStack Page[]
|
---@field pageStack Page[]
|
||||||
local PageView = {
|
local PageView = {
|
||||||
__tostring = function() return "PageView" end
|
__name = "PageView"
|
||||||
}
|
}
|
||||||
|
|
||||||
local function pushStack(t, o)
|
local function pushStack(t, o)
|
||||||
|
@ -17,7 +17,7 @@ end
|
||||||
---Create a new PageView instance
|
---Create a new PageView instance
|
||||||
---@return PageView
|
---@return PageView
|
||||||
function PageView.new()
|
function PageView.new()
|
||||||
local self = CreateInstance(PageView, {})
|
local self = CreateInstance(PageView)
|
||||||
self.pageStack = {}
|
self.pageStack = {}
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,11 +12,11 @@ end
|
||||||
---Create polimorphic class
|
---Create polimorphic class
|
||||||
---@generic BaseT, T
|
---@generic BaseT, T
|
||||||
---@param cls T # class metatable
|
---@param cls T # class metatable
|
||||||
---@param o? table # initial parameters
|
---@param params? table # initial parameters
|
||||||
---@param ... BaseT # base class metatables (if any)
|
---@param ... BaseT # base class metatables (if any)
|
||||||
---@return T # class instance
|
---@return T # class instance
|
||||||
function CreateInstance(cls, o, ...)
|
function CreateInstance(cls, params, ...)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
local nargs = select("#", ...)
|
local nargs = select("#", ...)
|
||||||
local vargs = { select(1, ...) }
|
local vargs = { select(1, ...) }
|
||||||
cls.__index = cls
|
cls.__index = cls
|
||||||
|
@ -24,14 +24,14 @@ function CreateInstance(cls, o, ...)
|
||||||
-- single inheritance
|
-- single inheritance
|
||||||
local base = vargs[1]
|
local base = vargs[1]
|
||||||
setmetatable(cls, {__index = base})
|
setmetatable(cls, {__index = base})
|
||||||
o = base.new(o)
|
params = base.new(params)
|
||||||
elseif nargs > 1 then
|
elseif nargs > 1 then
|
||||||
-- multiple inheritance (note: slow(er) member lookup)
|
-- multiple inheritance (note: slow(er) member lookup)
|
||||||
setmetatable(cls, {__index = function(t, k) return search(k, vargs) end})
|
setmetatable(cls, {__index = function(t, k) return search(k, vargs) end})
|
||||||
for _, base in ipairs(vargs) do
|
for _, base in ipairs(vargs) do
|
||||||
o = base.new(o)
|
params = base.new(params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
setmetatable(o, cls)
|
setmetatable(params, cls)
|
||||||
return o
|
return params
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,26 +8,27 @@ local SplashScreen = require "titlescreen.splash"
|
||||||
---@class BootScreen : Screen
|
---@class BootScreen : Screen
|
||||||
---@field bootpage BootPage
|
---@field bootpage BootPage
|
||||||
local BootScreen = {
|
local BootScreen = {
|
||||||
__tostring = function() return "BootScreen" end
|
__name = "BootScreen"
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new BootScreen instance
|
---Create a new BootScreen instance
|
||||||
---@param o? BootScreen
|
---@param params? BootScreen
|
||||||
---@return BootScreen
|
---@return BootScreen
|
||||||
function BootScreen.new(o)
|
function BootScreen.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.bootpage = o.bootpage or BootPage.new()
|
params.bootpage = params.bootpage or BootPage.new()
|
||||||
|
|
||||||
return CreateInstance(BootScreen, o, Screen)
|
return CreateInstance(BootScreen, params, Screen)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BootScreen:init()
|
function BootScreen:init()
|
||||||
|
Screen.init(self)
|
||||||
self.pageview:replace(self.bootpage)
|
self.pageview:replace(self.bootpage)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BootScreen:deactivate()
|
function BootScreen:deactivate()
|
||||||
self.onDeactivation({reason = "deactivation", hint = tostring(SplashScreen)})
|
self.onDeactivation({reason = "deactivation", hint = SplashScreen.__name})
|
||||||
end
|
end
|
||||||
|
|
||||||
return BootScreen
|
return BootScreen
|
|
@ -6,27 +6,28 @@ local ServiceField = require("titlescreen.components.servicefield")
|
||||||
---@field onUpdateAvailable nil|fun(url: string, version: string)
|
---@field onUpdateAvailable nil|fun(url: string, version: string)
|
||||||
---@field _timer number
|
---@field _timer number
|
||||||
local CheckUpdateField = {
|
local CheckUpdateField = {
|
||||||
__tostring = function() return "CheckUpdateField" end,
|
__name = "CheckUpdateField",
|
||||||
PROGRESS_FREQ = 3, -- seconds
|
PROGRESS_FREQ = 3, -- seconds
|
||||||
CHECK_UPDATE_TIMEOUT = 5, -- seconds
|
CHECK_UPDATE_TIMEOUT = 5, -- seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new CheckUpdateField instance
|
---Create a new CheckUpdateField instance
|
||||||
---@param o? table # initial parameters
|
---@param params? CheckUpdateField # initial parameters
|
||||||
---@return CheckUpdateField
|
---@return CheckUpdateField
|
||||||
function CheckUpdateField.new(o)
|
function CheckUpdateField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o._timer = o._timer or 0
|
params.onUpdateAvailable = params.onUpdateAvailable or nil
|
||||||
o.onUpdateAvailable = o.onUpdateAvailable or nil
|
|
||||||
|
|
||||||
local this = CreateInstance(CheckUpdateField, o, ServiceField)
|
local self = CreateInstance(CheckUpdateField, params, ServiceField)
|
||||||
|
|
||||||
this._url = nil
|
self._timer = 0
|
||||||
this._version = nil
|
|
||||||
this._onUpdateAvailableFired = false
|
|
||||||
|
|
||||||
return this
|
self._url = nil
|
||||||
|
self._version = nil
|
||||||
|
self._onUpdateAvailableFired = false
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function CheckUpdateField:drawLabel(deltaTime)
|
function CheckUpdateField:drawLabel(deltaTime)
|
||||||
|
|
|
@ -4,21 +4,21 @@ local ServiceField = require("titlescreen.components.servicefield")
|
||||||
|
|
||||||
---@class ColorGradientField: ServiceField
|
---@class ColorGradientField: ServiceField
|
||||||
local ColorGradientField = {
|
local ColorGradientField = {
|
||||||
__tostring = function() return "ColorGradientField" end,
|
__name = "ColorGradientField",
|
||||||
GRADIENT_X_OFFSET = 128,
|
GRADIENT_X_OFFSET = 128,
|
||||||
GRADIENT_WIDTH = 576,
|
GRADIENT_WIDTH = 576,
|
||||||
GRADIENT_STEPS = 32
|
GRADIENT_STEPS = 32
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new ColorGradientField instance
|
---Create a new ColorGradientField instance
|
||||||
---@param o? table # initial parameters
|
---@param params? ColorGradientField # initial parameters
|
||||||
---@return ColorGradientField
|
---@return ColorGradientField
|
||||||
function ColorGradientField.new(o)
|
function ColorGradientField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.value = o.value or {0, 0, 0, 255}
|
params.value = params.value or {0, 0, 0, 255}
|
||||||
|
|
||||||
return CreateInstance(ColorGradientField, o, ServiceField)
|
return CreateInstance(ColorGradientField, params, ServiceField)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param obj? any # message object for the field
|
---@param obj? any # message object for the field
|
||||||
|
|
|
@ -5,7 +5,7 @@ local ContainerField = require("api.page.containerfield")
|
||||||
---@field _symbolMargin number
|
---@field _symbolMargin number
|
||||||
---@field _symbolSize number
|
---@field _symbolSize number
|
||||||
local DialogField = {
|
local DialogField = {
|
||||||
__tostring = function() return "ContainerField" end,
|
__name = "ContainerField",
|
||||||
BGCOLOR = {0, 0, 0, 255}, --{r, g, b, a}
|
BGCOLOR = {0, 0, 0, 255}, --{r, g, b, a}
|
||||||
DEFAULT_WIDTH = 400,
|
DEFAULT_WIDTH = 400,
|
||||||
DEFAULT_HEIGHT = 200,
|
DEFAULT_HEIGHT = 200,
|
||||||
|
@ -35,20 +35,20 @@ local DialogField = {
|
||||||
---Create a new DialogField instance
|
---Create a new DialogField instance
|
||||||
---
|
---
|
||||||
---Inherits from ContainerField
|
---Inherits from ContainerField
|
||||||
---@param o ContainerField
|
---@param params? DialogField # initial parameters
|
||||||
---@return DialogField
|
---@return DialogField
|
||||||
function DialogField.new(o)
|
function DialogField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.aabbW = o.aabbW or DialogField.DEFAULT_WIDTH
|
params.aabbW = params.aabbW or DialogField.DEFAULT_WIDTH
|
||||||
o.aabbH = o.aabbH or DialogField.DEFAULT_HEIGHT
|
params.aabbH = params.aabbH or DialogField.DEFAULT_HEIGHT
|
||||||
|
|
||||||
local this = CreateInstance(DialogField, o, ContainerField)
|
local self = CreateInstance(DialogField, params, ContainerField)
|
||||||
|
|
||||||
this._symbolMargin = 8
|
self._symbolMargin = 8
|
||||||
this._symbolSize = 48
|
self._symbolSize = 48
|
||||||
|
|
||||||
return this
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Draw the dialog symbol
|
---Draw the dialog symbol
|
||||||
|
|
|
@ -4,18 +4,18 @@ local ServiceField = require("titlescreen.components.servicefield")
|
||||||
---@class InputButtonField: ServiceField
|
---@class InputButtonField: ServiceField
|
||||||
---@field button integer
|
---@field button integer
|
||||||
local InputButtonField = {
|
local InputButtonField = {
|
||||||
__tostring = function() return "InputButtonField" end,
|
__name = "InputButtonField"
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new InputButtonField instance
|
---Create a new InputButtonField instance
|
||||||
---@param o? table # initial parameters
|
---@param params? InputButtonField # initial parameters
|
||||||
---@return InputButtonField
|
---@return InputButtonField
|
||||||
function InputButtonField.new(o)
|
function InputButtonField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.button = o.button or nil
|
params.button = params.button or nil
|
||||||
|
|
||||||
return CreateInstance(InputButtonField, o, ServiceField)
|
return CreateInstance(InputButtonField, params, ServiceField)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param obj? any # message object for the field
|
---@param obj? any # message object for the field
|
||||||
|
|
|
@ -5,7 +5,7 @@ local ServiceField = require("titlescreen.components.servicefield")
|
||||||
---@class InputKnobField: ServiceField
|
---@class InputKnobField: ServiceField
|
||||||
---@field knob integer
|
---@field knob integer
|
||||||
local InputKnobField = {
|
local InputKnobField = {
|
||||||
__tostring = function() return "InputKnobField" end,
|
__name = "InputKnobField",
|
||||||
SLIDER_SIZE = {200, 16}, --{w, h}
|
SLIDER_SIZE = {200, 16}, --{w, h}
|
||||||
SLIDER_BGCOLOR = {255, 0, 0, 255},
|
SLIDER_BGCOLOR = {255, 0, 0, 255},
|
||||||
SLIDER_FRAME_COLOR = ServiceField.FONT_COLOR,
|
SLIDER_FRAME_COLOR = ServiceField.FONT_COLOR,
|
||||||
|
@ -16,14 +16,14 @@ local InputKnobField = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new InputKnobField instance
|
---Create a new InputKnobField instance
|
||||||
---@param o? table # initial parameters
|
---@param params? InputKnobField # initial parameters
|
||||||
---@return InputKnobField
|
---@return InputKnobField
|
||||||
function InputKnobField.new(o)
|
function InputKnobField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.knob = o.knob or nil
|
params.knob = params.knob or nil
|
||||||
|
|
||||||
return CreateInstance(InputKnobField, o, ServiceField)
|
return CreateInstance(InputKnobField, params, ServiceField)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param obj? any # message object for the field
|
---@param obj? any # message object for the field
|
||||||
|
|
|
@ -7,29 +7,29 @@ local ServiceField = require("titlescreen.components.servicefield")
|
||||||
---@field locked boolean
|
---@field locked boolean
|
||||||
---@field PADDING number[]
|
---@field PADDING number[]
|
||||||
local ListField = {
|
local ListField = {
|
||||||
__tostring = function() return "ListField" end,
|
__name = "ListField",
|
||||||
MARGIN = {0, 0, 0, 0}, --{left, top, right, bottom}
|
MARGIN = {0, 0, 0, 0}, --{left, top, right, bottom}
|
||||||
PADDING = {0, 0, 0, 0}, --{left, top, right, bottom}
|
PADDING = {0, 0, 0, 0}, --{left, top, right, bottom}
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new ListField instance
|
---Create a new ListField instance
|
||||||
---@param o? table # initial parameters
|
---@param params? ListField # initial parameters
|
||||||
---@return ListField
|
---@return ListField
|
||||||
function ListField.new(o)
|
function ListField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
--set instance members
|
--set instance members
|
||||||
o.selectedIndex = o.selectedIndex or 1
|
params.selectedIndex = params.selectedIndex or 1
|
||||||
o.locked = o.locked or false
|
params.locked = params.locked or false
|
||||||
|
|
||||||
local this = CreateInstance(ListField, o, ContainerField, ServiceField)
|
local self = CreateInstance(ListField, params, ContainerField, ServiceField)
|
||||||
|
|
||||||
local minW = this.MARGIN[1] + this.PADDING[1] + this.PADDING[3] + this.MARGIN[3]
|
local minW = self.MARGIN[1] + self.PADDING[1] + self.PADDING[3] + self.MARGIN[3]
|
||||||
local minH = this.MARGIN[2] + this.PADDING[2] + this.PADDING[4] + this.MARGIN[4]
|
local minH = self.MARGIN[2] + self.PADDING[2] + self.PADDING[4] + self.MARGIN[4]
|
||||||
this.aabbW = math.max(this.aabbW, minW)
|
self.aabbW = math.max(self.aabbW, minW)
|
||||||
this.aabbH = math.max(this.aabbH, minH)
|
self.aabbH = math.max(self.aabbH, minH)
|
||||||
|
|
||||||
return this
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param obj? any # message object for the field
|
---@param obj? any # message object for the field
|
||||||
|
|
|
@ -23,7 +23,7 @@ end
|
||||||
---@field _thread thread
|
---@field _thread thread
|
||||||
---@field _timer number
|
---@field _timer number
|
||||||
local SelfTestField = {
|
local SelfTestField = {
|
||||||
__tostring = function () return "SelfTestField" end,
|
__name = "SelfTestField",
|
||||||
COLOR_INPROGRESS = {255, 255, 255, 255},
|
COLOR_INPROGRESS = {255, 255, 255, 255},
|
||||||
COLOR_OK = {0, 255, 0, 255},
|
COLOR_OK = {0, 255, 0, 255},
|
||||||
COLOR_PASS = {255, 255, 0, 255},
|
COLOR_PASS = {255, 255, 0, 255},
|
||||||
|
@ -32,20 +32,23 @@ local SelfTestField = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new SelfTestField instance
|
---Create a new SelfTestField instance
|
||||||
---@param o? table
|
---@param params? SelfTestField
|
||||||
---@return SelfTestField
|
---@return SelfTestField
|
||||||
function SelfTestField.new(o)
|
function SelfTestField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.status = o.status or SelfTestStatusEnum.IDLE
|
params.status = params.status or SelfTestStatusEnum.IDLE
|
||||||
o._timer = 0
|
|
||||||
o._thread = nil
|
|
||||||
|
|
||||||
assert((not o.onStatusChange) or (o.checkTask and o.onStatusChange),
|
assert((not params.onStatusChange) or (params.checkTask and params.onStatusChange),
|
||||||
"Failed to construct SelfTestField, checkTask is mandatory when onStatusChange is defined!\n" .. debug.traceback()
|
"Failed to construct SelfTestField, checkTask is mandatory when onStatusChange is defined!\n" .. debug.traceback()
|
||||||
)
|
)
|
||||||
|
|
||||||
return CreateInstance(SelfTestField, o, ServiceField)
|
local self = CreateInstance(SelfTestField, params, ServiceField)
|
||||||
|
|
||||||
|
self._timer = 0
|
||||||
|
self._thread = nil
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function SelfTestField:_closeThread()
|
function SelfTestField:_closeThread()
|
||||||
|
|
|
@ -22,7 +22,7 @@ ServiceFieldState = {
|
||||||
---@field MARGIN number[] # {left, top, right, bottom}
|
---@field MARGIN number[] # {left, top, right, bottom}
|
||||||
---@field VALUE_OFFSETX number
|
---@field VALUE_OFFSETX number
|
||||||
local ServiceField = {
|
local ServiceField = {
|
||||||
__tostring = function() return "ServiceField" end,
|
__name = "ServiceField",
|
||||||
FONT_SIZE = 24,
|
FONT_SIZE = 24,
|
||||||
FONT_FACE = "dfmarugoth.ttf",
|
FONT_FACE = "dfmarugoth.ttf",
|
||||||
FONT_COLOR = {255, 255, 255, 255},
|
FONT_COLOR = {255, 255, 255, 255},
|
||||||
|
@ -33,29 +33,29 @@ local ServiceField = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new ServiceField instance
|
---Create a new ServiceField instance
|
||||||
---@param o? table # initial parameters
|
---@param params? ServiceField # initial parameters
|
||||||
---@return ServiceField
|
---@return ServiceField
|
||||||
function ServiceField.new(o)
|
function ServiceField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
local h = ServiceField.FONT_SIZE + ServiceField.MARGIN[2] + ServiceField.MARGIN[4]
|
local h = ServiceField.FONT_SIZE + ServiceField.MARGIN[2] + ServiceField.MARGIN[4]
|
||||||
|
|
||||||
o.aabbH = o.aabbH or h
|
params.aabbH = params.aabbH or h
|
||||||
o.aabbW = o.aabbW or Dim.design.width --:shrug:
|
params.aabbW = params.aabbW or Dim.design.width --:shrug:
|
||||||
|
|
||||||
o.label = o.label or "<UNDEFINED>"
|
params.label = params.label or "<UNDEFINED>"
|
||||||
o.value = o.value or nil
|
params.value = params.value or nil
|
||||||
o.footer = o.footer or nil
|
params.footer = params.footer or nil
|
||||||
|
|
||||||
o._state = ServiceFieldState.INACTIVE
|
local self = CreateInstance(ServiceField, params, Field)
|
||||||
|
|
||||||
local this = CreateInstance(ServiceField, o, Field)
|
self._state = ServiceFieldState.INACTIVE
|
||||||
|
|
||||||
if this.aabbH < h then
|
if self.aabbH < h then
|
||||||
this.aabbH = h
|
self.aabbH = h
|
||||||
end
|
end
|
||||||
|
|
||||||
return this
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param obj? any # message object for the field
|
---@param obj? any # message object for the field
|
||||||
|
|
|
@ -4,16 +4,16 @@ local ServiceField = require("titlescreen.components.servicefield")
|
||||||
|
|
||||||
---@class ServiceLinkField: LinkField, ServiceField
|
---@class ServiceLinkField: LinkField, ServiceField
|
||||||
local ServiceLinkField = {
|
local ServiceLinkField = {
|
||||||
__tostring = function() return "ServiceLinkField" end,
|
__name = "ServiceLinkField",
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new ServiceLinkField instance
|
---Create a new ServiceLinkField instance
|
||||||
---@param o? table # initial parameters
|
---@param params? ServiceLinkField # initial parameters
|
||||||
---@return ServiceLinkField
|
---@return ServiceLinkField
|
||||||
function ServiceLinkField.new(o)
|
function ServiceLinkField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
return CreateInstance(ServiceLinkField, o, ServiceField, LinkField)
|
return CreateInstance(ServiceLinkField, params, ServiceField, LinkField)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param deltaTime number # frametime in seconds
|
---@param deltaTime number # frametime in seconds
|
||||||
|
|
|
@ -4,7 +4,7 @@ local ServiceField = require("titlescreen.components.servicefield")
|
||||||
---@class UpdateField: ServiceField
|
---@class UpdateField: ServiceField
|
||||||
---@field _timer number
|
---@field _timer number
|
||||||
local UpdateField = {
|
local UpdateField = {
|
||||||
__tostring = function() return "UpdateField" end,
|
__name = "UpdateField",
|
||||||
UPDATE_FLICKER_TIME = 0.5,
|
UPDATE_FLICKER_TIME = 0.5,
|
||||||
UPDATE_FLICKER_COLORS = {
|
UPDATE_FLICKER_COLORS = {
|
||||||
{255, 0, 0, 255},
|
{255, 0, 0, 255},
|
||||||
|
@ -13,14 +13,16 @@ local UpdateField = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new UpdateField instance
|
---Create a new UpdateField instance
|
||||||
---@param o? table # initial parameters
|
---@param params? UpdateField # initial parameters
|
||||||
---@return UpdateField
|
---@return UpdateField
|
||||||
function UpdateField.new(o)
|
function UpdateField.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o._timer = 0
|
local self = CreateInstance(UpdateField, params, ServiceField)
|
||||||
|
|
||||||
return CreateInstance(UpdateField, o, ServiceField)
|
self._timer = 0
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param obj? any # message object for the field
|
---@param obj? any # message object for the field
|
||||||
|
|
|
@ -10,50 +10,50 @@ local SelfTestField = require("titlescreen.components.selftestfield")
|
||||||
|
|
||||||
---@class BootPage: Page
|
---@class BootPage: Page
|
||||||
local BootPage = {
|
local BootPage = {
|
||||||
__tostring = function() return "BootPage" end,
|
__name = "BootPage",
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new BootPage instance
|
---Create a new BootPage instance
|
||||||
---@param o? table # initial parameters
|
---@param params? BootPage # initial parameters
|
||||||
---@return BootPage
|
---@return BootPage
|
||||||
function BootPage.new(o)
|
function BootPage.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
local this = CreateInstance(BootPage, o, Page)
|
local self = CreateInstance(BootPage, params, Page)
|
||||||
|
|
||||||
this._networkResult = {}
|
self._networkResult = {}
|
||||||
|
|
||||||
this:addField(ServiceField.new{posX = 32, posY = 32, label = Version.getLongVersion(), value = ""})
|
self: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 = ""})
|
self:addField(ServiceField.new{posX = 64, posY = 64, label = "UNNAMED SDVX CLONE STARTUP...", value = ""})
|
||||||
|
|
||||||
local valueOffX = 220
|
local valueOffX = 220
|
||||||
this._mainIoTestField = SelfTestField.new{label = "MAIN I/O", VALUE_OFFSETX = valueOffX}
|
self._mainIoTestField = SelfTestField.new{label = "MAIN I/O", VALUE_OFFSETX = valueOffX}
|
||||||
this._mainIoTestField.checkTask = function(obj)
|
self._mainIoTestField.checkTask = function(obj)
|
||||||
return SelfTestStatusEnum.OK
|
return SelfTestStatusEnum.OK
|
||||||
end
|
end
|
||||||
this._mainIoTestField.onStatusChange = function(status)
|
self._mainIoTestField.onStatusChange = function(status)
|
||||||
if status == SelfTestStatusEnum.OK then
|
if status == SelfTestStatusEnum.OK then
|
||||||
this._skinConfigTestField:activate()
|
self._skinConfigTestField:activate()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
this._skinConfigTestField = SelfTestField.new{label = "SKIN CONFIG", VALUE_OFFSETX = valueOffX}
|
self._skinConfigTestField = SelfTestField.new{label = "SKIN CONFIG", VALUE_OFFSETX = valueOffX}
|
||||||
this._skinConfigTestField.checkTask = function(obj)
|
self._skinConfigTestField.checkTask = function(obj)
|
||||||
local crewpath = "skins/" .. game.GetSkin() .. "/textures/crew/anim/" .. game.GetSkinSetting("single_idol")
|
local crewpath = "skins/" .. game.GetSkin() .. "/textures/crew/anim/" .. game.GetSkinSetting("single_idol")
|
||||||
if not IsDir(crewpath) then
|
if not IsDir(crewpath) then
|
||||||
return SelfTestStatusEnum.ERROR
|
return SelfTestStatusEnum.ERROR
|
||||||
end
|
end
|
||||||
return SelfTestStatusEnum.OK
|
return SelfTestStatusEnum.OK
|
||||||
end
|
end
|
||||||
this._skinConfigTestField.onStatusChange = function(status)
|
self._skinConfigTestField.onStatusChange = function(status)
|
||||||
if status == SelfTestStatusEnum.OK then
|
if status == SelfTestStatusEnum.OK then
|
||||||
this._networkTestField:activate()
|
self._networkTestField:activate()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
this._networkTestField = SelfTestField.new{label = "NETWORK", VALUE_OFFSETX = valueOffX}
|
self._networkTestField = SelfTestField.new{label = "NETWORK", VALUE_OFFSETX = valueOffX}
|
||||||
-- set up async network check
|
-- set up async network check
|
||||||
this._networkTestField.checkTask = function(obj)
|
self._networkTestField.checkTask = function(obj)
|
||||||
local status = SelfTestStatusEnum.INPROGRESS
|
local status = SelfTestStatusEnum.INPROGRESS
|
||||||
|
|
||||||
if not IRData.Active then
|
if not IRData.Active then
|
||||||
|
@ -61,9 +61,9 @@ function BootPage.new(o)
|
||||||
end
|
end
|
||||||
|
|
||||||
while status == SelfTestStatusEnum.INPROGRESS do
|
while status == SelfTestStatusEnum.INPROGRESS do
|
||||||
if this._networkResult.statusCode == IRData.States.Success then
|
if self._networkResult.statusCode == IRData.States.Success then
|
||||||
status = SelfTestStatusEnum.OK
|
status = SelfTestStatusEnum.OK
|
||||||
elseif this._networkResult.statusCode then
|
elseif self._networkResult.statusCode then
|
||||||
status = SelfTestStatusEnum.ERROR -- there's a response, but it's not success
|
status = SelfTestStatusEnum.ERROR -- there's a response, but it's not success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,23 +72,23 @@ function BootPage.new(o)
|
||||||
|
|
||||||
return status
|
return status
|
||||||
end
|
end
|
||||||
this._networkTestField.onStatusChange = function(status)
|
self._networkTestField.onStatusChange = function(status)
|
||||||
if status == SelfTestStatusEnum.INPROGRESS then
|
if status == SelfTestStatusEnum.INPROGRESS then
|
||||||
IR.Heartbeat(function(res) this._networkResult = res end) -- IR doesn't like being called in a coroutine
|
IR.Heartbeat(function(res) self._networkResult = res end) -- IR doesn't like being called in a coroutine
|
||||||
elseif status == SelfTestStatusEnum.PASS or status == SelfTestStatusEnum.OK then
|
elseif status == SelfTestStatusEnum.PASS or status == SelfTestStatusEnum.OK then
|
||||||
if this.viewHandler then
|
if self.viewHandler then
|
||||||
this.viewHandler:navigate(CheckUpdatePage.new())
|
self.viewHandler:navigate(CheckUpdatePage.new())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local list = ListField.new{posX = 64, posY = 96}
|
local list = ListField.new{posX = 64, posY = 96}
|
||||||
list:addField(this._mainIoTestField)
|
list:addField(self._mainIoTestField)
|
||||||
list:addField(this._skinConfigTestField)
|
list:addField(self._skinConfigTestField)
|
||||||
list:addField(this._networkTestField)
|
list:addField(self._networkTestField)
|
||||||
this:addField(list)
|
self:addField(list)
|
||||||
|
|
||||||
return this
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param deltaTime number # frametime in seconds
|
---@param deltaTime number # frametime in seconds
|
||||||
|
|
|
@ -7,20 +7,20 @@ local DialogField = require("titlescreen.components.dialogfield")
|
||||||
---@class CheckUpdatePage: Page
|
---@class CheckUpdatePage: Page
|
||||||
---@field _focusedField CheckUpdateField
|
---@field _focusedField CheckUpdateField
|
||||||
local CheckUpdatePage = {
|
local CheckUpdatePage = {
|
||||||
__tostring = function() return "CheckUpdatePage" end,
|
__name = "CheckUpdatePage",
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new CheckUpdatePage instance
|
---Create a new CheckUpdatePage instance
|
||||||
---@param o? table # initial parameters
|
---@param params? CheckUpdatePage # initial parameters
|
||||||
---@return CheckUpdatePage
|
---@return CheckUpdatePage
|
||||||
function CheckUpdatePage.new(o)
|
function CheckUpdatePage.new(params)
|
||||||
local this = CreateInstance(CheckUpdatePage, o, Page)
|
local self = CreateInstance(CheckUpdatePage, params, Page)
|
||||||
|
|
||||||
local width = DialogField.DEFAULT_WIDTH
|
local width = DialogField.DEFAULT_WIDTH
|
||||||
local height = DialogField.DEFAULT_HEIGHT
|
local height = DialogField.DEFAULT_HEIGHT
|
||||||
local posX = (Dim.design.width - width) / 2
|
local posX = (Dim.design.width - width) / 2
|
||||||
local posY = (Dim.design.height - height) / 2
|
local posY = (Dim.design.height - height) / 2
|
||||||
this._updateDialogField = DialogField.new{
|
self._updateDialogField = DialogField.new{
|
||||||
posX = posX,
|
posX = posX,
|
||||||
posY = posY,
|
posY = posY,
|
||||||
aabbW = width,
|
aabbW = width,
|
||||||
|
@ -44,37 +44,37 @@ function CheckUpdatePage.new(o)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._updateDialogField.handleButtonInput = function (self, button)
|
self._updateDialogField.handleButtonInput = function (_, button)
|
||||||
if not this.viewHandler then
|
if not self.viewHandler then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if button == game.BUTTON_BCK then
|
if button == game.BUTTON_BCK then
|
||||||
this.viewHandler:clear() -- Cancel update, close screen
|
self.viewHandler:clear() -- Cancel update, close screen
|
||||||
return true
|
return true
|
||||||
elseif button == game.BUTTON_STA then
|
elseif button == game.BUTTON_STA then
|
||||||
-- NOTE: this is a huge ass hack, please rethink
|
-- NOTE: this is a huge ass hack, please rethink
|
||||||
local MainMenuPage = require("titlescreen.pages.service.mainmenupage")
|
local MainMenuPage = require("titlescreen.pages.service.mainmenupage")
|
||||||
local VersionInfoPage = require("titlescreen.pages.service.versioninfopage")
|
local VersionInfoPage = require("titlescreen.pages.service.versioninfopage")
|
||||||
this.viewHandler:replace(MainMenuPage.new())
|
self.viewHandler:replace(MainMenuPage.new())
|
||||||
this.viewHandler:navigate(VersionInfoPage.new())
|
self.viewHandler:navigate(VersionInfoPage.new())
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
this._checkUpdateField = CheckUpdateField.new{posX = 32, posY = 64, label = "update check"}
|
self._checkUpdateField = CheckUpdateField.new{posX = 32, posY = 64, label = "update check"}
|
||||||
this._checkUpdateField.onUpdateAvailable = function(url, version)
|
self._checkUpdateField.onUpdateAvailable = function(url, version)
|
||||||
this:addField(this._updateDialogField)
|
self:addField(self._updateDialogField)
|
||||||
this._focusedField = this._updateDialogField
|
self._focusedField = self._updateDialogField
|
||||||
end
|
end
|
||||||
|
|
||||||
this:addField(this._checkUpdateField)
|
self:addField(self._checkUpdateField)
|
||||||
|
|
||||||
this._focusedField = this._checkUpdateField
|
self._focusedField = self._checkUpdateField
|
||||||
|
|
||||||
return this
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function CheckUpdatePage:handleButtonInput(button)
|
function CheckUpdatePage:handleButtonInput(button)
|
||||||
|
|
|
@ -14,7 +14,7 @@ local crew = game.GetSkinSetting("single_idol")
|
||||||
---@class ModeSelectPage: Page
|
---@class ModeSelectPage: Page
|
||||||
---@field _idolAnimationState AnimationState
|
---@field _idolAnimationState AnimationState
|
||||||
local ModeSelectPage = {
|
local ModeSelectPage = {
|
||||||
__tostring = function () return "ModeSelectPage" end,
|
__name = "ModeSelectPage",
|
||||||
images = {
|
images = {
|
||||||
selectorBgImage = gfx.CreateSkinImage("titlescreen/selector_bg.png", 0),
|
selectorBgImage = gfx.CreateSkinImage("titlescreen/selector_bg.png", 0),
|
||||||
selectorArrowsImage = gfx.CreateSkinImage("titlescreen/selector_arrows.png", 0),
|
selectorArrowsImage = gfx.CreateSkinImage("titlescreen/selector_arrows.png", 0),
|
||||||
|
@ -41,8 +41,8 @@ local ModeSelectPage = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ModeSelectPage.new(o)
|
function ModeSelectPage.new(params)
|
||||||
local self = CreateInstance(ModeSelectPage, o, Page)
|
local self = CreateInstance(ModeSelectPage, params, Page)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ local ColorGradientField = require("titlescreen.components.colorgradientfield")
|
||||||
|
|
||||||
---@class ColorCheckPage: ServicePage
|
---@class ColorCheckPage: ServicePage
|
||||||
local ColorCheckPage = {
|
local ColorCheckPage = {
|
||||||
__tostring = function() return "ColorCheckPage" end,
|
__name = "ColorCheckPage",
|
||||||
|
|
||||||
PADDING = {56, 120, 0, 56}, --{left, top, right, bottom}
|
PADDING = {56, 120, 0, 56}, --{left, top, right, bottom}
|
||||||
|
|
||||||
|
@ -19,18 +19,18 @@ local ColorCheckPage = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new ColorCheckPage instance
|
---Create a new ColorCheckPage instance
|
||||||
---@param o? table # initial parameters
|
---@param params? ColorCheckPage # initial parameters
|
||||||
---@return ColorCheckPage
|
---@return ColorCheckPage
|
||||||
function ColorCheckPage.new(o)
|
function ColorCheckPage.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.title = o.title or "COLOR CHECK"
|
params.title = params.title or "COLOR CHECK"
|
||||||
o.footer = o.footer or {
|
params.footer = params.footer or {
|
||||||
"START BUTTON = EXIT",
|
"START BUTTON = EXIT",
|
||||||
"BACK BUTTON = EXIT"
|
"BACK BUTTON = EXIT"
|
||||||
}
|
}
|
||||||
|
|
||||||
local this = CreateInstance(ColorCheckPage, o, ServicePage)
|
local self = CreateInstance(ColorCheckPage, params, ServicePage)
|
||||||
|
|
||||||
local height = ColorCheckPage.GRADIENT_SPACING
|
local height = ColorCheckPage.GRADIENT_SPACING
|
||||||
local list = ListField.new()
|
local list = ListField.new()
|
||||||
|
@ -43,10 +43,10 @@ function ColorCheckPage.new(o)
|
||||||
list:addField(ColorGradientField.new{label = "WHITE", value = {255, 255, 255, 255}, aabbH = height})
|
list:addField(ColorGradientField.new{label = "WHITE", value = {255, 255, 255, 255}, aabbH = height})
|
||||||
list:refreshFields()
|
list:refreshFields()
|
||||||
|
|
||||||
this:addField(list)
|
self:addField(list)
|
||||||
this:refreshFields()
|
self:refreshFields()
|
||||||
|
|
||||||
return this
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
||||||
|
|
|
@ -6,19 +6,19 @@ local ListField = require("titlescreen.components.listfield")
|
||||||
|
|
||||||
---@class InputCheckPage: ServicePage
|
---@class InputCheckPage: ServicePage
|
||||||
local InputCheckPage = {
|
local InputCheckPage = {
|
||||||
__tostring = function() return "InputCheckPage" end,
|
__name = "InputCheckPage",
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new InputCheckPage instance
|
---Create a new InputCheckPage instance
|
||||||
---@param o? table # initial parameters
|
---@param params? InputCheckPage # initial parameters
|
||||||
---@return InputCheckPage
|
---@return InputCheckPage
|
||||||
function InputCheckPage.new(o)
|
function InputCheckPage.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.title = o.title or "INPUT CHECK"
|
params.title = params.title or "INPUT CHECK"
|
||||||
o.footer = o.footer or "BACK BUTTON = EXIT"
|
params.footer = params.footer or "BACK BUTTON = EXIT"
|
||||||
|
|
||||||
local this = CreateInstance(InputCheckPage, o, ServicePage)
|
local self = CreateInstance(InputCheckPage, params, ServicePage)
|
||||||
|
|
||||||
local list = ListField.new()
|
local list = ListField.new()
|
||||||
list:addField(InputButtonField.new{label="START BUTTON", button=game.BUTTON_STA})
|
list:addField(InputButtonField.new{label="START BUTTON", button=game.BUTTON_STA})
|
||||||
|
@ -32,10 +32,10 @@ function InputCheckPage.new(o)
|
||||||
list:addField(InputKnobField.new{label="ANALOG VOLUME R", knob=1})
|
list:addField(InputKnobField.new{label="ANALOG VOLUME R", knob=1})
|
||||||
list:refreshFields()
|
list:refreshFields()
|
||||||
|
|
||||||
this:addField(list)
|
self:addField(list)
|
||||||
this:refreshFields()
|
self:refreshFields()
|
||||||
|
|
||||||
return this
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
||||||
|
|
|
@ -9,18 +9,18 @@ local ListField = require("titlescreen.components.listfield")
|
||||||
|
|
||||||
---@class MainMenuPage: ServicePage
|
---@class MainMenuPage: ServicePage
|
||||||
local MainMenuPage = {
|
local MainMenuPage = {
|
||||||
__tostring = function() return "MainMenuPage" end,
|
__name = "MainMenuPage",
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new MainMenuPage instance
|
---Create a new MainMenuPage instance
|
||||||
---@param o? table # initial parameters
|
---@param params? MainMenuPage # initial parameters
|
||||||
---@return MainMenuPage
|
---@return MainMenuPage
|
||||||
function MainMenuPage.new(o)
|
function MainMenuPage.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.title = o.title or "MAIN MENU"
|
params.title = params.title or "MAIN MENU"
|
||||||
|
|
||||||
local this = CreateInstance(MainMenuPage, o, ServicePage)
|
local self = CreateInstance(MainMenuPage, params, ServicePage)
|
||||||
|
|
||||||
local list = ListField.new()
|
local list = ListField.new()
|
||||||
list:addField(ServiceLinkField.new{label = "INPUT CHECK", link = InputCheckPage.new()})
|
list:addField(ServiceLinkField.new{label = "INPUT CHECK", link = InputCheckPage.new()})
|
||||||
|
@ -29,10 +29,10 @@ function MainMenuPage.new(o)
|
||||||
list:addField(ServiceLinkField.new{label = "VERSION INFORMATION", link = VersionInfoPage.new()})
|
list:addField(ServiceLinkField.new{label = "VERSION INFORMATION", link = VersionInfoPage.new()})
|
||||||
list:refreshFields()
|
list:refreshFields()
|
||||||
|
|
||||||
this:addField(list)
|
self:addField(list)
|
||||||
this:refreshFields()
|
self:refreshFields()
|
||||||
|
|
||||||
return this
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
return MainMenuPage
|
return MainMenuPage
|
||||||
|
|
|
@ -4,7 +4,7 @@ local ServicePage = require("titlescreen.pages.service.servicepage")
|
||||||
|
|
||||||
---@class ScreenCheckPage: ServicePage
|
---@class ScreenCheckPage: ServicePage
|
||||||
local ScreenCheckPage = {
|
local ScreenCheckPage = {
|
||||||
__tostring = function() return "ScreenCheckPage" end,
|
__name = "ScreenCheckPage",
|
||||||
|
|
||||||
BG_COLOR = {255, 255, 255, 255},
|
BG_COLOR = {255, 255, 255, 255},
|
||||||
STROKE_COLOR = {255, 0, 0, 255},
|
STROKE_COLOR = {255, 0, 0, 255},
|
||||||
|
@ -17,18 +17,18 @@ local ScreenCheckPage = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new ScreenCheckPage instance
|
---Create a new ScreenCheckPage instance
|
||||||
---@param o? table # initial parameters
|
---@param params? ScreenCheckPage # initial parameters
|
||||||
---@return ScreenCheckPage
|
---@return ScreenCheckPage
|
||||||
function ScreenCheckPage.new(o)
|
function ScreenCheckPage.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.title = o.title or "SCREEN CHECK"
|
params.title = params.title or "SCREEN CHECK"
|
||||||
o.footer = o.footer or {
|
params.footer = params.footer or {
|
||||||
"START BUTTON = EXIT",
|
"START BUTTON = EXIT",
|
||||||
"BACK BUTTON = EXIT"
|
"BACK BUTTON = EXIT"
|
||||||
}
|
}
|
||||||
|
|
||||||
return CreateInstance(ScreenCheckPage, o, ServicePage)
|
return CreateInstance(ScreenCheckPage, params, ServicePage)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
||||||
|
|
|
@ -17,7 +17,7 @@ local ServiceField = require("titlescreen.components.servicefield")
|
||||||
---@field FOOTER string|string[]
|
---@field FOOTER string|string[]
|
||||||
---@field FOOTER_SPACING number
|
---@field FOOTER_SPACING number
|
||||||
local ServicePage = {
|
local ServicePage = {
|
||||||
__tostring = function() return "ServicePage" end,
|
__name = "ServicePage",
|
||||||
FONT_SIZE = ServiceField.FONT_SIZE,
|
FONT_SIZE = ServiceField.FONT_SIZE,
|
||||||
FONT_FACE = ServiceField.FONT_FACE,
|
FONT_FACE = ServiceField.FONT_FACE,
|
||||||
FONT_COLOR = ServiceField.FONT_COLOR, --{r, g, b, a}
|
FONT_COLOR = ServiceField.FONT_COLOR, --{r, g, b, a}
|
||||||
|
@ -34,16 +34,16 @@ local ServicePage = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new ServicePage instance
|
---Create a new ServicePage instance
|
||||||
---@param o? table # initial parameters
|
---@param params? ServicePage # initial parameters
|
||||||
---@return ServicePage
|
---@return ServicePage
|
||||||
function ServicePage.new(o)
|
function ServicePage.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.title = o.title or ""
|
params.title = params.title or ""
|
||||||
o.selectedIndex = o.selectedIndex or 1
|
params.selectedIndex = params.selectedIndex or 1
|
||||||
o.footer = o.footer or ServicePage.FOOTER
|
params.footer = params.footer or ServicePage.FOOTER
|
||||||
|
|
||||||
return CreateInstance(ServicePage, o, Page)
|
return CreateInstance(ServicePage, params, Page)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Refresh content values
|
---Refresh content values
|
||||||
|
|
|
@ -14,23 +14,23 @@ end
|
||||||
|
|
||||||
---@class VersionInfoPage: ServicePage
|
---@class VersionInfoPage: ServicePage
|
||||||
local VersionInfoPage = {
|
local VersionInfoPage = {
|
||||||
__tostring = function() return "VersionInfoPage" end,
|
__name = "VersionInfoPage",
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new VersionInfoPage instance
|
---Create a new VersionInfoPage instance
|
||||||
---@param o? table # initial parameters
|
---@param params? VersionInfoPage # initial parameters
|
||||||
---@return VersionInfoPage
|
---@return VersionInfoPage
|
||||||
function VersionInfoPage.new(o)
|
function VersionInfoPage.new(params)
|
||||||
o = o or {}
|
params = params or {}
|
||||||
|
|
||||||
o.title = o.title or "SYSTEM INFORMATION"
|
params.title = params.title or "SYSTEM INFORMATION"
|
||||||
o.footer = o.footer or {
|
params.footer = params.footer or {
|
||||||
"START BUTTON = UPDATE",
|
"START BUTTON = UPDATE",
|
||||||
"BACK BUTTON = EXIT"
|
"BACK BUTTON = EXIT"
|
||||||
}
|
}
|
||||||
o.selectedIndex = o.selectedIndex or 1
|
params.selectedIndex = params.selectedIndex or 1
|
||||||
|
|
||||||
local this = CreateInstance(VersionInfoPage, o, ServicePage)
|
local self = CreateInstance(VersionInfoPage, params, ServicePage)
|
||||||
|
|
||||||
local logStr = ReadGameFile("log_usc-game.exe.txt") or ReadGameFile("log_usc-game.txt")
|
local logStr = ReadGameFile("log_usc-game.exe.txt") or ReadGameFile("log_usc-game.txt")
|
||||||
|
|
||||||
|
@ -45,10 +45,10 @@ function VersionInfoPage.new(o)
|
||||||
list:addField(ServiceField.new{label = "GL VENDOR", value = getGameLogValue("OpenGL Vendor", logStr)})
|
list:addField(ServiceField.new{label = "GL VENDOR", value = getGameLogValue("OpenGL Vendor", logStr)})
|
||||||
list:refreshFields()
|
list:refreshFields()
|
||||||
|
|
||||||
this:addField(list)
|
self:addField(list)
|
||||||
this:refreshFields()
|
self:refreshFields()
|
||||||
|
|
||||||
return this
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
---@param button integer # options are under the `game` table prefixed with `BUTTON`
|
||||||
|
|
|
@ -6,19 +6,19 @@ local PageView = require "api.page.pageview"
|
||||||
---@class Screen
|
---@class Screen
|
||||||
---@field pageview PageView
|
---@field pageview PageView
|
||||||
local Screen = {
|
local Screen = {
|
||||||
__tostring = function() return "Screen" end
|
__name = "Screen"
|
||||||
}
|
}
|
||||||
|
|
||||||
---Create a new Screen instance
|
---Create a new Screen instance
|
||||||
---@param o? Screen
|
---@param params? Screen
|
||||||
---@return Screen
|
---@return Screen
|
||||||
function Screen.new(o)
|
function Screen.new(params)
|
||||||
local self = CreateInstance(Screen, o)
|
local self = CreateInstance(Screen, params)
|
||||||
self.pageview = PageView.new()
|
self.pageview = PageView.new()
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
---Initialize screen, override to push new page into pageview
|
---Initialize screen
|
||||||
function Screen:init()
|
function Screen:init()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -63,10 +63,6 @@ end
|
||||||
|
|
||||||
---@param deltaTime number # frametime in seconds
|
---@param deltaTime number # frametime in seconds
|
||||||
function Screen:render(deltaTime)
|
function Screen:render(deltaTime)
|
||||||
if not self.pageview:get() then
|
|
||||||
self:deactivate()
|
|
||||||
end
|
|
||||||
|
|
||||||
self.pageview:render(deltaTime)
|
self.pageview:render(deltaTime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue