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")