1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-08-20 07:25:59 +00:00

Fixing up a rough Git merge

This commit is contained in:
EliteMasterEric 2023-11-24 00:58:12 -05:00
parent 4e1945b373
commit a2cee82779
2 changed files with 82 additions and 1 deletions

2
assets

@ -1 +1 @@
Subproject commit 74847831dec229fc1c639ca4ca963973022b8648
Subproject commit 76dc8659ec238a0521955da56d5e928f94878d7c

View file

@ -103,6 +103,87 @@ class ChartEditorDialogHandler
return dialog;
}
/**
* Builds and opens a dialog letting the user know a backup is available, and prompting them to load it.
*/
public static function openBackupAvailableDialog(state:ChartEditorState, welcomeDialog:Null<Dialog>):Null<Dialog>
{
var dialog:Null<Dialog> = 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<Label> = dialog.findComponent('backupTimeLabel', Label);
if (backupTimeLabel == null) throw 'Could not locate backupTimeLabel button in Backup Available dialog';
var latestBackupDate:Null<Date> = ChartEditorImportExportHandler.getLatestBackupDate();
if (latestBackupDate != null)
{
var latestBackupDateStr:String = DateUtil.generateCleanTimestamp(latestBackupDate);
backupTimeLabel.text = latestBackupDateStr;
}
var buttonCancel:Null<Button> = dialog.findComponent('dialogCancel', Button);
if (buttonCancel == null) throw 'Could not locate dialogCancel button in Backup Available dialog';
buttonCancel.onClick = function(_event) {
// Don't hide the welcome dialog behind this.
dialog.hideDialog(DialogButton.CANCEL);
}
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) {
state.openBackupsFolder();
// Don't hide the welcome dialog behind this.
// dialog.hideDialog(DialogButton.CANCEL);
}
var buttonOpenBackup:Null<Button> = dialog.findComponent('buttonOpenBackup', Button);
if (buttonOpenBackup == null) throw 'Could not locate buttonOpenBackup button in Backup Available dialog';
buttonOpenBackup.onClick = function(_event) {
var latestBackupPath:Null<String> = ChartEditorImportExportHandler.getLatestBackupPath();
var result:Null<Array<String>> = (latestBackupPath != null) ? state.loadFromFNFCPath(latestBackupPath) : null;
if (result != null)
{
if (result.length == 0)
{
// No warnings.
state.success('Loaded Chart', 'Loaded chart (${latestBackupPath})');
}
else
{
// One or more warnings.
state.warning('Loaded Chart', 'Loaded chart (${latestBackupPath})\n${result.join("\n")}');
}
// Close the welcome dialog behind this.
dialog.hideDialog(DialogButton.APPLY);
}
else
{
state.error('Failed to Load Chart', 'Failed to load chart (${latestBackupPath})');
// Song failed to load, don't close the Welcome dialog so we aren't in a broken state.
dialog.hideDialog(DialogButton.CANCEL);
}
}
return dialog;
}
/**
* Builds and opens a dialog letting the user browse for a chart file to open.
* @param state The current chart editor state.