From 1e5f90774ccaf00aef30d80b081878a0844436f0 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 1 May 2024 21:51:33 -0400 Subject: [PATCH] =?UTF-8?q?What=20if=20modded=20songs=20showed=20up=20in?= =?UTF-8?q?=20game=20with=20no=20extra=20work=3F=20=F0=9F=98=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../funkin/data/story/level/LevelRegistry.hx | 8 +++++ source/funkin/ui/freeplay/FreeplayState.hx | 2 +- source/funkin/ui/story/StoryMenuState.hx | 36 ++----------------- 3 files changed, 11 insertions(+), 35 deletions(-) diff --git a/source/funkin/data/story/level/LevelRegistry.hx b/source/funkin/data/story/level/LevelRegistry.hx index e94b5870b..ad580953e 100644 --- a/source/funkin/data/story/level/LevelRegistry.hx +++ b/source/funkin/data/story/level/LevelRegistry.hx @@ -1,5 +1,6 @@ package funkin.data.story.level; +import funkin.util.SortUtil; import funkin.ui.story.Level; import funkin.data.story.level.LevelData; import funkin.ui.story.ScriptedLevel; @@ -105,6 +106,13 @@ class LevelRegistry extends BaseRegistry ]; } + public function listSortedLevelIds():Array + { + var result = listEntryIds(); + result.sort(SortUtil.defaultsThenAlphabetically.bind(listBaseGameLevelIds())); + return result; + } + /** * A list of all installed story weeks that are not from the base game. */ diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index a030f6a76..dd2299490 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -189,7 +189,7 @@ class FreeplayState extends MusicBeatSubState displayedVariations = (currentCharacter == 'bf') ? [Constants.DEFAULT_VARIATION, 'erect'] : [currentCharacter]; // programmatically adds the songs via LevelRegistry and SongRegistry - for (levelId in LevelRegistry.instance.listBaseGameLevelIds()) + for (levelId in LevelRegistry.instance.listSortedLevelIds()) { for (songId in LevelRegistry.instance.parseEntryData(levelId).songs) { diff --git a/source/funkin/ui/story/StoryMenuState.hx b/source/funkin/ui/story/StoryMenuState.hx index d8bfd59fb..daab5aef8 100644 --- a/source/funkin/ui/story/StoryMenuState.hx +++ b/source/funkin/ui/story/StoryMenuState.hx @@ -43,8 +43,6 @@ class StoryMenuState extends MusicBeatState var exitingMenu:Bool = false; var selectedLevel:Bool = false; - var displayingModdedLevels:Bool = false; - // // RENDER OBJECTS // @@ -172,13 +170,6 @@ class StoryMenuState extends MusicBeatState scoreText.zIndex = 1000; add(scoreText); - modeText = new FlxText(10, 10, 0, 'Base Game Levels [TAB to switch]'); - modeText.setFormat('VCR OSD Mono', 32); - modeText.screenCenter(X); - modeText.visible = hasModdedLevels(); - modeText.zIndex = 1000; - add(modeText); - levelTitleText = new FlxText(FlxG.width * 0.7, 10, 0, 'LEVEL 1'); levelTitleText.setFormat('VCR OSD Mono', 32, FlxColor.WHITE, RIGHT); levelTitleText.alpha = 0.7; @@ -282,7 +273,7 @@ class StoryMenuState extends MusicBeatState { levelTitles.clear(); - var levelIds:Array = displayingModdedLevels ? LevelRegistry.instance.listModdedLevelIds() : LevelRegistry.instance.listBaseGameLevelIds(); + var levelIds:Array = LevelRegistry.instance.listSortedLevelIds(); if (levelIds.length == 0) levelIds = ['tutorial']; // Make sure there's at least one level to display. for (levelIndex in 0...levelIds.length) @@ -298,15 +289,6 @@ class StoryMenuState extends MusicBeatState } } - function switchMode(moddedLevels:Bool):Void - { - displayingModdedLevels = moddedLevels; - buildLevelTitles(); - - changeLevel(999999); // Jump past the end of the list to the beginning. - changeDifficulty(0); - } - override function update(elapsed:Float):Void { Conductor.instance.update(); @@ -315,9 +297,6 @@ class StoryMenuState extends MusicBeatState scoreText.text = 'LEVEL SCORE: ${Math.round(highScoreLerp)}'; - modeText.text = displayingModdedLevels ? 'Mods [TAB to switch]' : 'Base Game [TAB to switch]'; - modeText.screenCenter(X); - levelTitleText.text = currentLevel.getTitle(); levelTitleText.x = FlxG.width - (levelTitleText.width + 10); // Right align. @@ -372,11 +351,6 @@ class StoryMenuState extends MusicBeatState { leftDifficultyArrow.animation.play('idle'); } - - if (FlxG.keys.justPressed.TAB && modeText.visible) - { - switchMode(!displayingModdedLevels); - } } if (controls.ACCEPT) @@ -393,19 +367,13 @@ class StoryMenuState extends MusicBeatState } } - function hasModdedLevels():Bool - { - return false; - // return LevelRegistry.instance.listModdedLevelIds().length > 0; - } - /** * Changes the selected level. * @param change +1 (down), -1 (up) */ function changeLevel(change:Int = 0):Void { - var levelList:Array = displayingModdedLevels ? LevelRegistry.instance.listModdedLevelIds() : LevelRegistry.instance.listBaseGameLevelIds(); + var levelList:Array = LevelRegistry.instance.listSortedLevelIds(); if (levelList.length == 0) levelList = ['tutorial']; var currentIndex:Int = levelList.indexOf(currentLevelId);