sustain dragging finally good :D

This commit is contained in:
lunarcleint
2024-03-09 21:34:23 -07:00
parent eda52577c6
commit cd5556fb5c
3 changed files with 11 additions and 29 deletions
+7 -8
View File
@@ -590,11 +590,7 @@ class Charter extends UIState {
if (gridActionType == NONE) {
if (s is CharterNote) {
var n:CharterNote = cast s;
if (n.sustainDraggable) { // So it feels smoother :D -lunar
if (FlxG.mouse.justPressed && !selection.contains(s)) select(cast s);
} else if (FlxG.mouse.justReleased && s.hovered) select(cast s);
if ((n.hovered || n.sustainDraggable) && FlxG.mouse.justReleased) select(cast s);
} else if (FlxG.mouse.justReleased && s.hovered) select(cast s);
}
});
@@ -762,9 +758,12 @@ class Charter extends UIState {
if (selectionDragging) {
currentCursor = BUTTON;
selection.loop(function (n:CharterNote) {
n.tempSusLength = Math.max((mousePos.y-dragStartPos.y) / 40, -n.susLength);
if (!FlxG.keys.pressed.SHIFT) n.tempSusLength = quantStep(n.tempSusLength);
@:privateAccess n.__susInstaLerp = true;
var change:Float = Math.max((mousePos.y-(FlxG.keys.pressed.SHIFT ? dragStartPos.y : quantStep(dragStartPos.y))) / 40, -n.susLength);
n.tempSusLength = change;
if (!FlxG.keys.pressed.SHIFT)
n.tempSusLength -= (n.susLength + change) - quantStepRounded(n.susLength + change, change > 0 ? 0.35 : 0.65);
@:privateAccess n.__susInstaLerp = FlxG.keys.pressed.SHIFT;
});
} else {
var undoChanges:Array<NoteSustainChange> = [];
+3 -20
View File
@@ -21,7 +21,6 @@ class CharterNote extends UISprite implements ICharterSelectable {
];
public var sustainSpr:UISprite;
public var sustainHitbox:UISprite;
public var tempSusLength:Float = 0;
public var sustainDraggable:Bool = false;
@@ -44,16 +43,9 @@ class CharterNote extends UISprite implements ICharterSelectable {
sustainSpr.scale.set(10, 0);
members.push(sustainSpr);
sustainHitbox = new UISprite(20, 40);
sustainHitbox.makeSolid(1, 1, -1);
sustainHitbox.scale.set(20, 20);
sustainHitbox.updateHitbox();
members.push(sustainHitbox);
sustainHitbox.alpha = 0;
typeText = new UIText(x, y, 0, Std.string(type));
cursor = sustainSpr.cursor = sustainHitbox.cursor = BUTTON;
cursor = sustainSpr.cursor = BUTTON;
moves = false;
}
@@ -94,8 +86,6 @@ class CharterNote extends UISprite implements ICharterSelectable {
y = step * 40;
sustainHitbox.exists = susLength == 0;
if (angleTween != null) angleTween.cancel();
var destAngle = switch(animation.curAnim.curFrame = (id % 4)) {
@@ -143,20 +133,13 @@ class CharterNote extends UISprite implements ICharterSelectable {
public override function update(elapsed:Float) {
super.update(elapsed);
sustainDraggable = false;
if (sustainHitbox.exists) {
sustainHitbox.follow(this, 10, height-10);
UIState.state.updateSpriteRect(sustainHitbox);
sustainDraggable = UIState.state.isOverlapping(sustainHitbox, @:privateAccess sustainHitbox.__rect);
}
var sprLength:Float = (40 * (susLength+tempSusLength)) + ((susLength+tempSusLength) != 0 ? (height/2) : 0);
sustainSpr.scale.set(10, __susInstaLerp ? sprLength : CoolUtil.fpsLerp(sustainSpr.scale.y, sprLength, 1/2));
sustainSpr.updateHitbox();
sustainSpr.follow(this, 15, 20);
if (!hovered && !sustainDraggable && susLength != 0) {
sustainDraggable = false;
if (!hovered && susLength != 0) {
UIState.state.updateSpriteRect(sustainSpr);
sustainDraggable = UIState.state.isOverlapping(sustainSpr, @:privateAccess sustainSpr.__rect);
}
@@ -7,7 +7,7 @@ class CharterNoteHoverer extends CharterNote {
super();
snappedToStrumline = selectable = autoAlpha = false; visible = sustainSpr.visible = false;
@:privateAccess __animSpeed = 1.25; typeText.visible = false; alpha = 0.4; sustainHitbox.exists = false;
@:privateAccess __animSpeed = 1.25; typeText.visible = false; alpha = 0.4;
}
@:noCompletion var __mousePos:FlxPoint = FlxPoint.get();