2022-06-29 00:35:52 +02:00
require " common.globals "
require " common.class "
2022-04-27 02:03:42 +02:00
2022-03-26 02:21:54 +01:00
local Footer = require ( " components.footer " )
local Wallpaper = require ( " components.wallpaper " )
local Background = require ( " components.background " )
2024-02-02 02:50:48 +01:00
local Display = require ( " scripts.graphics.display " )
2023-08-19 04:25:27 +02:00
local lang = require ( " language " )
2022-03-27 03:54:02 +02:00
local util = require ( " common.util " )
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
local cursorIndex = 3
local buttonHeight = 128 + 16
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
local SELECTOR_BAR_OFFSET_FROM_CENTER = 128
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
local BAR_ALPHA = 191
2021-12-19 23:16:19 +01:00
local HEADER_HEIGHT = 100
2022-03-26 02:21:54 +01:00
local crew = game.GetSkinSetting ( " single_idol " )
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 )
}
}
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
-- load audio samples
for _ , path in pairs ( resources.audiosamples ) do
game.LoadSkinSample ( path )
end
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
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 ,
} ,
}
2021-12-19 23:16:19 +01:00
2022-03-27 03:54:02 +02:00
local miscButtons = {
upArrow = {
2024-02-02 02:50:48 +01:00
x = Display.design . width - 265 ,
y = Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - buttonHeight + 4 ,
2022-03-27 03:54:02 +02:00
w = 64 ,
h = 36
} ,
downArrow = {
2024-02-02 02:50:48 +01:00
x = Display.design . width - 265 ,
y = Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER + buttonHeight / 2 + 28 ,
2022-03-27 03:54:02 +02:00
w = 64 ,
h = 36
} ,
mainButton = {
2024-02-02 02:50:48 +01:00
x = Display.design . width - 512 ,
y = Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - buttonHeight / 2 - 28 ,
2022-03-27 03:54:02 +02:00
w = 505 ,
h = 196
} ,
upButton1 = {
2024-02-02 02:50:48 +01:00
x = Display.design . width - 512 ,
y = Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - 128 - buttonHeight ,
2022-03-27 03:54:02 +02:00
w = 1026 / 2 ,
h = 257 / 2
} ,
upButton2 = {
2024-02-02 02:50:48 +01:00
x = Display.design . width - 512 ,
y = Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - 128 - buttonHeight * 2 ,
2022-03-27 03:54:02 +02:00
w = 1026 / 2 ,
h = 257 / 2
} ,
downButton1 = {
2024-02-02 02:50:48 +01:00
x = Display.design . width - 512 ,
y = Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 128 + 10 ,
2022-03-27 03:54:02 +02:00
w = 1026 / 2 ,
h = 257 / 2
} ,
downButton2 = {
2024-02-02 02:50:48 +01:00
x = Display.design . width - 512 ,
y = Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 128 + buttonHeight + 10 ,
2022-03-27 03:54:02 +02:00
w = 1026 / 2 ,
h = 257 / 2
} ,
}
2022-03-26 02:21:54 +01:00
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
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
local idolAnimTransitionScale = 0
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
local oldCursorIndex = 3
local scrollingUp = false
local playedBgm = false
2021-12-19 23:16:19 +01:00
2021-12-20 00:39:38 +01:00
local triggerServiceMenu = false
2022-03-27 03:54:02 +02:00
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
2022-03-26 02:21:54 +01:00
local function draw_button ( button , x , y , selected , index )
2021-12-19 23:16:19 +01:00
if ( selected ) then
-- Draw button background
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
2022-03-12 15:18:41 +01:00
gfx.ImageRect ( x , y + ( 196 / 2 * ( 1 - scrollTransitionScale ) ) , 505 , 196 * scrollTransitionScale ,
2022-03-26 02:21:54 +01:00
resources.images . selectedButtonBgImage , 1 , 0 )
2021-12-19 23:16:19 +01:00
-- Draw button main label
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
gfx.ImageRect ( x + 256 - ( button.labelWidth / 2 ) , ( y + 58 ) + ( 64 / 2 * ( 1 - scrollTransitionScale ) ) ,
button.labelWidth , 64 * scrollTransitionScale , button.labelImage , 1 , 0 )
2021-12-19 23:16:19 +01:00
-- Draw description
gfx.GlobalAlpha ( ( scrollTransitionScale - 0.8 ) * 5 )
gfx.TextAlign ( gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE )
2022-03-26 02:21:54 +01:00
gfx.FontSize ( 40 )
gfx.BeginPath ( )
gfx.Text ( button.description , x + 256 , y + 28 )
2021-12-19 23:16:19 +01:00
gfx.GlobalAlpha ( 1 )
-- Draw the glow overlay
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
2022-03-12 15:18:41 +01:00
gfx.ImageRect ( x + 2 , ( y - 42 ) + ( 277 / 2 * ( 1 - scrollTransitionScale ) ) , 501 , 277 * scrollTransitionScale ,
2022-03-26 02:21:54 +01:00
resources.images . selectedButtonOverImage , 1 , 0 )
2021-12-19 23:16:19 +01:00
else
if scrollingUp then
2022-03-26 02:21:54 +01:00
if ( index == 3 or index == 0 ) then gfx.GlobalAlpha ( 1 - scrollTransitionScale ) end
if ( index == 2 or index == 5 ) then gfx.GlobalAlpha ( scrollTransitionScale ) end
2021-12-19 23:16:19 +01:00
else
2022-03-26 02:21:54 +01:00
if ( index == 3 or index == 6 ) then gfx.GlobalAlpha ( 1 - scrollTransitionScale ) end
if ( index == 1 or index == 4 ) then gfx.GlobalAlpha ( scrollTransitionScale ) end
2021-12-19 23:16:19 +01:00
end
-- Draw button background
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
gfx.ImageRect ( x , y + buttonsMovementScale * buttonHeight , 1026 / 2 , 257 / 2 , resources.images . unselectedButtonImage , 1 , 0 )
2021-12-19 23:16:19 +01:00
-- Draw button main label
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
gfx.ImageRect ( x + 64 , y + 28 + buttonsMovementScale * buttonHeight , button.labelWidth , 64 , button.labelImage , 1 ,
0 )
2021-12-19 23:16:19 +01:00
-- Draw description
gfx.TextAlign ( gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE )
2022-03-26 02:21:54 +01:00
gfx.FontSize ( 28 )
gfx.BeginPath ( )
gfx.Text ( button.description , x + 64 , y + 18 + buttonsMovementScale * buttonHeight )
2021-12-19 23:16:19 +01:00
gfx.GlobalAlpha ( 1 )
end
2022-03-26 02:21:54 +01:00
end
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
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
local function draw_buttons ( )
local indexes = {
2021-12-19 23:16:19 +01:00
getCorrectedButtonIndex ( cursorIndex , - 2 ) ,
2022-03-12 15:18:41 +01:00
getCorrectedButtonIndex ( cursorIndex , - 1 ) ,
cursorIndex ,
2021-12-19 23:16:19 +01:00
getCorrectedButtonIndex ( cursorIndex , 1 ) ,
2022-03-12 15:18:41 +01:00
getCorrectedButtonIndex ( cursorIndex , 2 ) ,
2021-12-19 23:16:19 +01:00
}
2024-02-02 02:50:48 +01:00
local yBase = Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
local centerButtonY = yBase - buttonHeight / 2 - 28 -- to fit with the selector bg
local marginFromDesHCenter = 128
2021-12-19 23:16:19 +01:00
if scrollingUp then
2024-02-02 02:50:48 +01:00
draw_button ( buttons [ indexes [ 5 ] ] , Display.design . width - 512 , yBase - marginFromDesHCenter - buttonHeight * 3 , false ,
2022-03-26 02:21:54 +01:00
0 ) -- Placeholder for fadeout transition
2021-12-19 23:16:19 +01:00
end
2024-02-02 02:50:48 +01:00
draw_button ( buttons [ indexes [ 1 ] ] , Display.design . width - 512 , yBase - marginFromDesHCenter - buttonHeight * 2 , false , 1 )
draw_button ( buttons [ indexes [ 2 ] ] , Display.design . width - 512 , yBase - marginFromDesHCenter - buttonHeight , false , 2 )
2021-12-19 23:16:19 +01:00
2024-02-02 02:50:48 +01:00
draw_button ( buttons [ indexes [ 3 ] ] , Display.design . width - 512 , centerButtonY , true ) -- The main selected center button
2021-12-19 23:16:19 +01:00
if scrollingUp then
2024-02-02 02:50:48 +01:00
draw_button ( buttons [ indexes [ 3 ] ] , Display.design . width - 512 , yBase + marginFromDesHCenter - buttonHeight , false , 3 ) -- Placeholder for transition that goes to the bottom
2021-12-19 23:16:19 +01:00
else
2024-02-02 02:50:48 +01:00
draw_button ( buttons [ indexes [ 3 ] ] , Display.design . width - 512 , centerButtonY , false , 3 ) -- Placeholder for transition that goes to the top
2021-12-19 23:16:19 +01:00
end
2024-02-02 02:50:48 +01:00
draw_button ( buttons [ indexes [ 4 ] ] , Display.design . width - 512 , yBase + marginFromDesHCenter + 10 , false , 4 )
draw_button ( buttons [ indexes [ 5 ] ] , Display.design . width - 512 , yBase + marginFromDesHCenter + buttonHeight + 10 , false , 5 )
2021-12-19 23:16:19 +01:00
if not scrollingUp then
2024-02-02 02:50:48 +01:00
draw_button ( buttons [ indexes [ 1 ] ] , Display.design . width - 512 , yBase + marginFromDesHCenter + buttonHeight * 2 , false ,
2022-03-26 02:21:54 +01:00
6 )
2021-12-19 23:16:19 +01:00
end
end
2022-03-26 02:21:54 +01:00
local function drawTexts ( )
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
local currentFullDescriptionText = buttons [ cursorIndex ] . details
gfx.BeginPath ( )
gfx.UpdateLabel ( resources.labels . selectorDescriptionLabel , currentFullDescriptionText , 22 )
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
-- gfx.UpdateLabel(resources.labels.selectorLegendScrollLabel, 'SCROLL', 20)
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
-- descriptionAlpha = math.abs(selectedButtonScaleY - 0.5) * 2
gfx.TextAlign ( gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE )
2021-12-19 23:16:19 +01:00
-- Description
2022-03-26 02:21:54 +01:00
gfx.FillColor ( 255 , 255 , 255 , math.floor ( scrollTransitionScale * 255 ) )
gfx.BeginPath ( )
2024-02-02 02:50:48 +01:00
gfx.DrawLabel ( resources.labels . selectorDescriptionLabel , 64 , Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - 52 )
2021-12-19 23:16:19 +01:00
-- Legend on the selector
2022-03-26 02:21:54 +01:00
gfx.FillColor ( 217 , 177 , 126 )
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
2024-02-02 02:50:48 +01:00
gfx.DrawLabel ( resources.labels . selectorLegendScrollLabel , 118 , Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56 )
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
2024-02-02 02:50:48 +01:00
gfx.DrawLabel ( resources.labels . selectorLegendSelectLabel , 360 , Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56 )
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
gfx.FillColor ( 255 , 255 , 255 )
2021-12-19 23:16:19 +01:00
end
2022-03-26 02:21:54 +01:00
local function drawHeader ( )
gfx.BeginPath ( )
gfx.FillColor ( 0 , 0 , 0 , BAR_ALPHA )
2024-02-02 02:50:48 +01:00
gfx.Rect ( 0 , 0 , Display.design . width , HEADER_HEIGHT )
2022-03-26 02:21:54 +01:00
gfx.Fill ( )
2021-12-19 23:16:19 +01:00
gfx.ClosePath ( )
2024-02-02 02:50:48 +01:00
gfx.ImageRect ( Display.design . width / 2 - 200 , HEADER_HEIGHT / 2 - 20 , 400 , 40 , resources.images . headerTitleImage , 1 , 0 )
2021-12-19 23:16:19 +01:00
end
2022-03-26 02:21:54 +01:00
local function draw_titlescreen ( deltaTime )
2021-12-19 23:16:19 +01:00
gfx.LoadSkinFont ( " segoeui.ttf " )
-- Draw background
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
2021-12-19 23:16:19 +01:00
Background.draw ( deltaTime )
2022-03-26 02:21:54 +01:00
local idolAnimTickRes = gfx.TickAnimation ( resources.anims . idolAnimation , deltaTime )
2021-12-19 23:16:19 +01:00
if idolAnimTickRes == 1 then
2022-03-26 02:21:54 +01:00
gfx.GlobalAlpha ( idolAnimTransitionScale )
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
idolAnimTransitionScale = idolAnimTransitionScale + 1 / 60
if ( idolAnimTransitionScale > 1 ) then idolAnimTransitionScale = 1 end
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
2024-02-02 02:50:48 +01:00
gfx.ImageRect ( 0 , 0 , Display.design . width , Display.design . height , resources.anims . idolAnimation , 1 , 0 )
2022-03-26 02:21:54 +01:00
gfx.GlobalAlpha ( 1 )
2021-12-19 23:16:19 +01:00
end
-- Draw selector background
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
2024-02-02 02:50:48 +01:00
gfx.ImageRect ( 0 , ( Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER ) - 280 / 2 , 1079 , 280 , resources.images . selectorBgImage , 1 ,
2022-03-26 02:21:54 +01:00
0 )
2021-12-19 23:16:19 +01:00
2024-02-02 02:50:48 +01:00
buttonY = ( Display.design . height / 2 ) - 2 * ( 257 + 5 )
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
draw_buttons ( )
drawTexts ( )
2021-12-19 23:16:19 +01:00
-- Draw the arrows around the selected button
2022-03-26 02:21:54 +01:00
gfx.BeginPath ( )
2024-02-02 02:50:48 +01:00
gfx.ImageRect ( Display.design . width - 512 , Display.design . height / 2 + SELECTOR_BAR_OFFSET_FROM_CENTER - buttonHeight - 8 ,
2022-03-26 02:21:54 +01:00
501 , 300 , resources.images . selectorArrowsImage , 1 , 0 )
2021-12-19 23:16:19 +01:00
-- Draw top and bottom bars
2022-03-26 02:21:54 +01:00
drawHeader ( )
Footer.draw ( deltaTime )
2022-03-27 03:54:02 +02:00
end
2021-12-19 23:16:19 +01:00
2022-03-27 03:54:02 +02:00
local function tickTransitions ( deltaTime )
scrollTransitionScale = scrollTransitionScale + deltaTime / 0.2
if ( scrollTransitionScale > 1 ) then scrollTransitionScale = 1 end
if scrollingUp then
buttonsMovementScale = 1 - scrollTransitionScale
else
buttonsMovementScale = - 1 + scrollTransitionScale
end
2021-12-19 23:16:19 +01:00
end
2022-05-04 03:34:37 +02:00
local PageView = require " api.page.pageview "
2022-07-12 01:46:49 +02:00
local ModeSelectPage = require " titlescreen.modeselect.modeselectpage "
2022-05-04 03:34:37 +02:00
local PageViewInstance = PageView.new ( ModeSelectPage.new ( ) )
2022-03-26 02:21:54 +01:00
local function render ( deltaTime )
2022-05-04 03:34:37 +02:00
--[[
2021-12-19 23:16:19 +01:00
if not playedBgm then
2022-03-29 04:27:12 +02:00
game.PlaySample ( resources.audiosamples . bgm , true )
2022-03-26 02:21:54 +01:00
playedBgm = true
2021-12-19 23:16:19 +01:00
end
2022-05-04 03:34:37 +02:00
] ]
2021-12-19 23:16:19 +01:00
2022-03-27 03:54:02 +02:00
game.SetSkinSetting ( " _currentScreen " , " title " )
2024-02-02 02:50:48 +01:00
Display.updateResolution ( )
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
Wallpaper.render ( )
2021-12-19 23:16:19 +01:00
2024-02-02 02:50:48 +01:00
Display.transformToScreenSpace ( )
2021-12-19 23:16:19 +01:00
2022-03-27 03:54:02 +02:00
tickTransitions ( deltaTime )
2021-12-19 23:16:19 +01:00
2022-05-04 03:34:37 +02:00
--draw_titlescreen(deltaTime)
PageViewInstance : render ( deltaTime )
2021-12-19 23:16:19 +01:00
2021-12-20 00:39:38 +01:00
if ( triggerServiceMenu ) then
2022-03-26 02:21:54 +01:00
triggerServiceMenu = false
2022-03-12 15:18:41 +01:00
return { eventType = " switch " , toScreen = " service " }
2021-12-20 00:39:38 +01:00
end
2022-03-27 03:54:02 +02:00
end
2021-12-20 00:39:38 +01:00
2022-05-04 03:34:37 +02:00
local function reset ( )
PageViewInstance : get ( ) : init ( )
end
2022-03-27 03:54:02 +02:00
local function callButtonAction ( )
if buttons [ cursorIndex ] . action == nil then setButtonActions ( ) end
buttons [ cursorIndex ] . action ( )
end
local function onKnobsChange ( direction )
2022-04-11 18:47:26 +02:00
cursorIndex = util.modIndex ( cursorIndex + direction , # buttons )
2022-03-27 03:54:02 +02:00
scrollTransitionScale = 0 -- Reset transitions and play them
scrollingUp = false
if ( ( cursorIndex > oldCursorIndex and not ( cursorIndex == 6 and oldCursorIndex == 1 ) ) or
( cursorIndex == 1 and oldCursorIndex == 6 ) ) then scrollingUp = true end
2022-03-29 04:27:12 +02:00
game.PlaySample ( resources.audiosamples . cursorChange )
2022-03-27 03:54:02 +02:00
oldCursorIndex = cursorIndex
2022-03-26 02:21:54 +01:00
end
2021-12-19 23:16:19 +01:00
2022-03-26 02:21:54 +01:00
local function onButtonPressed ( button )
2021-12-19 23:16:19 +01:00
if button == game.BUTTON_STA then
2022-03-29 04:27:12 +02:00
game.PlaySample ( resources.audiosamples . cursorSelect )
game.StopSample ( resources.audiosamples . bgm )
2022-03-26 02:21:54 +01:00
2022-03-27 03:54:02 +02:00
callButtonAction ( )
2022-03-26 02:21:54 +01:00
2021-12-19 23:16:19 +01:00
elseif button == game.BUTTON_BCK then
Menu.Exit ( )
2022-03-26 02:21:54 +01:00
2021-12-20 00:39:38 +01:00
elseif button == game.BUTTON_FXR then
2022-03-26 02:21:54 +01:00
triggerServiceMenu = true
2021-12-19 23:16:19 +01:00
end
end
2022-03-27 03:54:02 +02:00
local function onMousePressed ( button )
2024-02-02 02:50:48 +01:00
local mousePosX , mousePosY = Display.toViewSpace ( game.GetMousePos ( ) )
2022-03-27 03:54:02 +02:00
local changeIndex = 0
if button ~= 0 then
return
end
if util.areaOverlap ( mousePosX , mousePosY ,
miscButtons.mainButton . x , miscButtons.mainButton . y , miscButtons.mainButton . w , miscButtons.mainButton . h ) then
2022-03-29 04:27:12 +02:00
game.StopSample ( resources.audiosamples . bgm )
game.PlaySample ( resources.audiosamples . cursorSelect )
2022-03-27 03:54:02 +02:00
callButtonAction ( )
return
elseif util.areaOverlap ( mousePosX , mousePosY ,
miscButtons.upArrow . x , miscButtons.upArrow . y , miscButtons.upArrow . w , miscButtons.upArrow . h ) or
util.areaOverlap ( mousePosX , mousePosY ,
miscButtons.upButton1 . x , miscButtons.upButton1 . y , miscButtons.upButton1 . w , miscButtons.upButton1 . h ) then
changeIndex = - 1
scrollTransitionScale = 0
scrollingUp = false
elseif util.areaOverlap ( mousePosX , mousePosY ,
miscButtons.downArrow . x , miscButtons.downArrow . y , miscButtons.downArrow . w , miscButtons.downArrow . h ) or
util.areaOverlap ( mousePosX , mousePosY ,
miscButtons.downButton1 . x , miscButtons.downButton1 . y , miscButtons.downButton1 . w , miscButtons.downButton1 . h ) then
changeIndex = 1
scrollTransitionScale = 0
scrollingUp = true
elseif util.areaOverlap ( mousePosX , mousePosY ,
miscButtons.upButton2 . x , miscButtons.upButton2 . y , miscButtons.upButton2 . w , miscButtons.upButton2 . h ) then
changeIndex = - 2
scrollTransitionScale = 0
scrollingUp = false
elseif util.areaOverlap ( mousePosX , mousePosY ,
miscButtons.downButton2 . x , miscButtons.downButton2 . y , miscButtons.downButton2 . w , miscButtons.downButton2 . h ) then
changeIndex = 2
scrollTransitionScale = 0
scrollingUp = true
end
2022-04-11 18:47:26 +02:00
cursorIndex = util.modIndex ( cursorIndex + changeIndex , # buttons )
2022-03-29 04:27:12 +02:00
game.PlaySample ( resources.audiosamples . cursorChange )
2022-03-27 03:54:02 +02:00
end
2021-12-19 23:16:19 +01:00
2022-06-29 00:35:52 +02:00
local Background = require " components.background "
2023-08-19 04:48:46 +02:00
local Animation = require " scripts.graphics.frameanimation "
2022-06-29 00:35:52 +02:00
local AudioSample = require " api.audiosample "
local Page = require " api.page.page "
local Footer = require " components.footer "
local crew = game.GetSkinSetting ( " single_idol " )
---@class MainMenuPage : Page
---@field _idolAnimationState AnimationState
local MainMenuPage = {
__name = " MainMenuPage " ,
2022-07-16 02:45:20 +02:00
ANIM = {
2024-02-02 02:27:05 +01:00
idolAnimation = Animation.new {
animPath = " crew/anim/ " .. crew ,
animFPS = 30 , loop = true ,
2024-02-02 02:50:48 +01:00
centered = true , x = Display.design . width / 2 , y = Display.design . height / 2 ,
width = Display.design . width , height = Display.design . height ,
2024-02-02 02:27:05 +01:00
}
2022-06-29 00:35:52 +02:00
} ,
2022-07-16 02:45:20 +02:00
AUDIO = {
2022-06-29 00:35:52 +02:00
bgm = AudioSample.new { path = " titlescreen/bgm.wav " , exclusive = true , loop = true } ,
}
2021-12-19 23:16:19 +01:00
}
2022-06-29 00:35:52 +02:00
function MainMenuPage . new ( params )
local self = CreateInstance ( MainMenuPage , params , Page )
return self
end
function MainMenuPage : init ( )
2022-07-16 02:45:20 +02:00
self._idolAnimationState = self.ANIM . idolAnimation : start ( )
self.AUDIO . bgm : play ( )
2022-06-29 00:35:52 +02:00
end
function MainMenuPage : drawBackground ( deltaTime )
Background.draw ( deltaTime )
self._idolAnimationState : render ( deltaTime )
end
function MainMenuPage : drawForeground ( deltaTime )
Footer.draw ( deltaTime )
end
2023-08-19 04:25:27 +02:00
return MainMenuPage