diff --git a/source/funkin/ui/debug/charting/ChartEditorImportExportHandler.hx b/source/funkin/ui/debug/charting/ChartEditorImportExportHandler.hx index 9ac903e38..f116ad3f1 100644 --- a/source/funkin/ui/debug/charting/ChartEditorImportExportHandler.hx +++ b/source/funkin/ui/debug/charting/ChartEditorImportExportHandler.hx @@ -116,10 +116,10 @@ class ChartEditorImportExportHandler /** * @param force Whether to force the export without prompting the user for a file location. - * @param tmp If true, save to the temporary directory instead of the local `backup` directory. */ - public static function exportAllSongData(state:ChartEditorState, force:Bool = false, tmp:Bool = false):Void + public static function exportAllSongData(state:ChartEditorState, force:Bool = false):Void { + var tmp = false; var zipEntries:Array = []; for (variation in state.availableVariations) @@ -133,9 +133,9 @@ class ChartEditorImportExportHandler if (variationId == '') { var variationMetadata:Null = state.songMetadata.get(variation); - if (variationMetadata != null) zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-metadata.json', SerializerUtil.toJSON(variationMetadata))); + if (variationMetadata != null) zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-metadata.json', variationMetadata.serialize())); var variationChart:Null = state.songChartData.get(variation); - if (variationChart != null) zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-chart.json', SerializerUtil.toJSON(variationChart))); + if (variationChart != null) zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-chart.json', variationChart.serialize())); } else { diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index ea4acb69d..67e3c1dc8 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1619,6 +1619,7 @@ class ChartEditorState extends HaxeUIState addUIClickListener('menubarItemSaveChartAs', _ -> ChartEditorImportExportHandler.exportAllSongData(this)); addUIClickListener('menubarItemLoadInst', _ -> ChartEditorDialogHandler.openUploadInstDialog(this, true)); addUIClickListener('menubarItemImportChart', _ -> ChartEditorDialogHandler.openImportChartDialog(this, 'legacy', true)); + addUIClickListener('menubarItemExit', _ -> quitChartEditor()); addUIClickListener('menubarItemUndo', _ -> undoLastCommand()); @@ -1811,7 +1812,7 @@ class ChartEditorState extends HaxeUIState // Auto-save to local storage. #else // Auto-save to temp file. - ChartEditorImportExportHandler.exportAllSongData(this, true, true); + ChartEditorImportExportHandler.exportAllSongData(this, true); #end } @@ -1833,6 +1834,13 @@ class ChartEditorState extends HaxeUIState public override function update(elapsed:Float):Void { + // Override F4 behavior to include the autosave. + if (FlxG.keys.justPressed.F4) + { + quitChartEditor(); + return; + } + // dispatchEvent gets called here. super.update(elapsed); @@ -3064,10 +3072,16 @@ class ChartEditorState extends HaxeUIState // CTRL + Q = Quit to Menu if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Q) { - FlxG.switchState(new MainMenuState()); + quitChartEditor(); } } + function quitChartEditor():Void + { + autoSave(); + FlxG.switchState(new MainMenuState()); + } + /** * Handle keybinds for edit menu items. */ @@ -3969,6 +3983,8 @@ class ChartEditorState extends HaxeUIState */ public function testSongInPlayState(minimal:Bool = false):Void { + autoSave(); + var startTimestamp:Float = 0; if (playtestStartTime) startTimestamp = scrollPositionInMs + playheadPositionInMs;