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