diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 1b2ad184..32cb7ab4 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -594,21 +594,31 @@ class Charter extends UIState { }); currentCursor = HAND; } else { + var hoverOffset:FlxPoint = FlxPoint.get(); + for (s in selection) + if (s.hovered) { + hoverOffset.set(mousePos.x - s.x, mousePos.y - s.y); + break; + } + dragStartPos.set(Std.int(dragStartPos.x / 40) * 40, Std.int(dragStartPos.y / 40) * 40); - var verticalChange:Float = (mousePos.y - dragStartPos.y) / 40; - if (!FlxG.keys.pressed.SHIFT) - verticalChange = CoolUtil.floorInt(verticalChange); + var verticalChange:Float = + FlxG.keys.pressed.SHIFT ? ((mousePos.y - hoverOffset.y) - dragStartPos.y) / 40 + : CoolUtil.floorInt((mousePos.y - dragStartPos.y) / 40); var horizontalChange:Int = CoolUtil.floorInt((mousePos.x - dragStartPos.x) / 40); var changePoint:FlxPoint = FlxPoint.get(verticalChange, horizontalChange); + trace(dragStartPos, hoverOffset,changePoint); for (s in selection) { if (!s.draggable) continue; s.handleDrag(changePoint); if (s is UISprite) cast(s, UISprite).cursor = BUTTON; } + sortNotes(); addToUndo(CSelectionDrag(selection, changePoint.clone())); changePoint.put(); + hoverOffset.put(); gridActionType = NONE; currentCursor = ARROW; @@ -633,6 +643,7 @@ class Charter extends UIState { note.updatePos(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Math.floor(mousePos.y / 40), id, 0, 0); notesGroup.add(note); selection = [note]; + sortNotes(); addToUndo(CCreateSelection([note])); } } @@ -641,10 +652,12 @@ class Charter extends UIState { // TODO: NOTE DRAGGING if (FlxG.mouse.pressed && (Math.abs(mousePos.x - dragStartPos.x) > 5 || Math.abs(mousePos.y - dragStartPos.y) > 5)) { var noteHovered:Bool = false; - for(n in selection) if (n.hovered) { - noteHovered = true; - break; - } + for(n in selection) + if (n.hovered) { + noteHovered = true; + break; + } + gridActionType = noteHovered ? DRAG : INVALID_DRAG; } } @@ -694,6 +707,7 @@ class Charter extends UIState { eventsGroup.remove(event, true); event.kill(); } + sortNotes(); if (addToUndo) this.addToUndo(CDeleteSelection([selected])); @@ -1347,6 +1361,8 @@ typedef NoteSustainChange = { } interface ICharterSelectable { + public var x(default, set):Float; + public var y(default, set):Float; public var step:Float; public var selected:Bool; diff --git a/source/funkin/editors/charter/CharterSelection.hx b/source/funkin/editors/charter/CharterSelection.hx index c753027a..2477a65f 100644 --- a/source/funkin/editors/charter/CharterSelection.hx +++ b/source/funkin/editors/charter/CharterSelection.hx @@ -104,6 +104,7 @@ class CharterSelection extends EditorTreeMenu { #end // Add to List + freeplayList.songs.insert(0, creation.meta); main.members.insert(1, new IconOption(creation.meta.name, "Press ACCEPT to choose a difficulty to edit.", creation.meta.icon, function() { var list:Array = [ for(d in creation.meta.difficulties) diff --git a/source/funkin/editors/charter/SongCreationScreen.hx b/source/funkin/editors/charter/SongCreationScreen.hx index 82bf9777..d4f6f57f 100644 --- a/source/funkin/editors/charter/SongCreationScreen.hx +++ b/source/funkin/editors/charter/SongCreationScreen.hx @@ -201,7 +201,7 @@ class SongCreationScreen extends UISubstateWindow { } else saveButton.selectable = true; - + saveButton.alpha = saveButton.field.alpha = saveButton.selectable ? 1 : 0.4; super.update(elapsed); } diff --git a/source/funkin/editors/ui/UIAudioPlayer.hx b/source/funkin/editors/ui/UIAudioPlayer.hx index 37227ca5..daf6b3b2 100644 --- a/source/funkin/editors/ui/UIAudioPlayer.hx +++ b/source/funkin/editors/ui/UIAudioPlayer.hx @@ -123,7 +123,9 @@ class UIAudioPlayer extends UIButton { } } } + spritePos.put(); } + mousePos.put(); if (FlxG.mouse.released) { if (draggingObj == timeBar && wasPlaying) diff --git a/source/funkin/editors/ui/UIButton.hx b/source/funkin/editors/ui/UIButton.hx index 74199d67..f39730f9 100644 --- a/source/funkin/editors/ui/UIButton.hx +++ b/source/funkin/editors/ui/UIButton.hx @@ -39,7 +39,6 @@ class UIButton extends UISliceSprite { public override function update(elapsed:Float) { field.follow(this, 0, (bHeight - field.height) / 2); if (!hovered && hasBeenPressed && FlxG.mouse.justReleased) hasBeenPressed = false; - alpha = field.alpha = selectable ? 1 : 0.4; super.update(elapsed); }