diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 2df502b6..717aa224 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -684,6 +684,7 @@ class Charter extends UIState { public var dragStartPos:FlxPoint = new FlxPoint(); public var mousePos:FlxPoint = new FlxPoint(); public var selectionDragging:Bool = false; + public var isSelecting:Bool = false; public function updateSelectionLogic() { function select(s:ICharterSelectable) { @@ -752,7 +753,7 @@ class Charter extends UIState { case BOX_SELECTION: if (gridBackdropDummy.hoveredByChild) { selectionBox.visible = true; - if (FlxG.mouse.pressed) { + if (isSelecting) { selectionBox.x = Math.min(mousePos.x, dragStartPos.x); selectionBox.y = Math.min(mousePos.y, dragStartPos.y); selectionBox.bWidth = Std.int(Math.abs(mousePos.x - dragStartPos.x)); @@ -862,26 +863,29 @@ class Charter extends UIState { if (gridBackdropDummy.hovered) { // AUTO DETECT - if (FlxG.mouse.pressed && (Math.abs(mousePos.x - dragStartPos.x) > 20 || Math.abs(mousePos.y - dragStartPos.y) > 20)) + if (FlxG.mouse.justPressed && (Math.abs(mousePos.x - dragStartPos.x) > 20 || Math.abs(mousePos.y - dragStartPos.y) > 20)) { + isSelecting = true; gridActionType = BOX_SELECTION; + } var id = Math.floor(mousePos.x / 40); var mouseOnGrid = id >= 0 && id < 4 * gridBackdrops.strumlinesAmount && mousePos.y >= 0; if (FlxG.mouse.justReleased) { - for (n in selection) n.selected = false; - selection = []; + for (n in selection) n.selected = false; + selection = []; - if (mouseOnGrid && mousePos.y > 0 && mousePos.y < (__endStep)*40) { - var note = new CharterNote(); - note.updatePos( - FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : quantStep(mousePos.y/40), 0, __endStep-1), - id % 4, 0, noteType, strumLines.members[Std.int(id/4)] - ); - notesGroup.add(note); - selection = [note]; - undos.addToUndo(CCreateSelection([note])); - } + if (mouseOnGrid && mousePos.y > 0 && mousePos.y < (__endStep)*40) { + var note = new CharterNote(); + note.updatePos( + FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : quantStep(mousePos.y/40), 0, __endStep-1), + id % 4, 0, noteType, strumLines.members[Std.int(id/4)] + ); + notesGroup.add(note); + selection = [note]; + undos.addToUndo(CCreateSelection([note])); + } + isSelecting = false; } } else if (gridBackdropDummy.hoveredByChild) { if (FlxG.mouse.pressed) { diff --git a/source/funkin/editors/ui/UIScrollBar.hx b/source/funkin/editors/ui/UIScrollBar.hx index c6ef73d2..55514e09 100644 --- a/source/funkin/editors/ui/UIScrollBar.hx +++ b/source/funkin/editors/ui/UIScrollBar.hx @@ -31,6 +31,7 @@ class UIScrollBar extends UISprite { members.push(thumbIcon); } + public var isScrolling:Bool = false; public override function update(elapsed:Float) { var lastHovered = hovered; @@ -42,7 +43,9 @@ class UIScrollBar extends UISprite { thumbIcon.follow(thumb, 0, Std.int((thumb.bHeight - thumbIcon.height) / 2)); thumbIcon.alpha = thumb.bHeight > 30 ? 1 : 0; - if ((lastHovered || lastHoveredThumb) && FlxG.mouse.pressed) { + if ((lastHovered || lastHoveredThumb) && FlxG.mouse.justPressed) isScrolling = true; + + if (isScrolling) { thumb.framesOffset = 18; var mousePos = FlxG.mouse.getScreenPosition(__lastDrawCameras[0], FlxPoint.get()); var yPos = FlxMath.bound(FlxMath.remapToRange(mousePos.y, y, y+height, -(size/2), length + size), 0, length); @@ -52,7 +55,10 @@ class UIScrollBar extends UISprite { onChange(value); } mousePos.put(); - } else + } + if (FlxG.mouse.justReleased && isScrolling) { + isScrolling = false; thumb.framesOffset = lastHoveredThumb ? 9 : 0; + } } } \ No newline at end of file diff --git a/source/funkin/editors/ui/UISlider.hx b/source/funkin/editors/ui/UISlider.hx index 0a6a853d..20fc219f 100644 --- a/source/funkin/editors/ui/UISlider.hx +++ b/source/funkin/editors/ui/UISlider.hx @@ -94,6 +94,8 @@ class UISlider extends UISprite { var __stepperWidth = 25; + public var isSliding:Bool = false; + public override function update(elapsed:Float) { selectableHitbox.follow(this, 0, (height-selectableHitbox.height)/2); @@ -103,10 +105,12 @@ class UISlider extends UISprite { var lastBarProgress:Float = __barProgress; - if (selectableHitbox.hovered && FlxG.mouse.pressed) { + if (selectableHitbox.hovered && FlxG.mouse.justPressed) isSliding = true; + if (isSliding) { var mousePos = FlxG.mouse.getScreenPosition(__lastDrawCameras[0], FlxPoint.get()); __barProgress = FlxMath.bound(mousePos.x-x, 0, barWidth)/barWidth; mousePos.put(); + if (FlxG.mouse.justReleased) isSliding = false; } if (__barProgress != lastBarProgress) {