- CardWidget (146×204px): affinity-coloured border + art placeholder, stats with tooltips, foil/serial indicators, selection highlight - DeckListItem: inline rename, clone/delete signals to parent - CardsView: paginated + filterable grid (search debounce, type/affinity filters, responsive columns, Load More pagination) - DecksView: deck list with New Deck form (ArchSpirit card picker), clone/rename/delete wired to API, ConfirmationDialog for delete - CollectionScreen: pill-tab container (Cards / Decks), background incremental content sync, back button → MainScreen - MainScreen: wire CollectionBtn → CollectionScreen - ContentCache: expose is_syncing() public method Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
86 lines
3.6 KiB
GDScript
86 lines
3.6 KiB
GDScript
extends VBoxContainer
|
|
## Collection screen — pill-tab container for Cards and Decks views.
|
|
##
|
|
## Checks for a background content sync on load; if the cache is already
|
|
## syncing (started by InitScreen) the SyncLabel shows "Syncing…" until done.
|
|
## If not syncing, triggers a silent background sync to pick up any new cards
|
|
## added since last session.
|
|
|
|
# ── Node references ───────────────────────────────────────────────────────────
|
|
|
|
@onready var back_btn : Button = %BackBtn
|
|
@onready var sync_label : Label = %SyncLabel
|
|
@onready var cards_tab_btn : Button = %CardsTabBtn
|
|
@onready var decks_tab_btn : Button = %DecksTabBtn
|
|
@onready var cards_view : VBoxContainer = %CardsView
|
|
@onready var decks_view : VBoxContainer = %DecksView
|
|
|
|
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
|
|
|
func _ready() -> void:
|
|
back_btn.pressed.connect(_on_back)
|
|
cards_tab_btn.pressed.connect(func(): _show_tab(0))
|
|
decks_tab_btn.pressed.connect(func(): _show_tab(1))
|
|
|
|
_show_tab(0)
|
|
_setup_sync()
|
|
|
|
|
|
func _exit_tree() -> void:
|
|
if ContentCache.sync_complete.is_connected(_on_sync_done):
|
|
ContentCache.sync_complete.disconnect(_on_sync_done)
|
|
if ContentCache.sync_failed.is_connected(_on_sync_done_or_failed):
|
|
ContentCache.sync_failed.disconnect(_on_sync_done_or_failed)
|
|
|
|
# ── Tab switching ─────────────────────────────────────────────────────────────
|
|
|
|
func _show_tab(index: int) -> void:
|
|
cards_view.visible = (index == 0)
|
|
decks_view.visible = (index == 1)
|
|
_apply_tab_style(cards_tab_btn, index == 0)
|
|
_apply_tab_style(decks_tab_btn, index == 1)
|
|
|
|
|
|
func _apply_tab_style(btn: Button, active: bool) -> void:
|
|
var style := StyleBoxFlat.new()
|
|
style.corner_radius_top_left = 6
|
|
style.corner_radius_top_right = 6
|
|
style.corner_radius_bottom_left = 6
|
|
style.corner_radius_bottom_right = 6
|
|
if active:
|
|
style.bg_color = Color(0.27, 0.47, 0.80, 1.0)
|
|
else:
|
|
style.bg_color = Color(0.18, 0.18, 0.26, 1.0)
|
|
btn.add_theme_stylebox_override("normal", style)
|
|
btn.add_theme_stylebox_override("hover", style)
|
|
btn.add_theme_stylebox_override("pressed", style)
|
|
|
|
# ── Background sync ───────────────────────────────────────────────────────────
|
|
|
|
func _setup_sync() -> void:
|
|
if ContentCache.is_syncing():
|
|
sync_label.text = "Syncing…"
|
|
sync_label.visible = true
|
|
ContentCache.sync_complete.connect(_on_sync_done, CONNECT_ONE_SHOT)
|
|
ContentCache.sync_failed.connect(_on_sync_done_or_failed, CONNECT_ONE_SHOT)
|
|
else:
|
|
# Trigger a silent background incremental sync
|
|
ContentCache.sync_complete.connect(_on_sync_done, CONNECT_ONE_SHOT)
|
|
ContentCache.sync_failed.connect(_on_sync_done_or_failed, CONNECT_ONE_SHOT)
|
|
sync_label.text = "Syncing…"
|
|
sync_label.visible = true
|
|
ContentCache.start_sync()
|
|
|
|
|
|
func _on_sync_done(_total: int) -> void:
|
|
sync_label.visible = false
|
|
|
|
|
|
func _on_sync_done_or_failed(_detail = null) -> void:
|
|
sync_label.visible = false
|
|
|
|
# ── Navigation ────────────────────────────────────────────────────────────────
|
|
|
|
func _on_back() -> void:
|
|
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")
|