From 8f4c2636926e9a0e426db9068127e0d361c5c09d Mon Sep 17 00:00:00 2001 From: MaybeMaru <97055307+MaybeMaru@users.noreply.github.com> Date: Wed, 15 May 2024 00:30:03 +0200 Subject: [PATCH] reset cam position on changing stages --- source/funkin/Controls.hx | 8 ++++++-- source/funkin/Preferences.hx | 4 ++++ source/funkin/states/PlayState.hx | 7 ++++--- source/funkin/states/menus/MainMenuState.hx | 15 +++++++++------ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/source/funkin/Controls.hx b/source/funkin/Controls.hx index c021796c..f3172075 100644 --- a/source/funkin/Controls.hx +++ b/source/funkin/Controls.hx @@ -22,6 +22,7 @@ class Controls gamepad = FlxG.gamepads.lastActive; } + @:unreflective static function initSave():Void { var save:Dynamic = SaveData.getSave("controls"); var keyboardSave:Map> = save.get("keyboardBinds"); @@ -55,6 +56,7 @@ class Controls } } + @:unreflective public static function setupBindings():Void { controlArray = new Array(); initGamepad(); @@ -116,9 +118,9 @@ class Controls //@:deprecated("Use getKey with the inputType argument instead") public static function getKeyOld(key:String):Bool { key = key.toUpperCase(); - var parts:Array = key.split('-'); + var parts:Array = key.split('-'); - return getKey(parts[0], switch (parts[1]) { + return getKey(parts[0], switch (parts[1] ?? "") { case "R": JUST_RELEASED; case "P": JUST_PRESSED; default: PRESSED; @@ -167,6 +169,7 @@ class Controls public static var headers:Array = []; public static var headerContents:Map> = []; + @:unreflective static function addHeader(name:String) { if (name != curHeader) { curHeader = name; @@ -175,6 +178,7 @@ class Controls } } + @:unreflective private static function addBind(bind:String, keys:Array, gamepadKeys:Array):Void { bind = bind.toUpperCase().trim(); controlArray.push(bind); diff --git a/source/funkin/Preferences.hx b/source/funkin/Preferences.hx index cbef23bb..034f0603 100644 --- a/source/funkin/Preferences.hx +++ b/source/funkin/Preferences.hx @@ -23,6 +23,7 @@ class Preferences ]; #end + @:unreflective public static function setupPrefs():Void { prefsArray = []; preferences = SaveData.getSave('preferences'); @@ -79,6 +80,7 @@ class Preferences public static var headers:Array = []; public static var headerContents:Map> = []; + @:unreflective static function addHeader(name:String) { if (name != curHeader) { curHeader = name; @@ -87,6 +89,7 @@ class Preferences } } + @:unreflective public static function addPref(id:String, label:String, defaultValue:Dynamic):Void { id = id.toLowerCase().trim(); @@ -126,6 +129,7 @@ class Preferences updateGpuTextures(); } + @:unreflective private static function fixOldPrefs() { if (preferences.exists("ghost-tap")) { if (preferences.get("deghost-tap")) { diff --git a/source/funkin/states/PlayState.hx b/source/funkin/states/PlayState.hx index 97537e22..8c36a172 100644 --- a/source/funkin/states/PlayState.hx +++ b/source/funkin/states/PlayState.hx @@ -696,12 +696,13 @@ class PlayState extends MusicBeatState final nextSong:String = PlayState.storyPlaylist[0]; trace('LOADING NEXT SONG [$nextSong-$curDifficulty]'); - prevCamFollow = camFollow; - seenCutscene = false; - PlayState.SONG = Song.loadFromFile(curDifficulty, nextSong); Conductor.stop(); + // Reset cam follow if the stage changed + prevCamFollow = (SONG.stage == curStage) ? camFollow : null; + seenCutscene = false; + clearCache = true; clearCacheData = {tempCache: false, skins: false} ModdingUtil.addCall('switchSong', [nextSong, curDifficulty]); // Could be used to change cache clear diff --git a/source/funkin/states/menus/MainMenuState.hx b/source/funkin/states/menus/MainMenuState.hx index 65546055..d0cc8c63 100644 --- a/source/funkin/states/menus/MainMenuState.hx +++ b/source/funkin/states/menus/MainMenuState.hx @@ -2,8 +2,10 @@ package funkin.states.menus; import flixel.effects.FlxFlicker; import lime.app.Application; -class MainMenuState extends MusicBeatState { +class MainMenuState extends MusicBeatState +{ var magenta:FunkinSprite; + var versionText:FlxText; var camFollow:FlxObject; var optionShit:Array = [ @@ -12,6 +14,7 @@ class MainMenuState extends MusicBeatState { 'options', 'donate' ]; + var curSelected:Int = 0; var menuItems:TypedGroup; @@ -61,12 +64,12 @@ class MainMenuState extends MusicBeatState { FlxG.camera.follow(camFollow, null, 0.06); - var versionText:String = 'Mau Engin v${Main.engineVersion}\nFriday Night Funkin v${Application.current.meta.get('version')}'; + var txt:String = 'Mau Engin v${Main.engineVersion}\nFriday Night Funkin v${Application.current.meta.get('version')}'; - var versionShit:FlxText = new FlxText(5, FlxG.height - 18*2, 0, versionText, 12); - versionShit.scrollFactor.set(); - versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); - add(versionShit); + versionText = new FlxText(5, FlxG.height - 18*2, 0, txt, 12); + versionText.scrollFactor.set(); + versionText.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); + add(versionText); changeItem();