1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-09-12 05:07:06 +00:00

Merge pull request #184 from FunkinCrew/rewrite/bugfix/glowup-autosave

Fix exit button in Chart Editor menu
This commit is contained in:
Cameron Taylor 2023-10-11 06:32:00 -04:00 committed by GitHub
commit 6e2441b540
2 changed files with 22 additions and 6 deletions

View file

@ -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<haxe.zip.Entry> = [];
for (variation in state.availableVariations)
@ -133,9 +133,9 @@ class ChartEditorImportExportHandler
if (variationId == '')
{
var variationMetadata:Null<SongMetadata> = 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<SongChartData> = 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
{

View file

@ -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;