This commit is contained in:
Kolo 2025-04-04 16:04:03 -04:00 committed by GitHub
commit d0f0d53a5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -427,8 +427,6 @@ class StoryMenuState extends MusicBeatState
{
var item:LevelTitle = levelTitles.members[index];
item.targetY = (index - currentIndex) * 125 + 480;
if (index == currentIndex)
{
currentLevelTitle = item;
@ -442,6 +440,7 @@ class StoryMenuState extends MusicBeatState
if (currentIndex != prevIndex) FunkinSound.playOnce(Paths.sound('scrollMenu'), 0.4);
repositionTitles();
updateText();
updateBackground(previousLevelId);
updateProps();
@ -662,4 +661,37 @@ class StoryMenuState extends MusicBeatState
highScore = levelScore?.score ?? 0;
// levelScore.accuracy
}
/**
* Reposition titles based on the currently selected one.
*/
function repositionTitles()
{
var currentIndex:Int = levelList.indexOf(currentLevelId);
// The current item should be at y 480.
levelTitles.members[currentIndex].targetY = 480;
// Every item above it should be positioned in relation to the next item.
if (currentIndex > 0)
{
var i:Int = currentIndex - 1;
while (i >= 0)
{
var nextItem:LevelTitle = levelTitles.members[i + 1];
levelTitles.members[i].targetY = nextItem.targetY - (levelTitles.members[i].height + 20);
i--;
}
}
// Every item below it should be positioned in relation to the previous item.
if (currentIndex < levelTitles.members.length - 1)
{
for (i in (currentIndex + 1)...levelTitles.members.length)
{
var previousItem:LevelTitle = levelTitles.members[i - 1];
levelTitles.members[i].targetY = previousItem.targetY + (previousItem.height + 20);
}
}
}
}