2025-01-25 18:40:14 +07:00
|
|
|
extends Control
|
2025-01-26 01:58:35 +07:00
|
|
|
class_name CardBase
|
|
|
|
|
|
|
|
|
|
signal left_clicked
|
|
|
|
|
signal right_clicked
|
2025-01-26 11:49:25 +07:00
|
|
|
signal un_right_clicked
|
2025-01-26 01:58:35 +07:00
|
|
|
signal hovering(delta: float)
|
2025-01-25 18:40:14 +07:00
|
|
|
|
|
|
|
|
@export var card_name_label: Label
|
|
|
|
|
@export var card_desc_label: Label
|
|
|
|
|
@export var icon_rect: TextureRect
|
|
|
|
|
|
|
|
|
|
var _card: SupportCard
|
|
|
|
|
var card: SupportCard:
|
|
|
|
|
get:
|
|
|
|
|
return _card
|
|
|
|
|
set(value):
|
|
|
|
|
_update(value)
|
|
|
|
|
_card = value
|
|
|
|
|
|
|
|
|
|
func _update(card: SupportCard):
|
|
|
|
|
card_name_label.text = card.name
|
|
|
|
|
card_desc_label.text = card.description
|
|
|
|
|
icon_rect.texture = card.icon
|
|
|
|
|
|
2025-01-26 01:58:35 +07:00
|
|
|
func _process(delta):
|
|
|
|
|
var mouse_position = get_global_mouse_position()
|
|
|
|
|
var rect = get_global_rect()
|
2025-01-26 11:49:25 +07:00
|
|
|
if rect.has_point(mouse_position) and get_window().has_focus():
|
2025-01-26 01:58:35 +07:00
|
|
|
hovering.emit(delta)
|
|
|
|
|
|
|
|
|
|
func _input(event):
|
|
|
|
|
if event is InputEventMouseButton:
|
|
|
|
|
var mouse_position = get_global_mouse_position()
|
|
|
|
|
var rect = get_global_rect()
|
|
|
|
|
|
2025-01-26 11:49:25 +07:00
|
|
|
if rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed() and get_window().has_focus():
|
2025-01-26 01:58:35 +07:00
|
|
|
left_clicked.emit()
|
2025-01-26 11:49:25 +07:00
|
|
|
elif rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_RIGHT and event.is_pressed() and get_window().has_focus():
|
2025-01-26 01:58:35 +07:00
|
|
|
right_clicked.emit()
|
2025-01-26 11:49:25 +07:00
|
|
|
elif event.button_index == MOUSE_BUTTON_RIGHT and !event.is_pressed():
|
|
|
|
|
un_right_clicked.emit()
|