109 lines
3.7 KiB
GDScript
109 lines
3.7 KiB
GDScript
extends Panel
|
|
class_name CompactCardDisplay
|
|
|
|
# Node references (will be created programmatically)
|
|
var card_name_label: Label
|
|
var rank_label: Label
|
|
var description_label: Label
|
|
var effect_type_label: Label
|
|
|
|
# Card rank colors (same as other card components)
|
|
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
|
|
}
|
|
|
|
# Effect type descriptions
|
|
var effect_type_names = {
|
|
Card.EffectType.MOVEMENT_MODIFIER: "Movement Modifier",
|
|
Card.EffectType.BOARD_EFFECT: "Board Effect",
|
|
Card.EffectType.PIECE_EFFECT: "Piece Effect",
|
|
Card.EffectType.SPECIAL_ACTION: "Special Action"
|
|
}
|
|
|
|
var current_card = null
|
|
|
|
func _ready():
|
|
# Create a stylish background
|
|
var style = StyleBoxFlat.new()
|
|
style.bg_color = Color(0.15, 0.15, 0.15, 1.0)
|
|
style.corner_radius_top_left = 5
|
|
style.corner_radius_top_right = 5
|
|
style.corner_radius_bottom_left = 5
|
|
style.corner_radius_bottom_right = 5
|
|
style.border_width_left = 2
|
|
style.border_width_top = 2
|
|
style.border_width_right = 2
|
|
style.border_width_bottom = 2
|
|
style.border_color = Color(0.3, 0.3, 0.3)
|
|
add_theme_stylebox_override("panel", style)
|
|
|
|
# Create a content container
|
|
var content = VBoxContainer.new()
|
|
content.set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
content.add_theme_constant_override("separation", 2) # Tight spacing
|
|
add_child(content)
|
|
|
|
card_name_label = Label.new()
|
|
card_name_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
card_name_label.add_theme_font_size_override("font_size", 12)
|
|
card_name_label.clip_text = true # Prevent overflow
|
|
content.add_child(card_name_label)
|
|
|
|
rank_label = Label.new()
|
|
rank_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
rank_label.add_theme_font_size_override("font_size", 10)
|
|
content.add_child(rank_label)
|
|
|
|
# Create description label (limited to 2-3 lines)
|
|
description_label = Label.new()
|
|
description_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
description_label.add_theme_font_size_override("font_size", 9)
|
|
description_label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
|
description_label.max_lines_visible = 3
|
|
description_label.size_flags_vertical = SIZE_EXPAND_FILL
|
|
content.add_child(description_label)
|
|
|
|
effect_type_label = Label.new()
|
|
effect_type_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
effect_type_label.add_theme_font_size_override("font_size", 8)
|
|
effect_type_label.clip_text = true
|
|
content.add_child(effect_type_label)
|
|
|
|
|
|
func set_selected(is_selected: bool) -> void:
|
|
var style = get_theme_stylebox("panel").duplicate()
|
|
|
|
if is_selected:
|
|
style.bg_color = Utils.GREEN_CELL # Selected color
|
|
else:
|
|
style.bg_color = Utils.DARK_CELL
|
|
|
|
add_theme_stylebox_override("panel", style)
|
|
|
|
func set_card(card: Card):
|
|
if !card:
|
|
return
|
|
|
|
if !is_inside_tree():
|
|
await ready
|
|
|
|
current_card = card
|
|
|
|
card_name_label.text = card.cardName
|
|
|
|
rank_label.text = "Rank " + str(card.rank)
|
|
if card.rank in rank_colors:
|
|
rank_label.add_theme_color_override("font_color", rank_colors[card.rank])
|
|
var style = get_theme_stylebox("panel").duplicate()
|
|
style.border_color = rank_colors[card.rank]
|
|
add_theme_stylebox_override("panel", style)
|
|
|
|
description_label.text = card.description
|
|
|
|
if card.effectType in effect_type_names:
|
|
effect_type_label.text = "Effect: " + effect_type_names[card.effectType]
|
|
else:
|
|
effect_type_label.text = "Effect: Unknown"
|