From 7eab9809c8ac460e319465a5f8bbab0e08bf87d2 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Sat, 18 Mar 2023 13:23:48 -0700 Subject: [PATCH] Testing Cursor --- buildnumber.txt | 2 +- source/funkin/editors/ui/UIState.hx | 11 +++++++++-- source/funkin/editors/ui/UIUtil.hx | 11 +++++++++++ source/funkin/editors/ui/UIWarningSubstate.hx | 5 +++++ source/funkin/system/Main.hx | 2 ++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/buildnumber.txt b/buildnumber.txt index 83e43906..3d23d59c 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2605 \ No newline at end of file +2592 diff --git a/source/funkin/editors/ui/UIState.hx b/source/funkin/editors/ui/UIState.hx index e83ff608..78073495 100644 --- a/source/funkin/editors/ui/UIState.hx +++ b/source/funkin/editors/ui/UIState.hx @@ -1,5 +1,6 @@ package funkin.editors.ui; +import openfl.ui.Mouse; import funkin.editors.ui.UIContextMenu.UIContextMenuOption; import flixel.math.FlxPoint; import flixel.math.FlxRect; @@ -7,6 +8,7 @@ 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; private var __rect:FlxRect; @@ -19,6 +21,11 @@ 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) { @@ -56,6 +63,8 @@ class UIState extends MusicBeatState { buttonHandler(); buttonHandler = null; } + + UIUtil.updateCursor(); } public override function destroy() { @@ -71,8 +80,6 @@ class UIState extends MusicBeatState { state.persistentDraw = true; state.persistentUpdate = true; - - openSubState(new UIContextMenu(options, x.getDefault(__mousePos.x), y.getDefault(__mousePos.y))); } } \ No newline at end of file diff --git a/source/funkin/editors/ui/UIUtil.hx b/source/funkin/editors/ui/UIUtil.hx index 764bb30f..21f0bb60 100644 --- a/source/funkin/editors/ui/UIUtil.hx +++ b/source/funkin/editors/ui/UIUtil.hx @@ -1,9 +1,20 @@ package funkin.editors.ui; +import openfl.ui.Mouse; + class UIUtil { public static function follow(spr:FlxSprite, target:FlxSprite, x:Float = 0, y:Float = 0) { spr.cameras = target is UISprite ? cast(target, UISprite).__lastDrawCameras : target.cameras; 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 b6eb1dbe..8910d407 100644 --- a/source/funkin/editors/ui/UIWarningSubstate.hx +++ b/source/funkin/editors/ui/UIWarningSubstate.hx @@ -24,6 +24,8 @@ class UIWarningSubstate extends MusicBeatSubstate { } public override function create() { + UIUtil.focusedUI = []; + for(c in FlxG.cameras.list) { camShaders.push(c); c.addShader(blurShader); @@ -53,6 +55,8 @@ class UIWarningSubstate extends MusicBeatSubstate { close(); }, 160, 30); add(button); + + UIUtil.focusedUI.push(button); } FlxTween.tween(camera, {alpha: 1}, 0.25, {ease: FlxEase.cubeOut}); @@ -62,6 +66,7 @@ class UIWarningSubstate extends MusicBeatSubstate { } public override function destroy() { + UIUtil.focusedUI = UIState.state.uiElements; super.destroy(); for(e in camShaders) e.removeShader(blurShader); diff --git a/source/funkin/system/Main.hx b/source/funkin/system/Main.hx index 7e87d42b..c311a7b1 100644 --- a/source/funkin/system/Main.hx +++ b/source/funkin/system/Main.hx @@ -209,6 +209,8 @@ class Main extends Sprite FlxG.signals.preStateSwitch.add(onStateSwitch); FlxG.signals.postStateSwitch.add(onStateSwitchPost); + FlxG.mouse.useSystemCursor = true; + #if MOD_SUPPORT ModsFolder.switchMod(modToLoad.getDefault(Options.lastLoadedMod)); #end