From 6e011b19eb1024ca760a193f200b72cbef06600c Mon Sep 17 00:00:00 2001 From: Hersi Date: Sat, 12 Mar 2022 15:18:24 +0100 Subject: [PATCH] add triggers to titlescreen --- scripts/titlescreen/splash.lua | 39 ++++++++++++++++++++++++++++++++-- scripts/titlescreen/title.lua | 14 ++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/scripts/titlescreen/splash.lua b/scripts/titlescreen/splash.lua index ead8982..e8f4661 100644 --- a/scripts/titlescreen/splash.lua +++ b/scripts/titlescreen/splash.lua @@ -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 } \ No newline at end of file diff --git a/scripts/titlescreen/title.lua b/scripts/titlescreen/title.lua index a3ee2e0..d3af510 100644 --- a/scripts/titlescreen/title.lua +++ b/scripts/titlescreen/title.lua @@ -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