diff --git a/assets b/assets index 4ed2b3084..4cbffd074 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 4ed2b3084d54899e10d10a97eaafe210158768be +Subproject commit 4cbffd074bb6d1d5fa13492d19e0736869338ac3 diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index 06b679c87..db1f2b69a 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -181,12 +181,12 @@ abstract Save(RawSaveData) function get_chartEditorHasBackup():Bool { - if (this.optionsChartEditor.hasBackup == null) this.optionsChartEditor.hasBackup = []; + if (this.optionsChartEditor.hasBackup == null) this.optionsChartEditor.hasBackup = false; return this.optionsChartEditor.hasBackup; } - function set_chartEditorHasBackup(value:Array):Bool + function set_chartEditorHasBackup(value:Bool):Bool { // Set and apply. this.optionsChartEditor.hasBackup = value; diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index c381a8599..92279ef27 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -48,7 +48,6 @@ import funkin.data.song.SongData.SongNoteData; import funkin.data.song.SongData.SongCharacterData; import funkin.data.song.SongDataUtils; import funkin.ui.debug.charting.commands.ChartEditorCommand; -import funkin.ui.debug.charting.handlers.ChartEditorShortcutHandler; import funkin.play.stage.StageData; import funkin.save.Save; import funkin.ui.debug.charting.commands.AddEventsCommand; @@ -1539,8 +1538,12 @@ class ChartEditorState extends HaxeUIState this.error('Failure', 'Failed to load chart (${params.fnfcTargetPath})'); // Song failed to load, open the Welcome dialog so we aren't in a broken state. - this.openWelcomeDialog(false); - if (shouldShowBackupAvailableDialog)} + var welcomeDialog = this.openWelcomeDialog(false); + if (shouldShowBackupAvailableDialog) + { + this.openBackupAvailableDialog(welcomeDialog); + } + } } else if (params != null && params.targetSongId != null) { @@ -1566,7 +1569,6 @@ class ChartEditorState extends HaxeUIState { var save:Save = Save.get(); - showBackupAvailablePopup = save.chartEditorHasBackup; if (previousWorkingFilePaths[0] == null) { previousWorkingFilePaths = [null].concat(save.chartEditorPreviousFiles); @@ -1598,9 +1600,11 @@ class ChartEditorState extends HaxeUIState var filteredWorkingFilePaths:Array = []; for (chartPath in previousWorkingFilePaths) if (chartPath != null) filteredWorkingFilePaths.push(chartPath); - - save.chartEditorHasBackup = hasBackup; save.chartEditorPreviousFiles = filteredWorkingFilePaths; + + if (hasBackup) trace('Queuing backup prompt for next time!'); + save.chartEditorHasBackup = hasBackup; + save.chartEditorNoteQuant = noteSnapQuantIndex; save.chartEditorLiveInputStyle = currentLiveInputStyle; save.chartEditorDownscroll = isViewDownscroll; @@ -2023,7 +2027,7 @@ class ChartEditorState extends HaxeUIState } else { - this.exportAllSongData(false); + this.exportAllSongData(false, null); } }); addUIClickListener('menubarItemSaveChartAs', _ -> this.exportAllSongData()); @@ -2239,10 +2243,12 @@ class ChartEditorState extends HaxeUIState */ function autoSave():Void { + var needsAutoSave:Bool = saveDataDirty; + saveDataDirty = false; // Auto-save preferences. - writePreferences(false); + writePreferences(needsAutoSave); // Auto-save the chart. #if html5 @@ -2250,7 +2256,10 @@ class ChartEditorState extends HaxeUIState // TODO: Implement this. #else // Auto-save to temp file. - this.exportAllSongData(true); + if (needsAutoSave) + { + this.exportAllSongData(true, null); + } #end } @@ -2269,7 +2278,7 @@ class ChartEditorState extends HaxeUIState if (needsAutoSave) { - this.exportAllSongData(true); + this.exportAllSongData(true, null); } } @@ -2286,7 +2295,7 @@ class ChartEditorState extends HaxeUIState if (needsAutoSave) { - this.exportAllSongData(true); + this.exportAllSongData(true, null); } } @@ -3995,7 +4004,7 @@ class ChartEditorState extends HaxeUIState if (currentWorkingFilePath == null || FlxG.keys.pressed.SHIFT) { // CTRL + SHIFT + S = Save As - this.exportAllSongData(false); + this.exportAllSongData(false, null); } else { @@ -4006,7 +4015,11 @@ class ChartEditorState extends HaxeUIState if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.SHIFT && FlxG.keys.justPressed.S) { - this.exportAllSongData(false); + this.exportAllSongData(false, null, function(path:String) { + // CTRL + SHIFT + S Successful + }, function() { + // CTRL + SHIFT + S Cancelled + }); } // CTRL + Q = Quit to Menu if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Q) diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx index 6985a5d60..86717132b 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx @@ -20,6 +20,8 @@ import funkin.util.FileUtil; import funkin.util.SerializerUtil; import funkin.util.SortUtil; import funkin.util.VersionUtil; +import funkin.util.DateUtil; +import funkin.util.WindowUtil; import haxe.io.Path; import haxe.ui.components.Button; import haxe.ui.components.DropDown; @@ -61,6 +63,7 @@ class ChartEditorDialogHandler static final CHART_EDITOR_DIALOG_USER_GUIDE_LAYOUT:String = Paths.ui('chart-editor/dialogs/user-guide'); static final CHART_EDITOR_DIALOG_ADD_VARIATION_LAYOUT:String = Paths.ui('chart-editor/dialogs/add-variation'); static final CHART_EDITOR_DIALOG_ADD_DIFFICULTY_LAYOUT:String = Paths.ui('chart-editor/dialogs/add-difficulty'); + static final CHART_EDITOR_DIALOG_BACKUP_AVAILABLE_LAYOUT:String = Paths.ui('chart-editor/dialogs/backup-available'); /** * Builds and opens a dialog giving brief credits for the chart editor. @@ -246,32 +249,84 @@ class ChartEditorDialogHandler * @param state * @return Null */ - public static function openBackupAvailableDialog(state:ChartEditorState):Null + public static function openBackupAvailableDialog(state:ChartEditorState, welcomeDialog:Null):Null { var dialog:Null = openDialog(state, CHART_EDITOR_DIALOG_BACKUP_AVAILABLE_LAYOUT, true, true); if (dialog == null) throw 'Could not locate Backup Available dialog'; + dialog.onDialogClosed = function(_event) { + state.isHaxeUIDialogOpen = false; + if (_event.button == DialogButton.APPLY) + { + // User loaded the backup! Close the welcome dialog behind this. + if (welcomeDialog != null) welcomeDialog.hideDialog(DialogButton.CANCEL); + } + else + { + // User cancelled the dialog, don't close the welcome dialog so we aren't in a broken state. + } + }; state.isHaxeUIDialogOpen = true; + var backupTimeLabel:Null