add cursor_manager and cursor_click image

This commit is contained in:
Teatov 2024-10-05 17:06:06 +10:00
parent 368a72106a
commit ffde3104fe
4 changed files with 60 additions and 0 deletions

BIN
assets/textures/gui/cursor_click.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bhfdgwwogwo2l"
path="res://.godot/imported/cursor_click.png-33dc5b0de3732bfe684b0a9b2516f551.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/textures/gui/cursor_click.png"
dest_files=["res://.godot/imported/cursor_click.png-33dc5b0de3732bfe684b0a9b2516f551.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -18,6 +18,10 @@ boot_splash/bg_color=Color(0, 0, 0, 1)
boot_splash/show_image=false
config/icon="res://icon.svg"
[autoload]
CursorManager="*res://scripts/globals/cursor_manager.gd"
[debug]
settings/crash_handler/message="Oh my, there's a BUG in the game! How queer and unexpected!"

View File

@ -0,0 +1,19 @@
extends Node
const CURSOR_HOTSPOT = Vector2(32, 32)
var cursor_normal := load("res://assets/textures/gui/cursor.png")
var cursor_click := load("res://assets/textures/gui/cursor_click.png")
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CONFINED
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if (event as InputEventMouseButton).pressed:
set_cursor(cursor_click)
else:
set_cursor(cursor_normal)
func set_cursor(image: Resource) -> void:
Input.set_custom_mouse_cursor(image, Input.CURSOR_ARROW, CURSOR_HOTSPOT)