From 6f0c35ac30cc6c18b2768cb3e1113826d38993b6 Mon Sep 17 00:00:00 2001 From: Hersi Date: Sat, 16 Jul 2022 02:45:20 +0200 Subject: [PATCH] wip misc things, no real implementation change --- scripts/api/animation.lua | 2 + scripts/common/filereader.lua | 2 +- scripts/titlescreen/mainmenu.lua | 8 +- .../titlescreen/modeselect/modeselectpage.lua | 113 ++++++++++++++++-- 4 files changed, 112 insertions(+), 13 deletions(-) diff --git a/scripts/api/animation.lua b/scripts/api/animation.lua index d11c440..c265e9f 100644 --- a/scripts/api/animation.lua +++ b/scripts/api/animation.lua @@ -86,6 +86,8 @@ end ---@param params AnimationParams ---@return Animation function Animation.new(animPath, params) + local self = CreateInstance(Animation, params) + local frames, frameCount = loadSequentialAnimationFrames(animPath); local instance = { diff --git a/scripts/common/filereader.lua b/scripts/common/filereader.lua index 1ac858f..122a0a5 100644 --- a/scripts/common/filereader.lua +++ b/scripts/common/filereader.lua @@ -80,7 +80,7 @@ end --- Check if a file or directory exists in this path ---@param file string # relative path to game file ---@return boolean # file exists ----@return string # error message +---@return string? # error message function IsFileExists(file) local gamepath, sep = getGamePath() file = gamepath .. sep .. file diff --git a/scripts/titlescreen/mainmenu.lua b/scripts/titlescreen/mainmenu.lua index 0e68d9b..523be84 100644 --- a/scripts/titlescreen/mainmenu.lua +++ b/scripts/titlescreen/mainmenu.lua @@ -484,14 +484,14 @@ local crew = game.GetSkinSetting("single_idol") ---@field _idolAnimationState AnimationState local MainMenuPage = { __name = "MainMenuPage", - anims = { + ANIM = { idolAnimation = Animation.new("crew/anim/" .. crew, { fps = 30, loop = true, centered = true, x = Dim.design.width / 2, y = Dim.design.height / 2, width = Dim.design.width, height = Dim.design.height, }) }, - audiosamples = { + AUDIO = { bgm = AudioSample.new{path = "titlescreen/bgm.wav", exclusive = true, loop = true}, } } @@ -503,8 +503,8 @@ function MainMenuPage.new(params) end function MainMenuPage:init() - self._idolAnimationState = self.anims.idolAnimation:start() - self.audiosamples.bgm:play() + self._idolAnimationState = self.ANIM.idolAnimation:start() + self.AUDIO.bgm:play() end function MainMenuPage:drawBackground(deltaTime) diff --git a/scripts/titlescreen/modeselect/modeselectpage.lua b/scripts/titlescreen/modeselect/modeselectpage.lua index 68a967e..dcc01f7 100644 --- a/scripts/titlescreen/modeselect/modeselectpage.lua +++ b/scripts/titlescreen/modeselect/modeselectpage.lua @@ -1,5 +1,9 @@ require "common.class" + +local Dim = require "common.dimensions" + local Lang = require "language.call" + local AudioSample = require "api.audiosample" local Page = require "api.page.page" @@ -10,30 +14,123 @@ local crew = game.GetSkinSetting("single_idol") ---@class ModeSelectPage: Page local ModeSelectPage = { __name = "ModeSelectPage", - images = { + IMAGES = { 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 = { - + ANIMS = { + }, - audiosamples = { - cursorChange = AudioSample.new{path = "titlescreen/cursor_change.wav"}, - cursorSelect = AudioSample.new{path = "titlescreen/cursor_select.wav"} + AUDIO = { + cursorChange = AudioSample.new { path = "titlescreen/cursor_change.wav" }, + cursorSelect = AudioSample.new { path = "titlescreen/cursor_select.wav" } }, - labels = { + 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) - } + }, + SELECTOR_BAR_OFFSET_FROM_CENTER = 128 } function ModeSelectPage.new(params) local self = CreateInstance(ModeSelectPage, params, Page) + 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 buttonHeight = 100 + + local miscButtons = { + upArrow = { + x = Dim.design.width - 265, + y = Dim.design.height / 2 + self.SELECTOR_BAR_OFFSET_FROM_CENTER - buttonHeight + 4, + w = 64, + h = 36 + }, + downArrow = { + x = Dim.design.width - 265, + y = Dim.design.height / 2 + self.SELECTOR_BAR_OFFSET_FROM_CENTER + buttonHeight / 2 + 28, + w = 64, + h = 36 + }, + mainButton = { + x = Dim.design.width - 512, + y = Dim.design.height / 2 + self.SELECTOR_BAR_OFFSET_FROM_CENTER - buttonHeight / 2 - 28, + w = 505, + h = 196 + }, + upButton1 = { + x = Dim.design.width - 512, + y = Dim.design.height / 2 + self.SELECTOR_BAR_OFFSET_FROM_CENTER - 128 - buttonHeight, + w = 1026 / 2, + h = 257 / 2 + }, + upButton2 = { + x = Dim.design.width - 512, + y = Dim.design.height / 2 + self.SELECTOR_BAR_OFFSET_FROM_CENTER - 128 - buttonHeight * 2, + w = 1026 / 2, + h = 257 / 2 + }, + downButton1 = { + x = Dim.design.width - 512, + y = Dim.design.height / 2 + self.SELECTOR_BAR_OFFSET_FROM_CENTER + 128 + 10, + w = 1026 / 2, + h = 257 / 2 + }, + downButton2 = { + x = Dim.design.width - 512, + y = Dim.design.height / 2 + self.SELECTOR_BAR_OFFSET_FROM_CENTER + 128 + buttonHeight + 10, + w = 1026 / 2, + h = 257 / 2 + }, + } + return self end