From 796e1fcbabd8703da8686bc2509ae52401978c38 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 8 Dec 2023 20:21:55 -0500 Subject: [PATCH 1/4] note highlight preview --- .../ui/debug/charting/ChartEditorState.hx | 18 ++++++++++++++- .../components/ChartEditorNotePreview.hx | 23 +++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 66effc775..02994bf71 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -720,7 +720,23 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState /** * The notes which are currently in the user's selection. */ - var currentNoteSelection:Array = []; + var currentNoteSelection(default, set):Array = []; + + function set_currentNoteSelection(value:Array):Array + { + currentNoteSelection = value; + + if (currentNoteSelection.length > 0) + { + notePreview.addNotes(currentNoteSelection, Std.int(songLengthInMs), true); + } + else + { + notePreviewDirty = true; + } + + return currentNoteSelection; + } /** * The events which are currently in the user's selection. diff --git a/source/funkin/ui/debug/charting/components/ChartEditorNotePreview.hx b/source/funkin/ui/debug/charting/components/ChartEditorNotePreview.hx index 7decc8988..09c99531d 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorNotePreview.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorNotePreview.hx @@ -26,6 +26,7 @@ class ChartEditorNotePreview extends FlxSprite static final UP_COLOR:FlxColor = 0xFF00CC00; static final RIGHT_COLOR:FlxColor = 0xFFCC1111; static final EVENT_COLOR:FlxColor = 0xFF111111; + static final SELECTED_COLOR:FlxColor = 0xFFFFFF00; var previewHeight:Int; @@ -57,11 +58,11 @@ class ChartEditorNotePreview extends FlxSprite * @param note The data for the note. * @param songLengthInMs The total length of the song in milliseconds. */ - public function addNote(note:SongNoteData, songLengthInMs:Int):Void + public function addNote(note:SongNoteData, songLengthInMs:Int, ?isSelection:Bool = false):Void { var noteDir:Int = note.getDirection(); var mustHit:Bool = note.getStrumlineIndex() == 0; - drawNote(noteDir, mustHit, Std.int(note.time), songLengthInMs); + drawNote(noteDir, mustHit, Std.int(note.time), songLengthInMs, isSelection); } /** @@ -79,11 +80,11 @@ class ChartEditorNotePreview extends FlxSprite * @param notes The data for the notes. * @param songLengthInMs The total length of the song in milliseconds. */ - public function addNotes(notes:Array, songLengthInMs:Int):Void + public function addNotes(notes:Array, songLengthInMs:Int, ?isSelection:Bool = false):Void { for (note in notes) { - addNote(note, songLengthInMs); + addNote(note, songLengthInMs, isSelection); } } @@ -106,8 +107,9 @@ class ChartEditorNotePreview extends FlxSprite * @param mustHit False if opponent, true if player. * @param strumTimeInMs Time in milliseconds to strum the note. * @param songLengthInMs Length of the song in milliseconds. + * @param isSelection If current note is selected note, which then it's forced to be green */ - function drawNote(dir:Int, mustHit:Bool, strumTimeInMs:Int, songLengthInMs:Int):Void + public function drawNote(dir:Int, mustHit:Bool, strumTimeInMs:Int, songLengthInMs:Int, ?isSelection:Bool = false):Void { var color:FlxColor = switch (dir) { @@ -118,13 +120,20 @@ class ChartEditorNotePreview extends FlxSprite default: EVENT_COLOR; }; + var noteHeight:Int = NOTE_HEIGHT; + + if (isSelection != null && isSelection) + { + color = SELECTED_COLOR; + noteHeight += 1; + } + var noteX:Float = NOTE_WIDTH * dir; if (mustHit) noteX += NOTE_WIDTH * 4; if (dir == -1) noteX = NOTE_WIDTH * 8; var noteY:Float = FlxMath.remapToRange(strumTimeInMs, 0, songLengthInMs, 0, previewHeight); - - drawRect(noteX, noteY, NOTE_WIDTH, NOTE_HEIGHT, color); + drawRect(noteX, noteY, NOTE_WIDTH, noteHeight, color); } function eraseNote(dir:Int, mustHit:Bool, strumTimeInMs:Int, songLengthInMs:Int):Void From 6f141e5f52810ae1dcc062ba33d27a31d200cc6c Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 8 Dec 2023 22:28:34 -0500 Subject: [PATCH 2/4] copy text popup --- .../ui/debug/charting/ChartEditorState.hx | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 66effc775..b52ab10bc 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -114,6 +114,7 @@ import haxe.ui.events.UIEvent; import haxe.ui.events.UIEvent; import haxe.ui.focus.FocusManager; import openfl.display.BitmapData; +import flixel.text.FlxText; using Lambda; @@ -1618,6 +1619,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState */ var healthIconBF:Null = null; + /** + * The text that pop's up when copying something + */ + var txtCopyNotif:Null = null; + /** * The purple background sprite. */ @@ -2273,6 +2279,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState add(playbarHeadLayout); + txtCopyNotif = new FlxText(0, 0, 0, '', 24); + txtCopyNotif.setBorderStyle(OUTLINE, 0xFF074809, 1); + txtCopyNotif.color = 0xFF52FF77; + txtCopyNotif.zIndex = 120; + add(txtCopyNotif); + if (!Preferences.debugDisplay) menubar.paddingLeft = null; this.setupNotifications(); @@ -4444,7 +4456,22 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // CTRL + C = Copy if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.C) { - // Copy selected notes. + if (currentNoteSelection.length > 0) + { + txtCopyNotif.visible = true; + txtCopyNotif.text = "Copied " + currentNoteSelection.length + " notes to clipboard"; + txtCopyNotif.x = FlxG.mouse.x - (txtCopyNotif.width / 2); + txtCopyNotif.y = FlxG.mouse.y - 16; + FlxTween.tween(txtCopyNotif, {y: txtCopyNotif.y - 32}, 0.5, + { + type: FlxTween.ONESHOT, + ease: FlxEase.quadOut, + onComplete: function(_) { + txtCopyNotif.visible = false; + } + }); + } + // We don't need a command for this since we can't undo it. SongDataUtils.writeItemsToClipboard( { From 87c866f662963989c475e8205d37bd9cbb4550d2 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 8 Dec 2023 22:55:14 -0500 Subject: [PATCH 3/4] copy notifier polish --- .../ui/debug/charting/ChartEditorState.hx | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index b52ab10bc..6686da462 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4470,6 +4470,32 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState txtCopyNotif.visible = false; } }); + + for (note in renderedNotes.members) + { + if (isNoteSelected(note.noteData)) + { + FlxTween.globalManager.cancelTweensOf(note); + FlxTween.globalManager.cancelTweensOf(note.scale); + note.playNoteAnimation(); + var prevX:Float = note.scale.x; + var prevY:Float = note.scale.y; + + note.scale.x *= 1.2; + note.scale.y *= 1.2; + + note.angle = FlxG.random.bool() ? -10 : 10; + FlxTween.tween(note, {"angle": 0}, 0.8, {ease: FlxEase.elasticOut}); + + FlxTween.tween(note.scale, {"y": prevX, "x": prevY}, 0.7, + { + ease: FlxEase.elasticOut, + onComplete: function(_) { + note.playNoteAnimation(); + } + }); + } + } } // We don't need a command for this since we can't undo it. From 7876b07c37f564bfe20988e70ef7204e3ed30052 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 9 Dec 2023 18:00:32 -0500 Subject: [PATCH 4/4] mac delete key fix --- source/funkin/ui/debug/charting/ChartEditorState.hx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 66effc775..7f556c05f 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4480,7 +4480,14 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } // DELETE = Delete - if (FlxG.keys.justPressed.DELETE) + var delete:Bool = FlxG.keys.justPressed.DELETE; + + // on macbooks, Delete == backspace + #if mac + delete = delete || FlxG.keys.justPressed.BACKSPACE; + #end + + if (delete) { // Delete selected items. if (currentNoteSelection.length > 0 && currentEventSelection.length > 0)