44 lines
No EOL
1.3 KiB
GDScript
44 lines
No EOL
1.3 KiB
GDScript
extends Control
|
|
class_name CardBankItem
|
|
|
|
signal card_selected(card_item, card)
|
|
|
|
var current_card = null
|
|
|
|
@onready var rank_label = $RankLabel
|
|
@onready var card_name_label = $CardNameLabel
|
|
@onready var card_frame = $CardFrame
|
|
|
|
# Card rank colors (matching CardSlot colors)
|
|
var rank_colors = {
|
|
Card.Rank.RANK_0: Color(0.9, 0.1, 0.1, 1.0), # Red
|
|
Card.Rank.RANK_1: Color(0.9, 0.6, 0.1, 1.0), # Orange
|
|
Card.Rank.RANK_2: Color(0.1, 0.7, 0.1, 1.0), # Green
|
|
Card.Rank.RANK_3: Color(0.1, 0.7, 0.9, 1.0) # Blue
|
|
}
|
|
|
|
func _ready():
|
|
# Connect signals for interaction
|
|
mouse_filter = Control.MOUSE_FILTER_STOP
|
|
gui_input.connect(_on_gui_input)
|
|
|
|
func set_card(card):
|
|
current_card = card
|
|
update_appearance()
|
|
|
|
func update_appearance():
|
|
if current_card:
|
|
# Update card details
|
|
card_name_label.text = current_card.cardName
|
|
rank_label.text = str(current_card.rank)
|
|
|
|
# Set color based on rank
|
|
if current_card.rank in rank_colors:
|
|
rank_label.modulate = rank_colors[current_card.rank]
|
|
card_frame.modulate = rank_colors[current_card.rank]
|
|
|
|
func _on_gui_input(event):
|
|
if event is InputEventMouseButton:
|
|
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
|
if current_card:
|
|
emit_signal("card_selected", self, current_card) |