2024-01-20 12:17:43 +00:00
|
|
|
class_name CursorManager extends Node
|
|
|
|
|
|
|
|
@export var speaker : AudioStreamPlayer2D
|
|
|
|
@export var cursor_point : CompressedTexture2D
|
|
|
|
@export var cursor_hover : CompressedTexture2D
|
|
|
|
@export var cursor_invalid : CompressedTexture2D
|
|
|
|
var cursor_visible = false
|
2024-04-05 10:52:30 +01:00
|
|
|
var controller_active = false
|
2024-01-20 12:17:43 +00:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
SetCursor(false, false)
|
|
|
|
|
|
|
|
func SetCursor(isVisible : bool, playSound : bool):
|
2024-04-05 10:52:30 +01:00
|
|
|
if (playSound): speaker.play()
|
2024-01-20 12:17:43 +00:00
|
|
|
if (isVisible):
|
2024-04-05 10:52:30 +01:00
|
|
|
if (!controller_active): Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
|
|
|
else: Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
2024-01-20 12:17:43 +00:00
|
|
|
cursor_visible = true
|
|
|
|
if (!isVisible):
|
|
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
|
|
|
cursor_visible = false
|
|
|
|
|
|
|
|
func SetCursorImage(alias : String):
|
|
|
|
match(alias):
|
|
|
|
"point": Input.set_custom_mouse_cursor(cursor_point, 0, Vector2(12, 0))
|
|
|
|
"hover": Input.set_custom_mouse_cursor(cursor_hover, 0, Vector2(9, 0))
|
|
|
|
"invalid": Input.set_custom_mouse_cursor(cursor_invalid, 0, Vector2(12, 0))
|
|
|
|
pass
|