update
This commit is contained in:
+109
@@ -28,10 +28,27 @@ extends Control
|
||||
# UI References - Status
|
||||
@onready var connection_status = $StatusBar/ConnectionStatus
|
||||
|
||||
# UI References - User Profile Bar (will be added to scene)
|
||||
var user_profile_bar: Control
|
||||
var profile_panel_instance: Control
|
||||
|
||||
# Store current match ID for copy function
|
||||
var current_match_id: String = ""
|
||||
|
||||
func _ready():
|
||||
# Check if user is authenticated
|
||||
if not AuthManager.is_logged_in():
|
||||
# Redirect to login screen
|
||||
get_tree().change_scene_to_file("res://scenes/ui/login_screen.tscn")
|
||||
return
|
||||
|
||||
# Initialize user profile bar
|
||||
_setup_user_profile_bar()
|
||||
|
||||
# Set player name from profile
|
||||
if player_name_input:
|
||||
player_name_input.text = UserProfileManager.get_display_name()
|
||||
|
||||
# Connect button signals
|
||||
create_room_btn.pressed.connect(_on_create_room_pressed)
|
||||
browse_rooms_btn.pressed.connect(_on_browse_rooms_pressed)
|
||||
@@ -59,6 +76,98 @@ func _ready():
|
||||
|
||||
# Show main menu initially
|
||||
_show_panel("main_menu")
|
||||
_update_profile_bar()
|
||||
|
||||
# =============================================================================
|
||||
# User Profile Bar
|
||||
# =============================================================================
|
||||
|
||||
func _setup_user_profile_bar() -> void:
|
||||
# Create profile bar dynamically (or get reference if in scene)
|
||||
user_profile_bar = _create_profile_bar()
|
||||
add_child(user_profile_bar)
|
||||
|
||||
func _create_profile_bar() -> Control:
|
||||
var bar := HBoxContainer.new()
|
||||
bar.name = "UserProfileBar"
|
||||
bar.set_anchors_preset(Control.PRESET_TOP_WIDE)
|
||||
bar.offset_top = 5
|
||||
bar.offset_bottom = 45
|
||||
bar.offset_left = 10
|
||||
bar.offset_right = -10
|
||||
|
||||
# Avatar
|
||||
var avatar := TextureRect.new()
|
||||
avatar.name = "Avatar"
|
||||
avatar.custom_minimum_size = Vector2(35, 35)
|
||||
avatar.expand_mode = TextureRect.EXPAND_FIT_WIDTH
|
||||
avatar.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
bar.add_child(avatar)
|
||||
|
||||
# Display name
|
||||
var name_label := Label.new()
|
||||
name_label.name = "DisplayName"
|
||||
name_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
name_label.add_theme_color_override("font_color", Color(0, 0.831, 1))
|
||||
bar.add_child(name_label)
|
||||
|
||||
# Account type badge
|
||||
var badge := Label.new()
|
||||
badge.name = "AccountBadge"
|
||||
badge.add_theme_font_size_override("font_size", 10)
|
||||
badge.add_theme_color_override("font_color", Color(0.5, 0.5, 0.6))
|
||||
bar.add_child(badge)
|
||||
|
||||
# Profile button
|
||||
var profile_btn := Button.new()
|
||||
profile_btn.name = "ProfileBtn"
|
||||
profile_btn.text = "Profile"
|
||||
profile_btn.pressed.connect(_on_profile_btn_pressed)
|
||||
bar.add_child(profile_btn)
|
||||
|
||||
# Logout button
|
||||
var logout_btn := Button.new()
|
||||
logout_btn.name = "LogoutBtn"
|
||||
logout_btn.text = "Logout"
|
||||
logout_btn.pressed.connect(_on_logout_pressed)
|
||||
bar.add_child(logout_btn)
|
||||
|
||||
return bar
|
||||
|
||||
func _update_profile_bar() -> void:
|
||||
if not user_profile_bar:
|
||||
return
|
||||
|
||||
var name_label := user_profile_bar.get_node_or_null("DisplayName") as Label
|
||||
if name_label:
|
||||
name_label.text = UserProfileManager.get_display_name()
|
||||
|
||||
var badge := user_profile_bar.get_node_or_null("AccountBadge") as Label
|
||||
if badge:
|
||||
badge.text = "[Guest]" if AuthManager.is_guest else "[Registered]"
|
||||
|
||||
var avatar := user_profile_bar.get_node_or_null("Avatar") as TextureRect
|
||||
if avatar:
|
||||
var avatar_url := UserProfileManager.get_avatar_url()
|
||||
if ResourceLoader.exists(avatar_url):
|
||||
avatar.texture = load(avatar_url)
|
||||
|
||||
func _on_profile_btn_pressed() -> void:
|
||||
# Show profile panel
|
||||
if not profile_panel_instance:
|
||||
var profile_panel_scene := load("res://scenes/ui/profile_panel.tscn")
|
||||
profile_panel_instance = profile_panel_scene.instantiate()
|
||||
profile_panel_instance.closed.connect(func(): profile_panel_instance.hide())
|
||||
profile_panel_instance.profile_updated.connect(_update_profile_bar)
|
||||
add_child(profile_panel_instance)
|
||||
|
||||
profile_panel_instance.show_panel()
|
||||
# Center the panel
|
||||
profile_panel_instance.position = (get_viewport_rect().size - profile_panel_instance.size) / 2
|
||||
|
||||
func _on_logout_pressed() -> void:
|
||||
AuthManager.logout()
|
||||
get_tree().change_scene_to_file("res://scenes/ui/login_screen.tscn")
|
||||
|
||||
# =============================================================================
|
||||
# Panel Management
|
||||
|
||||
Reference in New Issue
Block a user