broke selection

This commit is contained in:
Frakits
2025-01-25 16:38:17 +02:00
parent bb42fdc583
commit 0102cbbdb6
3 changed files with 31 additions and 17 deletions
+18 -14
View File
@@ -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) {
+8 -2
View File
@@ -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;
}
}
}
+5 -1
View File
@@ -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) {