Standardize programmatic UI to scene-based instantiation (Phases 1-5)
Convert all screens that built UI nodes in GDScript into proper .tscn
scene files. Each component gets its own scene; parent screens use
preload + instantiate; data flows through setup() methods; actions use
signals. Eliminates ~1000 lines of boilerplate node-creation code.
Phase 1 — Simple row components (6 new scenes):
LeaderboardRow, NotificationRow, StarterDeckCard, DeckPickerButton,
StatRow, AbilityRow
Modifies: leaderboard_screen, account_screen, starter_deck_screen,
matchmaking_screen, card_detail_popup (GridContainer→VBox)
Phase 2 — Lobby browser rows (2 new scenes):
LobbyBrowserRow (signal join_requested), ActiveGameRow (signal spectate_requested)
Modifies: free_play_screen
Phase 3 — RulesEditorDialog (1 new scene):
Replaces 150+ line _open_rules_editor() in lobby_room_screen with
4-line instantiate pattern; signal confirmed(overrides)
Phase 4 — DeckEditorPanel.tscn:
Moves split-pane deck editor into scene file; removes _setup_ui(),
_make_left_pane(), _make_right_pane(); switches to @onready refs;
DecksView.tscn updated to instance the scene
Phase 5 — ChatOverlay.tscn:
Fully populates ChatPanel with header, 7 tab buttons, 7 content panes
(FriendsPane/PresencePane/GlobalPane/LobbyPane/GamePane/PartyPane/DmsPane),
and InputBar; removes _build_panel() and all _make_*/_build_*_tab()
functions from chat_overlay.gd; replaces with @onready refs and
_ready() wiring from scene children
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>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/starter_deck/components/starter_deck_card.gd" id="1_sdc"]
|
||||
|
||||
[node name="StarterDeckCard" type="Button"]
|
||||
focus_mode = 1
|
||||
size_flags_horizontal = 2
|
||||
script = ExtResource("1_sdc")
|
||||
|
||||
[node name="Inner" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 5
|
||||
|
||||
[node name="NameLabel" type="Label" parent="Inner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
|
||||
[node name="SubtitleLabel" type="Label" parent="Inner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
modulate = Color(0.7, 0.7, 0.8, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
@@ -0,0 +1,46 @@
|
||||
extends Button
|
||||
## Selectable starter deck card in the deck picker screen.
|
||||
|
||||
signal selected(id: String)
|
||||
|
||||
const SEL_COLOR := Color(0.36, 0.56, 1.0, 1.0)
|
||||
const DEF_COLOR := Color(0.25, 0.25, 0.35, 1.0)
|
||||
|
||||
@onready var name_label : Label = %NameLabel
|
||||
@onready var subtitle_label : Label = %SubtitleLabel
|
||||
|
||||
var _id : String = ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pressed.connect(func(): selected.emit(_id))
|
||||
_apply_style(false)
|
||||
|
||||
|
||||
func setup(id: String, deck_name: String, subtitle: String) -> void:
|
||||
_id = id
|
||||
name_label.text = deck_name
|
||||
subtitle_label.text = subtitle
|
||||
|
||||
|
||||
func set_selected(v: bool) -> void:
|
||||
_apply_style(v)
|
||||
|
||||
|
||||
func _apply_style(sel: bool) -> void:
|
||||
var bg := Color(0.13, 0.13, 0.20, 1.0)
|
||||
var make := func(b: Color) -> StyleBoxFlat:
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = b
|
||||
s.border_color = SEL_COLOR if sel else DEF_COLOR
|
||||
s.set_border_width_all(2)
|
||||
s.set_corner_radius_all(6)
|
||||
s.content_margin_left = 14
|
||||
s.content_margin_right = 14
|
||||
s.content_margin_top = 12
|
||||
s.content_margin_bottom = 12
|
||||
return s
|
||||
add_theme_stylebox_override("normal", make.call(bg))
|
||||
add_theme_stylebox_override("hover", make.call(Color(0.20, 0.20, 0.30, 1.0)))
|
||||
add_theme_stylebox_override("pressed", make.call(bg))
|
||||
add_theme_stylebox_override("focus", make.call(bg))
|
||||
@@ -1,5 +1,7 @@
|
||||
extends Control
|
||||
## Starter deck selection screen — shown to new players immediately after auth.
|
||||
|
||||
const CARD = preload("res://scenes/starter_deck/components/StarterDeckCard.tscn")
|
||||
##
|
||||
## Flow:
|
||||
## 1. Send collection.get_starter_decks → populate deck list.
|
||||
@@ -63,79 +65,23 @@ func _populate_list(decks: Array) -> void:
|
||||
child.queue_free()
|
||||
|
||||
for deck in decks:
|
||||
var d := deck as Dictionary
|
||||
var id := d.get("id", "") as String
|
||||
deck_list.add_child(_build_card(d, id))
|
||||
|
||||
|
||||
func _build_card(d: Dictionary, id: String) -> Button:
|
||||
var btn := Button.new()
|
||||
btn.name = "Deck_%s" % id
|
||||
btn.flat = false
|
||||
btn.focus_mode = Control.FOCUS_CLICK
|
||||
btn.size_flags_horizontal = Control.SIZE_FILL
|
||||
_apply_card_style(btn, false)
|
||||
|
||||
var inner := VBoxContainer.new()
|
||||
inner.add_theme_constant_override("separation", 5)
|
||||
btn.add_child(inner)
|
||||
|
||||
# Deck name
|
||||
var name_lbl := Label.new()
|
||||
name_lbl.text = d.get("name", "Unknown Deck")
|
||||
name_lbl.add_theme_font_size_override("font_size", 16)
|
||||
inner.add_child(name_lbl)
|
||||
|
||||
# ArchSpirit · card count
|
||||
var arch : String = d.get("archSpiritName", "")
|
||||
var total : int = d.get("totalCards", 0)
|
||||
var sub_lbl := Label.new()
|
||||
sub_lbl.text = ("%s · %d cards" % [arch, total]) if not arch.is_empty() \
|
||||
else ("%d cards" % total)
|
||||
sub_lbl.modulate = Color(0.7, 0.7, 0.8)
|
||||
sub_lbl.add_theme_font_size_override("font_size", 12)
|
||||
inner.add_child(sub_lbl)
|
||||
|
||||
# Optional description
|
||||
var desc : String = d.get("description", "")
|
||||
if not desc.is_empty():
|
||||
var desc_lbl := Label.new()
|
||||
desc_lbl.text = desc
|
||||
desc_lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
desc_lbl.modulate = Color(0.65, 0.65, 0.75)
|
||||
desc_lbl.add_theme_font_size_override("font_size", 11)
|
||||
inner.add_child(desc_lbl)
|
||||
|
||||
btn.pressed.connect(func(): _select_deck(id))
|
||||
return btn
|
||||
|
||||
|
||||
func _apply_card_style(btn: Button, selected: bool,
|
||||
bg: Color = Color(0.13, 0.13, 0.20, 1.0)) -> void:
|
||||
var make := func(b: Color) -> StyleBoxFlat:
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = b
|
||||
s.border_color = SEL_COLOR if selected else DEF_COLOR
|
||||
s.set_border_width_all(2)
|
||||
s.set_corner_radius_all(6)
|
||||
s.content_margin_left = 14
|
||||
s.content_margin_right = 14
|
||||
s.content_margin_top = 12
|
||||
s.content_margin_bottom = 12
|
||||
return s
|
||||
btn.add_theme_stylebox_override("normal", make.call(bg))
|
||||
btn.add_theme_stylebox_override("hover", make.call(Color(0.20, 0.20, 0.30, 1.0)))
|
||||
btn.add_theme_stylebox_override("pressed", make.call(bg))
|
||||
btn.add_theme_stylebox_override("focus", make.call(bg))
|
||||
var d := deck as Dictionary
|
||||
var id := d.get("id", "") as String
|
||||
var arch : String = d.get("archSpiritName", "")
|
||||
var total : int = d.get("totalCards", 0)
|
||||
var sub : String = ("%s · %d cards" % [arch, total]) if not arch.is_empty() \
|
||||
else ("%d cards" % total)
|
||||
var card := CARD.instantiate()
|
||||
card.setup(id, d.get("name", "Unknown Deck"), sub)
|
||||
card.selected.connect(_select_deck)
|
||||
deck_list.add_child(card)
|
||||
|
||||
|
||||
func _select_deck(id: String) -> void:
|
||||
_selected_id = id
|
||||
for child in deck_list.get_children():
|
||||
var btn := child as Button
|
||||
if btn == null:
|
||||
continue
|
||||
_apply_card_style(btn, btn.name == ("Deck_%s" % id))
|
||||
if child.has_method("set_selected"):
|
||||
child.set_selected(child._id == id)
|
||||
confirm_btn.disabled = false
|
||||
|
||||
# ── Confirm ───────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user