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
+28 -8
View File
@@ -2,6 +2,8 @@ extends Control
# UI References - Main Menu
@onready var main_menu_panel = $MainMenuPanel
@onready var main_title = $MainMenuPanel/VBoxContainer/TitleContainer/Title
@onready var main_subtitle = $MainMenuPanel/VBoxContainer/TitleContainer/Subtitle
@onready var create_room_btn = $MainMenuPanel/VBoxContainer/ButtonSection/CreateRoomBtn
@onready var browse_rooms_btn = $MainMenuPanel/VBoxContainer/ButtonSection/BrowseRoomsBtn
@onready var main_menu_profile_btn = $MainMenuPanel/VBoxContainer/ButtonSection/ProfileBtn
@@ -116,11 +118,8 @@ func _ready():
# Setup Game Mode specific UI dynamically
_create_custom_settings_ui()
# Set player name from profile
if AuthManager.is_guest:
LobbyManager.local_player_name = NameGenerator.generate_guest_name()
else:
LobbyManager.local_player_name = UserProfileManager.get_display_name()
# Initial UI update
_on_profile_updated()
# Connect button signals - Main Menu
create_room_btn.pressed.connect(_on_create_room_pressed)
@@ -208,8 +207,12 @@ func _ready():
NakamaManager.connection_failed.connect(_on_connection_failed)
# Connect UserProfileManager signals
UserProfileManager.profile_loaded.connect(func(_p): _on_profile_updated())
UserProfileManager.profile_updated.connect(_on_profile_updated)
# Set initial title if already loaded
_on_profile_updated()
# Show main menu initially
_show_panel("main_menu")
@@ -239,6 +242,9 @@ func _load_character_textures() -> void:
print("[Lobby] Character texture not found: ", tex_path)
func _on_server_option_selected(index: int) -> void:
if main_subtitle and server_option:
main_subtitle.text = server_option.get_item_text(index).to_upper()
if index == 0:
# Nakama Localhost
if server_ip_input: server_ip_input.visible = false
@@ -805,10 +811,24 @@ func _on_connection_failed(error_message: String) -> void:
func _on_profile_updated() -> void:
"""Handle profile updates (name/avatar change)."""
var new_name = UserProfileManager.get_display_name()
var display_name: String = ""
# Sync to LobbyManager if we are in a room or just locally
LobbyManager.set_player_name(new_name)
if UserProfileManager.is_profile_loaded:
display_name = UserProfileManager.get_display_name()
elif not AuthManager.is_guest and AuthManager.is_authenticated:
display_name = "LOADING..."
else:
# Is Guest or not logged in yet
if LobbyManager.local_player_name.is_empty() or LobbyManager.local_player_name == "Guest":
display_name = NameGenerator.generate_guest_name()
else:
display_name = LobbyManager.local_player_name
if main_title:
main_title.text = display_name
# Sync to LobbyManager
LobbyManager.set_player_name(display_name)
# =============================================================================
# Player Slot Updates