feat: edit some login indicator

This commit is contained in:
2026-04-03 05:11:49 +08:00
parent e1a3ef8e85
commit 733b1da8e0
5 changed files with 121 additions and 39 deletions
+7 -2
View File
@@ -9,6 +9,7 @@ signal avatar_changed(url: String)
# Profile data
var profile: Dictionary = {}
var stats: Dictionary = {}
var is_profile_loaded: bool = false
# Nakama storage collection names
const PROFILE_COLLECTION := "profiles"
@@ -36,6 +37,7 @@ func _on_auth_completed(success: bool, _user_data: Dictionary) -> void:
func _on_logged_out() -> void:
profile = {}
stats = {}
is_profile_loaded = false
# =============================================================================
# Profile Loading
@@ -81,6 +83,7 @@ func load_profile() -> Dictionary:
# Load stats
await load_stats()
is_profile_loaded = true
emit_signal("profile_loaded", profile)
print("[UserProfileManager] Profile loaded: ", profile.display_name)
return profile
@@ -257,8 +260,10 @@ func record_game_result(won: bool, score: int) -> void:
# Getters
# =============================================================================
func get_display_name() -> String:
return profile.get("display_name", "Guest")
func get_display_name(fallback: String = "Guest") -> String:
if not is_profile_loaded:
return fallback
return profile.get("display_name", fallback)
func get_avatar_url() -> String:
var index: int = profile.get("avatar_index", 0)