From ded62283ffd35e56a93ce7ee281928eec8df06c5 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Tue, 16 Apr 2024 02:51:27 +0200 Subject: [PATCH] Added dragging + Fixed bug with cursor icon --- source/funkin/editors/stage/StageEditor.hx | 6 ++++++ .../stage/elements/StageElementButton.hx | 18 +++++++++++++++--- source/funkin/editors/ui/UIButton.hx | 6 +++++- source/funkin/editors/ui/UIState.hx | 6 ++---- source/funkin/editors/ui/UIWindow.hx | 4 ++++ 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/source/funkin/editors/stage/StageEditor.hx b/source/funkin/editors/stage/StageEditor.hx index d5e39655..51f8c3bb 100644 --- a/source/funkin/editors/stage/StageEditor.hx +++ b/source/funkin/editors/stage/StageEditor.hx @@ -248,6 +248,12 @@ class StageEditor extends UIState { stageSpritesWindow.middleAlpha = 0.5; stageSpritesWindow.bottomAlpha = 0.5; stageSpritesWindow.buttonSpacing = 0; + stageSpritesWindow.dragCallback = (button, oldID, newID) -> { + var sprite:FunkinSprite = button.getSprite(); + var idx = members.indexOf(sprite); + members.splice(idx, 1); + members.insert(newID, sprite); + } stageSpritesWindow.addButton.callback = () -> { // TODO: implement this } diff --git a/source/funkin/editors/stage/elements/StageElementButton.hx b/source/funkin/editors/stage/elements/StageElementButton.hx index d8137986..49194d5d 100644 --- a/source/funkin/editors/stage/elements/StageElementButton.hx +++ b/source/funkin/editors/stage/elements/StageElementButton.hx @@ -92,17 +92,29 @@ class StageElementButton extends UIButton { field.x += 12; tagColor.color = color; + } - if(selected != _lastSelected) { - _lastSelected = selected; + //private var _lastHovered:Bool = false; + + public override function draw() { + //if(_lastHovered != (_lastHovered = hovered && !pressed)) { + if(_lastSelected != (_lastSelected = selected)) { updateColorTransform(); } + super.draw(); } + /*public override function setFrameOffset() { + var _frameOffset = 0; + if(selected) _frameOffset = 9; + if(hovered && pressed) _frameOffset = 18; + framesOffset = _frameOffset; + }*/ + public override function updateColorTransform() { super.updateColorTransform(); - if (selected) { + if(selected) { useColorTransform = true; colorTransform.setOffsets(70, 70, 70, 0); } else { diff --git a/source/funkin/editors/ui/UIButton.hx b/source/funkin/editors/ui/UIButton.hx index bb10fad9..46bc30b5 100644 --- a/source/funkin/editors/ui/UIButton.hx +++ b/source/funkin/editors/ui/UIButton.hx @@ -38,7 +38,11 @@ class UIButton extends UISliceSprite { } public override function draw() { - framesOffset = hovered ? (pressed ? 18 : 9) : 0; + setFrameOffset(); super.draw(); } + + public function setFrameOffset() { + framesOffset = hovered ? (pressed ? 18 : 9) : 0; + } } \ No newline at end of file diff --git a/source/funkin/editors/ui/UIState.hx b/source/funkin/editors/ui/UIState.hx index ea2f6781..953a4f07 100644 --- a/source/funkin/editors/ui/UIState.hx +++ b/source/funkin/editors/ui/UIState.hx @@ -105,14 +105,12 @@ class UIState extends MusicBeatState { FlxG.sound.keysAllowed = currentFocus != null ? !(currentFocus is UITextBox) : true; - if (hoveredSprite != null) { + if (hoveredSprite != null && hoveredSprite.cursor != null) { NativeAPI.setCursorIcon(hoveredSprite.cursor); - //Mouse.cursor = hoveredSprite.cursor; - hoveredSprite = null; } else { NativeAPI.setCursorIcon(currentCursor); - //Mouse.cursor = currentCursor; } + hoveredSprite = null; } public override function destroy() { diff --git a/source/funkin/editors/ui/UIWindow.hx b/source/funkin/editors/ui/UIWindow.hx index 84fb80e4..29abb538 100644 --- a/source/funkin/editors/ui/UIWindow.hx +++ b/source/funkin/editors/ui/UIWindow.hx @@ -31,6 +31,10 @@ class UIWindow extends UISliceSprite { drawMiddle = !drawMiddle; drawBottom = !drawBottom; } + } else { + if(!content.exists) { + cursor = null; + } } }