Fix @onready null crash: add_child before setup() across all scene rows
@onready vars are resolved when a node enters the scene tree. Calling setup() before add_child() means all %NodeName refs are still null, causing "Invalid assignment... on base object of type Nil" errors. Fixed ordering in every affected screen: - free_play_screen.gd: LobbyBrowserRow, ActiveGameRow, DeckPickerButton - lobby_room_screen.gd: RulesEditorDialog - matchmaking_screen.gd: DeckPickerButton - card_detail_popup.gd: StatRow, AbilityRow - starter_deck_screen.gd: StarterDeckCard - account_screen.gd: NotificationRow - leaderboard_screen.gd: LeaderboardRow 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:
@@ -70,12 +70,12 @@ func _on_notifications_ok(p: Variant) -> void:
|
|||||||
for n in notifs:
|
for n in notifs:
|
||||||
var nd := n as Dictionary
|
var nd := n as Dictionary
|
||||||
var row := NOTIF_ROW.instantiate()
|
var row := NOTIF_ROW.instantiate()
|
||||||
|
mailbox_list.add_child(row)
|
||||||
row.setup(
|
row.setup(
|
||||||
nd.get("title", "Notification"),
|
nd.get("title", "Notification"),
|
||||||
nd.get("body", ""),
|
nd.get("body", ""),
|
||||||
nd.get("readAt", null) == null
|
nd.get("readAt", null) == null
|
||||||
)
|
)
|
||||||
mailbox_list.add_child(row)
|
|
||||||
|
|
||||||
|
|
||||||
# ── Navigation ────────────────────────────────────────────────────────────────
|
# ── Navigation ────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ func _populate_stats(def: Dictionary) -> void:
|
|||||||
|
|
||||||
func _add_stat(key: String, value: String) -> void:
|
func _add_stat(key: String, value: String) -> void:
|
||||||
var row := _StatRow.instantiate()
|
var row := _StatRow.instantiate()
|
||||||
row.setup(key, value)
|
|
||||||
stats_grid.add_child(row)
|
stats_grid.add_child(row)
|
||||||
|
row.setup(key, value)
|
||||||
|
|
||||||
|
|
||||||
func _populate_abilities(def: Dictionary) -> void:
|
func _populate_abilities(def: Dictionary) -> void:
|
||||||
@@ -124,8 +124,8 @@ func _populate_abilities(def: Dictionary) -> void:
|
|||||||
var desc := str(d.get("description", d.get("Description", "")))
|
var desc := str(d.get("description", d.get("Description", "")))
|
||||||
|
|
||||||
var row := _AbilityRow.instantiate()
|
var row := _AbilityRow.instantiate()
|
||||||
row.setup(name_, desc)
|
|
||||||
abilities_list.add_child(row)
|
abilities_list.add_child(row)
|
||||||
|
row.setup(name_, desc)
|
||||||
|
|
||||||
|
|
||||||
func _on_overlay_input(event: InputEvent) -> void:
|
func _on_overlay_input(event: InputEvent) -> void:
|
||||||
|
|||||||
@@ -133,9 +133,9 @@ func _populate_open_lobbies() -> void:
|
|||||||
var has_deck := not _selected_deck.is_empty()
|
var has_deck := not _selected_deck.is_empty()
|
||||||
for lobby in _open_lobbies:
|
for lobby in _open_lobbies:
|
||||||
var row := LOBBY_ROW.instantiate()
|
var row := LOBBY_ROW.instantiate()
|
||||||
row.setup(lobby, has_deck)
|
|
||||||
row.join_requested.connect(_on_row_join_requested)
|
row.join_requested.connect(_on_row_join_requested)
|
||||||
lobby_list_container.add_child(row)
|
lobby_list_container.add_child(row)
|
||||||
|
row.setup(lobby, has_deck)
|
||||||
|
|
||||||
|
|
||||||
func _on_row_join_requested(lobby_id: String, _has_password: bool) -> void:
|
func _on_row_join_requested(lobby_id: String, _has_password: bool) -> void:
|
||||||
@@ -156,9 +156,9 @@ func _populate_active_games() -> void:
|
|||||||
return
|
return
|
||||||
for game in _active_games:
|
for game in _active_games:
|
||||||
var row := ACTIVE_ROW.instantiate()
|
var row := ACTIVE_ROW.instantiate()
|
||||||
row.setup(game)
|
|
||||||
row.spectate_requested.connect(_on_spectate_pressed)
|
row.spectate_requested.connect(_on_spectate_pressed)
|
||||||
active_list_container.add_child(row)
|
active_list_container.add_child(row)
|
||||||
|
row.setup(game)
|
||||||
|
|
||||||
|
|
||||||
func _populate_create_deck_buttons() -> void:
|
func _populate_create_deck_buttons() -> void:
|
||||||
@@ -182,9 +182,9 @@ func _populate_create_deck_buttons() -> void:
|
|||||||
# Auto-press first button to reflect the auto-selected deck.
|
# Auto-press first button to reflect the auto-selected deck.
|
||||||
if i == 0:
|
if i == 0:
|
||||||
btn.button_pressed = true
|
btn.button_pressed = true
|
||||||
btn.setup(did, str(deck.get("name", "Unnamed Deck")), int(deck.get("cardCount", 0)))
|
|
||||||
btn.picked.connect(func(id: String): _selected_deck = id)
|
btn.picked.connect(func(id: String): _selected_deck = id)
|
||||||
deck_select_container.add_child(btn)
|
deck_select_container.add_child(btn)
|
||||||
|
btn.setup(did, str(deck.get("name", "Unnamed Deck")), int(deck.get("cardCount", 0)))
|
||||||
|
|
||||||
# ── Action handlers ───────────────────────────────────────────────────────────
|
# ── Action handlers ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -353,9 +353,9 @@ func _on_deck_picker_confirmed() -> void:
|
|||||||
|
|
||||||
func _on_edit_rules_pressed() -> void:
|
func _on_edit_rules_pressed() -> void:
|
||||||
var dlg := RULES_DIALOG.instantiate()
|
var dlg := RULES_DIALOG.instantiate()
|
||||||
dlg.setup(_current_rules, CustomLobby.is_host)
|
|
||||||
dlg.confirmed.connect(_on_rules_dialog_confirmed)
|
dlg.confirmed.connect(_on_rules_dialog_confirmed)
|
||||||
add_child(dlg)
|
add_child(dlg)
|
||||||
|
dlg.setup(_current_rules, CustomLobby.is_host)
|
||||||
dlg.popup_centered()
|
dlg.popup_centered()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ func _on_leaderboard_ok(p: Variant) -> void:
|
|||||||
for entry in entries:
|
for entry in entries:
|
||||||
var e := entry as Dictionary
|
var e := entry as Dictionary
|
||||||
var row := ROW.instantiate()
|
var row := ROW.instantiate()
|
||||||
|
entry_list.add_child(row)
|
||||||
row.setup(
|
row.setup(
|
||||||
int(e.get("rank", 0)),
|
int(e.get("rank", 0)),
|
||||||
e.get("displayName", "???"),
|
e.get("displayName", "???"),
|
||||||
@@ -66,7 +67,6 @@ func _on_leaderboard_ok(p: Variant) -> void:
|
|||||||
e.get("accountId", "") == Auth.user_id,
|
e.get("accountId", "") == Auth.user_id,
|
||||||
int(e.get("rank", 99)) <= 3
|
int(e.get("rank", 99)) <= 3
|
||||||
)
|
)
|
||||||
entry_list.add_child(row)
|
|
||||||
|
|
||||||
|
|
||||||
func _update_pagination() -> void:
|
func _update_pagination() -> void:
|
||||||
|
|||||||
@@ -76,15 +76,15 @@ func _on_decks_response(_type: String, payload: Variant) -> void:
|
|||||||
sub_label.text = ""
|
sub_label.text = ""
|
||||||
for deck: Dictionary in decks:
|
for deck: Dictionary in decks:
|
||||||
var btn := DECK_BTN.instantiate()
|
var btn := DECK_BTN.instantiate()
|
||||||
|
btn.picked.connect(func(id: String) -> void:
|
||||||
|
_selected_deck_id = id
|
||||||
|
_join_queue())
|
||||||
|
deck_list.add_child(btn)
|
||||||
btn.setup(
|
btn.setup(
|
||||||
str(deck.get("id", "")),
|
str(deck.get("id", "")),
|
||||||
str(deck.get("name", "Unnamed")),
|
str(deck.get("name", "Unnamed")),
|
||||||
int(deck.get("cardCount", 0))
|
int(deck.get("cardCount", 0))
|
||||||
)
|
)
|
||||||
btn.picked.connect(func(id: String) -> void:
|
|
||||||
_selected_deck_id = id
|
|
||||||
_join_queue())
|
|
||||||
deck_list.add_child(btn)
|
|
||||||
|
|
||||||
# ── Queue actions ─────────────────────────────────────────────────────────────
|
# ── Queue actions ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ func _populate_list(decks: Array) -> void:
|
|||||||
var sub : String = ("%s · %d cards" % [arch, total]) if not arch.is_empty() \
|
var sub : String = ("%s · %d cards" % [arch, total]) if not arch.is_empty() \
|
||||||
else ("%d cards" % total)
|
else ("%d cards" % total)
|
||||||
var card := CARD.instantiate()
|
var card := CARD.instantiate()
|
||||||
card.setup(id, d.get("name", "Unknown Deck"), sub)
|
|
||||||
card.selected.connect(_select_deck)
|
card.selected.connect(_select_deck)
|
||||||
deck_list.add_child(card)
|
deck_list.add_child(card)
|
||||||
|
card.setup(id, d.get("name", "Unknown Deck"), sub)
|
||||||
|
|
||||||
|
|
||||||
func _select_deck(id: String) -> void:
|
func _select_deck(id: String) -> void:
|
||||||
|
|||||||
Reference in New Issue
Block a user