diff --git a/buildnumber.txt b/buildnumber.txt index 773855c9..035d0f0c 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -810 \ No newline at end of file +822 \ No newline at end of file diff --git a/source/funkin/desktop/DesktopMain.hx b/source/funkin/desktop/DesktopMain.hx index 038b6b19..40a0c3f7 100644 --- a/source/funkin/desktop/DesktopMain.hx +++ b/source/funkin/desktop/DesktopMain.hx @@ -68,6 +68,8 @@ class DesktopMain extends MusicBeatState { windows.add(new Window(new HelloWorld())); if (FlxG.keys.justPressed.F1) windows.add(new Window(new CharacterEditor('dad'))); + if (FlxG.keys.justPressed.F2) + windows.add(new Window(new EditorPlayState())); } public function openWindow(content:WindowContent) { diff --git a/source/funkin/desktop/editors/EditorPlayState.hx b/source/funkin/desktop/editors/EditorPlayState.hx new file mode 100644 index 00000000..caa2fd90 --- /dev/null +++ b/source/funkin/desktop/editors/EditorPlayState.hx @@ -0,0 +1,94 @@ +package funkin.desktop.editors; + +import flixel.FlxG; +import flixel.FlxCamera; +import flixel.math.FlxPoint; + +class EditorPlayState extends WindowContent { + var state:PlayState; + + public function new() { + super("PlayState", 120, 120, 1280, 720); + state = new PlayState(); + } + public override function create() { + super.create(); + + beforeStateShit(); + state.camera = parent.windowCameras[0].camera; + state.create(); + afterStateShit(); + + parent.windowCameras[0].resizeScroll = false; + parent.windowCameras.push( + { + camera: state.camHUD, + width: 1280, + height: 720, + resizeScroll: true + } + ); + parent.move(winX, winY); + parent.resize(1280, 720); + beforeStateShit(); + state.createPost(); + afterStateShit(); + } + var oldSize = FlxPoint.get(FlxG.width, FlxG.height); + var oldCamList:Array; + var oldCam:FlxCamera; + + public function beforeStateShit() { + oldSize.set(FlxG.width, FlxG.height); + @:privateAccess + FlxG.width = 1280; + @:privateAccess + FlxG.height = 720; + + oldCamList = FlxG.cameras.list; + oldCam = FlxG.camera; + @:privateAccess + FlxG.cameras.list = [for(e in parent.windowCameras) e.camera]; + FlxG.camera = parent.windowCameras[0].camera; + } + public function afterStateShit() { + @:privateAccess + FlxG.width = Std.int(oldSize.x); + @:privateAccess + FlxG.height = Std.int(oldSize.y); + + parent.windowCameras = [for(e in FlxG.cameras.list) { + camera: e, + width: 1280, + height: 720, + resizeScroll: false + }]; + @:privateAccess + FlxG.cameras.list = oldCamList; + FlxG.camera = oldCam; + + oldCamList = null; + oldCam = null; + } + + public override function update(elapsed:Float) { + beforeStateShit(); + super.update(elapsed); + state.update(elapsed); + afterStateShit(); + } + + public override function destroy() { + beforeStateShit(); + super.destroy(); + state.destroy(); + afterStateShit(); + } + + public override function draw() { + beforeStateShit(); + super.draw(); + state.draw(); + afterStateShit(); + } +} \ No newline at end of file diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 74c2639a..bf5f63de 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -153,11 +153,10 @@ class PlayState extends MusicBeatState scripts = new ScriptPack("PlayState"); scripts.setParent(this); - camGame = new FlxCamera(); + camGame = camera; camHUD = new FlxCamera(); camHUD.bgColor.alpha = 0; - FlxG.cameras.reset(camGame); FlxG.cameras.add(camHUD, false); // camGame.widescreen = true; @@ -170,6 +169,7 @@ class PlayState extends MusicBeatState scrollSpeed = SONG.speed; + Conductor.reset(); Conductor.mapBPMChanges(SONG); Conductor.changeBPM(SONG.bpm); @@ -413,6 +413,9 @@ class PlayState extends MusicBeatState super.destroy(); FlxDestroyUtil.destroy(scripts); instance = null; + if (vocals != null) { + vocals.destroy(); + } } public var debugNum:Int = 0; @@ -800,8 +803,8 @@ class PlayState extends MusicBeatState songTime += FlxG.game.ticks - previousFrameTime; previousFrameTime = FlxG.game.ticks; - // if (Math.abs(FlxG.sound.music.time - Conductor.songPosition) > 20) - // resyncVocals(); + if (Math.abs(FlxG.sound.music.time - Conductor.songPosition) > 25) + resyncVocals(); } // Conductor.lastSongPos = FlxG.sound.music.time; diff --git a/source/funkin/game/Strum.hx b/source/funkin/game/Strum.hx index bf1ba1ad..a92a6603 100644 --- a/source/funkin/game/Strum.hx +++ b/source/funkin/game/Strum.hx @@ -44,7 +44,7 @@ class Strum extends FlxSprite { public function updateNotePosition(daNote:Note) { if (!daNote.exists) return; - var offset = FlxPoint.get(daNote.isSustainNote ? ((Note.swagWidth - daNote.width) / 2) : 0, (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(PlayState.instance.scrollSpeed, 2))); + var offset = FlxPoint.get(daNote.isSustainNote ? ((Note.swagWidth - daNote.width) / 2) : 0, (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(getScrollSpeed(), 2))); var realOffset = FlxPoint.get(0, 0); if (daNote.isSustainNote) offset.y -= Note.swagWidth / 2; diff --git a/source/funkin/system/Conductor.hx b/source/funkin/system/Conductor.hx index 7e16e6a4..cfc27f19 100644 --- a/source/funkin/system/Conductor.hx +++ b/source/funkin/system/Conductor.hx @@ -49,6 +49,11 @@ class Conductor @:dox(hide) public function new() {} + public static function reset() { + songPosition = lastSongPos = 0; + bpmChangeMap = []; + changeBPM(100); + } /** * Maps BPM changes from a song. * @param song Song to map BPM changes from.