mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-08-20 07:25:59 +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.
|
||||
// SongNoteData's == operation has been overridden so that this will work.
|
||||
if (x == note)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x == note) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -94,8 +91,13 @@ class SongDataUtils
|
|||
if (events.length == 0 || subtrahend.length == 0) return events;
|
||||
|
||||
return events.filter(function(event:SongEventData):Bool {
|
||||
// SongEventData's == operation has been overridden so that this will work.
|
||||
return !subtrahend.has(event);
|
||||
for (x in subtrahend)
|
||||
{
|
||||
// The currently iterated event is in the subtrahend array.
|
||||
// SongEventData's == operation has been overridden so that this will work.
|
||||
if (x == event) return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class MoveEventsCommand implements ChartEditorCommand
|
|||
var movedEvents:Array<SongEventData>;
|
||||
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.
|
||||
this.events = [for (event in events) event.clone()];
|
||||
|
@ -38,6 +38,7 @@ class MoveEventsCommand implements ChartEditorCommand
|
|||
movedEvents.push(resultEvent);
|
||||
}
|
||||
|
||||
state.currentSongChartEventData = SongDataUtils.subtractEvents(state.currentSongChartEventData, events);
|
||||
state.currentSongChartEventData = state.currentSongChartEventData.concat(movedEvents);
|
||||
state.currentEventSelection = movedEvents;
|
||||
|
||||
|
|
|
@ -366,17 +366,24 @@ class ChartEditorImportExportHandler
|
|||
var targetMode:FileWriteMode = Force;
|
||||
if (targetPath == null)
|
||||
{
|
||||
// Force writing to a generic path (autosave or crash recovery)
|
||||
targetMode = Skip;
|
||||
targetPath = Path.join([
|
||||
'./backups/',
|
||||
'chart-editor-${DateUtil.generateTimestamp()}.${Constants.EXT_CHART}'
|
||||
]);
|
||||
// We have to force write because the program will die before the save dialog is closed.
|
||||
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
|
||||
{
|
||||
// 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.
|
||||
}
|
||||
|
||||
// We have to force write because the program will die before the save dialog is closed.
|
||||
trace('Force exporting to $targetPath...');
|
||||
FileUtil.saveFilesAsZIPToPath(zipEntries, targetPath, targetMode);
|
||||
state.saveDataDirty = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue