extends Node ## Handle all the cursor appareance related stuff. @export var NOCUSTOM := false ## A dictionary mapping 9 directional vectors to custom cursor configurations for edgescroll navigation. ##[br][br] ## This constant defines custom cursor images and their hotspots for 8 primary directions and a neutral state, ## used with [method Input.set_custom_mouse_cursor] to override the default mouse cursor based on ## edgescroll direction. Each key is a [Vector2] representing a normalized direction (e.g., [code](-1, -1)[/code] ## for top-left). Each value is an array where:[br] ## - [b]Index 0[/b]: A preloaded [Texture2D] resource for the cursor image.[br] ## - [b]Index 1[/b]: A [Vector2] specifying the hotspot (the pixel within the image that aligns with the mouse position).[br] ##[br] ## ## [b]Direction Details:[/b][br] ## - [code](-1, -1)[/code]: up-left.[br] ## - [code](0, -1)[/code]: up.[br] ## - [code](1, -1)[/code]: up-right.[br] ## - [code](1, 0)[/code]: right.[br] ## - [code](1, 1)[/code]: down-right.[br] ## - [code](0, 1)[/code]: down.[br] ## - [code](-1, 1)[/code]: down-left.[br] ## - [code](-1, 0)[/code]: left.[br] ## - [code](0, 0)[/code]: Neutral state (no scroll, default cursor, sued for resetting purpose).[br] const DIRECTION_CURSOR_MAP = { Vector2(-1, -1): [preload("uid://bnwb6728ln3ae"), Vector2(6,22)], Vector2(0, -1): [preload("uid://cgx332aowj6dn"),Vector2(16,22)], Vector2(1, -1): [preload("uid://dmn7dlir4ohff"), Vector2(22,22)], Vector2(1, 0): [preload("uid://bwfy3euyxmi7j"),Vector2(22,16)], Vector2(1, 1): [preload("uid://cpklilc6jmw0d"),Vector2(22,6)], Vector2(0, 1): [preload("uid://cbr6j5g1ipdi4"),Vector2(16,6)], Vector2(-1, 1): [preload("uid://doia8nobwmv4n"), Vector2(6,6)], Vector2(-1, 0): [preload("uid://bqg7s8lukudkc"),Vector2(6,16)], Vector2(0, 0): [preload("uid://dp4ed16rb1754"),Vector2(7,3)], } var edge_scroll_vector = Vector2(1,1) func _ready() -> void: if NOCUSTOM: Input.set_default_cursor_shape(Input.CURSOR_DRAG) func _on_player_root_cursor_edge_scrolling(direction: Vector2) -> void: if NOCUSTOM:return if direction.length() > 0 or edge_scroll_vector.length() != 0: edge_scroll_vector = direction Input.set_custom_mouse_cursor(DIRECTION_CURSOR_MAP.get(direction)[0],Input.CURSOR_ARROW,DIRECTION_CURSOR_MAP.get(direction)[1]) if OS.is_debug_build(): DebugTools.MouseOverlay.update_cursor(DIRECTION_CURSOR_MAP.get(direction)[0],Input.CURSOR_ARROW,DIRECTION_CURSOR_MAP.get(direction)[1]) print(direction)