ExperimentalGear/scripts/titlescreen/title.lua

55 lines
1.4 KiB
Lua
Raw Normal View History

require "common.globals"
2021-12-21 19:39:34 +01:00
local Version = require "common.version"
2024-02-02 02:50:48 +01:00
local Display = require "scripts.graphics.display"
2021-12-21 19:49:11 +01:00
2023-08-19 04:48:46 +02:00
local Image = require "scripts.graphics.image"
2021-12-21 19:39:34 +01:00
local Page = require "api.page.page"
2021-12-21 19:39:34 +01:00
local versionString = Version.long_version()
---@class TitlePage : Page
---@field background_img Image
local TitlePage = {
__name = "TitlePage",
BACKGROUND_IMG_PATH = "titlescreen/title/background.png",
}
2021-12-21 19:39:34 +01:00
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)
2024-02-02 02:50:48 +01:00
self.background_img:setSize(Display.design.width, Display.design.height)
return self
2021-12-21 19:39:34 +01:00
end
function TitlePage:handleButtonInput(button)
2022-03-12 15:18:24 +01:00
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
2022-03-12 15:18:24 +01:00
end
2021-12-21 19:39:34 +01:00
if button == game.BUTTON_STA then
self:onInvalidation()
2021-12-21 19:39:34 +01:00
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