Testing Cursor

This commit is contained in:
lunarcleint
2023-03-18 13:23:48 -07:00
parent 43c269a126
commit 7eab9809c8
5 changed files with 28 additions and 3 deletions
+1 -1
View File
@@ -1 +1 @@
2605
2592
+9 -2
View File
@@ -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<UISprite> = [];
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)));
}
}
+11
View File
@@ -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<UISprite> = [];
public static function updateCursor() {
for (element in focusedUI)
if (element.hovered) {Mouse.cursor = BUTTON; return;}
Mouse.cursor = ARROW;
}
}
@@ -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);
+2
View File
@@ -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