minor admin portal changes

This commit is contained in:
dingo
2026-03-02 08:37:51 -05:00
parent 0a1796cd77
commit d3e39f9511
20 changed files with 869 additions and 587 deletions
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3]
[gd_scene load_steps=2 format=3 uid="uid://qvv1n31fsf8k"]
[ext_resource type="Script" path="res://scenes/collection/components/card_widget.gd" id="1_cw"]
[ext_resource type="Script" uid="uid://cqrcq3lrws6qm" path="res://scenes/collection/components/card_widget.gd" id="1_cw"]
[node name="CardWidget" type="PanelContainer"]
custom_minimum_size = Vector2(146, 204)
@@ -18,15 +18,15 @@ layout_mode = 2
theme_override_constants/separation = 3
[node name="TopRow" type="HBoxContainer" parent="Margin/VBox"]
layout_mode = 2
custom_minimum_size = Vector2(0, 20)
layout_mode = 2
theme_override_constants/separation = 2
[node name="SpLabel" type="Label" parent="Margin/VBox/TopRow"]
unique_name_in_owner = true
layout_mode = 2
text = "◆?"
theme_override_font_sizes/font_size = 12
text = "◆?"
[node name="TopFill" type="Control" parent="Margin/VBox/TopRow"]
layout_mode = 2
@@ -34,23 +34,22 @@ size_flags_horizontal = 3
[node name="FoilLabel" type="Label" parent="Margin/VBox/TopRow"]
unique_name_in_owner = true
layout_mode = 2
text = "✦"
visible = false
modulate = Color(0.95, 0.85, 0.30, 1.0)
modulate = Color(0.95, 0.85, 0.3, 1)
layout_mode = 2
theme_override_font_sizes/font_size = 12
text = "✦"
[node name="StLabel" type="Label" parent="Margin/VBox/TopRow"]
unique_name_in_owner = true
layout_mode = 2
text = ""
visible = false
layout_mode = 2
theme_override_font_sizes/font_size = 12
[node name="ArtArea" type="Panel" parent="Margin/VBox"]
custom_minimum_size = Vector2(0, 80)
layout_mode = 2
size_flags_vertical = 3
custom_minimum_size = Vector2(0, 80)
[node name="ArtRect" type="ColorRect" parent="Margin/VBox/ArtArea"]
unique_name_in_owner = true
@@ -60,10 +59,11 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.18, 0.18, 0.24, 1.0)
color = Color(0.18, 0.18, 0.24, 1)
[node name="ArtSymbol" type="TextureRect" parent="Margin/VBox/ArtArea"]
unique_name_in_owner = true
modulate = Color(1, 1, 1, 0.85)
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
@@ -72,26 +72,24 @@ grow_horizontal = 2
grow_vertical = 2
expand_mode = 1
stretch_mode = 5
modulate = Color(1, 1, 1, 0.85)
[node name="NameLabel" type="Label" parent="Margin/VBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 18)
layout_mode = 2
theme_override_font_sizes/font_size = 13
text = "Card Name"
text_overrun_behavior = 3
custom_minimum_size = Vector2(0, 18)
theme_override_font_sizes/font_size = 13
[node name="TypeRarityRow" type="HBoxContainer" parent="Margin/VBox"]
layout_mode = 2
custom_minimum_size = Vector2(0, 14)
layout_mode = 2
theme_override_constants/separation = 2
[node name="TypeLabel" type="Label" parent="Margin/VBox/TypeRarityRow"]
unique_name_in_owner = true
modulate = Color(0.7, 0.7, 0.75, 1)
layout_mode = 2
text = ""
modulate = Color(0.70, 0.70, 0.75, 1.0)
theme_override_font_sizes/font_size = 10
[node name="TypeFill" type="Control" parent="Margin/VBox/TypeRarityRow"]
@@ -101,19 +99,18 @@ size_flags_horizontal = 3
[node name="RarityLabel" type="Label" parent="Margin/VBox/TypeRarityRow"]
unique_name_in_owner = true
layout_mode = 2
text = ""
theme_override_font_sizes/font_size = 10
[node name="StatsRow" type="HBoxContainer" parent="Margin/VBox"]
layout_mode = 2
custom_minimum_size = Vector2(0, 18)
layout_mode = 2
theme_override_constants/separation = 2
[node name="DmgLabel" type="Label" parent="Margin/VBox/StatsRow"]
unique_name_in_owner = true
layout_mode = 2
text = "⚔ –"
theme_override_font_sizes/font_size = 11
text = "⚔ –"
[node name="StatsFill" type="Control" parent="Margin/VBox/StatsRow"]
layout_mode = 2
@@ -122,8 +119,8 @@ size_flags_horizontal = 3
[node name="HpLabel" type="Label" parent="Margin/VBox/StatsRow"]
unique_name_in_owner = true
layout_mode = 2
text = "♥ –"
theme_override_font_sizes/font_size = 11
text = "♥ –"
[node name="StatsFill2" type="Control" parent="Margin/VBox/StatsRow"]
layout_mode = 2
@@ -132,5 +129,5 @@ size_flags_horizontal = 3
[node name="DefLabel" type="Label" parent="Margin/VBox/StatsRow"]
unique_name_in_owner = true
layout_mode = 2
text = "▲ –"
theme_override_font_sizes/font_size = 11
text = "▲ –"
@@ -72,6 +72,14 @@ theme_override_font_sizes/font_size = 11
layout_mode = 2
theme_override_constants/separation = 4
[node name="EditBtn" type="Button" parent="Margin/HBox/Actions"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(60, 36)
text = "Edit"
tooltip_text = "Edit deck contents"
theme_override_font_sizes/font_size = 13
[node name="RenameBtn" type="Button" parent="Margin/HBox/Actions"]
unique_name_in_owner = true
layout_mode = 2
@@ -212,7 +212,7 @@ func _load_stats(def: Dictionary) -> void:
func _load_abilities(def: Dictionary) -> void:
var json_str := str(def.get("abilitiesJson", ""))
var json_str := str(def.get("abilities", ""))
if json_str.is_empty() or json_str == "[]":
return
var parsed: Variant = JSON.parse_string(json_str)
@@ -0,0 +1,499 @@
extends VBoxContainer
## Deck editor panel — add/remove cards from an existing deck.
##
## The entire UI is built programmatically in _setup_ui() so no separate
## .tscn is needed. Embed this script on a VBoxContainer node in DecksView.
##
## Usage:
## call open_deck(deck_id, deck_name) to load a deck for editing.
## connect back_pressed to return to the deck list.
signal back_pressed()
const PAGE_SIZE := 50
# ── Node refs (created in _setup_ui) ─────────────────────────────────────────
var _title_lbl : Label
var _count_lbl : Label
var _deck_loading_lbl : Label
var _deck_card_list : VBoxContainer
var _search_input : LineEdit
var _type_option : OptionButton
var _coll_loading_lbl : Label
var _coll_list : VBoxContainer
var _load_more_btn : Button
# ── State ─────────────────────────────────────────────────────────────────────
var _deck_id : String = ""
var _deck_name : String = ""
## { cardDefinitionId(String): quantity(int) } — kept in sync after mutations
var _deck_qty : Dictionary = {}
var _coll_page : int = 1
var _coll_total : int = 0
var _has_more : bool = false
var _is_loading : bool = false
var _search_timer : float = 0.0
const _DEBOUNCE := 0.4
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
_setup_ui()
func _process(delta: float) -> void:
if _search_timer > 0.0:
_search_timer -= delta
if _search_timer <= 0.0:
_search_timer = 0.0
_reload_collection()
# ── UI construction ───────────────────────────────────────────────────────────
func _setup_ui() -> void:
size_flags_horizontal = Control.SIZE_EXPAND_FILL
size_flags_vertical = Control.SIZE_EXPAND_FILL
add_theme_constant_override("separation", 0)
# Top bar
var top_panel := PanelContainer.new()
var top_margin := MarginContainer.new()
top_margin.add_theme_constant_override("margin_left", 10)
top_margin.add_theme_constant_override("margin_right", 10)
top_margin.add_theme_constant_override("margin_top", 8)
top_margin.add_theme_constant_override("margin_bottom", 8)
top_panel.add_child(top_margin)
var top_bar := HBoxContainer.new()
top_bar.add_theme_constant_override("separation", 8)
top_margin.add_child(top_bar)
var back_btn := Button.new()
back_btn.text = "◄ Back"
back_btn.custom_minimum_size = Vector2(80, 32)
back_btn.pressed.connect(func(): back_pressed.emit())
top_bar.add_child(back_btn)
_title_lbl = Label.new()
_title_lbl.text = "Editing deck"
_title_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_title_lbl.add_theme_font_size_override("font_size", 15)
_title_lbl.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
top_bar.add_child(_title_lbl)
_count_lbl = Label.new()
_count_lbl.text = "0 / 40"
_count_lbl.add_theme_font_size_override("font_size", 13)
_count_lbl.modulate = Color(0.75, 0.75, 0.8)
top_bar.add_child(_count_lbl)
add_child(top_panel)
# Split area
var split := HBoxContainer.new()
split.size_flags_vertical = Control.SIZE_EXPAND_FILL
split.add_theme_constant_override("separation", 0)
var left := _make_left_pane()
left.size_flags_horizontal = Control.SIZE_EXPAND_FILL
split.add_child(left)
var vsep := VSeparator.new()
split.add_child(vsep)
var right := _make_right_pane()
right.size_flags_horizontal = Control.SIZE_EXPAND_FILL
split.add_child(right)
add_child(split)
func _make_left_pane() -> VBoxContainer:
var pane := VBoxContainer.new()
pane.add_theme_constant_override("separation", 4)
var margin := MarginContainer.new()
margin.size_flags_vertical = Control.SIZE_EXPAND_FILL
margin.add_theme_constant_override("margin_left", 8)
margin.add_theme_constant_override("margin_right", 8)
margin.add_theme_constant_override("margin_top", 6)
margin.add_theme_constant_override("margin_bottom", 6)
pane.add_child(margin)
var inner := VBoxContainer.new()
inner.size_flags_vertical = Control.SIZE_EXPAND_FILL
inner.add_theme_constant_override("separation", 4)
margin.add_child(inner)
var hdr := Label.new()
hdr.text = "Deck Contents"
hdr.add_theme_font_size_override("font_size", 13)
hdr.modulate = Color(0.8, 0.8, 0.85)
inner.add_child(hdr)
_deck_loading_lbl = Label.new()
_deck_loading_lbl.text = "Loading…"
_deck_loading_lbl.modulate = Color(0.65, 0.65, 0.7)
_deck_loading_lbl.add_theme_font_size_override("font_size", 12)
_deck_loading_lbl.visible = false
inner.add_child(_deck_loading_lbl)
var scroll := ScrollContainer.new()
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
inner.add_child(scroll)
_deck_card_list = VBoxContainer.new()
_deck_card_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_deck_card_list.add_theme_constant_override("separation", 2)
scroll.add_child(_deck_card_list)
return pane
func _make_right_pane() -> VBoxContainer:
var pane := VBoxContainer.new()
pane.add_theme_constant_override("separation", 4)
var margin := MarginContainer.new()
margin.size_flags_vertical = Control.SIZE_EXPAND_FILL
margin.add_theme_constant_override("margin_left", 8)
margin.add_theme_constant_override("margin_right", 8)
margin.add_theme_constant_override("margin_top", 6)
margin.add_theme_constant_override("margin_bottom", 6)
pane.add_child(margin)
var inner := VBoxContainer.new()
inner.size_flags_vertical = Control.SIZE_EXPAND_FILL
inner.add_theme_constant_override("separation", 4)
margin.add_child(inner)
var hdr := Label.new()
hdr.text = "Add Cards"
hdr.add_theme_font_size_override("font_size", 13)
hdr.modulate = Color(0.8, 0.8, 0.85)
inner.add_child(hdr)
var search_bar := HBoxContainer.new()
search_bar.add_theme_constant_override("separation", 4)
inner.add_child(search_bar)
_search_input = LineEdit.new()
_search_input.placeholder_text = "Search…"
_search_input.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_search_input.custom_minimum_size = Vector2(0, 30)
_search_input.add_theme_font_size_override("font_size", 13)
_search_input.text_changed.connect(_on_search_changed)
search_bar.add_child(_search_input)
_type_option = OptionButton.new()
_type_option.custom_minimum_size = Vector2(110, 30)
_type_option.add_theme_font_size_override("font_size", 12)
_type_option.item_selected.connect(func(_i): _reload_collection())
_populate_type_options()
search_bar.add_child(_type_option)
_coll_loading_lbl = Label.new()
_coll_loading_lbl.text = "Loading…"
_coll_loading_lbl.modulate = Color(0.65, 0.65, 0.7)
_coll_loading_lbl.add_theme_font_size_override("font_size", 12)
_coll_loading_lbl.visible = false
inner.add_child(_coll_loading_lbl)
var scroll := ScrollContainer.new()
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
inner.add_child(scroll)
_coll_list = VBoxContainer.new()
_coll_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_coll_list.add_theme_constant_override("separation", 2)
scroll.add_child(_coll_list)
_load_more_btn = Button.new()
_load_more_btn.text = "Load More"
_load_more_btn.visible = false
_load_more_btn.pressed.connect(_on_load_more)
inner.add_child(_load_more_btn)
return pane
func _populate_type_options() -> void:
_type_option.clear()
_type_option.add_item("All Types")
for t in ["Creature", "Spell", "Item", "ArchSpirit"]:
_type_option.add_item(t)
# ── Public ────────────────────────────────────────────────────────────────────
func open_deck(deck_id: String, deck_name: String) -> void:
_deck_id = deck_id
_deck_name = deck_name
_title_lbl.text = "Editing: %s" % deck_name
_search_input.text = ""
_type_option.selected = 0
_deck_qty.clear()
_load_deck_contents()
_reload_collection()
# ── Deck contents ─────────────────────────────────────────────────────────────
func _load_deck_contents() -> void:
for child in _deck_card_list.get_children():
child.queue_free()
_deck_loading_lbl.visible = true
Network.request(
"collection.get_deck",
{ "deckId": _deck_id },
func(_t: String, p: Variant): _on_deck_response(p),
func(_code: String, msg: String): _on_deck_error(msg)
)
func _on_deck_response(payload: Variant) -> void:
_deck_loading_lbl.visible = false
var p := payload as Dictionary
var deck_raw := p.get("deck", null)
if deck_raw == null or typeof(deck_raw) != TYPE_DICTIONARY:
push_warning("DeckEditor: missing deck in response")
return
var deck := deck_raw as Dictionary
var cards : Array = deck.get("cards", [])
_deck_qty.clear()
var non_as_total := 0
for c in cards:
var def_id := str(c.get("cardDefinitionId", ""))
var qty := int(c.get("quantity", 0))
if not def_id.is_empty():
_deck_qty[def_id] = qty
if str(c.get("cardType", "")) != "ArchSpirit":
non_as_total += qty
_count_lbl.text = "%d / 40" % non_as_total
for c in cards:
_deck_card_list.add_child(_make_deck_row(c))
_refresh_coll_in_deck_labels()
func _on_deck_error(msg: String) -> void:
_deck_loading_lbl.visible = false
push_warning("DeckEditor get_deck: %s" % msg)
func _make_deck_row(card: Dictionary) -> Control:
var def_id := str(card.get("cardDefinitionId", ""))
var qty := int(card.get("quantity", 0))
var owned := int(card.get("ownedCount", 0))
var outer := MarginContainer.new()
outer.add_theme_constant_override("margin_left", 2)
outer.add_theme_constant_override("margin_right", 2)
outer.add_theme_constant_override("margin_top", 1)
outer.add_theme_constant_override("margin_bottom", 1)
outer.set_meta("def_id", def_id)
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 4)
outer.add_child(row)
var info := VBoxContainer.new()
info.size_flags_horizontal = Control.SIZE_EXPAND_FILL
info.add_theme_constant_override("separation", 1)
row.add_child(info)
var name_lbl := Label.new()
name_lbl.text = str(card.get("name", "?"))
name_lbl.add_theme_font_size_override("font_size", 13)
name_lbl.clip_text = true
info.add_child(name_lbl)
var sub_lbl := Label.new()
sub_lbl.text = "%s · %s" % [str(card.get("cardType", "")), str(card.get("affinity", ""))]
sub_lbl.add_theme_color_override("font_color", Color(0.55, 0.55, 0.62))
sub_lbl.add_theme_font_size_override("font_size", 10)
info.add_child(sub_lbl)
var qty_lbl := Label.new()
qty_lbl.text = "×%d/%d" % [qty, owned]
qty_lbl.add_theme_font_size_override("font_size", 12)
qty_lbl.custom_minimum_size = Vector2(52, 0)
qty_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
row.add_child(qty_lbl)
var minus_btn := Button.new()
minus_btn.text = "–"
minus_btn.custom_minimum_size = Vector2(28, 30)
minus_btn.pressed.connect(func(): _remove_card(def_id, 1))
row.add_child(minus_btn)
var remove_btn := Button.new()
remove_btn.text = "✕"
remove_btn.custom_minimum_size = Vector2(28, 30)
remove_btn.pressed.connect(func(): _remove_card(def_id, null))
row.add_child(remove_btn)
return outer
# ── Collection browser ────────────────────────────────────────────────────────
func _reload_collection() -> void:
_coll_page = 1
_coll_total = 0
_has_more = false
for child in _coll_list.get_children():
child.queue_free()
_load_more_btn.visible = false
_fetch_coll_page(1)
func _fetch_coll_page(page: int) -> void:
if _is_loading:
return
_is_loading = true
_coll_loading_lbl.visible = true
var payload := { "page": page, "pageSize": PAGE_SIZE }
var search := _search_input.text.strip_edges()
if not search.is_empty():
payload["nameFilter"] = search
var type_idx := _type_option.selected
if type_idx > 0:
payload["cardTypeFilter"] = _type_option.get_item_text(type_idx)
Network.request(
"collection.get_cards",
payload,
func(_t: String, p: Variant): _on_coll_response(p, page),
func(_code: String, msg: String): _on_coll_error(msg)
)
func _on_coll_response(payload: Variant, page: int) -> void:
_is_loading = false
_coll_loading_lbl.visible = false
var p := payload as Dictionary
var cards : Array = p.get("cards", [])
_coll_total = int(p.get("totalCount", 0))
var ps := int(p.get("pageSize", PAGE_SIZE))
_coll_page = page
_has_more = (page * ps) < _coll_total
_load_more_btn.visible = _has_more
# Track def_ids already in the list to avoid duplicates across pages
var seen : Dictionary = {}
for child in _coll_list.get_children():
if child.has_meta("def_id"):
seen[str(child.get_meta("def_id"))] = true
for dto in cards:
var def_id := str(dto.get("cardDefinitionId", ""))
if def_id.is_empty() or def_id in seen:
continue
# Tier 1 ArchSpirits are commanders — cannot be added as deck cards
if str(dto.get("cardType", "")) == "ArchSpirit" \
and int(dto.get("tier", 1)) <= 1:
continue
seen[def_id] = true
_coll_list.add_child(_make_coll_row(dto))
func _on_coll_error(msg: String) -> void:
_is_loading = false
_coll_loading_lbl.visible = false
push_warning("DeckEditor collection: %s" % msg)
func _make_coll_row(dto: Dictionary) -> Control:
var def_id := str(dto.get("cardDefinitionId", ""))
var in_deck := int(_deck_qty.get(def_id, 0))
var outer := MarginContainer.new()
outer.add_theme_constant_override("margin_left", 2)
outer.add_theme_constant_override("margin_right", 2)
outer.add_theme_constant_override("margin_top", 1)
outer.add_theme_constant_override("margin_bottom", 1)
outer.set_meta("def_id", def_id)
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 4)
outer.add_child(row)
var info := VBoxContainer.new()
info.size_flags_horizontal = Control.SIZE_EXPAND_FILL
info.add_theme_constant_override("separation", 1)
row.add_child(info)
var name_lbl := Label.new()
name_lbl.text = str(dto.get("name", "?"))
name_lbl.add_theme_font_size_override("font_size", 13)
name_lbl.clip_text = true
info.add_child(name_lbl)
var sub_lbl := Label.new()
sub_lbl.text = "%s · %s" % [str(dto.get("cardType", "")), str(dto.get("affinity", ""))]
sub_lbl.add_theme_color_override("font_color", Color(0.55, 0.55, 0.62))
sub_lbl.add_theme_font_size_override("font_size", 10)
info.add_child(sub_lbl)
var deck_lbl := Label.new()
deck_lbl.text = "In deck: %d" % in_deck
deck_lbl.add_theme_font_size_override("font_size", 11)
deck_lbl.custom_minimum_size = Vector2(72, 0)
deck_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
outer.set_meta("deck_lbl", deck_lbl)
row.add_child(deck_lbl)
var add_btn := Button.new()
add_btn.text = "+"
add_btn.custom_minimum_size = Vector2(28, 30)
add_btn.pressed.connect(func(): _add_card(def_id))
row.add_child(add_btn)
return outer
func _refresh_coll_in_deck_labels() -> void:
for child in _coll_list.get_children():
if not child.has_meta("def_id"):
continue
var def_id := str(child.get_meta("def_id"))
var in_deck := int(_deck_qty.get(def_id, 0))
if child.has_meta("deck_lbl"):
(child.get_meta("deck_lbl") as Label).text = "In deck: %d" % in_deck
func _on_load_more() -> void:
_fetch_coll_page(_coll_page + 1)
func _on_search_changed(_t: String) -> void:
_search_timer = _DEBOUNCE
# ── Mutate: add / remove ──────────────────────────────────────────────────────
func _add_card(def_id: String) -> void:
Network.request(
"collection.add_card",
{ "deckId": _deck_id, "cardDefinitionId": def_id, "quantity": 1 },
func(_t: String, _p: Variant): _load_deck_contents(),
func(_code: String, msg: String): push_warning("DeckEditor add_card: %s" % msg)
)
func _remove_card(def_id: String, qty: Variant) -> void:
var payload : Dictionary = { "deckId": _deck_id, "cardDefinitionId": def_id }
if qty != null:
payload["quantity"] = int(qty)
Network.request(
"collection.remove_card",
payload,
func(_t: String, _p: Variant): _load_deck_contents(),
func(_code: String, msg: String): push_warning("DeckEditor remove_card: %s" % msg)
)
@@ -7,12 +7,14 @@ extends PanelContainer
signal rename_requested(deck_id: String, new_name: String)
signal delete_requested(deck_id: String, deck_name: String)
signal clone_requested(deck_id: String)
signal edit_requested(deck_id: String, deck_name: String)
@onready var name_label : Label = %NameLabel
@onready var name_edit : LineEdit = %NameEdit
@onready var arch_spirit_label : Label = %ArchSpiritLabel
@onready var count_label : Label = %CountLabel
@onready var valid_label : Label = %ValidLabel
@onready var edit_btn : Button = %EditBtn
@onready var rename_btn : Button = %RenameBtn
@onready var clone_btn : Button = %CloneBtn
@onready var delete_btn : Button = %DeleteBtn
@@ -21,13 +23,17 @@ signal clone_requested(deck_id: String)
var _deck_id : String = ""
var _deck_name : String = ""
var _is_ready : bool = false
var _pending_deck : Dictionary = {}
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
_is_ready = true
_apply_row_style()
_exit_rename_mode()
edit_btn.pressed.connect(func(): edit_requested.emit(_deck_id, _deck_name))
rename_btn.pressed.connect(_start_rename)
clone_btn.pressed.connect(func(): clone_requested.emit(_deck_id))
delete_btn.pressed.connect(func(): delete_requested.emit(_deck_id, _deck_name))
@@ -35,9 +41,21 @@ func _ready() -> void:
cancel_rename.pressed.connect(_cancel_rename)
name_edit.text_submitted.connect(func(_t): _finish_rename())
if not _pending_deck.is_empty():
_apply_setup(_pending_deck)
_pending_deck.clear()
# ── Public ────────────────────────────────────────────────────────────────────
func setup(deck: Dictionary) -> void:
if not _is_ready:
_pending_deck = deck.duplicate(true)
return
_apply_setup(deck)
func _apply_setup(deck: Dictionary) -> void:
_deck_id = str(deck.get("id", ""))
_deck_name = str(deck.get("name", "Unnamed Deck"))