buckshotroulette-decomp/CursorManager.gd

29 lines
951 B
GDScript3
Raw Normal View History

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
var controller_active = false
2024-01-20 12:17:43 +00:00
func _ready():
SetCursor(false, false)
func SetCursor(isVisible : bool, playSound : bool):
if (playSound): speaker.play()
2024-01-20 12:17:43 +00:00
if (isVisible):
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