From 279970289338e1a6cbe19149373301d92faf9bce Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Thu, 27 Jul 2023 16:10:16 -0700 Subject: [PATCH] bpm events not draggable --- source/funkin/editors/charter/Charter.hx | 13 +++++++++---- source/funkin/editors/charter/CharterEvent.hx | 8 ++++++++ source/funkin/editors/charter/CharterNote.hx | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 6f2ac093..1f3f3305 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -569,6 +569,7 @@ class Charter extends UIState { var changePoint:FlxPoint = FlxPoint.get(verticalChange, horizontalChange); for (s in selection) { + if (!s.draggable) continue; s.handleDrag(changePoint); if (s is UISprite) cast(s, UISprite).cursor = BUTTON; } @@ -1051,7 +1052,8 @@ class Charter extends UIState { case CEditEvent(event, oldEvents, newEvents): // case CSelectionDrag(selection, change): - for (s in selection) s.handleDrag(change * -1); + for (s in selection) + if (s.draggable) s.handleDrag(change * -1); this.selection = selection; case CDeleteStrumLine(strumLineID, strumLine): createStrumline(strumLineID, strumLine, false); @@ -1107,7 +1109,8 @@ class Charter extends UIState { for(n in changes) n.note.updatePos(n.note.step, n.note.id, n.after, n.note.type); case CSelectionDrag(selection, change): - for (s in selection) s.handleDrag(change); + for (s in selection) + if (s.draggable) s.handleDrag(change); this.selection = selection; case CDeleteStrumLine(strumLineID, strumLine): deleteStrumline(strumLineID, false); @@ -1302,9 +1305,9 @@ typedef NoteSustainChange = { // too lazy to put this in every for loop so i made it a abstract public inline function loop(onNote:CharterNote->Void, ?onEvent:CharterEvent->Void) { for (s in this) { - if (s is CharterNote && onNote != null) + if (s is CharterNote && onNote != null && s.draggable) onNote(cast(s, CharterNote)); - else if (s is CharterEvent && onEvent != null) + else if (s is CharterEvent && onEvent != null && s.draggable) onEvent(cast(s, CharterEvent)); } } @@ -1312,8 +1315,10 @@ typedef NoteSustainChange = { interface ICharterSelectable { public var step:Float; + public var selected:Bool; public var hovered:Bool; + public var draggable:Bool; public function handleSelection(selectionBox:UISliceSprite):Bool; public function handleDrag(change:FlxPoint):Void; diff --git a/source/funkin/editors/charter/CharterEvent.hx b/source/funkin/editors/charter/CharterEvent.hx index 8123f3ed..21723627 100644 --- a/source/funkin/editors/charter/CharterEvent.hx +++ b/source/funkin/editors/charter/CharterEvent.hx @@ -13,6 +13,7 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable { public var icons:Array = []; public var selected:Bool = false; + public var draggable:Bool = true; public function new(step:Float, ?events:Array) { super(-100, (step * 40) - 17, 100, 34, 'editors/charter/event-spr'); @@ -94,6 +95,13 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable { members.push(spr); } + draggable = true; + for (event in events) + if (event.name == "BPM Change") { + draggable = false; + break; + } + x = -(bWidth = 37 + (icons.length * 22)); } } \ No newline at end of file diff --git a/source/funkin/editors/charter/CharterNote.hx b/source/funkin/editors/charter/CharterNote.hx index 353b0a8d..fc817b94 100644 --- a/source/funkin/editors/charter/CharterNote.hx +++ b/source/funkin/editors/charter/CharterNote.hx @@ -21,6 +21,7 @@ class CharterNote extends UISprite implements ICharterSelectable { var __doAnim:Bool = false; public var selected:Bool = false; + public var draggable:Bool = true; public function new() { super();