Add "Go to Backups" menu item

This commit is contained in:
EliteMasterEric 2023-11-22 19:42:28 -05:00
parent 700ebb6a83
commit 4ace7c9cf4
3 changed files with 29 additions and 4 deletions

2
assets

@ -1 +1 @@
Subproject commit 4cbffd074bb6d1d5fa13492d19e0736869338ac3
Subproject commit 4a0004864b620a83f7468dfcc10e0a2036bba872

View file

@ -2126,6 +2126,16 @@ class ChartEditorState extends HaxeUIState
addUIClickListener('menubarItemAbout', _ -> this.openAboutDialog());
addUIClickListener('menubarItemWelcomeDialog', _ -> this.openWelcomeDialog(true));
#if sys
addUIClickListener('menubarItemGoToBackupsFolder', _ -> this.openBackupsFolder());
#else
// Disable the menu item if we're not on a desktop platform.
var menubarItemGoToBackupsFolder = findComponent('menubarItemGoToBackupsFolder', MenuItem);
if (menubarItemGoToBackupsFolder != null) menubarItemGoToBackupsFolder.disabled = true;
menubarItemGoToBackupsFolder.disabled = true;
#end
addUIClickListener('menubarItemUserGuide', _ -> this.openUserGuideDialog());
addUIChangeListener('menubarItemDownscroll', event -> isViewDownscroll = event.value);
@ -2259,10 +2269,27 @@ class ChartEditorState extends HaxeUIState
if (needsAutoSave)
{
this.exportAllSongData(true, null);
this.infoWithActions('Auto-Save', 'Chart auto-saved to your backups folder.', [
{
"text": "Take Me There",
action: openBackupsFolder,
}
], true);
}
#end
}
/**
* Open the backups folder in the file explorer.
* Don't call this on HTML5.
*/
function openBackupsFolder():Void
{
// TODO: Is there a way to open a folder and highlight a file in it?
var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]);
WindowUtil.openFolder(absoluteBackupsPath);
}
/**
* Called when the window was closed, to save a backup of the chart.
* @param exitCode The exit code of the window. We use `-1` when calling the function due to a game crash.

View file

@ -288,9 +288,7 @@ class ChartEditorDialogHandler
var buttonGoToFolder:Null<Button> = dialog.findComponent('buttonGoToFolder', Button);
if (buttonGoToFolder == null) throw 'Could not locate buttonGoToFolder button in Backup Available dialog';
buttonGoToFolder.onClick = function(_event) {
// TODO: Is there a way to open a folder and highlight a file in it?
var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]);
WindowUtil.openFolder(absoluteBackupsPath);
state.openBackupsFolder();
// Don't hide the welcome dialog behind this.
dialog.hideDialog(DialogButton.CANCEL);
}