From 5d3e4457eb9ea7f9537473f1203bdbef6bff82c9 Mon Sep 17 00:00:00 2001 From: Hersi Date: Sat, 26 Mar 2022 02:21:54 +0100 Subject: [PATCH] refactor and format document for mode_select add wallpaper and dim modules to mode_select --- scripts/titlescreen/mode_select.lua | 443 ++++++++++++++-------------- 1 file changed, 223 insertions(+), 220 deletions(-) diff --git a/scripts/titlescreen/mode_select.lua b/scripts/titlescreen/mode_select.lua index 1f5a057..ae665a2 100644 --- a/scripts/titlescreen/mode_select.lua +++ b/scripts/titlescreen/mode_select.lua @@ -1,146 +1,173 @@ require("common") -local Footer = require("components.footer"); -local Background = require("components.background"); - +local Footer = require("components.footer") +local Wallpaper = require("components.wallpaper") +local Background = require("components.background") +local Dim = require("common.dimensions") local lang = require("language.call") -local cursorIndex = 3; -local buttonHeight = 128 + 16; +local cursorIndex = 3 +local buttonHeight = 128 + 16 -local SELECTOR_BAR_OFFSET_FROM_CENTER = 128; +local SELECTOR_BAR_OFFSET_FROM_CENTER = 128 -local BAR_ALPHA = 191; +local BAR_ALPHA = 191 local HEADER_HEIGHT = 100 -local buttons = nil -local resx, resy = game.GetResolution() -local desw = 1080 -local desh = 1920 -local scale; +local crew = game.GetSkinSetting("single_idol") -local backgroundImage = gfx.CreateSkinImage("bg_pattern.png", gfx.IMAGE_REPEATX | gfx.IMAGE_REPEATY) -local headerTitleImage = gfx.CreateSkinImage("titlescreen/title.png", 0); -local selectorBgImage = gfx.CreateSkinImage("titlescreen/selector_bg.png", 0); -local selectorArrowsImage = gfx.CreateSkinImage("titlescreen/selector_arrows.png", 0); +local resources = { + images = { + headerTitleImage = gfx.CreateSkinImage("titlescreen/title.png", 0), + selectorBgImage = gfx.CreateSkinImage("titlescreen/selector_bg.png", 0), + selectorArrowsImage = gfx.CreateSkinImage("titlescreen/selector_arrows.png", 0), + unselectedButtonImage = gfx.CreateSkinImage("titlescreen/unselected_button.png", 0), + selectedButtonBgImage = gfx.CreateSkinImage("titlescreen/selected_button_bg.png", 0), + selectedButtonOverImage = gfx.CreateSkinImage("titlescreen/selected_button_over.png", 0) + }, + anims = { + idolAnimation = gfx.LoadSkinAnimation("crew/anim/" .. crew, 1 / 30, 0, true) + }, + audiosamples = { + bgm = "titlescreen/bgm.wav", + cursorChange = "titlescreen/cursor_change.wav", + cursorSelect = "titlescreen/cursor_select.wav" + }, + labels = { + selectorDescriptionLabel = gfx.CreateLabel(lang.Start.desc, 22, 0), + selectorLegendScrollLabel = gfx.CreateLabel(lang.Start.sc, 20, 0), + selectorLegendSelectLabel = gfx.CreateLabel(lang.Start.st3, 20, 0) + } +} -local unselectedButtonImage = gfx.CreateSkinImage("titlescreen/unselected_button.png", 0); +-- load audio samples +for _, path in pairs(resources.audiosamples) do + game.LoadSkinSample(path) +end -local selectedButtonBgImage = gfx.CreateSkinImage("titlescreen/selected_button_bg.png", 0); -local selectedButtonOverImage = gfx.CreateSkinImage("titlescreen/selected_button_over.png", 0); +local buttons = { + { + labelImage = gfx.CreateSkinImage("titlescreen/labels/skill.png", 0), + labelWidth = 412, + action = nil, -- Menu.Challenges, + description = lang.Challanges.ch, + details = lang.Challanges.ch1, + }, + { + labelImage = gfx.CreateSkinImage("titlescreen/labels/friend.png", 0), + labelWidth = 169, + action = nil, -- Menu.Multiplayer, + description = lang.Multiplayer.mp, + details = lang.Multiplayer.mp2, + }, + { + labelImage = gfx.CreateSkinImage("titlescreen/labels/normal.png", 0), + labelWidth = 210, + action = nil, -- Menu.Start, + description = lang.Start.st, + details = lang.Start.st2, + }, + { + labelImage = gfx.CreateSkinImage("titlescreen/labels/nautica.png", 0), + labelWidth = 230, + action = nil, -- Menu.DLScreen, + description = lang.Nautica.dls, + details = lang.Nautica.dls2, + }, + { + labelImage = gfx.CreateSkinImage("titlescreen/labels/settings.png", 0), + labelWidth = 247, + action = nil, -- Menu.Settings, + description = lang.Settings.se, + details = lang.Settings.se1, + }, + { + labelImage = gfx.CreateSkinImage("titlescreen/labels/exit.png", 0), + labelWidth = 110, + action = nil, -- Menu.Exit, + description = lang.Exit.ex, + details = lang.Exit.ex2, + }, +} -local skillLabelImage = gfx.CreateSkinImage("titlescreen/labels/skill.png", 0); -local friendLabelImage = gfx.CreateSkinImage("titlescreen/labels/friend.png", 0); -local normalLabelImage = gfx.CreateSkinImage("titlescreen/labels/normal.png", 0); -local nauticaLabelImage = gfx.CreateSkinImage("titlescreen/labels/nautica.png", 0); -local settingsLabelImage = gfx.CreateSkinImage("titlescreen/labels/settings.png", 0); -local exitLabelImage = gfx.CreateSkinImage("titlescreen/labels/exit.png", 0); +local scrollTransitionScale = 1 -- Goes from 0 to 1 when transition is happening, sits at 1 when it's not. +local buttonsMovementScale = 0 -- Basically same as `scrollTransitionScale` but with a +/- sign for the scroll direction and goes from 1 to 0 -local creww = game.GetSkinSetting("single_idol") +local idolAnimTransitionScale = 0 --- ANIMS -local idolAnimation = gfx.LoadSkinAnimation("crew/anim/" .. creww, 1 / 30, 0, true); - --- AUDIO -game.LoadSkinSample("titlescreen/bgm.wav"); -game.LoadSkinSample("titlescreen/cursor_change.wav"); -game.LoadSkinSample("titlescreen/cursor_select.wav"); - -local selectorDescriptionLabel = gfx.CreateLabel(lang.Start.desc, 22, 0); - -local selectorLegendScrollLabel = gfx.CreateLabel(lang.Start.sc, 20, 0); -local selectorLegendSelectLabel = gfx.CreateLabel(lang.Start.st3, 20, 0); - -local scrollTransitionScale = 1; -- Goes from 0 to 1 when transition is happening, sits at 1 when it's not. -local buttonsMovementScale = 0; -- Basically same as `scrollTransitionScale` but with a +/- sign for the scroll direction and goes from 1 to 0 - -local idolAnimTransitionScale = 0; - -local oldCursorIndex = 3; -local scrollingUp = false; -local playedBgm = false; +local oldCursorIndex = 3 +local scrollingUp = false +local playedBgm = false local triggerServiceMenu = false --- Window variables -local resX, resY - --- Aspect Ratios -local landscapeWidescreenRatio = 16 / 9 -local landscapeStandardRatio = 4 / 3 -local portraitWidescreenRatio = 9 / 16 - --- Portrait sizes -local fullX, fullY - -local resolutionChange = function(x, y) - resX = x - resY = y - fullX = portraitWidescreenRatio * y - fullY = y -end - -function resetLayoutInformation() - resx, resy = game.GetResolution() - desw = 1080 - desh = 1920 - scale = resx / desw -end - -draw_button = function(button, x, y, selected, index) - local labelImage = button[1]; - local labelWidth = button[2]; - local descriptionText = button[4]; - +local function draw_button(button, x, y, selected, index) if (selected) then -- Draw button background - gfx.BeginPath(); + gfx.BeginPath() gfx.ImageRect(x, y + (196 / 2 * (1 - scrollTransitionScale)), 505, 196 * scrollTransitionScale, - selectedButtonBgImage, 1, 0); + resources.images.selectedButtonBgImage, 1, 0) -- Draw button main label - gfx.BeginPath(); - gfx.ImageRect(x + 256 - (labelWidth / 2), (y + 58) + (64 / 2 * (1 - scrollTransitionScale)), labelWidth, - 64 * scrollTransitionScale, labelImage, 1, 0); + gfx.BeginPath() + gfx.ImageRect(x + 256 - (button.labelWidth / 2), (y + 58) + (64 / 2 * (1 - scrollTransitionScale)), + button.labelWidth, 64 * scrollTransitionScale, button.labelImage, 1, 0) -- Draw description gfx.GlobalAlpha((scrollTransitionScale - 0.8) * 5) gfx.TextAlign(gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE) - gfx.FontSize(40); - gfx.BeginPath(); - gfx.Text(descriptionText, x + 256, y + 28); + gfx.FontSize(40) + gfx.BeginPath() + gfx.Text(button.description, x + 256, y + 28) gfx.GlobalAlpha(1) -- Draw the glow overlay - gfx.BeginPath(); + gfx.BeginPath() gfx.ImageRect(x + 2, (y - 42) + (277 / 2 * (1 - scrollTransitionScale)), 501, 277 * scrollTransitionScale, - selectedButtonOverImage, 1, 0); + resources.images.selectedButtonOverImage, 1, 0) else if scrollingUp then - if (index == 3 or index == 0) then gfx.GlobalAlpha(1 - scrollTransitionScale); end - if (index == 2 or index == 5) then gfx.GlobalAlpha(scrollTransitionScale); end + if (index == 3 or index == 0) then gfx.GlobalAlpha(1 - scrollTransitionScale) end + if (index == 2 or index == 5) then gfx.GlobalAlpha(scrollTransitionScale) end else - if (index == 3 or index == 6) then gfx.GlobalAlpha(1 - scrollTransitionScale); end - if (index == 1 or index == 4) then gfx.GlobalAlpha(scrollTransitionScale); end + if (index == 3 or index == 6) then gfx.GlobalAlpha(1 - scrollTransitionScale) end + if (index == 1 or index == 4) then gfx.GlobalAlpha(scrollTransitionScale) end end -- Draw button background - gfx.BeginPath(); - gfx.ImageRect(x, y + buttonsMovementScale * buttonHeight, 1026 / 2, 257 / 2, unselectedButtonImage, 1, 0); + gfx.BeginPath() + gfx.ImageRect(x, y + buttonsMovementScale * buttonHeight, 1026 / 2, 257 / 2, resources.images.unselectedButtonImage, 1, 0) -- Draw button main label - gfx.BeginPath(); - gfx.ImageRect(x + 64, y + 28 + buttonsMovementScale * buttonHeight, labelWidth, 64, labelImage, 1, 0); + gfx.BeginPath() + gfx.ImageRect(x + 64, y + 28 + buttonsMovementScale * buttonHeight, button.labelWidth, 64, button.labelImage, 1, + 0) -- Draw description gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE) - gfx.FontSize(28); - gfx.BeginPath(); - gfx.Text(descriptionText, x + 64, y + 18 + buttonsMovementScale * buttonHeight); + gfx.FontSize(28) + gfx.BeginPath() + gfx.Text(button.description, x + 64, y + 18 + buttonsMovementScale * buttonHeight) gfx.GlobalAlpha(1) end -end; +end -draw_buttons = function() - indexes = { +local function getCorrectedButtonIndex(from, offset) + local buttonsNum = #buttons + + local index = from + offset + + if index < 1 then + index = buttonsNum + (from + offset) -- this only happens if the offset is negative + end + + if index > buttonsNum then + index = offset - (buttonsNum - from) -- this only happens if the offset is positive + end + + return index +end + +local function draw_buttons() + local indexes = { getCorrectedButtonIndex(cursorIndex, -2), getCorrectedButtonIndex(cursorIndex, -1), cursorIndex, @@ -148,104 +175,86 @@ draw_buttons = function() getCorrectedButtonIndex(cursorIndex, 2), } - local yBase = desh / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER; + local yBase = Dim.design.height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - centerButtonY = yBase - buttonHeight / 2 - 28; -- to fit with the selector bg - marginFromDesHCenter = 128; + local centerButtonY = yBase - buttonHeight / 2 - 28 -- to fit with the selector bg + local marginFromDesHCenter = 128 if scrollingUp then - draw_button(buttons[indexes[5]], desw - 512, yBase - marginFromDesHCenter - buttonHeight * 3, false, 0); -- Placeholder for fadeout transition + draw_button(buttons[indexes[5]], Dim.design.width - 512, yBase - marginFromDesHCenter - buttonHeight * 3, false, + 0) -- Placeholder for fadeout transition end - draw_button(buttons[indexes[1]], desw - 512, yBase - marginFromDesHCenter - buttonHeight * 2, false, 1); - draw_button(buttons[indexes[2]], desw - 512, yBase - marginFromDesHCenter - buttonHeight, false, 2); + draw_button(buttons[indexes[1]], Dim.design.width - 512, yBase - marginFromDesHCenter - buttonHeight * 2, false, 1) + draw_button(buttons[indexes[2]], Dim.design.width - 512, yBase - marginFromDesHCenter - buttonHeight, false, 2) - draw_button(buttons[indexes[3]], desw - 512, centerButtonY, true); -- The main selected center button + draw_button(buttons[indexes[3]], Dim.design.width - 512, centerButtonY, true) -- The main selected center button if scrollingUp then - draw_button(buttons[indexes[3]], desw - 512, yBase + marginFromDesHCenter - buttonHeight, false, 3); -- Placeholder for transition that goes to the bottom + draw_button(buttons[indexes[3]], Dim.design.width - 512, yBase + marginFromDesHCenter - buttonHeight, false, 3) -- Placeholder for transition that goes to the bottom else - draw_button(buttons[indexes[3]], desw - 512, centerButtonY, false, 3); -- Placeholder for transition that goes to the top + draw_button(buttons[indexes[3]], Dim.design.width - 512, centerButtonY, false, 3) -- Placeholder for transition that goes to the top end - draw_button(buttons[indexes[4]], desw - 512, yBase + marginFromDesHCenter + 10, false, 4); - draw_button(buttons[indexes[5]], desw - 512, yBase + marginFromDesHCenter + buttonHeight + 10, false, 5); + draw_button(buttons[indexes[4]], Dim.design.width - 512, yBase + marginFromDesHCenter + 10, false, 4) + draw_button(buttons[indexes[5]], Dim.design.width - 512, yBase + marginFromDesHCenter + buttonHeight + 10, false, 5) if not scrollingUp then - draw_button(buttons[indexes[1]], desw - 512, yBase + marginFromDesHCenter + buttonHeight * 2, false, 6); + draw_button(buttons[indexes[1]], Dim.design.width - 512, yBase + marginFromDesHCenter + buttonHeight * 2, false, + 6) end -end; - -function getCorrectedButtonIndex(from, offset) - buttonsNum = #buttons; - - index = from + offset; - - if index < 1 then - index = buttonsNum + (from + offset) -- this only happens if the offset is negative - end - - if index > buttonsNum then - indexesUntilEnd = buttonsNum - from; - index = offset - indexesUntilEnd -- this only happens if the offset is positive - end - - return index; end -function drawTexts() +local function drawTexts() - currentFullDescriptionText = buttons[cursorIndex][5]; - gfx.BeginPath(); - gfx.UpdateLabel(selectorDescriptionLabel, currentFullDescriptionText, 22) + local currentFullDescriptionText = buttons[cursorIndex].details + gfx.BeginPath() + gfx.UpdateLabel(resources.labels.selectorDescriptionLabel, currentFullDescriptionText, 22) - gfx.BeginPath(); - -- gfx.UpdateLabel(selectorLegendScrollLabel, 'SCROLL', 20); + gfx.BeginPath() + -- gfx.UpdateLabel(resources.labels.selectorLegendScrollLabel, 'SCROLL', 20) - -- descriptionAlpha = math.abs(selectedButtonScaleY - 0.5) * 2; - gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE); + -- descriptionAlpha = math.abs(selectedButtonScaleY - 0.5) * 2 + gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE) -- Description - gfx.FillColor(255, 255, 255, math.floor(scrollTransitionScale * 255)); - gfx.BeginPath(); - gfx.DrawLabel(selectorDescriptionLabel, 64, desh / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - 52); + gfx.FillColor(255, 255, 255, math.floor(scrollTransitionScale * 255)) + gfx.BeginPath() + gfx.DrawLabel(resources.labels.selectorDescriptionLabel, 64, Dim.design.height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - 52) -- Legend on the selector - gfx.FillColor(217, 177, 126); + gfx.FillColor(217, 177, 126) - gfx.BeginPath(); - gfx.DrawLabel(selectorLegendScrollLabel, 118, desh / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56); + gfx.BeginPath() + gfx.DrawLabel(resources.labels.selectorLegendScrollLabel, 118, Dim.design.height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56) - gfx.BeginPath(); - gfx.DrawLabel(selectorLegendSelectLabel, 360, desh / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56); + gfx.BeginPath() + gfx.DrawLabel(resources.labels.selectorLegendSelectLabel, 360, Dim.design.height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56) - gfx.FillColor(255, 255, 255); + gfx.FillColor(255, 255, 255) end -function setButtons() - if buttons == nil then - buttons = {} - buttons[1] = {skillLabelImage, 412, Menu.Challenges, lang.Challanges.ch, lang.Challanges.ch1} - buttons[2] = {friendLabelImage, 169, Menu.Multiplayer, lang.Multiplayer.mp, lang.Multiplayer.mp2} - buttons[3] = {normalLabelImage, 210, Menu.Start, lang.Start.st, lang.Start.st2} - buttons[4] = {nauticaLabelImage, 230, Menu.DLScreen, lang.Nautica.dls, lang.Nautica.dls2} - buttons[5] = {settingsLabelImage, 247, Menu.Settings, lang.Settings.se, lang.Settings.se1} - buttons[6] = {exitLabelImage, 110, Menu.Exit, lang.Exit.ex, lang.Exit.ex2} - end +local function setButtonActions() + buttons[1].action = Menu.Challenges + buttons[2].action = Menu.Multiplayer + buttons[3].action = Menu.Start + buttons[4].action = Menu.DLScreen + buttons[5].action = Menu.Settings + buttons[6].action = Menu.Exit end -function drawHeader() - gfx.BeginPath(); - gfx.FillColor(0, 0, 0, BAR_ALPHA); - gfx.Rect(0, 0, desw, HEADER_HEIGHT); - gfx.Fill(); +local function drawHeader() + gfx.BeginPath() + gfx.FillColor(0, 0, 0, BAR_ALPHA) + gfx.Rect(0, 0, Dim.design.width, HEADER_HEIGHT) + gfx.Fill() gfx.ClosePath() - gfx.ImageRect(desw / 2 - 200, HEADER_HEIGHT / 2 - 20, 400, 40, headerTitleImage, 1, 0) + gfx.ImageRect(Dim.design.width / 2 - 200, HEADER_HEIGHT / 2 - 20, 400, 40, resources.images.headerTitleImage, 1, 0) end -local onKnobsChange = function(direction) - -- game.Log(direction, game.LOGGER_ERROR); +local function onKnobsChange(direction) + -- game.Log(direction, game.LOGGER_ERROR) cursorIndex = cursorIndex + direction if (cursorIndex == 0) then cursorIndex = #buttons @@ -253,85 +262,74 @@ local onKnobsChange = function(direction) cursorIndex = 1 end - scrollTransitionScale = 0; -- Reset transitions and play them + scrollTransitionScale = 0 -- Reset transitions and play them - scrollingUp = false; + scrollingUp = false if ((cursorIndex > oldCursorIndex and not (cursorIndex == 6 and oldCursorIndex == 1)) or - (cursorIndex == 1 and oldCursorIndex == 6)) then scrollingUp = true; end + (cursorIndex == 1 and oldCursorIndex == 6)) then scrollingUp = true end - game.PlaySample("titlescreen/cursor_change.wav"); + game.PlaySample("titlescreen/cursor_change.wav") - oldCursorIndex = cursorIndex; + oldCursorIndex = cursorIndex end -draw_titlescreen = function(x, y, w, h, deltaTime) - gfx.Scissor(x, y, w, h); - gfx.Translate(x, y); - gfx.Scale(w / 1080, h / 1920); - +local function draw_titlescreen(deltaTime) gfx.LoadSkinFont("segoeui.ttf") -- Draw background - gfx.BeginPath(); + gfx.BeginPath() Background.draw(deltaTime) - local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime); + local idolAnimTickRes = gfx.TickAnimation(resources.anims.idolAnimation, deltaTime) if idolAnimTickRes == 1 then - gfx.GlobalAlpha(idolAnimTransitionScale); + gfx.GlobalAlpha(idolAnimTransitionScale) - idolAnimTransitionScale = idolAnimTransitionScale + 1 / 60; - if (idolAnimTransitionScale > 1) then idolAnimTransitionScale = 1; end + idolAnimTransitionScale = idolAnimTransitionScale + 1 / 60 + if (idolAnimTransitionScale > 1) then idolAnimTransitionScale = 1 end - gfx.BeginPath(); - gfx.ImageRect(0, 0, desw, desh, idolAnimation, 1, 0); - gfx.GlobalAlpha(1); + gfx.BeginPath() + gfx.ImageRect(0, 0, Dim.design.width, Dim.design.height, resources.anims.idolAnimation, 1, 0) + gfx.GlobalAlpha(1) end -- Draw selector background - gfx.BeginPath(); - gfx.ImageRect(0, (desh / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER) - 280 / 2, 1079, 280, selectorBgImage, 1, 0); + gfx.BeginPath() + gfx.ImageRect(0, (Dim.design.height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER) - 280 / 2, 1079, 280, resources.images.selectorBgImage, 1, + 0) - setButtons() + buttonY = (Dim.design.height / 2) - 2 * (257 + 5) - buttonY = (desh / 2) - 2 * (257 + 5); - - draw_buttons(); - drawTexts(); + draw_buttons() + drawTexts() -- Draw the arrows around the selected button - gfx.BeginPath(); - gfx.ImageRect(desw - 512, desh / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - buttonHeight - 8, 501, 300, - selectorArrowsImage, 1, 0); + gfx.BeginPath() + gfx.ImageRect(Dim.design.width - 512, Dim.design.height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - buttonHeight - 8, + 501, 300, resources.images.selectorArrowsImage, 1, 0) -- Draw top and bottom bars - drawHeader(); - Footer.draw(deltaTime); + drawHeader() + Footer.draw(deltaTime) - gfx.ResetTransform(); + gfx.ResetTransform() end -local render = function(deltaTime) +local function render(deltaTime) if not playedBgm then - game.PlaySample("titlescreen/bgm.wav", true); - playedBgm = true; + game.PlaySample("titlescreen/bgm.wav", true) + playedBgm = true end - game.SetSkinSetting("_currentScreen", "title") + Dim.updateResolution() - -- detect resolution change - local resx, resy = game.GetResolution(); - if resx ~= resX or resy ~= resY then resolutionChange(resx, resy) end + Wallpaper.render() - gfx.BeginPath() - local bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage) - gfx.Rect(0, 0, resX, resY) - gfx.FillPaint(gfx.ImagePattern(0, 0, bgImageWidth, bgImageHeight, 0, backgroundImage, 0.2)) - gfx.Fill() + Dim.transformToScreenSpace() - draw_titlescreen((resX - fullX) / 2, 0, fullX, fullY, deltaTime); + draw_titlescreen(deltaTime) - scrollTransitionScale = scrollTransitionScale + deltaTime / 0.2; - if (scrollTransitionScale > 1) then scrollTransitionScale = 1; end + scrollTransitionScale = scrollTransitionScale + deltaTime / 0.2 + if (scrollTransitionScale > 1) then scrollTransitionScale = 1 end if scrollingUp then buttonsMovementScale = 1 - scrollTransitionScale @@ -340,27 +338,32 @@ local render = function(deltaTime) end if (triggerServiceMenu) then - triggerServiceMenu = false; + triggerServiceMenu = false return {eventType = "switch", toScreen = "service"} end - gfx.BeginPath(); -end; + gfx.BeginPath() +end -local onButtonPressed = function(button) +local function onButtonPressed(button) if button == game.BUTTON_STA then - game.PlaySample("titlescreen/cursor_select.wav"); - game.StopSample("titlescreen/bgm.wav"); - buttons[cursorIndex][3]() + game.PlaySample("titlescreen/cursor_select.wav") + game.StopSample("titlescreen/bgm.wav") + + if buttons[cursorIndex].action == nil then setButtonActions() end + buttons[cursorIndex].action() + elseif button == game.BUTTON_BCK then Menu.Exit() + elseif button == game.BUTTON_FXR then - triggerServiceMenu = true; + triggerServiceMenu = true + end end -- the thing is... titlescreen script does not have a call to reset function... WHYYYYY -function reset() playedBgm = false; end +function reset() playedBgm = false end return { render = render,