diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-12-15 16:53:12 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-12-15 16:53:12 +0100 |
commit | 75793bd23d275d10d6a0bd8024a7e412b64557ce (patch) | |
tree | eef8145a645a88c718a4004e3a5e5f8f7700fa47 /ui/cursor.gd | |
parent | a14e88ff4d0d87841a44254e2bff1784da6e8b48 (diff) |
next commit
Diffstat (limited to 'ui/cursor.gd')
-rw-r--r-- | ui/cursor.gd | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ui/cursor.gd b/ui/cursor.gd new file mode 100644 index 0000000..947356e --- /dev/null +++ b/ui/cursor.gd @@ -0,0 +1,33 @@ +extends Node2D + + +var current_action_idx := 0 +var last_action_idx := 0 + + +func _ready() -> void: + Input.mouse_mode = Input.MOUSE_MODE_HIDDEN + $Actions.play("000") + + +func _process(_delta: float) -> void: + global_position = get_global_mouse_position() + + if Input.get_current_cursor_shape() == Input.CURSOR_ARROW: + current_action_idx = 0 + elif Input.get_current_cursor_shape() == Input.CURSOR_POINTING_HAND: + current_action_idx = 2 + else: + # use default OS cursor + current_action_idx = -1 + + if current_action_idx != last_action_idx: + if current_action_idx == -1: + Input.mouse_mode = Input.MOUSE_MODE_VISIBLE + $Actions.visible = false + else: + Input.mouse_mode = Input.MOUSE_MODE_HIDDEN + $Actions.visible = true + $Actions.play(str(current_action_idx).pad_zeros(3)) + + last_action_idx = current_action_idx |