2024-04-19 17:48:20 +08:00
|
|
|
extends Sprite2D
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
set_process_input(true)
|
2024-05-06 17:28:42 +08:00
|
|
|
if $"../..".buttonType == $"../..".ButtonType.red:
|
2024-04-19 17:48:20 +08:00
|
|
|
var icon = preload("res://Assets/psl/按钮_红.png")
|
|
|
|
self.set_texture(icon)
|
2024-05-06 17:28:42 +08:00
|
|
|
elif $"../..".buttonType == $"../..".ButtonType.black:
|
2024-04-19 17:48:20 +08:00
|
|
|
var icon = preload("res://Assets/psl/按钮_黑.png")
|
|
|
|
self.set_texture(icon)
|
|
|
|
|
|
|
|
|
|
|
|
func test_enter():
|
|
|
|
var mouse_position = get_global_mouse_position()
|
|
|
|
return self.get_rect().has_point(to_local(mouse_position))
|
|
|
|
|
|
|
|
func _input(event):
|
|
|
|
if event is InputEventMouseMotion:
|
|
|
|
var flag1 = test_enter()
|
2024-04-22 15:32:19 +08:00
|
|
|
if flag1 and Input.get_current_cursor_shape() != Input.CursorShape.CURSOR_POINTING_HAND:
|
|
|
|
$"..".set_default_cursor_shape(Input.CursorShape.CURSOR_POINTING_HAND)
|
|
|
|
elif !flag1 and Input.get_current_cursor_shape() != Input.CursorShape.CURSOR_ARROW:
|
|
|
|
$"..".set_default_cursor_shape(Input.CursorShape.CURSOR_ARROW)
|
|
|
|
|
2024-04-19 17:48:20 +08:00
|
|
|
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
|
|
|
var flag2 = test_enter()
|
|
|
|
if flag2:
|
2024-05-13 15:44:09 +08:00
|
|
|
if !$"../..".allowHandle :
|
|
|
|
return
|
2024-05-06 17:28:42 +08:00
|
|
|
$"../..".clickButtonSignal.emit(true,$"../..")
|