Files
sor/Client/origin-client/scenes/account/account_screen.gd
T
3894fbdd16 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>
2026-03-22 10:36:01 -04:00

85 lines
2.9 KiB
GDScript

extends Control
## Account Management screen.
const NOTIF_ROW = preload("res://scenes/account/components/NotificationRow.tscn")
## Shows the player's own profile (display name, OP, rank score)
## and a mailbox tab with admin responses to bug reports.
@onready var back_btn : Button = %BackBtn
@onready var display_label : Label = %DisplayLabel
@onready var op_label : Label = %OpLabel
@onready var rank_label : Label = %RankLabel
@onready var mailbox_list : VBoxContainer = %MailboxList
@onready var loading_label : Label = %LoadingLabel
@onready var empty_label : Label = %EmptyLabel
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
back_btn.pressed.connect(_on_back)
_load_profile()
_load_notifications()
# ── Profile ───────────────────────────────────────────────────────────────────
func _load_profile() -> void:
display_label.text = Auth.display_name
op_label.text = "◆ — OP"
rank_label.text = "Rank: —"
Network.request(
"account.get_profile",
{},
func(_type: String, p: Variant): _on_profile_ok(p),
func(_c: String, _m: String): pass
)
func _on_profile_ok(p: Variant) -> void:
var d := p as Dictionary
op_label.text = "◆ %d OP" % int(d.get("originPoints", 0))
rank_label.text = "Rank Score: %d" % int(d.get("rankScore", 1000))
# ── Notifications (mailbox) ────────────────────────────────────────────────────
func _load_notifications() -> void:
loading_label.visible = true
empty_label.visible = false
for c in mailbox_list.get_children():
c.queue_free()
Network.request(
"chat.get_notifications",
{ "unreadOnly": false },
func(_type: String, p: Variant): _on_notifications_ok(p),
func(_c: String, _m: String):
loading_label.text = "Failed to load mailbox."
)
func _on_notifications_ok(p: Variant) -> void:
loading_label.visible = false
var notifs : Array = (p as Dictionary).get("notifications", []) as Array
if notifs.is_empty():
empty_label.visible = true
return
for n in notifs:
var nd := n as Dictionary
var row := NOTIF_ROW.instantiate()
mailbox_list.add_child(row)
row.setup(
nd.get("title", "Notification"),
nd.get("body", ""),
nd.get("readAt", null) == null
)
# ── Navigation ────────────────────────────────────────────────────────────────
func _on_back() -> void:
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")