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

Fixes for autosave notification

This commit is contained in:
EliteMasterEric 2023-11-22 20:25:25 -05:00
parent 4ace7c9cf4
commit 668fbd3b37
2 changed files with 40 additions and 32 deletions

View file

@ -1650,13 +1650,13 @@ class ChartEditorState extends HaxeUIState
} }
else else
{ {
this.error('Failure', 'Failed to load chart (${params.fnfcTargetPath})'); this.error('Failure', 'Failed to load chart (${chartPath.toString()})');
} }
} }
if (!FileUtil.doesFileExist(chartPath)) 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; menuItemRecentChart.disabled = true;
} }
else else
@ -2030,7 +2030,7 @@ class ChartEditorState extends HaxeUIState
this.exportAllSongData(false, null); this.exportAllSongData(false, null);
} }
}); });
addUIClickListener('menubarItemSaveChartAs', _ -> this.exportAllSongData()); addUIClickListener('menubarItemSaveChartAs', _ -> this.exportAllSongData(false, null));
addUIClickListener('menubarItemLoadInst', _ -> this.openUploadInstDialog(true)); addUIClickListener('menubarItemLoadInst', _ -> this.openUploadInstDialog(true));
addUIClickListener('menubarItemImportChart', _ -> this.openImportChartDialog('legacy', true)); addUIClickListener('menubarItemImportChart', _ -> this.openImportChartDialog('legacy', true));
addUIClickListener('menubarItemExit', _ -> quitChartEditor()); addUIClickListener('menubarItemExit', _ -> quitChartEditor());
@ -2269,12 +2269,13 @@ class ChartEditorState extends HaxeUIState
if (needsAutoSave) if (needsAutoSave)
{ {
this.exportAllSongData(true, null); 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", text: "Take Me There",
action: openBackupsFolder, callback: openBackupsFolder,
} }
], true); ]);
} }
#end #end
} }
@ -3487,6 +3488,11 @@ class ChartEditorState extends HaxeUIState
// Finished dragging. Release the note. // Finished dragging. Release the note.
currentPlaceNoteData = null; currentPlaceNoteData = null;
} }
else
{
// Cursor should be a grabby hand.
if (targetCursorMode == null) targetCursorMode = Grabbing;
}
} }
else else
{ {
@ -4031,23 +4037,21 @@ class ChartEditorState extends HaxeUIState
if (currentWorkingFilePath == null || FlxG.keys.pressed.SHIFT) if (currentWorkingFilePath == null || FlxG.keys.pressed.SHIFT)
{ {
// CTRL + SHIFT + S = Save As // 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 else
{ {
// CTRL + S = Save Chart // CTRL + S = Save Chart
this.exportAllSongData(true, currentWorkingFilePath); 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 // CTRL + Q = Quit to Menu
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Q) if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Q)
{ {

View file

@ -77,9 +77,9 @@ class ChartEditorNotificationHandler
* @param actions The actions to add to the notification. * @param actions The actions to add to the notification.
* @return The notification that was sent. * @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<NotificationAction>):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<NotificationAction>):Notification static function sendNotification(title:String, body:String, ?type:NotificationType, ?actions:Array<NotificationAction>):Notification
{ {
#if !mac #if !mac
var actionNames:Array<String> = actions.map(action -> action.text); var actionNames:Array<String> = actions == null ? [] : actions.map(action -> action.text);
var notif = NotificationManager.instance.addNotification( var notif = NotificationManager.instance.addNotification(
{ {
@ -115,21 +115,25 @@ class ChartEditorNotificationHandler
actions: actionNames actions: actionNames
}); });
// TODO: Tell Ian that this is REALLY dumb. if (actionNames.length > 0)
var actionsContainer:HBox = notif.findComponent('actionsContainer', HBox); {
actionsContainer.walkComponents(function(component) { // TODO: Tell Ian that this is REALLY dumb.
if (Std.isOfType(component, Button)) var actionsContainer:HBox = notif.findComponent('actionsContainer', HBox);
{ actionsContainer.walkComponents(function(component) {
var button:Button = cast component; if (Std.isOfType(component, Button))
var action:Null<NotificationAction> = actions.find(action -> action.text == button.text);
if (action != null && action.callback != null)
{ {
button.onClick = function(_) { var button:Button = cast component;
action.callback(); var action:Null<NotificationAction> = actions.find(action -> action.text == button.text);
}; if (action != null && action.callback != null)
{
button.onClick = function(_) {
action.callback();
};
}
} }
} return true; // Continue walking.
}); });
}
return notif; return notif;
#else #else