From bdfa9dfcb0b4d9948eff58d02cbf759c0fb4ea92 Mon Sep 17 00:00:00 2001 From: FajsiEx Date: Sat, 20 Nov 2021 19:12:12 +0100 Subject: [PATCH] + match the songwheel/filterwheel transitions to be AC-like --- scripts/songselect/filterwheel.lua | 57 ++++++++++++--------- scripts/songselect/songwheel.lua | 79 +++++++++++++++++------------- 2 files changed, 80 insertions(+), 56 deletions(-) diff --git a/scripts/songselect/filterwheel.lua b/scripts/songselect/filterwheel.lua index 32823fa..bb143aa 100644 --- a/scripts/songselect/filterwheel.lua +++ b/scripts/songselect/filterwheel.lua @@ -91,6 +91,8 @@ local resx, resy = game.GetResolution() local desw, desh = 1080, 1920 local scale = 1; +local isFilterWheelActive = false; + local selectionMode = 'folders'; local selectedFolder = 1; local selectedLevel = 1; @@ -103,6 +105,10 @@ local transitionEnterReverse = false; local transitionEnterScale = 0; local transitionEnterOffsetY = 0; +local transitionLeaveScale = 1; +local transitionLeaveReappearTimer = 0; +local TRANSITION_LEAVE_DURATION = 0.1; + function resetLayoutInformation() resx, resy = game.GetResolution() scale = resx / desw @@ -185,6 +191,8 @@ end function drawFolder(label, y) if (not label) then return end + gfx.LoadSkinFont('NotoSans-Regular.ttf') + local x = desw / 2 + 0 local folderData = getFolderData(label) @@ -204,6 +212,8 @@ function drawFolder(label, y) end function drawFolderList() + gfx.GlobalAlpha(1-transitionLeaveScale) + local numOfItemsAround = 7; local selectedIndex = 1; local folderList = filters.folder; @@ -236,6 +246,8 @@ function drawFolderList() desh / 2 - ITEM_HEIGHT / 2 + ITEM_HEIGHT * i + yOffset) i = i + 1; end + + gfx.GlobalAlpha(1); end function drawCursor() @@ -285,24 +297,26 @@ function tickTransitions(deltaTime) -ITEM_HEIGHT; end - -- ENTRY TRANSITION - if transitionEnterReverse then - if transitionEnterScale > 0 then - transitionEnterScale = transitionEnterScale - deltaTime / 0.5 -- transition should last for that time in seconds + -- LEAVE TRANSITION + if (not isFilterWheelActive) then + if transitionLeaveScale < 1 then + transitionLeaveScale = transitionLeaveScale + deltaTime / TRANSITION_LEAVE_DURATION -- transition should last for that time in seconds else - transitionEnterScale = 0 + transitionLeaveScale = 1 end + transitionLeaveReappearTimer = 1; else - if transitionEnterScale < 1 then - transitionEnterScale = transitionEnterScale + deltaTime / 0.5 -- transition should last for that time in seconds - else - transitionEnterScale = 1 + if (transitionLeaveReappearTimer == 1) then + -- This stuff happens right after filterwheel is deactivated + end + + transitionLeaveReappearTimer = transitionLeaveReappearTimer - deltaTime / TRANSITION_LEAVE_DURATION + 0.05 -- same reasoning as in the songwheel + + if (transitionLeaveReappearTimer <= 0) then + transitionLeaveScale = 0; + transitionLeaveReappearTimer = 0; end end - - transitionEnterOffsetY = -Easing.inOutQuad(1 - transitionEnterScale) * - (desh + ITEM_HEIGHT * 2 + 145 + - (transitionEnterReverse and -4 or 0)); end function drawFilterWheel(deltatime) @@ -315,20 +329,17 @@ function drawFilterWheel(deltatime) end render = function(deltatime, shown) + isFilterWheelActive = shown; + drawFilterWheel(deltatime) + if not shown then game.SetSkinSetting('_songWheelOverlayActive', 0); - transitionEnterReverse = true - - if (transitionEnterScale > 0) then - drawFilterWheel(deltatime) - else + if (transitionEnterScale <= 0) then game.SetSkinSetting('_songWheelDespawnSelectorElements', 0); end else - transitionEnterReverse = false game.SetSkinSetting('_songWheelOverlayActive', 1); game.SetSkinSetting('_songWheelDespawnSelectorElements', 1); - drawFilterWheel(deltatime) end game.SetSkinSetting('_songWheelActiveFolderLabel', getFolderData(filters.folder[selectedFolder]).label); @@ -345,9 +356,9 @@ render = function(deltatime, shown) gfx.FontSize(18) gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP) gfx.FillColor(255, 255, 255, 255); - -- gfx.Text('S_M: ' .. selectionMode .. ' // S_F: ' .. selectedFolder .. - -- ' // S_L: ' .. selectedLevel .. ' // T_E_S: ' .. - -- transitionEnterScale, 8, 1870); + gfx.Text('S_M: ' .. selectionMode .. ' // S_F: ' .. selectedFolder .. + ' // S_L: ' .. selectedLevel .. ' // L_TS: ' .. + transitionLeaveScale, 8, 1870); end set_selection = function(newIndex, isFolder) diff --git a/scripts/songselect/songwheel.lua b/scripts/songselect/songwheel.lua index ce75bc7..bae5794 100644 --- a/scripts/songselect/songwheel.lua +++ b/scripts/songselect/songwheel.lua @@ -131,9 +131,11 @@ local transitionLaserY = 0; local transitionFlashScale = 0; local transitionFlashAlpha = 1; -local transitionLeaveReverse = false; +local isFilterWheelActive = false; +local transitionLeaveReappearTimer = 0; local transitionLeaveScale = 0; -local transitionLeaveOffsetY = 0; +local TRANSITION_LEAVE_DURATION = 0.1; +local transitionLeaveOffsetY = 0; -- TODO: remove function resetLayoutInformation() resx, resy = game.GetResolution() @@ -233,29 +235,32 @@ end function drawBackground(deltaTime) Background.draw(deltaTime) - - -- If the score for song exists + local song = songwheel.songs[selectedIndex]; local diff = song and song.difficulties[selectedDifficulty] or false; - if song and diff then - local jacketImage = getJacketImage(song); - gfx.BeginPath() - gfx.ImageRect(transitionJacketBgScrollPosX, 0, 900, 900, jacketImage or defaultJacketImage, transitionJacketBgScrollAlpha, 0) - - gfx.BeginPath(); - gfx.FillColor(0,0,0,math.floor(transitionJacketBgScrollAlpha*64)); - gfx.Rect(0,0,900,900); - gfx.Fill(); - gfx.ClosePath(); - gfx.BeginPath(); + if (not isFilterWheelActive) then + -- If the score for song exists + if song and diff then + local jacketImage = getJacketImage(song); + gfx.BeginPath() + gfx.ImageRect(transitionJacketBgScrollPosX, 0, 900, 900, jacketImage or defaultJacketImage, transitionJacketBgScrollAlpha, 0) + + + gfx.BeginPath(); + gfx.FillColor(0,0,0,math.floor(transitionJacketBgScrollAlpha*64)); + gfx.Rect(0,0,900,900); + gfx.Fill(); + gfx.ClosePath(); + end end + gfx.BeginPath(); gfx.ImageRect(0, 0, desw, desh, dataPanelImage, 1, 0) drawLaserAnim() - if song and diff then + if song and diff and (not isFilterWheelActive) then gfx.BeginPath() gfx.ImageRect(0, 0, desw, desh, dataGlowOverlayImage, transitionAfterscrollDataOverlayAlpha, 0) gfx.BeginPath() @@ -351,6 +356,8 @@ function drawSong(song, y) end function drawSongList() + gfx.GlobalAlpha(1-transitionLeaveScale); + local numOfSongsAround = 7; -- How many songs should be up and how many should be down of the selected one local yOffset = transitionLeaveOffsetY + transitionScrollOffsetY; @@ -371,10 +378,15 @@ function drawSongList() drawSong(songwheel.songs[songIndex], desh/2-songPlateHeight/2+songPlateHeight*i + yOffset) i=i+1; end; + + gfx.GlobalAlpha(1); end local scoreNumbers = load_number_image("score_num"); function drawData() -- Draws the song data on the left panel + + if isFilterWheelActive then return false end; + local song = songwheel.songs[selectedIndex]; local diff = song and song.difficulties[selectedDifficulty] or false; local bestScore = diff and diff.scores[1]; @@ -689,21 +701,26 @@ function tickTransitions(deltaTime) transitionFlashAlpha = 1+transitionFlashAlpha*0.5 -- Leave transition - if (transitionLeaveReverse) then - if transitionLeaveScale > 0 then - transitionLeaveScale = transitionLeaveScale - deltaTime / 0.5 -- transition should last for that time in seconds - else - transitionLeaveScale = 0 - end - else + if (isFilterWheelActive) then if transitionLeaveScale < 1 then - transitionLeaveScale = transitionLeaveScale + deltaTime / 0.5 -- transition should last for that time in seconds + transitionLeaveScale = transitionLeaveScale + deltaTime / TRANSITION_LEAVE_DURATION -- transition should last for that time in seconds else transitionLeaveScale = 1 end - end + transitionLeaveReappearTimer = 1; + transitionAfterscrollScale = 0; -- Keep songwheel in the "afterscroll" state while the filterwheel is active + else + if (transitionLeaveReappearTimer == 1) then + -- This stuff happens right after filterwheel is deactivated + end - transitionLeaveOffsetY = Easing.inOutQuad(transitionLeaveScale) * (desh+songPlateHeight*2+145); + transitionLeaveReappearTimer = transitionLeaveReappearTimer - deltaTime / TRANSITION_LEAVE_DURATION + 0.05 -- 0.05s is a few frames between the completetion of the fade out and songs reappearing in the AC + + if (transitionLeaveReappearTimer <= 0) then + transitionLeaveScale = 0; + transitionLeaveReappearTimer = 0; + end + end end @@ -720,24 +737,20 @@ render = function (deltaTime) drawSongList() + isFilterWheelActive = game.GetSkinSetting('_songWheelOverlayActive') == 1; + drawData() drawFilterInfo(deltaTime) drawSearch(); - if (game.GetSkinSetting('_songWheelOverlayActive') ~= 1) then - transitionLeaveReverse = true; - else - transitionLeaveReverse = false; - end - gfx.BeginPath(); gfx.FontSize(18) gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP) local debugScrollingUp= "FALSE" if scrollingUp then debugScrollingUp = "TRUE" end; - -- gfx.Text('S_I: ' .. selectedIndex .. ' // S_D: ' .. selectedDifficulty .. ' // S_UP: ' .. debugScrollingUp .. ' // AC_TS: ' .. transitionAfterscrollScale, 8, 8); + gfx.Text('S_I: ' .. selectedIndex .. ' // S_D: ' .. selectedDifficulty .. ' // S_UP: ' .. debugScrollingUp .. ' // AC_TS: ' .. transitionAfterscrollScale .. ' // L_TS: ' .. transitionLeaveScale, 8, 8); end songs_changed = function (withAll)