diff --git a/buildnumber.txt b/buildnumber.txt index 8ee7f939..2f4a7459 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2606 +2607 \ No newline at end of file diff --git a/source/funkin/editors/ui/UIButton.hx b/source/funkin/editors/ui/UIButton.hx index 996fc579..e8d52d58 100644 --- a/source/funkin/editors/ui/UIButton.hx +++ b/source/funkin/editors/ui/UIButton.hx @@ -16,6 +16,8 @@ class UIButton extends UISpliceSprite { field.borderSize = 1; field.alignment = CENTER; field.fieldWidth = w; + + cursor = BUTTON; } public override function resize(w:Int, h:Int) { diff --git a/source/funkin/editors/ui/UICheckbox.hx b/source/funkin/editors/ui/UICheckbox.hx index f268dbad..043a458d 100644 --- a/source/funkin/editors/ui/UICheckbox.hx +++ b/source/funkin/editors/ui/UICheckbox.hx @@ -23,6 +23,8 @@ class UICheckbox extends UISprite { members.push(check); members.push(field); + + cursor = BUTTON; } public override function update(elapsed:Float) { diff --git a/source/funkin/editors/ui/UISprite.hx b/source/funkin/editors/ui/UISprite.hx index f0c3ad41..adf91650 100644 --- a/source/funkin/editors/ui/UISprite.hx +++ b/source/funkin/editors/ui/UISprite.hx @@ -2,6 +2,7 @@ package funkin.editors.ui; import flixel.util.FlxDestroyUtil; import flixel.math.FlxRect; +import openfl.ui.MouseCursor; @:allow(funkin.editors.ui.UIState) @:allow(funkin.editors.ui.UIUtil) @@ -19,6 +20,8 @@ class UISprite extends FlxSprite { public var hoverCallback:Void->Void = null; + public var cursor:MouseCursor = ARROW; + public override function update(elapsed:Float) { hovered = false; pressed = false; diff --git a/source/funkin/editors/ui/UIState.hx b/source/funkin/editors/ui/UIState.hx index 78073495..28f2c79f 100644 --- a/source/funkin/editors/ui/UIState.hx +++ b/source/funkin/editors/ui/UIState.hx @@ -8,8 +8,8 @@ import flixel.math.FlxRect; class UIState extends MusicBeatState { public static var state(get, null):UIState; - public var uiElements:Array = []; public var buttonHandler:Void->Void = null; + public var hoveredSprite:UISprite = null; private var __rect:FlxRect; private var __mousePos:FlxPoint; @@ -21,11 +21,6 @@ class UIState extends MusicBeatState { __rect = new FlxRect(); __mousePos = FlxPoint.get(); super.create(); - - memberAdded.add((basic:FlxBasic) -> { - if (basic is UISprite) uiElements.push(cast basic); - UIUtil.focusedUI = uiElements; - }); } public function updateButtonHandler(spr:UISprite, buttonHandler:Void->Void) { @@ -50,6 +45,7 @@ class UIState extends MusicBeatState { if (((__mousePos.x > __rect.x) && (__mousePos.x < __rect.x + rect.width)) && ((__mousePos.y > __rect.y) && (__mousePos.y < __rect.y + __rect.height))) { spr.hoveredByChild = true; + this.hoveredSprite = spr; this.buttonHandler = buttonHandler; return; } @@ -64,7 +60,12 @@ class UIState extends MusicBeatState { buttonHandler = null; } - UIUtil.updateCursor(); + if (hoveredSprite != null) { + Mouse.cursor = hoveredSprite.cursor; + hoveredSprite = null; + } else { + Mouse.cursor = ARROW; + } } public override function destroy() { diff --git a/source/funkin/editors/ui/UIUtil.hx b/source/funkin/editors/ui/UIUtil.hx index 21f0bb60..5f36e5a3 100644 --- a/source/funkin/editors/ui/UIUtil.hx +++ b/source/funkin/editors/ui/UIUtil.hx @@ -8,13 +8,4 @@ class UIUtil { spr.setPosition(target.x + x, target.y + y); spr.scrollFactor.set(target.scrollFactor.x, target.scrollFactor.y); } - - public static var focusedUI:Array = []; - - public static function updateCursor() { - for (element in focusedUI) - if (element.hovered) {Mouse.cursor = BUTTON; return;} - - Mouse.cursor = ARROW; - } } \ No newline at end of file diff --git a/source/funkin/editors/ui/UIWarningSubstate.hx b/source/funkin/editors/ui/UIWarningSubstate.hx index 8910d407..b6eb1dbe 100644 --- a/source/funkin/editors/ui/UIWarningSubstate.hx +++ b/source/funkin/editors/ui/UIWarningSubstate.hx @@ -24,8 +24,6 @@ class UIWarningSubstate extends MusicBeatSubstate { } public override function create() { - UIUtil.focusedUI = []; - for(c in FlxG.cameras.list) { camShaders.push(c); c.addShader(blurShader); @@ -55,8 +53,6 @@ class UIWarningSubstate extends MusicBeatSubstate { close(); }, 160, 30); add(button); - - UIUtil.focusedUI.push(button); } FlxTween.tween(camera, {alpha: 1}, 0.25, {ease: FlxEase.cubeOut}); @@ -66,7 +62,6 @@ class UIWarningSubstate extends MusicBeatSubstate { } public override function destroy() { - UIUtil.focusedUI = UIState.state.uiElements; super.destroy(); for(e in camShaders) e.removeShader(blurShader);