diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 35c1148b..b7fa5fca 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -464,10 +464,11 @@ class Charter extends UIState { refreshBPMSensitive(); } + public var __endStep:Float = 0; public function refreshBPMSensitive() { // refreshes everything dependant on BPM, and BPM changes var length = FlxG.sound.music.getDefault(vocals).length; - scrollBar.length = Conductor.getStepForTime(length); + scrollBar.length = __endStep = Conductor.getStepForTime(length); gridBackdropGroup.bottomLimitY = Conductor.getStepForTime(length) * 40; eventsBackdrop.bottomSeparator.y = gridBackdropGroup.bottomLimitY-2; @@ -558,6 +559,7 @@ class Charter extends UIState { selection.loop(function (n:CharterNote) { n.snappedToStrumline = false; n.setPosition(n.fullID * 40 + (mousePos.x - dragStartPos.x), n.step * 40 + (mousePos.y - dragStartPos.y)); + n.y = FlxMath.bound(n.y, 0, (__endStep*40) - n.height); n.cursor = HAND; }, function (e:CharterEvent) { e.y = e.step * 40 + (mousePos.y - dragStartPos.y) - 17; @@ -611,9 +613,9 @@ class Charter extends UIState { for (n in selection) n.selected = false; selection = []; // clear selection } else { - if (mouseOnGrid) { + if (mouseOnGrid && mousePos.y > 0 && mousePos.y < (__endStep)*40) { var note = new CharterNote(); - note.updatePos(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Math.floor(mousePos.y / 40), id % 4, 0, 0, strumLines.members[Std.int(id/4)]); + note.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Math.floor(mousePos.y / 40), 0, __endStep-1), id % 4, 0, 0, strumLines.members[Std.int(id/4)]); notesGroup.add(note); selection = [note]; undos.addToUndo(CCreateSelection([note])); diff --git a/source/funkin/editors/charter/CharterNote.hx b/source/funkin/editors/charter/CharterNote.hx index d4df4b26..df2b522e 100644 --- a/source/funkin/editors/charter/CharterNote.hx +++ b/source/funkin/editors/charter/CharterNote.hx @@ -152,11 +152,12 @@ class CharterNote extends UISprite implements ICharterSelectable { } public function handleDrag(change:FlxPoint) { + var newStep = FlxMath.bound(step + change.x, 0, Charter.instance.__endStep-1); var newID:Int = fullID + Std.int(change.y); if (newID > ((Charter.instance.strumLines.members.length*4)-1)) newID %= 4; else if (newID < 0) newID = (Charter.instance.strumLines.members.length*4) + newID % 4; - updatePos(step + change.x, newID % 4, susLength, type, Charter.instance.strumLines.members[Std.int(newID/4)]); + updatePos(newStep, newID % 4, susLength, type, Charter.instance.strumLines.members[Std.int(newID/4)]); } public override function draw() { diff --git a/source/funkin/editors/charter/CharterStrumLineGroup.hx b/source/funkin/editors/charter/CharterStrumLineGroup.hx index a970918a..f2f3667b 100644 --- a/source/funkin/editors/charter/CharterStrumLineGroup.hx +++ b/source/funkin/editors/charter/CharterStrumLineGroup.hx @@ -37,11 +37,11 @@ class CharterStrumLineGroup extends FlxTypedGroup { for (i=>strum in members) if (strum != null && !strum.dragging) strum.x = CoolUtil.fpsLerp(strum.x, 160 * i, 0.225); - if (Charter.instance.eventsBackdrop != null) + if (Charter.instance.eventsBackdrop != null && members[0] != null) Charter.instance.eventsBackdrop.x = members[0].button.x - Charter.instance.eventsBackdrop.width; - if (Charter.instance.strumlineLockButton != null) + if (Charter.instance.strumlineLockButton != null && members[0] != null) Charter.instance.strumlineLockButton.x = members[0].x - (40*4); - if (Charter.instance.strumlineAddButton != null) + if (Charter.instance.strumlineAddButton != null && members[Std.int(Math.max(0, members.length-1))] != null) Charter.instance.strumlineAddButton.x = members[members.length-1].x + (40*4); if ((FlxG.mouse.justReleased || !draggable) && isDragging)