From 16bec98b486e86f5715cf1161bfbdb25c440ffd6 Mon Sep 17 00:00:00 2001 From: FajsiEx Date: Thu, 26 Aug 2021 19:50:33 +0200 Subject: [PATCH] + separate anim timer for jacket bg to have it on loop --- scripts/songselect/songwheel.lua | 35 +++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/scripts/songselect/songwheel.lua b/scripts/songselect/songwheel.lua index 164e31c..2d9083a 100644 --- a/scripts/songselect/songwheel.lua +++ b/scripts/songselect/songwheel.lua @@ -127,6 +127,10 @@ local transitionAfterscrollTextSongArtist = 0; local transitionAfterscrollDifficultiesAlpha = 0; local transitionAfterscrollJacketBgAlpha = 0; +local transitionJacketBgScrollScale = 0; +local transitionJacketBgScrollAlpha = 0; +local transitionJacketBgScrollPosX = 0; + local transitionLaserScale = 0; local transitionLaserY = 0; @@ -245,11 +249,11 @@ function drawBackground(deltaTime) if song and diff then local jacketImage = getJacketImage(song); gfx.BeginPath() - gfx.ImageRect(0+transitionAfterscrollScale*-300, 0, 900, 900, jacketImage or defaultJacketImage, transitionAfterscrollJacketBgAlpha, 0) + gfx.ImageRect(transitionJacketBgScrollPosX, 0, 900, 900, jacketImage or defaultJacketImage, transitionJacketBgScrollAlpha, 0) gfx.BeginPath(); - gfx.FillColor(0,0,0,math.floor(transitionAfterscrollJacketBgAlpha*64)); + gfx.FillColor(0,0,0,math.floor(transitionJacketBgScrollAlpha*64)); gfx.Rect(0,0,900,900); gfx.Fill(); gfx.ClosePath(); @@ -622,17 +626,27 @@ function tickTransitions(deltaTime) transitionAfterscrollDifficultiesAlpha = 1; end - -- Jacket background alpha - if transitionAfterscrollScale < 0.05 or transitionAfterscrollScale >= 1 then - transitionAfterscrollJacketBgAlpha = 0; - elseif transitionAfterscrollScale >= 0.05 and transitionAfterscrollScale < 0.1 then - transitionAfterscrollJacketBgAlpha = math.min(1, (transitionAfterscrollScale-0.05) / 0.05); - elseif transitionAfterscrollScale >= 0.95 and transitionAfterscrollScale < 1 then - transitionAfterscrollJacketBgAlpha = math.min(1, 1-((transitionAfterscrollScale-0.95) / 0.05)); + -- Jacket bg animation + if transitionJacketBgScrollScale < 1 then + transitionJacketBgScrollScale = transitionJacketBgScrollScale + deltaTime / 20 -- transition should last for that time in seconds else - transitionAfterscrollJacketBgAlpha = 1; + transitionJacketBgScrollScale = 0 end + if transitionJacketBgScrollScale < 0.05 or transitionJacketBgScrollScale >= 1 then + transitionJacketBgScrollAlpha = 0; + elseif transitionJacketBgScrollScale >= 0.05 and transitionJacketBgScrollScale < 0.1 then + transitionJacketBgScrollAlpha = math.min(1, (transitionJacketBgScrollScale-0.05) / 0.05); + elseif transitionJacketBgScrollScale >= 0.8 and transitionJacketBgScrollScale < 1 then + transitionJacketBgScrollAlpha = math.max(0, + math.min(1, 1-((transitionJacketBgScrollScale-0.8) / 0.05)) + ); + else + transitionJacketBgScrollAlpha = 1; + end + + transitionJacketBgScrollPosX = 0+(transitionJacketBgScrollScale*(0.8/1))*-300; + -- Laser anim if transitionLaserScale < 1 then transitionLaserScale = transitionLaserScale + deltaTime / 2 -- transition should last for that time in seconds @@ -751,6 +765,7 @@ end set_index = function(newIndex) transitionScrollScale = 0; transitionAfterscrollScale = 0; + transitionJacketBgScrollScale = 0; scrollingUp = false; if ((newIndex > selectedIndex and not (newIndex == #songwheel.songs and selectedIndex == 1)) or (newIndex == 1 and selectedIndex == #songwheel.songs)) then