From 668fbd3b37abea4a97014aa6b6b87e393df0af55 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 22 Nov 2023 20:25:25 -0500 Subject: [PATCH] Fixes for autosave notification --- .../ui/debug/charting/ChartEditorState.hx | 36 ++++++++++--------- .../ChartEditorNotificationHandler.hx | 36 ++++++++++--------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 2cd79fdea..b6ca0db49 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1650,13 +1650,13 @@ class ChartEditorState extends HaxeUIState } else { - this.error('Failure', 'Failed to load chart (${params.fnfcTargetPath})'); + this.error('Failure', 'Failed to load chart (${chartPath.toString()})'); } } if (!FileUtil.doesFileExist(chartPath)) { - trace('Previously loaded chart file (${chartPath}) does not exist, disabling link...'); + trace('Previously loaded chart file (${chartPath.toString()}) does not exist, disabling link...'); menuItemRecentChart.disabled = true; } else @@ -2030,7 +2030,7 @@ class ChartEditorState extends HaxeUIState this.exportAllSongData(false, null); } }); - addUIClickListener('menubarItemSaveChartAs', _ -> this.exportAllSongData()); + addUIClickListener('menubarItemSaveChartAs', _ -> this.exportAllSongData(false, null)); addUIClickListener('menubarItemLoadInst', _ -> this.openUploadInstDialog(true)); addUIClickListener('menubarItemImportChart', _ -> this.openImportChartDialog('legacy', true)); addUIClickListener('menubarItemExit', _ -> quitChartEditor()); @@ -2269,12 +2269,13 @@ class ChartEditorState extends HaxeUIState if (needsAutoSave) { this.exportAllSongData(true, null); - this.infoWithActions('Auto-Save', 'Chart auto-saved to your backups folder.', [ + var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]); + this.infoWithActions('Auto-Save', 'Chart auto-saved to ${absoluteBackupsPath}.', [ { - "text": "Take Me There", - action: openBackupsFolder, + text: "Take Me There", + callback: openBackupsFolder, } - ], true); + ]); } #end } @@ -3487,6 +3488,11 @@ class ChartEditorState extends HaxeUIState // Finished dragging. Release the note. currentPlaceNoteData = null; } + else + { + // Cursor should be a grabby hand. + if (targetCursorMode == null) targetCursorMode = Grabbing; + } } else { @@ -4031,23 +4037,21 @@ class ChartEditorState extends HaxeUIState if (currentWorkingFilePath == null || FlxG.keys.pressed.SHIFT) { // CTRL + SHIFT + S = Save As - this.exportAllSongData(false, null); + this.exportAllSongData(false, null, function(path:String) { + // CTRL + SHIFT + S Successful + this.success('Saved Chart', 'Chart saved successfully to ${path}.'); + }, function() { + // CTRL + SHIFT + S Cancelled + }); } else { // CTRL + S = Save Chart this.exportAllSongData(true, currentWorkingFilePath); + this.success('Saved Chart', 'Chart saved successfully to ${currentWorkingFilePath}.'); } } - if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.SHIFT && FlxG.keys.justPressed.S) - { - 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/ChartEditorNotificationHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorNotificationHandler.hx index 69ba4f3ba..796e70381 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorNotificationHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorNotificationHandler.hx @@ -77,9 +77,9 @@ class ChartEditorNotificationHandler * @param actions The actions to add to the notification. * @return The notification that was sent. */ - public static function info(state:ChartEditorState, title:String, body:String):Notification + public static function infoWithActions(state:ChartEditorState, title:String, body:String, actions:Array):Notification { - return sendNotification(title, body, NotificationType.Info); + return sendNotification(title, body, NotificationType.Info, actions); } /** @@ -104,7 +104,7 @@ class ChartEditorNotificationHandler static function sendNotification(title:String, body:String, ?type:NotificationType, ?actions:Array):Notification { #if !mac - var actionNames:Array = actions.map(action -> action.text); + var actionNames:Array = actions == null ? [] : actions.map(action -> action.text); var notif = NotificationManager.instance.addNotification( { @@ -115,21 +115,25 @@ class ChartEditorNotificationHandler actions: actionNames }); - // TODO: Tell Ian that this is REALLY dumb. - var actionsContainer:HBox = notif.findComponent('actionsContainer', HBox); - actionsContainer.walkComponents(function(component) { - if (Std.isOfType(component, Button)) - { - var button:Button = cast component; - var action:Null = actions.find(action -> action.text == button.text); - if (action != null && action.callback != null) + if (actionNames.length > 0) + { + // TODO: Tell Ian that this is REALLY dumb. + var actionsContainer:HBox = notif.findComponent('actionsContainer', HBox); + actionsContainer.walkComponents(function(component) { + if (Std.isOfType(component, Button)) { - button.onClick = function(_) { - action.callback(); - }; + var button:Button = cast component; + var action:Null = actions.find(action -> action.text == button.text); + if (action != null && action.callback != null) + { + button.onClick = function(_) { + action.callback(); + }; + } } - } - }); + return true; // Continue walking. + }); + } return notif; #else