From 7137c13382ad729ed286759ba4762ba10f7a7470 Mon Sep 17 00:00:00 2001 From: Jenny Crowe Date: Fri, 26 Jan 2024 19:36:10 -0700 Subject: [PATCH] Copy command now pulses events in selection even if no notes are in the selection. "Copied" prompt now includes events in the text. --- source/funkin/data/song/SongDataUtils.hx | 8 +-- .../charting/commands/CopyItemsCommand.hx | 62 +++++++++++++------ 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/source/funkin/data/song/SongDataUtils.hx b/source/funkin/data/song/SongDataUtils.hx index 275106f3a..01ea2da32 100644 --- a/source/funkin/data/song/SongDataUtils.hx +++ b/source/funkin/data/song/SongDataUtils.hx @@ -153,8 +153,8 @@ class SongDataUtils public static function buildNoteClipboard(notes:Array, ?timeOffset:Int = null):Array { 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, ?timeOffset:Int = null):Array { 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); } /** diff --git a/source/funkin/ui/debug/charting/commands/CopyItemsCommand.hx b/source/funkin/ui/debug/charting/commands/CopyItemsCommand.hx index 4361f867f..6c5152a29 100644 --- a/source/funkin/ui/debug/charting/commands/CopyItemsCommand.hx +++ b/source/funkin/ui/debug/charting/commands/CopyItemsCommand.hx @@ -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