mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2025-04-21 19:31:52 -04:00
Merge 006f1c1848
into d31ef12363
This commit is contained in:
commit
d0f0d53a5b
1 changed files with 34 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue