mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-03-23 10:29:29 +00:00
[BUGFIX] Chart Editor Event Handling (#220)
* Fix a bug causing editing or removal of song events to not happen properly. * Fix an exception thrown as the application closes. * Fix an issue with moving events in the chart causing a crash. --------- Co-authored-by: Cameron Taylor <cameron.taylor.ninja@gmail.com>
This commit is contained in:
parent
daf1ba85dc
commit
e2250b18ff
|
@ -70,10 +70,7 @@ class SongDataUtils
|
||||||
{
|
{
|
||||||
// The currently iterated note is in the subtrahend array.
|
// The currently iterated note is in the subtrahend array.
|
||||||
// SongNoteData's == operation has been overridden so that this will work.
|
// SongNoteData's == operation has been overridden so that this will work.
|
||||||
if (x == note)
|
if (x == note) return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -94,8 +91,13 @@ class SongDataUtils
|
||||||
if (events.length == 0 || subtrahend.length == 0) return events;
|
if (events.length == 0 || subtrahend.length == 0) return events;
|
||||||
|
|
||||||
return events.filter(function(event:SongEventData):Bool {
|
return events.filter(function(event:SongEventData):Bool {
|
||||||
|
for (x in subtrahend)
|
||||||
|
{
|
||||||
|
// The currently iterated event is in the subtrahend array.
|
||||||
// SongEventData's == operation has been overridden so that this will work.
|
// SongEventData's == operation has been overridden so that this will work.
|
||||||
return !subtrahend.has(event);
|
if (x == event) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class MoveEventsCommand implements ChartEditorCommand
|
||||||
var movedEvents:Array<SongEventData>;
|
var movedEvents:Array<SongEventData>;
|
||||||
var offset:Float;
|
var offset:Float;
|
||||||
|
|
||||||
public function new(notes:Array<SongEventData>, offset:Float)
|
public function new(events:Array<SongEventData>, offset:Float)
|
||||||
{
|
{
|
||||||
// Clone the notes to prevent editing from affecting the history.
|
// Clone the notes to prevent editing from affecting the history.
|
||||||
this.events = [for (event in events) event.clone()];
|
this.events = [for (event in events) event.clone()];
|
||||||
|
@ -38,6 +38,7 @@ class MoveEventsCommand implements ChartEditorCommand
|
||||||
movedEvents.push(resultEvent);
|
movedEvents.push(resultEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.currentSongChartEventData = SongDataUtils.subtractEvents(state.currentSongChartEventData, events);
|
||||||
state.currentSongChartEventData = state.currentSongChartEventData.concat(movedEvents);
|
state.currentSongChartEventData = state.currentSongChartEventData.concat(movedEvents);
|
||||||
state.currentEventSelection = movedEvents;
|
state.currentEventSelection = movedEvents;
|
||||||
|
|
||||||
|
|
|
@ -366,17 +366,24 @@ class ChartEditorImportExportHandler
|
||||||
var targetMode:FileWriteMode = Force;
|
var targetMode:FileWriteMode = Force;
|
||||||
if (targetPath == null)
|
if (targetPath == null)
|
||||||
{
|
{
|
||||||
|
// Force writing to a generic path (autosave or crash recovery)
|
||||||
targetMode = Skip;
|
targetMode = Skip;
|
||||||
targetPath = Path.join([
|
targetPath = Path.join([
|
||||||
'./backups/',
|
'./backups/',
|
||||||
'chart-editor-${DateUtil.generateTimestamp()}.${Constants.EXT_CHART}'
|
'chart-editor-${DateUtil.generateTimestamp()}.${Constants.EXT_CHART}'
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
|
|
||||||
// We have to force write because the program will die before the save dialog is closed.
|
// We have to force write because the program will die before the save dialog is closed.
|
||||||
trace('Force exporting to $targetPath...');
|
trace('Force exporting to $targetPath...');
|
||||||
FileUtil.saveFilesAsZIPToPath(zipEntries, targetPath, targetMode);
|
FileUtil.saveFilesAsZIPToPath(zipEntries, targetPath, targetMode);
|
||||||
state.saveDataDirty = false;
|
// state.saveDataDirty = false; // Don't edit the saveData flag because the app might be closing.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Force writing to the specific path (user pressed CTRL-SHIFT-S)
|
||||||
|
trace('Force exporting to $targetPath...');
|
||||||
|
FileUtil.saveFilesAsZIPToPath(zipEntries, targetPath, targetMode);
|
||||||
|
state.saveDataDirty = false; // Don't edit the saveData flag because the app might be closing.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue