ExperimentalGear/scripts/titlescreen/title.lua

54 lines
1.4 KiB
Lua

require "common.globals"
local Version = require "common.version"
local Dim = require "common.dimensions"
local Image = require "api.image"
local Page = require "api.page.page"
local versionString = Version.getLongVersion()
---@class TitlePage : Page
---@field background_img Image
local TitlePage = {
__name = "TitlePage",
BACKGROUND_IMG_PATH = "titlescreen/title/background.png",
}
function TitlePage.new(params)
local self = CreateInstance(TitlePage, params, Page)
self.background_img = Image.new(self.BACKGROUND_IMG_PATH)
self.background_img:setPosition(0, 0)
self.background_img:setSize(Dim.design.width, Dim.design.height)
return self
end
function TitlePage:handleButtonInput(button)
if button == game.BUTTON_FXR and game.GetButton(game.BUTTON_FXL) or
button == game.BUTTON_FXL and game.GetButton(game.BUTTON_FXR) then
self:onInvalidation(true) -- true to switch to service menu
end
if button == game.BUTTON_STA then
self:onInvalidation()
end
end
function TitlePage:drawBackground(deltaTime)
self.background_img:render()
end
function TitlePage:drawForeground(deltaTime)
gfx.LoadSkinFont("segoeui.ttf")
gfx.FillColor(255, 255, 255)
gfx.StrokeColor(0, 0, 0)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
gfx.FontSize(28)
gfx.StrokeWidth(1)
gfx.Text(versionString, 10, 10)
end
return TitlePage