add triggers to titlescreen

This commit is contained in:
Hersi 2022-03-12 15:18:24 +01:00
parent 9add99e777
commit 6e011b19eb
2 changed files with 51 additions and 2 deletions

View File

@ -22,6 +22,8 @@ local splash2Duration = 4
game.LoadSkinSample("titlescreen/splash/splash1.wav")
local splash1SfxPlayed = false
local triggerSkip = false
local function calcFade(splashDuration)
local t = splashDuration - splashTimer
if t < fadeDuration then
@ -62,6 +64,14 @@ local function splash1(deltaTime)
gfx.BeginPath()
gfx.ImageRect(splash1LogoXOffset, splash1LogoYOffset, splash1LogoWidth, splash1LogoHeight, splash1Logo, fadeAlpha / 255, 0)
gfx.BeginPath()
gfx.LoadSkinFont("segoeui.ttf")
gfx.FillColor(255, 255, 255, fadeAlpha)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
gfx.FontSize(28)
gfx.Text("Press START to skip...", 10, 10)
if (splashTimer < 0) then
splashState = "splash2"
splash1SfxPlayed = false
@ -95,6 +105,14 @@ local function splash2(deltaTime)
gfx.BeginPath()
gfx.ImageRect(splash2LogoXOffset, splash2LogoYOffset, splash2LogoWidth, splash2LogoHeight, splash2Logo, fadeAlpha / 255, 0)
gfx.BeginPath()
gfx.LoadSkinFont("segoeui.ttf")
gfx.FillColor(0, 0, 0, fadeAlpha)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
gfx.FontSize(28)
gfx.Text("Press START to skip...", 10, 10)
if (splashTimer < 0) then
splashState = "done"
splashTimer = 0
@ -109,12 +127,22 @@ local function splash2(deltaTime)
end
function render(deltaTime)
if triggerSkip then
triggerSkip = false
game.StopSample("titlescreen/splash/splash1.wav")
return {
eventType = "switch",
toScreen = "title"
}
end
Dim.updateResolution()
Wallpaper.render()
gfx.BeginPath()
Dim.transformToScreenSpace()
gfx.BeginPath()
gfx.Rect(0, 0, Dim.design.width, Dim.design.height)
gfx.FillColor(0, 0, 0)
gfx.Fill()
@ -136,6 +164,13 @@ function render(deltaTime)
end
end
local function onButtonPressed(button)
if button == game.BUTTON_STA then
triggerSkip = true
end
end
return {
render = render
render = render,
onButtonPressed = onButtonPressed
}

View File

@ -6,6 +6,7 @@ local Wallpaper = require("components.wallpaper")
local splash1Image = gfx.CreateSkinImage('titlescreen/title/background.png', 0)
local triggerModeSelect = false
local triggerServiceMenu = false
local function render(deltaTime)
Dim.updateResolution()
@ -31,9 +32,22 @@ local function render(deltaTime)
toScreen = 'mode_select'
}
end
if (triggerServiceMenu) then
triggerServiceMenu = false
return {
eventType = 'switch',
toScreen = 'service'
}
end
end
local function onButtonPressed(button)
if button == game.BUTTON_FXR and game.GetButton(game.BUTTON_FXL) or
button == game.BUTTON_FXL and game.GetButton(game.BUTTON_FXR) then
triggerServiceMenu = true
end
if button == game.BUTTON_STA then
triggerModeSelect = true
end