1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-11 16:05:02 +00:00

Merge pull request #303 from FunkinCrew/bugfix/copy-prompt-fixes

Copy command fixes
This commit is contained in:
Cameron Taylor 2024-02-05 13:05:22 -05:00 committed by GitHub
commit bfd11ae097
2 changed files with 48 additions and 22 deletions

View file

@ -153,8 +153,8 @@ class SongDataUtils
public static function buildNoteClipboard(notes:Array<SongNoteData>, ?timeOffset:Int = null):Array<SongNoteData>
{
if (notes.length == 0) return notes;
if (timeOffset == null) timeOffset = -Std.int(notes[0].time);
return offsetSongNoteData(sortNotes(notes), timeOffset);
if (timeOffset == null) timeOffset = Std.int(notes[0].time);
return offsetSongNoteData(sortNotes(notes), -timeOffset);
}
/**
@ -165,8 +165,8 @@ class SongDataUtils
public static function buildEventClipboard(events:Array<SongEventData>, ?timeOffset:Int = null):Array<SongEventData>
{
if (events.length == 0) return events;
if (timeOffset == null) timeOffset = -Std.int(events[0].time);
return offsetSongEventData(sortEvents(events), timeOffset);
if (timeOffset == null) timeOffset = Std.int(events[0].time);
return offsetSongEventData(sortEvents(events), -timeOffset);
}
/**

View file

@ -46,26 +46,14 @@ class CopyItemsCommand implements ChartEditorCommand
function performVisuals(state:ChartEditorState):Void
{
var hasNotes:Bool = false;
var hasEvents:Bool = false;
// Wiggle copied notes.
if (state.currentNoteSelection.length > 0)
{
// Display the "Copied Notes" text.
if (state.txtCopyNotif != null)
{
state.txtCopyNotif.visible = true;
state.txtCopyNotif.text = "Copied " + state.currentNoteSelection.length + " notes to clipboard";
state.txtCopyNotif.x = FlxG.mouse.x - (state.txtCopyNotif.width / 2);
state.txtCopyNotif.y = FlxG.mouse.y - 16;
FlxTween.tween(state.txtCopyNotif, {y: state.txtCopyNotif.y - 32}, 0.5,
{
type: FlxTween.ONESHOT,
ease: FlxEase.quadOut,
onComplete: function(_) {
state.txtCopyNotif.visible = false;
}
});
}
hasNotes = true;
// Wiggle the notes.
for (note in state.renderedNotes.members)
{
if (state.isNoteSelected(note.noteData))
@ -91,8 +79,13 @@ class CopyItemsCommand implements ChartEditorCommand
});
}
}
}
// Wiggle copied events.
if (state.currentEventSelection.length > 0)
{
hasEvents = true;
// Wiggle the events.
for (event in state.renderedEvents.members)
{
if (state.isEventSelected(event.eventData))
@ -119,6 +112,39 @@ class CopyItemsCommand implements ChartEditorCommand
}
}
}
// Display the "Copied Notes" text.
if ((hasNotes || hasEvents) && state.txtCopyNotif != null)
{
var copiedString:String = '';
if (hasNotes)
{
var copiedNotes:Int = state.currentNoteSelection.length;
copiedString += '${copiedNotes} note';
if (copiedNotes > 1) copiedString += 's';
if (hasEvents) copiedString += ' and ';
}
if (hasEvents)
{
var copiedEvents:Int = state.currentEventSelection.length;
copiedString += '${state.currentEventSelection.length} event';
if (copiedEvents > 1) copiedString += 's';
}
state.txtCopyNotif.visible = true;
state.txtCopyNotif.text = 'Copied ${copiedString} to clipboard';
state.txtCopyNotif.x = FlxG.mouse.x - (state.txtCopyNotif.width / 2);
state.txtCopyNotif.y = FlxG.mouse.y - 16;
FlxTween.tween(state.txtCopyNotif, {y: state.txtCopyNotif.y - 32}, 0.5,
{
type: FlxTween.ONESHOT,
ease: FlxEase.quadOut,
onComplete: function(_) {
state.txtCopyNotif.visible = false;
}
});
}
}
public function undo(state:ChartEditorState):Void