diff --git a/scripts/common.lua b/scripts/common.lua index 63cba2b..8e02166 100644 --- a/scripts/common.lua +++ b/scripts/common.lua @@ -145,4 +145,12 @@ function GetDisplayDifficulty(jacketPath, difficulty) end return difficulty+1 +end + +function split(s, delimiter) + result = {}; + for match in (s..delimiter):gmatch("(.-)"..delimiter) do + table.insert(result, match); + end + return result; end \ No newline at end of file diff --git a/scripts/songselect/songwheel.lua b/scripts/songselect/songwheel.lua index cf03bfc..db3caed 100644 --- a/scripts/songselect/songwheel.lua +++ b/scripts/songselect/songwheel.lua @@ -130,6 +130,12 @@ local transitionAfterscrollJacketBgAlpha = 0; local transitionLaserScale = 0; local transitionLaserY = 0; +-- Flash transition (animation) +-- Used for flashing the badges +-- 0 = minimum brightness; 0.5 = maximum brightness; 1 = minimum brightness again +local transitionFlashScale = 0; +local transitionFlashAlpha = 1; + local transitionLeaveReverse = false; local transitionLeaveScale = 0; local transitionLeaveOffsetY = 0; @@ -318,17 +324,29 @@ function drawSong(song, y) if selectedSongDifficulty.topBadge then badgeImage = badgeImages[selectedSongDifficulty.topBadge+1]; end + + local badgeAlpha = 1; + if (selectedSongDifficulty.topBadge >= 3) then + badgeAlpha = transitionFlashAlpha; -- If hard clear or above, flash the badge + end + gfx.BeginPath() - gfx.ImageRect(songX+282, y+44, 79, 69, badgeImage, 1, 0) + gfx.ImageRect(songX+282, y+44, 79, 69, badgeImage, badgeAlpha, 0) -- Draw grade local gradeImage = gradeImages.none; + local gradeAlpha = 1; + if bestScore then gradeImage = getGradeImageForScore(bestScore.score) + + if (bestScore.score >= gradeCutoffs.S) then + gradeAlpha = transitionFlashAlpha; -- If S, flash the badge + end end gfx.BeginPath(); - gfx.ImageRect(songX+391, y+47, 60, 60, gradeImage, 1, 0); + gfx.ImageRect(songX+391, y+47, 60, 60, gradeImage, gradeAlpha, 0); -- Draw top 50 label if applicable if (top50diffs[selectedSongDifficulty.id]) then @@ -609,6 +627,31 @@ function tickTransitions(deltaTime) transitionLaserY = desh - math.min(transitionLaserScale * 2 * desh, desh); + -- Flash transition + if transitionFlashScale < 1 then + local songBpm = 120; + if (songwheel.songs[selectedIndex]) then + songBpm = songwheel.songs[selectedIndex].bpm; + + -- Is a variable BPM + if (type(songBpm) == "string") then + local s = split(songBpm, '-'); + songBpm = tonumber(s[1]); -- Lowest bpm value + end + end + + transitionFlashScale = transitionFlashScale + deltaTime / (60/songBpm) -- transition should last for that time in seconds + else + transitionFlashScale = 0 + end + + if transitionFlashScale < 0.5 then + transitionFlashAlpha = transitionFlashScale * 2; + else + transitionFlashAlpha = 1-((transitionFlashScale-0.5) * 2); + end + transitionFlashAlpha = 1+transitionFlashAlpha*0.5 + -- Leave transition if (transitionLeaveReverse) then if transitionLeaveScale > 0 then