From f6a30c618590b33d9897ef23611070bb6ce2f9df Mon Sep 17 00:00:00 2001 From: Frakist <90983918+Frakist@users.noreply.github.com> Date: Fri, 4 Aug 2023 15:46:44 +0300 Subject: [PATCH] minor changes --- source/funkin/editors/ui/UIButtonList.hx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/source/funkin/editors/ui/UIButtonList.hx b/source/funkin/editors/ui/UIButtonList.hx index 22ca2580..d3cffbb5 100644 --- a/source/funkin/editors/ui/UIButtonList.hx +++ b/source/funkin/editors/ui/UIButtonList.hx @@ -45,21 +45,23 @@ class UIButtonList extends UIWindow { members.push(addButton); members.push(buttons); - scrollY = buttonCameras.scroll.y = -this.buttonSpacing; + nextscrollY = buttonCameras.scroll.y = -this.buttonSpacing; } public inline function add(button:T) { buttons.add(button); curMovingInterval = 0; + nextscrollY += button.bHeight; } public inline function insert(button:T, position:Int) { buttons.insert(position, button); - scrollY += button.bHeight; + nextscrollY += button.bHeight; } public inline function remove(button:T) { + nextscrollY -= button.bHeight; buttons.members.remove(button); button.destroy(); } @@ -95,25 +97,19 @@ class UIButtonList extends UIWindow { } addIcon.x = addButton.x + addButton.bWidth / 2 - addIcon.width / 2; addIcon.y = addButton.y + addButton.bHeight / 2 - addIcon.height / 2; } - - var scrollY:Float = 0; - + var nextscrollY:Float = 0; public override function update(elapsed:Float) { updateButtonsPos(elapsed); dragging = Math.abs(curMovingInterval) > addButton.bHeight / 2; super.update(elapsed); - // Camera Stuff - var nextscrollY = scrollY - (hovered ? FlxG.mouse.wheel : 0) * 12; + nextscrollY = FlxMath.bound(buttonCameras.scroll.y - (hovered ? FlxG.mouse.wheel : 0) * 12, -buttonSpacing, Math.max((addButton.y + 32 + (buttonSpacing*1.5)) - buttonCameras.height, -buttonSpacing)); if (curMoving != null && dragging) { nextscrollY -= Math.min((bHeight - 100) - FlxG.mouse.getWorldPosition(buttonCameras).y, 0) / 8; nextscrollY += Math.min(FlxG.mouse.getWorldPosition(buttonCameras).y - 100, 0) / 8; } - - if (nextscrollY >= (-buttonSpacing) && nextscrollY + buttonCameras.height <= (addButton.y + 32 + (buttonSpacing*1.5))) - scrollY = nextscrollY; buttonCameras.scroll.y = FlxMath.lerp(buttonCameras.scroll.y, nextscrollY, 1/3);