X Tutup
Skip to content

Commit b31be10

Browse files
LasercarHundrec
authored andcommitted
chart name in backup filename
1 parent 6c4d27a commit b31be10

File tree

6 files changed

+19
-34
lines changed

6 files changed

+19
-34
lines changed

assets

source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,10 @@ class ChartEditorDialogHandler
168168
var backupTimeLabel:Null<Label> = dialog.findComponent('backupTimeLabel', Label);
169169
if (backupTimeLabel == null) throw 'Could not locate backupTimeLabel button in Backup Available dialog';
170170

171-
var latestBackupDate:Null<Date> = ChartEditorImportExportHandler.getLatestBackupDate();
171+
var latestBackupDate:Null<String> = ChartEditorImportExportHandler.getLatestBackupDate();
172172
if (latestBackupDate != null)
173173
{
174-
var latestBackupDateStr:String = DateUtil.generateCleanTimestamp(latestBackupDate);
175-
backupTimeLabel.text = latestBackupDateStr;
174+
backupTimeLabel.text = latestBackupDate;
176175
}
177176

178177
var buttonCancel:Null<Button> = dialog.findComponent('dialogCancel', Button);

source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class ChartEditorImportExportHandler
368368
#end
369369
}
370370

371-
public static function getLatestBackupDate():Null<Date>
371+
public static function getLatestBackupDate():Null<String>
372372
{
373373
#if sys
374374
var latestBackupPath:Null<String> = getLatestBackupPath();
@@ -377,19 +377,10 @@ class ChartEditorImportExportHandler
377377
var latestBackupName:String = haxe.io.Path.withoutDirectory(latestBackupPath);
378378
latestBackupName = haxe.io.Path.withoutExtension(latestBackupName);
379379

380-
var parts = latestBackupName.split('-');
380+
var stat = sys.FileSystem.stat(latestBackupPath);
381+
var sizeInMB = (stat.size / 1000000).round(3);
381382

382-
// var chart:String = parts[0];
383-
// var editor:String = parts[1];
384-
var year:Int = Std.parseInt(parts[2] ?? '0') ?? 0;
385-
var month:Int = Std.parseInt(parts[3] ?? '1') ?? 1;
386-
var day:Int = Std.parseInt(parts[4] ?? '0') ?? 0;
387-
var hour:Int = Std.parseInt(parts[5] ?? '0') ?? 0;
388-
var minute:Int = Std.parseInt(parts[6] ?? '0') ?? 0;
389-
var second:Int = Std.parseInt(parts[7] ?? '0') ?? 0;
390-
391-
var date:Date = new Date(year, month - 1, day, hour, minute, second);
392-
return date;
383+
return "Full Name: " + latestBackupName + "\nLast Modified: " + stat.mtime.toString() + "\nSize: " + sizeInMB + " MB";
393384
#else
394385
return null;
395386
#end
@@ -470,9 +461,10 @@ class ChartEditorImportExportHandler
470461
{
471462
// Force writing to a generic path (autosave or crash recovery)
472463
targetMode = Skip;
464+
if (state.currentSongId == '') state.currentSongName = 'New Chart'; // Hopefully no one notices this silliness
473465
targetPath = Path.join([
474466
BACKUPS_PATH,
475-
'chart-editor-${DateUtil.generateTimestamp()}.${Constants.EXT_CHART}'
467+
'chart-editor-${state.currentSongId}-${DateUtil.generateTimestamp()}.${Constants.EXT_CHART}'
476468
]);
477469
// We have to force write because the program will die before the save dialog is closed.
478470
trace('Force exporting to $targetPath...');

source/funkin/ui/debug/stageeditor/StageEditorState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class StageEditorState extends UIState
206206
var data = this.packShitToZip();
207207
var path = haxe.io.Path.join([
208208
BACKUPS_PATH,
209-
'stage-editor-${funkin.util.DateUtil.generateTimestamp()}.${FileUtil.FILE_EXTENSION_INFO_FNFS.extension}'
209+
'stage-editor-${stageName}-${funkin.util.DateUtil.generateTimestamp()}.${FileUtil.FILE_EXTENSION_INFO_FNFS.extension}'
210210
]);
211211

212212
FileUtil.writeBytesToPath(path, data);

source/funkin/ui/debug/stageeditor/components/BackupAvailableDialog.hx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import funkin.util.DateUtil;
99
using StringTools;
1010

1111
@:xml('
12-
<dialog id="backupAvailableDialog" width="475" height="150" title="Hey! Listen!">
12+
<dialog id="backupAvailableDialog" width="475" height="200" title="Hey! Listen!">
1313
<vbox width="100%" height="100%">
1414
<label text="There is a stage backup available, would you like to open it?\n" width="100%" textAlign="center" />
1515
<spacer height="6" />
@@ -34,20 +34,14 @@ class BackupAvailableDialog extends Dialog
3434
if (!FileUtil.fileExists(filePath)) return;
3535

3636
// time text
37-
var fileDate = Path.withoutExtension(Path.withoutDirectory(filePath));
38-
var dateParts = fileDate.split("-");
37+
var file = Path.withoutExtension(Path.withoutDirectory(filePath));
3938

40-
while (dateParts.length < 8)
41-
dateParts.push("0");
39+
#if sys
40+
var stat = sys.FileSystem.stat(filePath);
41+
var sizeInMB = (stat.size / 1000000).round(3);
4242

43-
var year:Int = Std.parseInt(dateParts[2]) ?? 0; // copied parts from ChartEditorImportExportHandler.hx
44-
var month:Int = Std.parseInt(dateParts[3]) ?? 1;
45-
var day:Int = Std.parseInt(dateParts[4]) ?? 0;
46-
var hour:Int = Std.parseInt(dateParts[5]) ?? 0;
47-
var minute:Int = Std.parseInt(dateParts[6]) ?? 0;
48-
var second:Int = Std.parseInt(dateParts[7]) ?? 0;
49-
50-
backupTimeLabel.text = DateUtil.generateCleanTimestamp(new Date(year, month - 1, day, hour, minute, second));
43+
backupTimeLabel.text = "Full Name: " + file + "\nLast Modified: " + stat.mtime.toString() + "\nSize: " + sizeInMB + " MB";
44+
#end
5145

5246
// button callbacks
5347
dialogCancel.onClick = function(_) hideDialog(DialogButton.CANCEL);

source/funkin/ui/debug/stageeditor/components/WelcomeDialog.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ class WelcomeDialog extends Dialog
4747

4848
#if sys
4949
var stat = sys.FileSystem.stat(file);
50-
var sizeInMB = (stat.size / 1000000).round(2);
50+
var sizeInMB = (stat.size / 1000000).round(3);
5151

52-
fileText.tooltip = "Full Name: " + file + "\nLast Modified: " + stat.mtime.toString() + "\nSize: " + sizeInMB + "MB";
52+
fileText.tooltip = "Full Name: " + file + "\nLast Modified: " + stat.mtime.toString() + "\nSize: " + sizeInMB + " MB";
5353
#end
5454

5555
contentRecent.addComponent(fileText);

0 commit comments

Comments
 (0)
X Tutup