From 285855b19571477c5b5cdc82711bddecf5aceef0 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Wed, 17 Jul 2024 10:07:02 -0700 Subject: [PATCH] fix button spacing/flicker --- .../editors/character/CharacterAnimButton.hx | 15 +++++++++------ source/funkin/editors/ui/UIButtonList.hx | 8 +++++--- source/funkin/game/Character.hx | 5 +++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/source/funkin/editors/character/CharacterAnimButton.hx b/source/funkin/editors/character/CharacterAnimButton.hx index 2dd828c0..643a5c1f 100644 --- a/source/funkin/editors/character/CharacterAnimButton.hx +++ b/source/funkin/editors/character/CharacterAnimButton.hx @@ -172,9 +172,7 @@ class CharacterAnimButton extends UIButton { members.push(ghostIcon); } - public override function update(elapsed:Float) { - bHeight = closed ? 52 : 208; - + public inline function updateButtonsPos() { playIcon.follow(this, 22, (52/2) - (playIcon.height/2)); field.follow(this, 22+16+10, (52/2) - (field.height/2) + 1); @@ -200,13 +198,17 @@ class CharacterAnimButton extends UIButton { indicesTextBox.follow(this, 158, 164); - for (button in foldableButtons) - button.visible = button.active = !closed; - for (ui => text in labels) { text.follow(ui, -(2+(ui is UICheckbox?12:0)), -(18+(ui is UICheckbox?6:0))); text.visible = text.active = ui.visible; } + } + + public override function update(elapsed:Float) { + bHeight = closed ? 52 : 208; + + for (button in foldableButtons) + button.visible = button.active = !closed; super.update(elapsed); } @@ -366,6 +368,7 @@ class CharacterAnimButton extends UIButton { } public override function draw() { + updateButtonsPos(); super.draw(); if (!closed && parent.displayAnimsFramesList.exists(anim)) { diff --git a/source/funkin/editors/ui/UIButtonList.hx b/source/funkin/editors/ui/UIButtonList.hx index faabae26..3d71997a 100644 --- a/source/funkin/editors/ui/UIButtonList.hx +++ b/source/funkin/editors/ui/UIButtonList.hx @@ -67,21 +67,23 @@ class UIButtonList extends UIWindow { } public inline function updateButtonsPos(elapsed:Float) { + var endButtonY:Float = 0; for (i => button in buttons.members) { if (button == null) continue; - + if (curMoving != button) { button.setPosition( (bWidth/2) - (buttonSize.x/2) + buttonOffset.x, - CoolUtil.fpsLerp(button.y, ((buttonSize.y+buttonSpacing) * i) + buttonOffset.y, 0.25)); + CoolUtil.fpsLerp(button.y, endButtonY + buttonOffset.y, 0.25)); } + endButtonY += button.bHeight+buttonSpacing; if (button.hovered && FlxG.mouse.justPressed) curMoving = button; } if (addButton != null) addButton.setPosition( (bWidth/2) - (buttonSize.x/2) + buttonOffset.x, - CoolUtil.fpsLerp(addButton.y, ((buttonSize.y+buttonSpacing) * buttons.members.length) + buttonOffset.y, 0.25)); + CoolUtil.fpsLerp(addButton.y, endButtonY + buttonOffset.y, 0.25)); if (curMoving != null) { curMovingInterval += FlxG.mouse.deltaY; diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index c1b55826..3dc833d0 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -305,6 +305,11 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset for (anim in xml.nodes.anim) XMLUtil.addXMLAnimation(this, anim); + for (offset in animOffsets) { + offset.x = FlxMath.roundDecimal(offset.x, 2); + offset.y = FlxMath.roundDecimal(offset.y, 2); + } + for (attribute in xml.x.attributes()) if (!characterProperties.contains(attribute)) extra[attribute] = xml.x.get(attribute);