2022-06-22 02:58:47 +02:00
|
|
|
require "common.globals"
|
|
|
|
require "common.class"
|
|
|
|
|
2024-02-02 02:50:48 +01:00
|
|
|
local Display = require "scripts.graphics.display"
|
2022-06-29 00:35:52 +02:00
|
|
|
|
2023-08-19 04:48:46 +02:00
|
|
|
local Image = require "scripts.graphics.image"
|
2022-06-29 00:35:52 +02:00
|
|
|
|
2022-06-22 02:58:47 +02:00
|
|
|
local Page = require "api.page.page"
|
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
---@class USCPage : Page
|
|
|
|
---@field logo_img Image
|
|
|
|
---@field _timer number
|
|
|
|
local USCPage = {
|
|
|
|
__name = "USCPage",
|
|
|
|
BACKGROUND_COLOR = {255, 255, 255},
|
|
|
|
LOGO_PATH = "titlescreen/splash/usc2.png",
|
|
|
|
TIMEOUT = 3.0
|
|
|
|
}
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
---Create a new USCPage instance
|
|
|
|
---@param params? USCPage
|
|
|
|
function USCPage.new(params)
|
|
|
|
local self = CreateInstance(USCPage, params, Page)
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
self.logo_img = Image.new(self.LOGO_PATH)
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
self._timer = 0.0
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
return self
|
|
|
|
end
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
function USCPage:init()
|
|
|
|
self._timer = 0.0
|
|
|
|
Page.init(self)
|
|
|
|
end
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
function USCPage:drawBackground(deltaTime)
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.FillColor(table.unpack(self.BACKGROUND_COLOR))
|
2024-02-02 02:50:48 +01:00
|
|
|
gfx.Rect(0, 0, Display.design.width, Display.design.height)
|
2022-06-29 00:35:52 +02:00
|
|
|
gfx.Fill()
|
|
|
|
end
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
function USCPage:drawContent(deltaTime)
|
2024-02-02 02:50:48 +01:00
|
|
|
local x = (Display.design.width - self.logo_img.width) / 2
|
|
|
|
local y = (Display.design.height - self.logo_img.height) / 2
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
self.logo_img:setPosition(x, y)
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
self.logo_img:render()
|
2022-06-22 02:58:47 +02:00
|
|
|
end
|
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
function USCPage:render(deltaTime)
|
|
|
|
Page.render(self, deltaTime)
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
if self._timer > self.TIMEOUT then
|
|
|
|
self:onInvalidation()
|
|
|
|
end
|
2022-06-22 02:58:47 +02:00
|
|
|
|
2022-06-29 00:35:52 +02:00
|
|
|
self._timer = self._timer + deltaTime
|
2022-06-22 02:58:47 +02:00
|
|
|
end
|
|
|
|
|
2023-08-19 04:48:46 +02:00
|
|
|
return USCPage
|