From 167976c8ba50befeee6d6625a8b2674bdf852649 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Mon, 5 Feb 2024 13:35:30 -0500 Subject: [PATCH 01/13] Work in progress --- assets | 2 +- source/funkin/play/PlayState.hx | 17 ++++++++--- source/funkin/play/song/Song.hx | 34 +++++++++++++++------- source/funkin/ui/freeplay/FreeplayState.hx | 23 +++++++++++++-- source/funkin/util/tools/ArrayTools.hx | 18 ++++++++++++ 5 files changed, 76 insertions(+), 18 deletions(-) diff --git a/assets b/assets index b2f8b6a78..5479e17b1 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit b2f8b6a780316959d0a79adc6dbf61f9e4ca675f +Subproject commit 5479e17b1085f72e05f1c1f9e0a668ef832d3341 diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index cc9debf13..763c05640 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -87,6 +87,12 @@ typedef PlayStateParams = * @default `bf`, or the first character in the song's character list. */ ?targetCharacter:String, + /** + * The instrumental to play with. + * Significant if the `targetSong` supports alternate instrumentals. + * @default `null` + */ + ?targetInstrumental:String, /** * Whether the song should start in Practice Mode. * @default `false` @@ -448,7 +454,7 @@ class PlayState extends MusicBeatSubState function get_currentChart():SongDifficulty { if (currentSong == null || currentDifficulty == null) return null; - return currentSong.getDifficulty(currentDifficulty); + return currentSong.getDifficulty(currentDifficulty, currentPlayerId); } /** @@ -2650,13 +2656,16 @@ class PlayState extends MusicBeatSubState { // Stop the music. FlxG.sound.music.pause(); - vocals.stop(); + if (vocals != null) vocals.stop(); } else { FlxG.sound.music.pause(); - vocals.pause(); - remove(vocals); + if (vocals != null) + { + vocals.pause(); + remove(vocals); + } } // Remove reference to stage and remove sprites from it to save memory. diff --git a/source/funkin/play/song/Song.hx b/source/funkin/play/song/Song.hx index 0434607f3..52a1ba6f8 100644 --- a/source/funkin/play/song/Song.hx +++ b/source/funkin/play/song/Song.hx @@ -184,7 +184,10 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry + public inline function getDifficulty(?diffId:String, ?variation:String):Null { if (diffId == null) diffId = listDifficulties()[0]; - return difficulties.get(diffId); + if (variation == null) variation = Constants.DEFAULT_VARIATION; + var variationSuffix = (variation != null && variation != '' && variation != Constants.DEFAULT_VARIATION) ? '-$variation' : ''; + + return difficulties.get('$diffId$variationSuffix'); } /** @@ -272,12 +279,16 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry = difficulties.keys().array().filter(function(diffId:String):Bool { - if (variationId == null) return true; + // The difficulties array contains entries like 'normal', 'nightmare-erect', and 'normal-pico', + // so we have to map it to the actual difficulty names. + // We also filter out difficulties that don't match the variation or that don't exist. + + var diffFiltered:Array = difficulties.keys().array().map(function(diffId:String):Null { var difficulty:Null = difficulties.get(diffId); - if (difficulty == null) return false; - return difficulty.variation == variationId; - }); + if (difficulty == null) return null; + if (variationId != null && difficulty.variation != variationId) return null; + return difficulty.difficulty; + }).nonNull().unique(); diffFiltered.sort(SortUtil.defaultsThenAlphabetically.bind(Constants.DEFAULT_DIFFICULTY_LIST)); @@ -286,8 +297,9 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry = difficulties.get(diffId); + if (variationId == '') variationId = Constants.DEFAULT_VARIATION; + var variationSuffix:String = (variationId == Constants.DEFAULT_VARIATION) ? '' : '-$variationId'; + var difficulty:Null = difficulties.get('$diffId$variationSuffix'); return variationId == null ? (difficulty != null) : (difficulty != null && difficulty.variation == variationId); } diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index de6484fd3..f981357cf 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -54,6 +54,14 @@ import funkin.util.MathUtil; import lime.app.Future; import lime.utils.Assets; +/** + * Parameters used to initialize the FreeplayState. + */ +typedef FreeplayStateParams = +{ + ?character:String; +}; + class FreeplayState extends MusicBeatSubState { var songs:Array> = []; @@ -64,6 +72,9 @@ class FreeplayState extends MusicBeatSubState var curSelected:Int = 0; var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY; + // Params + var currentCharacter:String; + var fp:FreeplayScore; var txtCompletion:AtlasText; var lerpCompletion:Float = 0; @@ -99,12 +110,13 @@ class FreeplayState extends MusicBeatSubState var stickerSubState:StickerSubState; - // static var rememberedDifficulty:Null = Constants.DEFAULT_DIFFICULTY; static var rememberedSongId:Null = null; - public function new(?stickers:StickerSubState = null) + public function new(?params:FreeplayParams, ?stickers:StickerSubState) { + currentCharacter = params?.character ?? Constants.DEFAULT_CHARACTER; + if (stickers != null) { stickerSubState = stickers; @@ -844,6 +856,13 @@ class FreeplayState extends MusicBeatSubState changeDiff(1); } + // TODO: DEBUG REMOVE THIS + if (FlxG.keys.justPressed.P) + { + currentCharacter = (currentCharacter == "bf") ? "pico" : "bf"; + changeSelection(0); + } + if (controls.BACK && !typing.hasFocus) { FlxTween.globalManager.clear(); diff --git a/source/funkin/util/tools/ArrayTools.hx b/source/funkin/util/tools/ArrayTools.hx index 0209cfc19..caf8e8aab 100644 --- a/source/funkin/util/tools/ArrayTools.hx +++ b/source/funkin/util/tools/ArrayTools.hx @@ -23,6 +23,24 @@ class ArrayTools return result; } + /** + * Returns a copy of the array with all `null` elements removed. + * @param array The array to remove `null` elements from. + * @return A copy of the array with all `null` elements removed. + */ + public static function nonNull(array:Array>):Array + { + var result:Array = []; + for (element in array) + { + if (element != null) + { + result.push(element); + } + } + return result; + } + /** * Return the first element of the array that satisfies the predicate, or null if none do. * @param input The array to search From e5fb1de4ba74412e7f3e6673a7223e8dbe373d37 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Mon, 5 Feb 2024 19:46:11 -0500 Subject: [PATCH 02/13] Fix a boatload of deprecation warnings and upgrade a few libraries. --- Project.xml | 3 +- hmm.json | 18 ++++--- .../transition/FlxTransitionableSubState.hx | 4 +- source/funkin/InitState.hx | 20 ++++---- source/funkin/play/GameOverSubState.hx | 4 +- source/funkin/play/GitarooPause.hx | 4 +- source/funkin/play/PauseSubState.hx | 4 +- source/funkin/play/PlayState.hx | 48 ++++++++++--------- source/funkin/play/ResultState.hx | 4 +- .../cutscene/dialogue/ConversationData.hx | 3 +- .../play/cutscene/dialogue/DialogueBoxData.hx | 3 +- .../play/cutscene/dialogue/SpeakerData.hx | 4 +- source/funkin/ui/MusicBeatState.hx | 2 +- source/funkin/ui/MusicBeatSubState.hx | 2 +- source/funkin/ui/debug/DebugMenuSubState.hx | 4 +- .../ui/debug/anim/DebugBoundingState.hx | 2 +- .../ui/debug/charting/ChartEditorState.hx | 2 +- .../charting/commands/CopyItemsCommand.hx | 2 +- .../handlers/ChartEditorAudioHandler.hx | 2 +- source/funkin/ui/haxeui/HaxeUISubState.hx | 2 +- source/funkin/ui/mainmenu/MainMenuState.hx | 9 ++-- source/funkin/ui/options/OptionsState.hx | 2 +- source/funkin/ui/story/StoryMenuState.hx | 4 +- source/funkin/ui/title/AttractState.hx | 2 +- source/funkin/ui/title/OutdatedSubState.hx | 2 +- source/funkin/ui/title/TitleState.hx | 9 ++-- source/funkin/ui/transition/LoadingState.hx | 18 +++---- .../funkin/ui/transition/StickerSubState.hx | 40 ++++++---------- .../util/plugins/EvacuateDebugPlugin.hx | 2 +- source/funkin/util/tools/Int64Tools.hx | 4 +- 30 files changed, 115 insertions(+), 114 deletions(-) diff --git a/Project.xml b/Project.xml index f5d506688..d09ee2dbb 100644 --- a/Project.xml +++ b/Project.xml @@ -108,7 +108,6 @@ - @@ -124,8 +123,8 @@ - diff --git a/hmm.json b/hmm.json index 4b2885a87..ebd760ac1 100644 --- a/hmm.json +++ b/hmm.json @@ -88,8 +88,10 @@ }, { "name": "hxcpp-debug-server", - "type": "haxelib", - "version": "1.2.4" + "type": "git", + "dir": "hxcpp-debug-server", + "ref": "147294123f983e35f50a966741474438069a7a8f", + "url": "https://github.com/FunkinCrew/hxcpp-debugger" }, { "name": "hxp", @@ -152,15 +154,17 @@ "ref": "cb11a95d0159271eb3587428cf4b9602e46dc469", "url": "https://github.com/larsiusprime/polymod" }, + { + "name": "thx.core", + "type": "git", + "dir": null, + "ref": "22605ff44f01971d599641790d6bae4869f7d9f4", + "url": "https://github.com/FunkinCrew/thx.core" + }, { "name": "thx.semver", "type": "haxelib", "version": "0.2.2" - }, - { - "name": "tink_json", - "type": "haxelib", - "version": "0.11.0" } ] } diff --git a/source/flixel/addons/transition/FlxTransitionableSubState.hx b/source/flixel/addons/transition/FlxTransitionableSubState.hx index 7bb536bb2..ab416adbc 100644 --- a/source/flixel/addons/transition/FlxTransitionableSubState.hx +++ b/source/flixel/addons/transition/FlxTransitionableSubState.hx @@ -16,7 +16,7 @@ import flixel.addons.transition.FlxTransitionableState; * var in:TransitionData = new TransitionData(...); // add your data where "..." is * var out:TransitionData = new TransitionData(...); * - * FlxG.switchState(new FooState(in,out)); + * FlxG.switchState(() -> new FooState(in,out)); * ``` * * Method 2: @@ -25,7 +25,7 @@ import flixel.addons.transition.FlxTransitionableState; * FlxTransitionableSubState.defaultTransIn = new TransitionData(...); * FlxTransitionableSubState.defaultTransOut = new TransitionData(...); * - * FlxG.switchState(new FooState()); + * FlxG.switchState(() -> new FooState()); * ``` */ class FlxTransitionableSubState extends FlxSubState diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index c9198c3d4..2e6974cf1 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -240,17 +240,17 @@ class InitState extends FlxState #elseif LEVEL // -DLEVEL=week1 -DDIFFICULTY=hard startLevel(defineLevel(), defineDifficulty()); #elseif FREEPLAY // -DFREEPLAY - FlxG.switchState(new FreeplayState()); + FlxG.switchState(() -> new funkin.ui.freeplay.FreeplayState()); #elseif ANIMATE // -DANIMATE - FlxG.switchState(new funkin.ui.debug.anim.FlxAnimateTest()); + FlxG.switchState(() -> new funkin.ui.debug.anim.FlxAnimateTest()); #elseif CHARTING // -DCHARTING - FlxG.switchState(new funkin.ui.debug.charting.ChartEditorState()); + FlxG.switchState(() -> new funkin.ui.debug.charting.ChartEditorState()); #elseif STAGEBUILD // -DSTAGEBUILD - FlxG.switchState(new funkin.ui.debug.stage.StageBuilderState()); + FlxG.switchState(() -> new funkin.ui.debug.stage.StageBuilderState()); #elseif ANIMDEBUG // -DANIMDEBUG - FlxG.switchState(new funkin.ui.debug.anim.DebugBoundingState()); + FlxG.switchState(() -> new funkin.ui.debug.anim.DebugBoundingState()); #elseif LATENCY // -DLATENCY - FlxG.switchState(new funkin.LatencyState()); + FlxG.switchState(() -> new funkin.LatencyState()); #else startGameNormally(); #end @@ -266,7 +266,7 @@ class InitState extends FlxState if (params.chart.shouldLoadChart) { - FlxG.switchState(new ChartEditorState( + FlxG.switchState(() -> new ChartEditorState( { fnfcTargetPath: params.chart.chartPath, })); @@ -274,7 +274,7 @@ class InitState extends FlxState else { FlxG.sound.cache(Paths.music('freakyMenu/freakyMenu')); - FlxG.switchState(new TitleState()); + FlxG.switchState(() -> new TitleState()); } } @@ -297,7 +297,7 @@ class InitState extends FlxState // TODO: Do this in the loading state. songData.cacheCharts(true); - LoadingState.loadAndSwitchState(new funkin.play.PlayState( + LoadingState.loadAndSwitchState(() -> new funkin.play.PlayState( { targetSong: songData, targetDifficulty: difficultyId, @@ -327,7 +327,7 @@ class InitState extends FlxState var targetSong:funkin.play.song.Song = SongRegistry.instance.fetchEntry(targetSongId); - LoadingState.loadAndSwitchState(new funkin.play.PlayState( + LoadingState.loadAndSwitchState(() -> new funkin.play.PlayState( { targetSong: targetSong, targetDifficulty: difficultyId, diff --git a/source/funkin/play/GameOverSubState.hx b/source/funkin/play/GameOverSubState.hx index 36f72237e..6027ea1ca 100644 --- a/source/funkin/play/GameOverSubState.hx +++ b/source/funkin/play/GameOverSubState.hx @@ -207,11 +207,11 @@ class GameOverSubState extends MusicBeatSubState } else if (PlayStatePlaylist.isStoryMode) { - FlxG.switchState(new StoryMenuState()); + FlxG.switchState(() -> new StoryMenuState()); } else { - FlxG.switchState(new FreeplayState()); + FlxG.switchState(() -> new FreeplayState()); } } diff --git a/source/funkin/play/GitarooPause.hx b/source/funkin/play/GitarooPause.hx index dbfbf5961..edeb4229c 100644 --- a/source/funkin/play/GitarooPause.hx +++ b/source/funkin/play/GitarooPause.hx @@ -66,11 +66,11 @@ class GitarooPause extends MusicBeatState { FlxTransitionableState.skipNextTransIn = false; FlxTransitionableState.skipNextTransOut = false; - FlxG.switchState(new PlayState(previousParams)); + FlxG.switchState(() -> new PlayState(previousParams)); } else { - FlxG.switchState(new MainMenuState()); + FlxG.switchState(() -> new MainMenuState()); } } diff --git a/source/funkin/play/PauseSubState.hx b/source/funkin/play/PauseSubState.hx index c9039ce40..f293919f3 100644 --- a/source/funkin/play/PauseSubState.hx +++ b/source/funkin/play/PauseSubState.hx @@ -234,11 +234,11 @@ class PauseSubState extends MusicBeatSubState if (PlayStatePlaylist.isStoryMode) { PlayStatePlaylist.reset(); - openSubState(new funkin.ui.transition.StickerSubState(null, STORY)); + openSubState(new funkin.ui.transition.StickerSubState(null, () -> new funkin.ui.story.StoryMenuState())); } else { - openSubState(new funkin.ui.transition.StickerSubState(null, FREEPLAY)); + openSubState(new funkin.ui.transition.StickerSubState(null, () -> new funkin.ui.freeplay.FreeplayState())); } case 'Exit to Chart Editor': diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 763c05640..c72ac1ed9 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -690,9 +690,9 @@ class PlayState extends MusicBeatSubState { message = 'The was a critical error selecting a difficulty for this song. Click OK to return to the main menu.'; } - else if (currentSong.getDifficulty(currentDifficulty) == null) + else if (currentChart == null) { - message = 'The was a critical error retrieving data for this song on "$currentDifficulty" difficulty. Click OK to return to the main menu.'; + message = 'The was a critical error retrieving data for this song on "$currentDifficulty" difficulty playing as "$currentPlayerId". Click OK to return to the main menu.'; } // Display a popup. This blocks the application until the user clicks OK. @@ -705,7 +705,7 @@ class PlayState extends MusicBeatSubState } else { - FlxG.switchState(new MainMenuState()); + FlxG.switchState(() -> new MainMenuState()); } return false; } @@ -834,7 +834,7 @@ class PlayState extends MusicBeatSubState // It's a reference to Gitaroo Man, which doesn't let you pause the game. if (!isSubState && event.gitaroo) { - FlxG.switchState(new GitarooPause( + FlxG.switchState(() -> new GitarooPause( { targetSong: currentSong, targetDifficulty: currentDifficulty, @@ -2235,7 +2235,7 @@ class PlayState extends MusicBeatSubState #end // Eject button - if (FlxG.keys.justPressed.F4) FlxG.switchState(new MainMenuState()); + if (FlxG.keys.justPressed.F4) FlxG.switchState(() -> new MainMenuState()); if (FlxG.keys.justPressed.F5) debug_refreshModules(); @@ -2253,7 +2253,7 @@ class PlayState extends MusicBeatSubState { disableKeys = true; persistentUpdate = false; - FlxG.switchState(new ChartEditorState( + FlxG.switchState(() -> new ChartEditorState( { targetSongId: currentSong.id, })); @@ -2595,14 +2595,16 @@ class PlayState extends MusicBeatSubState // TODO: Do this in the loading state. targetSong.cacheCharts(true); - var nextPlayState:PlayState = new PlayState( - { - targetSong: targetSong, - targetDifficulty: PlayStatePlaylist.campaignDifficulty, - targetCharacter: currentPlayerId, - }); - nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y); - LoadingState.loadAndSwitchState(nextPlayState); + LoadingState.loadAndSwitchState(() -> { + var nextPlayState:PlayState = new PlayState( + { + targetSong: targetSong, + targetDifficulty: PlayStatePlaylist.campaignDifficulty, + targetCharacter: currentPlayerId, + }); + nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y); + return nextPlayState; + }); }); } else @@ -2611,14 +2613,16 @@ class PlayState extends MusicBeatSubState // Load and cache the song's charts. // TODO: Do this in the loading state. targetSong.cacheCharts(true); - var nextPlayState:PlayState = new PlayState( - { - targetSong: targetSong, - targetDifficulty: PlayStatePlaylist.campaignDifficulty, - targetCharacter: currentPlayerId, - }); - nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y); - LoadingState.loadAndSwitchState(nextPlayState); + LoadingState.loadAndSwitchState(() -> { + var nextPlayState:PlayState = new PlayState( + { + targetSong: targetSong, + targetDifficulty: PlayStatePlaylist.campaignDifficulty, + targetCharacter: currentPlayerId, + }); + nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y); + return nextPlayState; + }); } } } diff --git a/source/funkin/play/ResultState.hx b/source/funkin/play/ResultState.hx index 507fa1236..caa576bcf 100644 --- a/source/funkin/play/ResultState.hx +++ b/source/funkin/play/ResultState.hx @@ -352,11 +352,11 @@ class ResultState extends MusicBeatSubState { if (params.storyMode) { - FlxG.switchState(new StoryMenuState()); + FlxG.switchState(() -> new StoryMenuState()); } else { - FlxG.switchState(new FreeplayState()); + FlxG.switchState(() -> new FreeplayState()); } } diff --git a/source/funkin/play/cutscene/dialogue/ConversationData.hx b/source/funkin/play/cutscene/dialogue/ConversationData.hx index 8c4aa9684..d36b75452 100644 --- a/source/funkin/play/cutscene/dialogue/ConversationData.hx +++ b/source/funkin/play/cutscene/dialogue/ConversationData.hx @@ -27,6 +27,7 @@ class ConversationData public static function fromString(i:String):ConversationData { + // TODO: Replace this with json2object. if (i == null || i == '') return null; var data: { @@ -35,7 +36,7 @@ class ConversationData ?outro:Dynamic, // TODO: tink.Json doesn't like when these are typed ?music:Dynamic, // TODO: tink.Json doesn't like when these are typed dialogue:Array // TODO: tink.Json doesn't like when these are typed - } = tink.Json.parse(i); + } = SerializerUtil.fromJSON(i); return fromJson(data); } diff --git a/source/funkin/play/cutscene/dialogue/DialogueBoxData.hx b/source/funkin/play/cutscene/dialogue/DialogueBoxData.hx index 801a01dd7..322a637e7 100644 --- a/source/funkin/play/cutscene/dialogue/DialogueBoxData.hx +++ b/source/funkin/play/cutscene/dialogue/DialogueBoxData.hx @@ -38,6 +38,7 @@ class DialogueBoxData public static function fromString(i:String):DialogueBoxData { + // TODO: Replace this with json2object. if (i == null || i == '') return null; var data: { @@ -51,7 +52,7 @@ class DialogueBoxData text:Dynamic, scale:Float, animations:Array - } = tink.Json.parse(i); + } = SerializerUtil.fromJSON(i); return fromJson(data); } diff --git a/source/funkin/play/cutscene/dialogue/SpeakerData.hx b/source/funkin/play/cutscene/dialogue/SpeakerData.hx index 88883ead8..7fe6a3b72 100644 --- a/source/funkin/play/cutscene/dialogue/SpeakerData.hx +++ b/source/funkin/play/cutscene/dialogue/SpeakerData.hx @@ -1,6 +1,7 @@ package funkin.play.cutscene.dialogue; import funkin.data.animation.AnimationData; +import funkin.util.SerializerUtil; /** * Data about a conversation. @@ -37,6 +38,7 @@ class SpeakerData public static function fromString(i:String):SpeakerData { + // TODO: Replace this with json2object. if (i == null || i == '') return null; var data: { @@ -48,7 +50,7 @@ class SpeakerData ?flipX:Bool, ?isPixel:Bool, ?scale:Float - } = tink.Json.parse(i); + } = SerializerUtil.fromJSON(i); return fromJson(data); } diff --git a/source/funkin/ui/MusicBeatState.hx b/source/funkin/ui/MusicBeatState.hx index 33333565f..884fc5061 100644 --- a/source/funkin/ui/MusicBeatState.hx +++ b/source/funkin/ui/MusicBeatState.hx @@ -74,7 +74,7 @@ class MusicBeatState extends FlxTransitionableState implements IEventHandler function handleFunctionControls():Void { // Emergency exit button. - if (FlxG.keys.justPressed.F4) FlxG.switchState(new MainMenuState()); + if (FlxG.keys.justPressed.F4) FlxG.switchState(() -> new MainMenuState()); // This can now be used in EVERY STATE YAY! if (FlxG.keys.justPressed.F5) debug_refreshModules(); diff --git a/source/funkin/ui/MusicBeatSubState.hx b/source/funkin/ui/MusicBeatSubState.hx index 0fa55c234..17c6e7fad 100644 --- a/source/funkin/ui/MusicBeatSubState.hx +++ b/source/funkin/ui/MusicBeatSubState.hx @@ -59,7 +59,7 @@ class MusicBeatSubState extends FlxTransitionableSubState implements IEventHandl else if (controls.VOLUME_DOWN) FlxG.sound.changeVolume(-0.1); // Emergency exit button. - if (FlxG.keys.justPressed.F4) FlxG.switchState(new MainMenuState()); + if (FlxG.keys.justPressed.F4) FlxG.switchState(() -> new MainMenuState()); // This can now be used in EVERY STATE YAY! if (FlxG.keys.justPressed.F5) debug_refreshModules(); diff --git a/source/funkin/ui/debug/DebugMenuSubState.hx b/source/funkin/ui/debug/DebugMenuSubState.hx index 404bf6f67..861e99f6b 100644 --- a/source/funkin/ui/debug/DebugMenuSubState.hx +++ b/source/funkin/ui/debug/DebugMenuSubState.hx @@ -87,12 +87,12 @@ class DebugMenuSubState extends MusicBeatSubState { FlxTransitionableState.skipNextTransIn = true; - FlxG.switchState(new ChartEditorState()); + FlxG.switchState(() -> new ChartEditorState()); } function openAnimationEditor() { - FlxG.switchState(new funkin.ui.debug.anim.DebugBoundingState()); + FlxG.switchState(() -> new funkin.ui.debug.anim.DebugBoundingState()); trace('Animation Editor'); } diff --git a/source/funkin/ui/debug/anim/DebugBoundingState.hx b/source/funkin/ui/debug/anim/DebugBoundingState.hx index 4e06913b4..5561a9dcd 100644 --- a/source/funkin/ui/debug/anim/DebugBoundingState.hx +++ b/source/funkin/ui/debug/anim/DebugBoundingState.hx @@ -364,7 +364,7 @@ class DebugBoundingState extends FlxState if (FlxG.keys.justPressed.H) hudCam.visible = !hudCam.visible; - if (FlxG.keys.justPressed.F4) FlxG.switchState(new MainMenuState()); + if (FlxG.keys.justPressed.F4) FlxG.switchState(() -> new MainMenuState()); MouseUtil.mouseCamDrag(); MouseUtil.mouseWheelZoom(); diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 467e36f74..686edb135 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -5037,7 +5037,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState stopWelcomeMusic(); // TODO: PR Flixel to make onComplete nullable. if (audioInstTrack != null) audioInstTrack.onComplete = null; - FlxG.switchState(new MainMenuState()); + FlxG.switchState(() -> new MainMenuState()); resetWindowTitle(); diff --git a/source/funkin/ui/debug/charting/commands/CopyItemsCommand.hx b/source/funkin/ui/debug/charting/commands/CopyItemsCommand.hx index 4361f867f..311451dcf 100644 --- a/source/funkin/ui/debug/charting/commands/CopyItemsCommand.hx +++ b/source/funkin/ui/debug/charting/commands/CopyItemsCommand.hx @@ -57,7 +57,7 @@ class CopyItemsCommand implements ChartEditorCommand state.txtCopyNotif.y = FlxG.mouse.y - 16; FlxTween.tween(state.txtCopyNotif, {y: state.txtCopyNotif.y - 32}, 0.5, { - type: FlxTween.ONESHOT, + type: FlxTweenType.ONESHOT, ease: FlxEase.quadOut, onComplete: function(_) { state.txtCopyNotif.visible = false; diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx index e1fcd1cb0..d5e888270 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx @@ -1,7 +1,7 @@ package funkin.ui.debug.charting.handlers; import flixel.system.FlxAssets.FlxSoundAsset; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; import funkin.audio.VoicesGroup; import funkin.audio.visualize.PolygonVisGroup; import funkin.audio.FunkinSound; diff --git a/source/funkin/ui/haxeui/HaxeUISubState.hx b/source/funkin/ui/haxeui/HaxeUISubState.hx index 82c15be4c..ac53f4b51 100644 --- a/source/funkin/ui/haxeui/HaxeUISubState.hx +++ b/source/funkin/ui/haxeui/HaxeUISubState.hx @@ -45,7 +45,7 @@ class HaxeUISubState extends MusicBeatSubState super.update(elapsed); // Force quit. - if (FlxG.keys.justPressed.F4) FlxG.switchState(new MainMenuState()); + if (FlxG.keys.justPressed.F4) FlxG.switchState(() -> new MainMenuState()); // Refresh the component. if (FlxG.keys.justPressed.F5) diff --git a/source/funkin/ui/mainmenu/MainMenuState.hx b/source/funkin/ui/mainmenu/MainMenuState.hx index f41eac07d..3da041ada 100644 --- a/source/funkin/ui/mainmenu/MainMenuState.hx +++ b/source/funkin/ui/mainmenu/MainMenuState.hx @@ -8,6 +8,7 @@ import flixel.FlxState; import flixel.addons.transition.FlxTransitionableState; import flixel.effects.FlxFlicker; import flixel.graphics.frames.FlxAtlasFrames; +import flixel.util.typeLimit.NextState; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.input.touch.FlxTouch; import flixel.text.FlxText; @@ -94,7 +95,7 @@ class MainMenuState extends MusicBeatState }); menuItems.enabled = true; // can move on intro - createMenuItem('storymode', 'mainmenu/storymode', function() startExitState(new StoryMenuState())); + createMenuItem('storymode', 'mainmenu/storymode', function() startExitState(() -> new StoryMenuState())); createMenuItem('freeplay', 'mainmenu/freeplay', function() { persistentDraw = true; persistentUpdate = false; @@ -110,7 +111,7 @@ class MainMenuState extends MusicBeatState #end createMenuItem('options', 'mainmenu/options', function() { - startExitState(new funkin.ui.options.OptionsState()); + startExitState(() -> new funkin.ui.options.OptionsState()); }); // Reset position of menu items. @@ -255,7 +256,7 @@ class MainMenuState extends MusicBeatState openSubState(prompt); } - function startExitState(state:FlxState) + function startExitState(state:NextState) { menuItems.enabled = false; // disable for exit var duration = 0.4; @@ -313,7 +314,7 @@ class MainMenuState extends MusicBeatState if (controls.BACK && menuItems.enabled && !menuItems.busy) { FlxG.sound.play(Paths.sound('cancelMenu')); - FlxG.switchState(new TitleState()); + FlxG.switchState(() -> new TitleState()); } } } diff --git a/source/funkin/ui/options/OptionsState.hx b/source/funkin/ui/options/OptionsState.hx index 53d972af1..7b233f03d 100644 --- a/source/funkin/ui/options/OptionsState.hx +++ b/source/funkin/ui/options/OptionsState.hx @@ -103,7 +103,7 @@ class OptionsState extends MusicBeatState { currentPage.enabled = false; // TODO: Animate this transition? - FlxG.switchState(new MainMenuState()); + FlxG.switchState(() -> new MainMenuState()); } } diff --git a/source/funkin/ui/story/StoryMenuState.hx b/source/funkin/ui/story/StoryMenuState.hx index 112817f42..2f0111841 100644 --- a/source/funkin/ui/story/StoryMenuState.hx +++ b/source/funkin/ui/story/StoryMenuState.hx @@ -397,7 +397,7 @@ class StoryMenuState extends MusicBeatState { FlxG.sound.play(Paths.sound('cancelMenu')); exitingMenu = true; - FlxG.switchState(new MainMenuState()); + FlxG.switchState(() -> new MainMenuState()); } } @@ -565,7 +565,7 @@ class StoryMenuState extends MusicBeatState FlxTransitionableState.skipNextTransIn = false; FlxTransitionableState.skipNextTransOut = false; - LoadingState.loadAndSwitchState(new PlayState( + LoadingState.loadAndSwitchState(() -> new PlayState( { targetSong: targetSong, targetDifficulty: PlayStatePlaylist.campaignDifficulty, diff --git a/source/funkin/ui/title/AttractState.hx b/source/funkin/ui/title/AttractState.hx index 38cff7cc8..ade24bffa 100644 --- a/source/funkin/ui/title/AttractState.hx +++ b/source/funkin/ui/title/AttractState.hx @@ -105,6 +105,6 @@ class AttractState extends MusicBeatState vid.destroy(); vid = null; - FlxG.switchState(new TitleState()); + FlxG.switchState(() -> new TitleState()); } } diff --git a/source/funkin/ui/title/OutdatedSubState.hx b/source/funkin/ui/title/OutdatedSubState.hx index 012823541..bc938f24a 100644 --- a/source/funkin/ui/title/OutdatedSubState.hx +++ b/source/funkin/ui/title/OutdatedSubState.hx @@ -39,7 +39,7 @@ class OutdatedSubState extends MusicBeatState if (controls.BACK) { leftState = true; - FlxG.switchState(new MainMenuState()); + FlxG.switchState(() -> new MainMenuState()); } super.update(elapsed); } diff --git a/source/funkin/ui/title/TitleState.hx b/source/funkin/ui/title/TitleState.hx index a5dcd6def..5424e2255 100644 --- a/source/funkin/ui/title/TitleState.hx +++ b/source/funkin/ui/title/TitleState.hx @@ -9,6 +9,7 @@ import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxDirectionFlags; import flixel.util.FlxTimer; +import flixel.util.typeLimit.NextState; import funkin.audio.visualize.SpectogramSprite; import funkin.graphics.shaders.ColorSwap; import funkin.graphics.shaders.LeftMaskShader; @@ -213,7 +214,7 @@ class TitleState extends MusicBeatState */ function moveToAttract():Void { - FlxG.switchState(new AttractState()); + FlxG.switchState(() -> new AttractState()); } function playMenuMusic():Void @@ -294,7 +295,7 @@ class TitleState extends MusicBeatState { if (touch.justPressed) { - FlxG.switchState(new FreeplayState()); + FlxG.switchState(() -> new FreeplayState()); pressedEnter = true; } } @@ -313,7 +314,7 @@ class TitleState extends MusicBeatState // If you spam Enter, we should skip the transition. if (pressedEnter && transitioning && skippedIntro) { - FlxG.switchState(new MainMenuState()); + FlxG.switchState(() -> new MainMenuState()); } if (pressedEnter && !transitioning && skippedIntro) @@ -328,7 +329,7 @@ class TitleState extends MusicBeatState FlxG.sound.play(Paths.sound('confirmMenu'), 0.7); transitioning = true; - var targetState:FlxState = new MainMenuState(); + var targetState:NextState = () -> new MainMenuState(); new FlxTimer().start(2, function(tmr:FlxTimer) { // These assets are very unlikely to be used for the rest of gameplay, so it unloads them from cache/memory diff --git a/source/funkin/ui/transition/LoadingState.hx b/source/funkin/ui/transition/LoadingState.hx index da9aeb28b..63dcb8f68 100644 --- a/source/funkin/ui/transition/LoadingState.hx +++ b/source/funkin/ui/transition/LoadingState.hx @@ -1,7 +1,6 @@ package funkin.ui.transition; import flixel.FlxSprite; -import flixel.FlxState; import flixel.math.FlxMath; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; @@ -21,12 +20,13 @@ import lime.utils.AssetManifest; import lime.utils.Assets as LimeAssets; import openfl.filters.ShaderFilter; import openfl.utils.Assets; +import flixel.util.typeLimit.NextState; class LoadingState extends MusicBeatState { inline static var MIN_TIME = 1.0; - var target:FlxState; + var target:NextState; var stopMusic = false; var callbacks:MultiCallback; var danceLeft = false; @@ -34,7 +34,7 @@ class LoadingState extends MusicBeatState var loadBar:FlxSprite; var funkay:FlxSprite; - function new(target:FlxState, stopMusic:Bool) + function new(target:NextState, stopMusic:Bool) { super(); this.target = target; @@ -172,12 +172,12 @@ class LoadingState extends MusicBeatState return Paths.inst(PlayState.instance.currentSong.id); } - inline static public function loadAndSwitchState(nextState:FlxState, shouldStopMusic = false):Void + inline static public function loadAndSwitchState(nextState:NextState, shouldStopMusic = false):Void { FlxG.switchState(getNextState(nextState, shouldStopMusic)); } - static function getNextState(nextState:FlxState, shouldStopMusic = false):FlxState + static function getNextState(nextState:NextState, shouldStopMusic = false):NextState { Paths.setCurrentLevel(PlayStatePlaylist.campaignId); @@ -186,7 +186,7 @@ class LoadingState extends MusicBeatState // && (!PlayState.currentSong.needsVoices || isSoundLoaded(getVocalPath())) // && isLibraryLoaded('shared'); // - if (true) return new LoadingState(nextState, shouldStopMusic); + if (true) return () -> new LoadingState(nextState, shouldStopMusic); #end if (shouldStopMusic && FlxG.sound.music != null) FlxG.sound.music.stop(); @@ -332,7 +332,7 @@ class MultiCallback public function getUnfired():ArrayVoid> return unfired.array(); - public static function coolSwitchState(state:FlxState, transitionTex:String = "shaderTransitionStuff/coolDots", time:Float = 2) + public static function coolSwitchState(state:NextState, transitionTex:String = "shaderTransitionStuff/coolDots", time:Float = 2) { var screenShit:FlxSprite = new FlxSprite().loadGraphic(Paths.image("shaderTransitionStuff/coolDots")); var screenWipeShit:ScreenWipeShader = new ScreenWipeShader(); @@ -343,9 +343,9 @@ class MultiCallback ease: FlxEase.quadInOut, onComplete: function(twn) { screenShit.destroy(); - FlxG.switchState(new MainMenuState()); + FlxG.switchState(state); } }); - FlxG.camera.setFilters([new ShaderFilter(screenWipeShit)]); + FlxG.camera.filters = [new ShaderFilter(screenWipeShit)]; } } diff --git a/source/funkin/ui/transition/StickerSubState.hx b/source/funkin/ui/transition/StickerSubState.hx index 1c012e00c..43ced1d7c 100644 --- a/source/funkin/ui/transition/StickerSubState.hx +++ b/source/funkin/ui/transition/StickerSubState.hx @@ -19,6 +19,7 @@ import funkin.ui.freeplay.FreeplayState; import openfl.geom.Matrix; import openfl.display.Sprite; import openfl.display.Bitmap; +import flixel.FlxState; using Lambda; using StringTools; @@ -30,7 +31,12 @@ class StickerSubState extends MusicBeatSubState // yes... a damn OpenFL sprite!!! public var dipshit:Sprite; - var nextState:NEXTSTATE = FREEPLAY; + /** + * The state to switch to after the stickers are done. + * This is a FUNCTION so we can pass it directly to `FlxG.switchState()`, + * and we can add constructor parameters in the caller. + */ + var targetState:Void->FlxState; // what "folders" to potentially load from (as of writing only "keys" exist) var soundSelections:Array = []; @@ -38,10 +44,15 @@ class StickerSubState extends MusicBeatSubState var soundSelection:String = ""; var sounds:Array = []; - public function new(?oldStickers:Array, ?nextState:NEXTSTATE = FREEPLAY):Void + public function new(?oldStickers:Array, ?targetState:Void->FlxState):Void { super(); + if (targetState != null) + { + this.targetState = () -> new MainMenuState(); + } + // todo still // make sure that ONLY plays mp3/ogg files // if there's no mp3/ogg file, then it regenerates/reloads the random folder @@ -84,10 +95,6 @@ class StickerSubState extends MusicBeatSubState trace(sounds); - // trace(assetsInList); - - this.nextState = nextState; - grpStickers = new FlxTypedGroup(); add(grpStickers); @@ -241,20 +248,8 @@ class StickerSubState extends MusicBeatSubState dipshit.addChild(bitmap); FlxG.addChildBelowMouse(dipshit); - switch (nextState) - { - case FREEPLAY: - FlxG.switchState(new FreeplayState(this)); - case STORY: - FlxG.switchState(new StoryMenuState(this)); - case MAIN_MENU: - FlxG.switchState(new MainMenuState()); - default: - FlxG.switchState(new MainMenuState()); - } + FlxG.switchState(targetState); } - - // sticky.angle *= FlxG.random.float(0, 0.05); }); }); } @@ -368,10 +363,3 @@ typedef StickerShit = stickers:Map>, stickerPacks:Map> } - -enum abstract NEXTSTATE(String) -{ - var MAIN_MENU = 'mainmenu'; - var FREEPLAY = 'freeplay'; - var STORY = 'story'; -} diff --git a/source/funkin/util/plugins/EvacuateDebugPlugin.hx b/source/funkin/util/plugins/EvacuateDebugPlugin.hx index 1803c25ba..eb292b852 100644 --- a/source/funkin/util/plugins/EvacuateDebugPlugin.hx +++ b/source/funkin/util/plugins/EvacuateDebugPlugin.hx @@ -24,7 +24,7 @@ class EvacuateDebugPlugin extends FlxBasic if (FlxG.keys.justPressed.F4) { - FlxG.switchState(new funkin.ui.mainmenu.MainMenuState()); + FlxG.switchState(() -> new funkin.ui.mainmenu.MainMenuState()); } } diff --git a/source/funkin/util/tools/Int64Tools.hx b/source/funkin/util/tools/Int64Tools.hx index d53fa315d..b6ac84ade 100644 --- a/source/funkin/util/tools/Int64Tools.hx +++ b/source/funkin/util/tools/Int64Tools.hx @@ -18,9 +18,9 @@ class Int64Tools public static function toFloat(i:Int64):Float { - var f:Float = Int64.getLow(i); + var f:Float = i.low; if (f < 0) f += MAX_32_PRECISION; - return (Int64.getHigh(i) * MAX_32_PRECISION + f); + return (i.high * MAX_32_PRECISION + f); } public static function isToIntSafe(i:Int64):Bool From 82b63c02e10c22005ba1256620e7f71bc3f9a142 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Mon, 5 Feb 2024 21:35:58 -0500 Subject: [PATCH 03/13] Reworks to make Pico mode actually work. --- assets | 2 +- source/funkin/data/song/SongData.hx | 44 +++++----- source/funkin/play/PauseSubState.hx | 4 +- source/funkin/play/PlayState.hx | 24 +++--- source/funkin/play/components/HealthIcon.hx | 3 +- source/funkin/play/song/Song.hx | 81 +++++++++++++++---- .../ui/debug/charting/ChartEditorState.hx | 5 +- .../ChartEditorImportExportHandler.hx | 38 ++++----- source/funkin/ui/freeplay/FreeplayState.hx | 60 ++++++++------ source/funkin/ui/story/Level.hx | 3 +- .../funkin/ui/transition/StickerSubState.hx | 11 +-- 11 files changed, 167 insertions(+), 108 deletions(-) diff --git a/assets b/assets index 5479e17b1..49970e24e 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 5479e17b1085f72e05f1c1f9e0a668ef832d3341 +Subproject commit 49970e24e919de25f4dcef5bd47116f1877ee360 diff --git a/source/funkin/data/song/SongData.hx b/source/funkin/data/song/SongData.hx index 52b9c19d6..0a430f196 100644 --- a/source/funkin/data/song/SongData.hx +++ b/source/funkin/data/song/SongData.hx @@ -915,6 +915,28 @@ class SongNoteDataRaw implements ICloneable return SongNoteData.buildDirectionName(this.data, strumlineSize); } + /** + * The strumline index of the note, if applicable. + * Strips the direction from the data. + * + * 0 = player, 1 = opponent, etc. + */ + public function getStrumlineIndex(strumlineSize:Int = 4):Int + { + return Math.floor(this.data / strumlineSize); + } + + /** + * Returns true if the note is one that Boyfriend should try to hit (i.e. it's on his side). + * TODO: The name of this function is a little misleading; what about mines? + * @param strumlineSize Defaults to 4. + * @return True if it's Boyfriend's note. + */ + public function getMustHitNote(strumlineSize:Int = 4):Bool + { + return getStrumlineIndex(strumlineSize) == 0; + } + @:jignored var _stepTime:Null = null; @@ -1003,28 +1025,6 @@ abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw } } - /** - * The strumline index of the note, if applicable. - * Strips the direction from the data. - * - * 0 = player, 1 = opponent, etc. - */ - public inline function getStrumlineIndex(strumlineSize:Int = 4):Int - { - return Math.floor(this.data / strumlineSize); - } - - /** - * Returns true if the note is one that Boyfriend should try to hit (i.e. it's on his side). - * TODO: The name of this function is a little misleading; what about mines? - * @param strumlineSize Defaults to 4. - * @return True if it's Boyfriend's note. - */ - public inline function getMustHitNote(strumlineSize:Int = 4):Bool - { - return getStrumlineIndex(strumlineSize) == 0; - } - @:jignored public var isHoldNote(get, never):Bool; diff --git a/source/funkin/play/PauseSubState.hx b/source/funkin/play/PauseSubState.hx index f293919f3..d38e3ac87 100644 --- a/source/funkin/play/PauseSubState.hx +++ b/source/funkin/play/PauseSubState.hx @@ -234,11 +234,11 @@ class PauseSubState extends MusicBeatSubState if (PlayStatePlaylist.isStoryMode) { PlayStatePlaylist.reset(); - openSubState(new funkin.ui.transition.StickerSubState(null, () -> new funkin.ui.story.StoryMenuState())); + openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new funkin.ui.story.StoryMenuState())); } else { - openSubState(new funkin.ui.transition.StickerSubState(null, () -> new funkin.ui.freeplay.FreeplayState())); + openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new funkin.ui.freeplay.FreeplayState(null, sticker))); } case 'Exit to Chart Editor': diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index c72ac1ed9..ad2ea5a45 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -83,10 +83,10 @@ typedef PlayStateParams = */ ?targetDifficulty:String, /** - * The character to play as. - * @default `bf`, or the first character in the song's character list. + * The variation to play on. + * @default `Constants.DEFAULT_VARIATION` . */ - ?targetCharacter:String, + ?targetVariation:String, /** * The instrumental to play with. * Significant if the `targetSong` supports alternate instrumentals. @@ -153,9 +153,9 @@ class PlayState extends MusicBeatSubState public var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY; /** - * The player character being used for this level, as a character ID. + * The currently selected variation. */ - public var currentPlayerId:String = 'bf'; + public var currentVariation:String = Constants.DEFAULT_VARIATION; /** * The currently active Stage. This is the object containing all the props. @@ -454,7 +454,7 @@ class PlayState extends MusicBeatSubState function get_currentChart():SongDifficulty { if (currentSong == null || currentDifficulty == null) return null; - return currentSong.getDifficulty(currentDifficulty, currentPlayerId); + return currentSong.getDifficulty(currentDifficulty, currentVariation); } /** @@ -512,7 +512,7 @@ class PlayState extends MusicBeatSubState // Apply parameters. currentSong = params.targetSong; if (params.targetDifficulty != null) currentDifficulty = params.targetDifficulty; - if (params.targetCharacter != null) currentPlayerId = params.targetCharacter; + if (params.targetVariation != null) currentVariation = params.targetVariation; isPracticeMode = params.practiceMode ?? false; isMinimalMode = params.minimalMode ?? false; startTimestamp = params.startTimestamp ?? 0.0; @@ -692,7 +692,7 @@ class PlayState extends MusicBeatSubState } else if (currentChart == null) { - message = 'The was a critical error retrieving data for this song on "$currentDifficulty" difficulty playing as "$currentPlayerId". Click OK to return to the main menu.'; + message = 'The was a critical error retrieving data for this song on "$currentDifficulty" difficulty with variation "$currentVariation". Click OK to return to the main menu.'; } // Display a popup. This blocks the application until the user clicks OK. @@ -838,7 +838,7 @@ class PlayState extends MusicBeatSubState { targetSong: currentSong, targetDifficulty: currentDifficulty, - targetCharacter: currentPlayerId, + targetVariation: currentVariation, })); } else @@ -1395,7 +1395,7 @@ class PlayState extends MusicBeatSubState trace('Song difficulty could not be loaded.'); } - var currentCharacterData:SongCharacterData = currentChart.characters; // Switch the character we are playing as by manipulating currentPlayerId. + var currentCharacterData:SongCharacterData = currentChart.characters; // Switch the variation we are playing on by manipulating targetVariation. // // GIRLFRIEND @@ -2600,7 +2600,7 @@ class PlayState extends MusicBeatSubState { targetSong: targetSong, targetDifficulty: PlayStatePlaylist.campaignDifficulty, - targetCharacter: currentPlayerId, + targetVariation: currentVariation, }); nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y); return nextPlayState; @@ -2618,7 +2618,7 @@ class PlayState extends MusicBeatSubState { targetSong: targetSong, targetDifficulty: PlayStatePlaylist.campaignDifficulty, - targetCharacter: currentPlayerId, + targetVariation: currentVariation, }); nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y); return nextPlayState; diff --git a/source/funkin/play/components/HealthIcon.hx b/source/funkin/play/components/HealthIcon.hx index 0d90df5a0..420a4fdc4 100644 --- a/source/funkin/play/components/HealthIcon.hx +++ b/source/funkin/play/components/HealthIcon.hx @@ -148,11 +148,12 @@ class HealthIcon extends FlxSprite { if (characterId == 'bf-old') { - characterId = PlayState.instance.currentPlayerId; + PlayState.instance.currentStage.getBoyfriend().initHealthIcon(false); } else { characterId = 'bf-old'; + loadCharacter(characterId); } } diff --git a/source/funkin/play/song/Song.hx b/source/funkin/play/song/Song.hx index 52a1ba6f8..5100e1888 100644 --- a/source/funkin/play/song/Song.hx +++ b/source/funkin/play/song/Song.hx @@ -184,9 +184,7 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry = difficulties.get(diffId); + var variationSuffix = (variation != Constants.DEFAULT_VARIATION) ? '-$variation' : ''; + var difficulty:Null = difficulties.get('$diffId$variationSuffix'); if (difficulty == null) { trace('Fabricated new difficulty for $diffId.'); difficulty = new SongDifficulty(this, diffId, variation); var metadata = _metadata.get(variation); - var variationSuffix = (variation != null && variation != '' && variation != Constants.DEFAULT_VARIATION) ? '-$variation' : ''; difficulties.set('$diffId$variationSuffix', difficulty); if (metadata != null) @@ -258,26 +256,52 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry + public function getDifficulty(?diffId:String, ?variation:String, ?variations:Array):Null { - if (diffId == null) diffId = listDifficulties()[0]; - + if (diffId == null) diffId = listDifficulties(variation)[0]; if (variation == null) variation = Constants.DEFAULT_VARIATION; - var variationSuffix = (variation != null && variation != '' && variation != Constants.DEFAULT_VARIATION) ? '-$variation' : ''; + if (variations == null) variations = [variation]; - return difficulties.get('$diffId$variationSuffix'); + for (currentVariation in variations) + { + var variationSuffix = (currentVariation != Constants.DEFAULT_VARIATION) ? '-$currentVariation' : ''; + + if (difficulties.exists('$diffId$variationSuffix')) + { + return difficulties.get('$diffId$variationSuffix'); + } + } + + return null; + } + + public function getFirstValidVariation(?diffId:String, ?possibleVariations:Array):Null + { + if (variations == null) possibleVariations = variations; + if (diffId == null) diffId = listDifficulties(null, possibleVariations)[0]; + + for (variation in variations) + { + if (difficulties.exists('$diffId-$variation')) return variation; + } + + return null; } /** * List all the difficulties in this song. - * @param variationId Optionally filter by variation. + * @param variationId Optionally filter by a single variation. + * @param variationIds Optionally filter by multiple variations. * @return The list of difficulties. */ - public function listDifficulties(?variationId:String):Array + public function listDifficulties(?variationId:String, ?variationIds:Array):Array { - if (variationId == '') variationId = null; + if (variationIds == null) variationIds = []; + if (variationId != null) variationIds.push(variationId); // The difficulties array contains entries like 'normal', 'nightmare-erect', and 'normal-pico', // so we have to map it to the actual difficulty names. @@ -286,7 +310,7 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry = difficulties.keys().array().map(function(diffId:String):Null { var difficulty:Null = difficulties.get(diffId); if (difficulty == null) return null; - if (variationId != null && difficulty.variation != variationId) return null; + if (variationIds.length > 0 && !variationIds.contains(difficulty.variation)) return null; return difficulty.difficulty; }).nonNull().unique(); @@ -504,7 +528,8 @@ class SongDifficulty var suffix:String = (variation != null && variation != '' && variation != 'default') ? '-$variation' : ''; // Automatically resolve voices by removing suffixes. - // For example, if `Voices-bf-car.ogg` does not exist, check for `Voices-bf.ogg`. + // For example, if `Voices-bf-car-erect.ogg` does not exist, check for `Voices-bf-erect.ogg`. + // Then, check for `Voices-bf-car.ogg`, then `Voices-bf.ogg`. var playerId:String = characters.player; var voicePlayer:String = Paths.voices(this.song.id, '-$playerId$suffix'); @@ -516,6 +541,19 @@ class SongDifficulty // Try again. voicePlayer = playerId == '' ? null : Paths.voices(this.song.id, '-${playerId}$suffix'); } + if (voicePlayer == null) + { + // Try again without $suffix. + playerId = characters.player; + voicePlayer = Paths.voices(this.song.id, '-${playerId}'); + while (voicePlayer != null && !Assets.exists(voicePlayer)) + { + // Remove the last suffix. + playerId = playerId.split('-').slice(0, -1).join('-'); + // Try again. + voicePlayer = playerId == '' ? null : Paths.voices(this.song.id, '-${playerId}$suffix'); + } + } var opponentId:String = characters.opponent; var voiceOpponent:String = Paths.voices(this.song.id, '-${opponentId}$suffix'); @@ -526,6 +564,19 @@ class SongDifficulty // Try again. voiceOpponent = opponentId == '' ? null : Paths.voices(this.song.id, '-${opponentId}$suffix'); } + if (voiceOpponent == null) + { + // Try again without $suffix. + opponentId = characters.opponent; + voiceOpponent = Paths.voices(this.song.id, '-${opponentId}'); + while (voiceOpponent != null && !Assets.exists(voiceOpponent)) + { + // Remove the last suffix. + opponentId = opponentId.split('-').slice(0, -1).join('-'); + // Try again. + voiceOpponent = opponentId == '' ? null : Paths.voices(this.song.id, '-${opponentId}$suffix'); + } + } var result:Array = []; if (voicePlayer != null) result.push(voicePlayer); diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 686edb135..af7eed129 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -5037,7 +5037,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState stopWelcomeMusic(); // TODO: PR Flixel to make onComplete nullable. if (audioInstTrack != null) audioInstTrack.onComplete = null; - FlxG.switchState(() -> new MainMenuState()); + FlxG.switchState(() -> new MainMenuState()); resetWindowTitle(); @@ -5303,8 +5303,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { targetSong: targetSong, targetDifficulty: selectedDifficulty, - // TODO: Add this. - // targetCharacter: targetCharacter, + targetVariation: selectedVariation, practiceMode: playtestPracticeMode, minimalMode: minimal, startTimestamp: startTimestamp, diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx index 9c86269e8..2d8e6a71e 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx @@ -70,28 +70,28 @@ class ChartEditorImportExportHandler { state.loadInstFromAsset(Paths.inst(songId, '-$variation'), variation); } - } - for (difficultyId in song.listDifficulties()) - { - var diff:Null = song.getDifficulty(difficultyId); - if (diff == null) continue; + for (difficultyId in song.listDifficulties(variation)) + { + var diff:Null = song.getDifficulty(difficultyId, variation); + if (diff == null) continue; - var instId:String = diff.variation == Constants.DEFAULT_VARIATION ? '' : diff.variation; - var voiceList:Array = diff.buildVoiceList(); // SongDifficulty accounts for variation already. + var instId:String = diff.variation == Constants.DEFAULT_VARIATION ? '' : diff.variation; + var voiceList:Array = diff.buildVoiceList(); // SongDifficulty accounts for variation already. - if (voiceList.length == 2) - { - state.loadVocalsFromAsset(voiceList[0], diff.characters.player, instId); - state.loadVocalsFromAsset(voiceList[1], diff.characters.opponent, instId); - } - else if (voiceList.length == 1) - { - state.loadVocalsFromAsset(voiceList[0], diff.characters.player, instId); - } - else - { - trace('[WARN] Strange quantity of voice paths for difficulty ${difficultyId}: ${voiceList.length}'); + if (voiceList.length == 2) + { + state.loadVocalsFromAsset(voiceList[0], diff.characters.player, instId); + state.loadVocalsFromAsset(voiceList[1], diff.characters.opponent, instId); + } + else if (voiceList.length == 1) + { + state.loadVocalsFromAsset(voiceList[0], diff.characters.player, instId); + } + else + { + trace('[WARN] Strange quantity of voice paths for difficulty ${difficultyId}: ${voiceList.length}'); + } } } diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index f981357cf..e2f01fb13 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -59,11 +59,14 @@ import lime.utils.Assets; */ typedef FreeplayStateParams = { - ?character:String; + ?character:String, }; class FreeplayState extends MusicBeatSubState { + // Params, you can't change these without transitioning to a new FreeplayState. + final currentCharacter:String; + var songs:Array> = []; var diffIdsCurrent:Array = []; @@ -72,9 +75,6 @@ class FreeplayState extends MusicBeatSubState var curSelected:Int = 0; var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY; - // Params - var currentCharacter:String; - var fp:FreeplayScore; var txtCompletion:AtlasText; var lerpCompletion:Float = 0; @@ -102,6 +102,8 @@ class FreeplayState extends MusicBeatSubState var ostName:FlxText; var difficultyStars:DifficultyStars; + var displayedVariations:Array; + var dj:DJBoyfriend; var letterSort:LetterSort; @@ -113,7 +115,7 @@ class FreeplayState extends MusicBeatSubState static var rememberedDifficulty:Null = Constants.DEFAULT_DIFFICULTY; static var rememberedSongId:Null = null; - public function new(?params:FreeplayParams, ?stickers:StickerSubState) + public function new(?params:FreeplayStateParams, ?stickers:StickerSubState) { currentCharacter = params?.character ?? Constants.DEFAULT_CHARACTER; @@ -159,6 +161,10 @@ class FreeplayState extends MusicBeatSubState // Add a null entry that represents the RANDOM option songs.push(null); + // TODO: This makes custom variations disappear from Freeplay. Figure out a better solution later. + // Default character (BF) shows default and Erect variations. Pico shows only Pico variations. + displayedVariations = (currentCharacter == "bf") ? [Constants.DEFAULT_VARIATION, "erect"] : [currentCharacter]; + // programmatically adds the songs via LevelRegistry and SongRegistry for (levelId in LevelRegistry.instance.listBaseGameLevelIds()) { @@ -166,9 +172,12 @@ class FreeplayState extends MusicBeatSubState { var song:Song = SongRegistry.instance.fetchEntry(songId); - songs.push(new FreeplaySongData(levelId, songId, song)); + // Only display songs which actually have available charts for the current character. + var availableDifficultiesForSong = song.listDifficulties(displayedVariations); + if (availableDifficultiesForSong.length == 0) continue; - for (difficulty in song.listDifficulties()) + songs.push(new FreeplaySongData(levelId, songId, song, displayedVariations)); + for (difficulty in availableDifficultiesForSong) { diffIdsTotal.pushUnique(difficulty); } @@ -287,6 +296,8 @@ class FreeplayState extends MusicBeatSubState x: -dj.width * 1.6, speed: 0.5 }); + // TODO: Replace this. + if (currentCharacter == "pico") dj.visible = false; add(dj); var bgDad:FlxSprite = new FlxSprite(pinkBack.width * 0.75, 0).loadGraphic(Paths.image('freeplay/freeplayBGdad')); @@ -859,8 +870,11 @@ class FreeplayState extends MusicBeatSubState // TODO: DEBUG REMOVE THIS if (FlxG.keys.justPressed.P) { - currentCharacter = (currentCharacter == "bf") ? "pico" : "bf"; - changeSelection(0); + var newParams:FreeplayStateParams = + { + character: currentCharacter == "bf" ? "pico" : "bf", + }; + openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new funkin.ui.freeplay.FreeplayState(newParams, sticker))); } if (controls.BACK && !typing.hasFocus) @@ -914,7 +928,7 @@ class FreeplayState extends MusicBeatSubState } else { - FlxG.switchState(new MainMenuState()); + FlxG.switchState(() -> new MainMenuState()); } }); } @@ -1080,13 +1094,7 @@ class FreeplayState extends MusicBeatSubState return; } var targetDifficulty:String = currentDifficulty; - - // TODO: Implement Pico into the interface properly. - var targetCharacter:String = 'bf'; - if (FlxG.keys.pressed.P) - { - targetCharacter = 'pico'; - } + var targetVariation:String = targetSong.getFirstValidVariation(targetDifficulty); PlayStatePlaylist.campaignId = cap.songData.levelId; @@ -1100,11 +1108,11 @@ class FreeplayState extends MusicBeatSubState new FlxTimer().start(1, function(tmr:FlxTimer) { Paths.setCurrentLevel(cap.songData.levelId); - LoadingState.loadAndSwitchState(new PlayState( + LoadingState.loadAndSwitchState(() -> new PlayState( { targetSong: targetSong, targetDifficulty: targetDifficulty, - targetCharacter: targetCharacter, + targetVariation: targetVariation, }), true); }); } @@ -1269,31 +1277,33 @@ class FreeplaySongData public var songRating(default, null):Int = 0; public var currentDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY; + public var displayedVariations(default, null):Array = [Constants.DEFAULT_VARIATION]; function set_currentDifficulty(value:String):String { if (currentDifficulty == value) return value; currentDifficulty = value; - updateValues(); + updateValues(displayedVariations); return value; } - public function new(levelId:String, songId:String, song:Song) + public function new(levelId:String, songId:String, song:Song, ?displayedVariations:Array) { this.levelId = levelId; this.songId = songId; this.song = song; + if (displayedVariations != null) this.displayedVariations = displayedVariations; - updateValues(); + updateValues(displayedVariations); } - function updateValues():Void + function updateValues(displayedVariations:Array):Void { - this.songDifficulties = song.listDifficulties(); + this.songDifficulties = song.listDifficulties(displayedVariations); if (!this.songDifficulties.contains(currentDifficulty)) currentDifficulty = Constants.DEFAULT_DIFFICULTY; - var songDifficulty:SongDifficulty = song.getDifficulty(currentDifficulty); + var songDifficulty:SongDifficulty = song.getDifficulty(currentDifficulty, displayedVariations); if (songDifficulty == null) return; this.songName = songDifficulty.songName; this.songCharacter = songDifficulty.characters.opponent; diff --git a/source/funkin/ui/story/Level.hx b/source/funkin/ui/story/Level.hx index 1b9252fde..f0c39c13f 100644 --- a/source/funkin/ui/story/Level.hx +++ b/source/funkin/ui/story/Level.hx @@ -150,7 +150,8 @@ class Level implements IRegistryEntry if (firstSong != null) { - for (difficulty in firstSong.listDifficulties()) + // Don't display alternate characters in Story Mode. + for (difficulty in firstSong.listDifficulties([Constants.DEFAULT_VARIATION, "erect"])) { difficulties.push(difficulty); } diff --git a/source/funkin/ui/transition/StickerSubState.hx b/source/funkin/ui/transition/StickerSubState.hx index 43ced1d7c..fa36cfd50 100644 --- a/source/funkin/ui/transition/StickerSubState.hx +++ b/source/funkin/ui/transition/StickerSubState.hx @@ -36,7 +36,7 @@ class StickerSubState extends MusicBeatSubState * This is a FUNCTION so we can pass it directly to `FlxG.switchState()`, * and we can add constructor parameters in the caller. */ - var targetState:Void->FlxState; + var targetState:StickerSubState->FlxState; // what "folders" to potentially load from (as of writing only "keys" exist) var soundSelections:Array = []; @@ -44,14 +44,11 @@ class StickerSubState extends MusicBeatSubState var soundSelection:String = ""; var sounds:Array = []; - public function new(?oldStickers:Array, ?targetState:Void->FlxState):Void + public function new(?oldStickers:Array, ?targetState:StickerSubState->FlxState):Void { super(); - if (targetState != null) - { - this.targetState = () -> new MainMenuState(); - } + this.targetState = (targetState == null) ? ((sticker) -> new MainMenuState()) : targetState; // todo still // make sure that ONLY plays mp3/ogg files @@ -248,7 +245,7 @@ class StickerSubState extends MusicBeatSubState dipshit.addChild(bitmap); FlxG.addChildBelowMouse(dipshit); - FlxG.switchState(targetState); + FlxG.switchState(() -> targetState(this)); } }); }); From fa2aebdc5289617757d022ddd5e35ad4db5cc05d Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 7 Feb 2024 19:37:19 -0500 Subject: [PATCH 04/13] Use the correct assets submodule commit. --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 49970e24e..ac2566d53 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 49970e24e919de25f4dcef5bd47116f1877ee360 +Subproject commit ac2566d531ea5ea8eb0123786e315e6094a49a1d From 2dd5f476b58732a3bd9e1ee641a46aa029e91af9 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 8 Feb 2024 02:21:12 -0500 Subject: [PATCH 05/13] Fix a bug where alt instrumentals will load but not cache. --- source/funkin/play/song/Song.hx | 21 ++++++++++++++------- source/funkin/ui/story/Level.hx | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/source/funkin/play/song/Song.hx b/source/funkin/play/song/Song.hx index 5100e1888..970aebc57 100644 --- a/source/funkin/play/song/Song.hx +++ b/source/funkin/play/song/Song.hx @@ -319,12 +319,17 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry):Bool { - if (variationId == '') variationId = Constants.DEFAULT_VARIATION; - var variationSuffix:String = (variationId == Constants.DEFAULT_VARIATION) ? '' : '-$variationId'; - var difficulty:Null = difficulties.get('$diffId$variationSuffix'); - return variationId == null ? (difficulty != null) : (difficulty != null && difficulty.variation == variationId); + if (variationIds == null) variationIds = []; + if (variationId != null) variationIds.push(variationId); + + for (targetVariation in variationIds) + { + var variationSuffix = (targetVariation != Constants.DEFAULT_VARIATION) ? '-$targetVariation' : ''; + if (difficulties.exists('$diffId$variationSuffix')) return true; + } + return false; } /** @@ -481,12 +486,14 @@ class SongDifficulty { if (instrumental != '' && characters.altInstrumentals.contains(instrumental)) { - FlxG.sound.cache(Paths.inst(this.song.id, instrumental)); + var instId = '-$instrumental'; + FlxG.sound.cache(Paths.inst(this.song.id, instId)); } else { // Fallback to default instrumental. - FlxG.sound.cache(Paths.inst(this.song.id, characters.instrumental)); + var instId = (characters.instrumental ?? '') != '' ? '-${characters.instrumental}' : ''; + FlxG.sound.cache(Paths.inst(this.song.id, instId)); } } else diff --git a/source/funkin/ui/story/Level.hx b/source/funkin/ui/story/Level.hx index f0c39c13f..ea6940c4a 100644 --- a/source/funkin/ui/story/Level.hx +++ b/source/funkin/ui/story/Level.hx @@ -169,7 +169,7 @@ class Level implements IRegistryEntry for (difficulty in difficulties) { - if (!song.hasDifficulty(difficulty)) + if (!song.hasDifficulty(difficulty, [Constants.DEFAULT_VARIATION, "erect"])) { difficulties.remove(difficulty); } From 6f125a97b1a58cbec720eceb1c6c4da99c468b6c Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 9 Feb 2024 23:44:35 -0500 Subject: [PATCH 06/13] Fix idle animations for Pico. --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 53257161f..9308c50bd 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 53257161fae317ae018fadea4446df7e53915ca9 +Subproject commit 9308c50bd7fd904787e2fbac511bb83e1197347f From 92f52b2c3f62c3402d95562de45849ded60b02df Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 12 Feb 2024 23:15:18 -0500 Subject: [PATCH 07/13] flixel debugging on test builds --- .github/workflows/build-shit.yml | 8 ++++---- Project.xml | 12 +++--------- source/funkin/InitState.hx | 13 ++++++------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-shit.yml b/.github/workflows/build-shit.yml index 76126d106..8ea3b16f3 100644 --- a/.github/workflows/build-shit.yml +++ b/.github/workflows/build-shit.yml @@ -31,7 +31,7 @@ jobs: sudo apt-get install -y libx11-dev xorg-dev libgl-dev libxi-dev libxext-dev libasound2-dev libxinerama-dev libxrandr-dev libgl1-mesa-dev - name: build game run: | - haxelib run lime build html5 -release --times + haxelib run lime build html5 -release --times -DGITHUB_BUILD ls - uses: ./.github/actions/upload-itch with: @@ -68,7 +68,7 @@ jobs: key: ${{ runner.os }}-build-win-${{ github.ref_name }}-${{ hashFiles('**/hmm.json') }} - name: build game run: | - haxelib run lime build windows -release -DNO_REDIRECT_ASSETS_FOLDER + haxelib run lime build windows -release -DNO_REDIRECT_ASSETS_FOLDER -DGITHUB_BUILD dir env: HXCPP_COMPILE_CACHE: "${{ runner.temp }}\\hxcpp_cache" @@ -110,7 +110,7 @@ jobs: key: ${{ runner.os }}-build-mac-${{ github.ref_name }}-${{ hashFiles('**/hmm.json') }} - name: Build game run: | - haxelib run lime build macos -release --times + haxelib run lime build macos -release --times -DGITHUB_BUILD ls env: HXCPP_COMPILE_CACHE: "${{ runner.temp }}/hxcpp_cache" @@ -119,7 +119,7 @@ jobs: butler-key: ${{ secrets.BUTLER_API_KEY}} build-dir: export/release/macos/bin target: macos - + # test-unit-win: # needs: create-nightly-win # runs-on: windows-latest diff --git a/Project.xml b/Project.xml index 40f309e1f..560baeadf 100644 --- a/Project.xml +++ b/Project.xml @@ -91,7 +91,8 @@ NOT USING A DIRECT THING TO THE ASSET!!! --> - + + @@ -118,7 +119,7 @@ - + @@ -211,13 +212,6 @@ -
- - - - -
- --> --> diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index 625a33ad7..21946819f 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -144,13 +144,12 @@ class InitState extends FlxState // Make errors and warnings less annoying. // TODO: Disable this so we know to fix warnings. - if (false) - { - LogStyle.ERROR.openConsole = false; - LogStyle.ERROR.errorSound = null; - LogStyle.WARNING.openConsole = false; - LogStyle.WARNING.errorSound = null; - } + #if FORCE_DEBUG_VERSION + LogStyle.ERROR.openConsole = false; + LogStyle.ERROR.errorSound = null; + LogStyle.WARNING.openConsole = false; + LogStyle.WARNING.errorSound = null; + #end #end // From 5f5b2bb80b4fed29f5046dd26c046659372e6df4 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 13 Feb 2024 00:00:27 -0500 Subject: [PATCH 08/13] pico death animation loop fix --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 594853037..3e6c397d1 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 594853037cbea06caa5c141b0d9ed3736818e592 +Subproject commit 3e6c397d11d190fcbf90545dc35110b2bde7830c From 1d8e82b108a75455948d9ba8e292e6eda46fa029 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 13 Feb 2024 00:18:47 -0500 Subject: [PATCH 09/13] makes prebuild.hx actually run on prebuild --- Project.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.xml b/Project.xml index 560baeadf..d15a5affd 100644 --- a/Project.xml +++ b/Project.xml @@ -213,7 +213,7 @@ - --> + --> --> From 6e0f577d54f48b77c6e1e7e58cbeddc5311d8c57 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 13 Feb 2024 00:29:46 -0500 Subject: [PATCH 10/13] debugger fixes --- source/funkin/InitState.hx | 5 ++--- source/funkin/play/GameOverSubState.hx | 1 + source/funkin/play/PauseSubState.hx | 2 +- source/funkin/play/PlayState.hx | 20 +++++++++---------- .../ui/debug/charting/ChartEditorState.hx | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index 21946819f..09afe6cf4 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -89,7 +89,7 @@ class InitState extends FlxState // // FLIXEL DEBUG SETUP // - #if debug + #if (debug || FORCE_DEBUG_VERSION) // Disable using ~ to open the console (we use that for the Editor menu) FlxG.debugger.toggleKeys = [F2]; @@ -141,16 +141,15 @@ class InitState extends FlxState FlxG.sound.music.pause(); FlxG.sound.music.time += FlxG.elapsed * 1000; }); + #end // Make errors and warnings less annoying. - // TODO: Disable this so we know to fix warnings. #if FORCE_DEBUG_VERSION LogStyle.ERROR.openConsole = false; LogStyle.ERROR.errorSound = null; LogStyle.WARNING.openConsole = false; LogStyle.WARNING.errorSound = null; #end - #end // // FLIXEL TRANSITIONS diff --git a/source/funkin/play/GameOverSubState.hx b/source/funkin/play/GameOverSubState.hx index 36f72237e..f6d75c61b 100644 --- a/source/funkin/play/GameOverSubState.hx +++ b/source/funkin/play/GameOverSubState.hx @@ -90,6 +90,7 @@ class GameOverSubState extends MusicBeatSubState { animationSuffix = ""; musicSuffix = ""; + blueBallSuffix = ""; } override public function create() diff --git a/source/funkin/play/PauseSubState.hx b/source/funkin/play/PauseSubState.hx index c9039ce40..77999b60a 100644 --- a/source/funkin/play/PauseSubState.hx +++ b/source/funkin/play/PauseSubState.hx @@ -168,7 +168,7 @@ class PauseSubState extends MusicBeatSubState var downP = controls.UI_DOWN_P; var accepted = controls.ACCEPT; - #if debug + #if (debug || FORCE_DEBUG_VERSION) // to pause the game and get screenshots easy, press H on pause menu! if (FlxG.keys.justPressed.H) { diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index aee9f2210..c9d41f254 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -638,7 +638,7 @@ class PlayState extends MusicBeatSubState rightWatermarkText.cameras = [camHUD]; // Initialize some debug stuff. - #if debug + #if (debug || FORCE_DEBUG_VERSION) // Display the version number (and git commit hash) in the bottom right corner. this.rightWatermarkText.text = Constants.VERSION; @@ -907,7 +907,7 @@ class PlayState extends MusicBeatSubState // Disable updates, preventing animations in the background from playing. persistentUpdate = false; - #if debug + #if (debug || FORCE_DEBUG_VERSION) if (FlxG.keys.pressed.THREE) { // TODO: Change the key or delete this? @@ -918,7 +918,7 @@ class PlayState extends MusicBeatSubState { #end persistentDraw = false; - #if debug + #if (debug || FORCE_DEBUG_VERSION) } #end @@ -1368,7 +1368,7 @@ class PlayState extends MusicBeatSubState // Add the stage to the scene. this.add(currentStage); - #if debug + #if (debug || FORCE_DEBUG_VERSION) FlxG.console.registerObject('stage', currentStage); #end } @@ -1458,7 +1458,7 @@ class PlayState extends MusicBeatSubState { currentStage.addCharacter(girlfriend, GF); - #if debug + #if (debug || FORCE_DEBUG_VERSION) FlxG.console.registerObject('gf', girlfriend); #end } @@ -1467,7 +1467,7 @@ class PlayState extends MusicBeatSubState { currentStage.addCharacter(boyfriend, BF); - #if debug + #if (debug || FORCE_DEBUG_VERSION) FlxG.console.registerObject('bf', boyfriend); #end } @@ -1478,7 +1478,7 @@ class PlayState extends MusicBeatSubState // Camera starts at dad. cameraFollowPoint.setPosition(dad.cameraFocusPoint.x, dad.cameraFocusPoint.y); - #if debug + #if (debug || FORCE_DEBUG_VERSION) FlxG.console.registerObject('dad', dad); #end } @@ -2253,7 +2253,7 @@ class PlayState extends MusicBeatSubState })); } - #if debug + #if (debug || FORCE_DEBUG_VERSION) // 1: End the song immediately. if (FlxG.keys.justPressed.ONE) endSong(); @@ -2267,7 +2267,7 @@ class PlayState extends MusicBeatSubState // 9: Toggle the old icon. if (FlxG.keys.justPressed.NINE) iconP1.toggleOldIcon(); - #if debug + #if (debug || FORCE_DEBUG_VERSION) // PAGEUP: Skip forward two sections. // SHIFT+PAGEUP: Skip forward twenty sections. if (FlxG.keys.justPressed.PAGEUP) changeSection(FlxG.keys.pressed.SHIFT ? 20 : 2); @@ -2768,7 +2768,7 @@ class PlayState extends MusicBeatSubState FlxG.camera.focusOn(cameraFollowPoint.getPosition()); } - #if debug + #if (debug || FORCE_DEBUG_VERSION) /** * Jumps forward or backward a number of sections in the song. * Accounts for BPM changes, does not prevent death from skipped notes. diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index dab79a21c..759a54ec7 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -3183,7 +3183,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState handleTestKeybinds(); handleHelpKeybinds(); - #if debug + #if (debug || FORCE_DEBUG_VERSION) handleQuickWatch(); #end From 1ad17aa904153333b6ec26936a8c81c6c5055f2a Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 13 Feb 2024 00:45:29 -0500 Subject: [PATCH 11/13] flixel hmm update --- assets | 2 +- hmm.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets b/assets index 594853037..160acbd8a 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 594853037cbea06caa5c141b0d9ed3736818e592 +Subproject commit 160acbd8a854a9f677ef7587396340e79a5ea6ca diff --git a/hmm.json b/hmm.json index b42a67928..7321e731f 100644 --- a/hmm.json +++ b/hmm.json @@ -11,7 +11,7 @@ "name": "flixel", "type": "git", "dir": null, - "ref": "07c6018008801972d12275690fc144fcc22e3de6", + "ref": "25c84b29665329f7c6366342542a3978f29300ee", "url": "https://github.com/FunkinCrew/flixel" }, { From 681cfa0883d9ac823cc768301708bc5d14bf04d3 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 13 Feb 2024 01:16:09 -0500 Subject: [PATCH 12/13] chart editor waveform fixes for single vocal audio files --- .../charting/toolboxes/ChartEditorFreeplayToolbox.hx | 2 +- .../charting/toolboxes/ChartEditorOffsetsToolbox.hx | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx index 8d3554a08..c384e7a6d 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx @@ -290,7 +290,7 @@ class ChartEditorFreeplayToolbox extends ChartEditorBaseToolbox // waveformMusic.waveform.forceUpdate = true; var perfStart = haxe.Timer.stamp(); var waveformData1 = playerVoice.waveformData; - var waveformData2 = opponentVoice.waveformData; + var waveformData2 = opponentVoice?.waveformData ?? playerVoice.waveformData; // this null check is for songs that only have 1 vocals file! var waveformData3 = chartEditorState.audioInstTrack.waveformData; var waveformData = waveformData1.merge(waveformData2).merge(waveformData3); trace('Waveform data merging took: ${haxe.Timer.stamp() - perfStart} seconds'); diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx index 67ca82b1b..fd9209294 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx @@ -276,8 +276,13 @@ class ChartEditorOffsetsToolbox extends ChartEditorBaseToolbox // Build opponent waveform. // waveformOpponent.waveform.forceUpdate = true; - waveformOpponent.waveform.waveformData = opponentVoice.waveformData; - waveformOpponent.waveform.duration = opponentVoice.length / Constants.MS_PER_SEC; + // note: if song only has one set of vocals (Vocals.ogg/mp3) then this is null and crashes charting editor + // so we null check + if (opponentVoice != null) + { + waveformOpponent.waveform.waveformData = opponentVoice.waveformData; + waveformOpponent.waveform.duration = opponentVoice.length / Constants.MS_PER_SEC; + } // Build instrumental waveform. // waveformInstrumental.waveform.forceUpdate = true; From e3623311743dd0f8a6d799ea3311cf2b0f46a19b Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 13 Feb 2024 01:19:00 -0500 Subject: [PATCH 13/13] assets submod update --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 3e6c397d1..160acbd8a 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 3e6c397d11d190fcbf90545dc35110b2bde7830c +Subproject commit 160acbd8a854a9f677ef7587396340e79a5ea6ca