From 7cc46374b51b5adc94c4d3a01d4ba3ed441c8cc5 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 22 Mar 2024 17:58:36 -0700 Subject: [PATCH] indicator for delete thingy --- source/funkin/editors/charter/Charter.hx | 6 ++--- .../editors/charter/CharterDeleteAnim.hx | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 34671758..aa7dc29c 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -806,7 +806,7 @@ class Charter extends UIState { FlxG.mouse.getWorldPosition(charterCamera, dragStartPos); else if (FlxG.mouse.justPressedRight) { closeCurrentContextMenu(); - gridActionType = DELTE_SELECTION; + gridActionType = DELETE_SELECTION; } if (gridBackdropDummy.hovered) { @@ -886,7 +886,7 @@ class Charter extends UIState { gridActionType = NONE; currentCursor = ARROW; } - case DELTE_SELECTION: + case DELETE_SELECTION: notesGroup.forEach(function(n) { if (n.hovered || n.sustainDraggable) { deletedNotes.push(n); @@ -1960,7 +1960,7 @@ enum abstract CharterGridActionType(Int) { var NOTE_DRAG = 2; var INVALID_DRAG = 3; var SUSTAIN_DRAG = 4; - var DELTE_SELECTION = 5; + var DELETE_SELECTION = 5; } typedef PlaytestInfo = { diff --git a/source/funkin/editors/charter/CharterDeleteAnim.hx b/source/funkin/editors/charter/CharterDeleteAnim.hx index 51a33eca..f291ab93 100644 --- a/source/funkin/editors/charter/CharterDeleteAnim.hx +++ b/source/funkin/editors/charter/CharterDeleteAnim.hx @@ -1,6 +1,8 @@ package funkin.editors.charter; class CharterDeleteAnim extends CharterNote { + public var garbageIcon:FlxSprite; + public var deleteNotes:Array<{note:CharterNote, time:Float}> = []; public var deleteTime:Float = .4; @@ -10,13 +12,31 @@ class CharterDeleteAnim extends CharterNote { sustainSpr.color = 0xFF6D2425; color = 0xFF797171; snappedToStrumline = selectable = autoAlpha = false; @:privateAccess __animSpeed = 1.25; + + garbageIcon = new FlxSprite().loadGraphic(Paths.image("editors/autosave-delete")); + garbageIcon.color = 0xFF880000; + garbageIcon.cameras = [Charter.instance.uiCamera]; } + var __garbageAlpha:Float = 0; + var __deletionTimer:Float = .1; public override function update(elapsed:Float) { for (deleteData in deleteNotes) { deleteData.time -= elapsed; if (deleteData.time < 0) deleteNotes.remove(deleteData); } + + if (FlxG.mouse.justPressedRight) __deletionTimer = .1; + __deletionTimer -= elapsed; + + __garbageAlpha = FlxMath.lerp(__garbageAlpha, FlxG.mouse.pressedRight && __deletionTimer <= 0 ? 1 : 0, 1/10); + + if (FlxG.mouse.pressedRight && __deletionTimer <= 0) + garbageIcon.setPosition( + FlxG.mouse.screenX + garbageIcon.width/2 + (.5*FlxG.random.float(-1, 1)), + FlxG.mouse.screenY - garbageIcon.height + (.5*FlxG.random.float(-1, 1)) + ); + garbageIcon.alpha = __garbageAlpha; } public override function draw() @:privateAccess { @@ -39,5 +59,7 @@ class CharterDeleteAnim extends CharterNote { super.draw(); } + + if (garbageIcon.alpha > 0) garbageIcon.draw(); } } \ No newline at end of file