feat: updated UI UX for profile and leaderboard menu
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://dpkx1a780pvwv" path="res://assets/textures/tile_diamond.png" id="10_sx8rm"]
|
[ext_resource type="Texture2D" uid="uid://dpkx1a780pvwv" path="res://assets/textures/tile_diamond.png" id="10_sx8rm"]
|
||||||
[ext_resource type="BoxMesh" uid="uid://fy4bhoeii40c" path="res://addons/enhanced_gridmap/meshlibrary/tile_safe_zone.tres" id="10_uwjsj"]
|
[ext_resource type="BoxMesh" uid="uid://fy4bhoeii40c" path="res://addons/enhanced_gridmap/meshlibrary/tile_safe_zone.tres" id="10_uwjsj"]
|
||||||
[ext_resource type="BoxMesh" uid="uid://b5cc3prem52r6" path="res://addons/enhanced_gridmap/meshlibrary/tile_freeze.tres" id="11_pgnbl"]
|
[ext_resource type="BoxMesh" uid="uid://b5cc3prem52r6" path="res://addons/enhanced_gridmap/meshlibrary/tile_freeze.tres" id="11_pgnbl"]
|
||||||
[ext_resource type="BoxMesh" path="res://addons/enhanced_gridmap/meshlibrary/tile_non_walkable.tres" id="11_uwjsj"]
|
[ext_resource type="BoxMesh" uid="uid://dcjdwbffgtutt" path="res://addons/enhanced_gridmap/meshlibrary/tile_non_walkable.tres" id="11_uwjsj"]
|
||||||
|
|
||||||
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_5d0gc"]
|
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_5d0gc"]
|
||||||
load_path = "res://.godot/imported/tile_heart.png-deeef50755ca225f028608dfd16900e6.s3tc.ctex"
|
load_path = "res://.godot/imported/tile_heart.png-deeef50755ca225f028608dfd16900e6.s3tc.ctex"
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ GoalsCycleManager="*res://scripts/managers/goals_cycle_manager.gd"
|
|||||||
Satori="*uid://b8vev00s34b7"
|
Satori="*uid://b8vev00s34b7"
|
||||||
SettingsManager="*uid://c1ouaaqnn0lrc"
|
SettingsManager="*uid://c1ouaaqnn0lrc"
|
||||||
SfxManager="*res://scripts/managers/sfx_manager.gd"
|
SfxManager="*res://scripts/managers/sfx_manager.gd"
|
||||||
|
NameGenerator="*res://scripts/generators/name_generator.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
|||||||
+43
-7
@@ -94,6 +94,9 @@ var current_match_id: String = ""
|
|||||||
|
|
||||||
var leaderboard_panel_instance: Control
|
var leaderboard_panel_instance: Control
|
||||||
|
|
||||||
|
# Bot name tracking keyed by slot index to avoid re-generating on each update
|
||||||
|
var _bot_names: Dictionary = {}
|
||||||
|
|
||||||
# Server Selection Controls (Now in tscn)
|
# Server Selection Controls (Now in tscn)
|
||||||
# var server_option: OptionButton
|
# var server_option: OptionButton
|
||||||
# var server_ip_input: LineEdit
|
# var server_ip_input: LineEdit
|
||||||
@@ -116,7 +119,7 @@ func _ready():
|
|||||||
|
|
||||||
# Set player name from profile
|
# Set player name from profile
|
||||||
if AuthManager.is_guest:
|
if AuthManager.is_guest:
|
||||||
LobbyManager.local_player_name = "Guest"
|
LobbyManager.local_player_name = NameGenerator.generate_guest_name()
|
||||||
else:
|
else:
|
||||||
LobbyManager.local_player_name = UserProfileManager.get_display_name()
|
LobbyManager.local_player_name = UserProfileManager.get_display_name()
|
||||||
|
|
||||||
@@ -329,17 +332,21 @@ func _on_create_room_pressed() -> void:
|
|||||||
# Use profile name for logged-in users, or guest for others
|
# Use profile name for logged-in users, or guest for others
|
||||||
if AuthManager.is_guest:
|
if AuthManager.is_guest:
|
||||||
if LobbyManager.local_player_name.is_empty() or LobbyManager.local_player_name == "Player":
|
if LobbyManager.local_player_name.is_empty() or LobbyManager.local_player_name == "Player":
|
||||||
LobbyManager.local_player_name = "Guest"
|
LobbyManager.local_player_name = NameGenerator.generate_guest_name()
|
||||||
else:
|
else:
|
||||||
LobbyManager.local_player_name = UserProfileManager.get_display_name()
|
LobbyManager.local_player_name = UserProfileManager.get_display_name()
|
||||||
|
|
||||||
if LobbyManager.is_lan_mode:
|
if LobbyManager.is_lan_mode:
|
||||||
connection_status.text = "Starting LAN room..."
|
connection_status.text = "Starting LAN room..."
|
||||||
|
# Apply loadout character before creating room
|
||||||
|
_apply_loadout_character()
|
||||||
var ok = await LobbyManager.create_room_lan("LAN Room " + str(randi_range(100, 999)))
|
var ok = await LobbyManager.create_room_lan("LAN Room " + str(randi_range(100, 999)))
|
||||||
if not ok:
|
if not ok:
|
||||||
connection_status.text = "Failed to start LAN room. Check port 7777."
|
connection_status.text = "Failed to start LAN room. Check port 7777."
|
||||||
else:
|
else:
|
||||||
connection_status.text = "Creating Nakama room..."
|
connection_status.text = "Creating Nakama room..."
|
||||||
|
# Apply loadout character before creating room
|
||||||
|
_apply_loadout_character()
|
||||||
LobbyManager.create_room("Room %d" % randi_range(1000, 9999))
|
LobbyManager.create_room("Room %d" % randi_range(1000, 9999))
|
||||||
|
|
||||||
func _on_browse_rooms_pressed() -> void:
|
func _on_browse_rooms_pressed() -> void:
|
||||||
@@ -399,7 +406,7 @@ func _on_join_pressed() -> void:
|
|||||||
# Determine player name
|
# Determine player name
|
||||||
if AuthManager.is_guest:
|
if AuthManager.is_guest:
|
||||||
if LobbyManager.local_player_name.is_empty():
|
if LobbyManager.local_player_name.is_empty():
|
||||||
LobbyManager.local_player_name = "Guest"
|
LobbyManager.local_player_name = NameGenerator.generate_guest_name()
|
||||||
else:
|
else:
|
||||||
LobbyManager.local_player_name = UserProfileManager.get_display_name()
|
LobbyManager.local_player_name = UserProfileManager.get_display_name()
|
||||||
|
|
||||||
@@ -417,6 +424,8 @@ func _on_join_pressed() -> void:
|
|||||||
return
|
return
|
||||||
|
|
||||||
connection_status.text = "Connecting to %s..." % match_id
|
connection_status.text = "Connecting to %s..." % match_id
|
||||||
|
# Apply loadout character before joining
|
||||||
|
_apply_loadout_character()
|
||||||
var ok = LobbyManager.join_room_lan(match_id)
|
var ok = LobbyManager.join_room_lan(match_id)
|
||||||
if not ok:
|
if not ok:
|
||||||
connection_status.text = "Failed to connect to %s" % match_id
|
connection_status.text = "Failed to connect to %s" % match_id
|
||||||
@@ -425,6 +434,8 @@ func _on_join_pressed() -> void:
|
|||||||
connection_status.text = "No room selected"
|
connection_status.text = "No room selected"
|
||||||
return
|
return
|
||||||
connection_status.text = "Joining Nakama room..."
|
connection_status.text = "Joining Nakama room..."
|
||||||
|
# Apply loadout character before joining
|
||||||
|
_apply_loadout_character()
|
||||||
LobbyManager.join_room(match_id)
|
LobbyManager.join_room(match_id)
|
||||||
|
|
||||||
func _on_back_pressed() -> void:
|
func _on_back_pressed() -> void:
|
||||||
@@ -529,6 +540,10 @@ func _on_leave_pressed() -> void:
|
|||||||
_show_panel("main_menu")
|
_show_panel("main_menu")
|
||||||
ready_btn.button_pressed = false
|
ready_btn.button_pressed = false
|
||||||
ready_btn.text = "READY"
|
ready_btn.text = "READY"
|
||||||
|
# Release bot names so they can be reused in the next session
|
||||||
|
for key in _bot_names.keys():
|
||||||
|
NameGenerator.release_bot_name(_bot_names[key])
|
||||||
|
_bot_names.clear()
|
||||||
|
|
||||||
func _on_copy_id_pressed() -> void:
|
func _on_copy_id_pressed() -> void:
|
||||||
DisplayServer.clipboard_set(current_match_id)
|
DisplayServer.clipboard_set(current_match_id)
|
||||||
@@ -611,10 +626,11 @@ func _on_profile_btn_pressed() -> void:
|
|||||||
var profile_panel_scene := load("res://scenes/ui/profile_panel.tscn")
|
var profile_panel_scene := load("res://scenes/ui/profile_panel.tscn")
|
||||||
profile_panel_instance = profile_panel_scene.instantiate()
|
profile_panel_instance = profile_panel_scene.instantiate()
|
||||||
profile_panel_instance.closed.connect(func(): profile_panel_instance.hide())
|
profile_panel_instance.closed.connect(func(): profile_panel_instance.hide())
|
||||||
|
# Full-screen overlay — fill the entire lobby viewport
|
||||||
|
profile_panel_instance.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||||
add_child(profile_panel_instance)
|
add_child(profile_panel_instance)
|
||||||
|
|
||||||
profile_panel_instance.show_panel()
|
profile_panel_instance.show_panel()
|
||||||
profile_panel_instance.position = (get_viewport_rect().size - profile_panel_instance.size) / 2
|
|
||||||
|
|
||||||
func _on_logout_pressed() -> void:
|
func _on_logout_pressed() -> void:
|
||||||
AuthManager.logout()
|
AuthManager.logout()
|
||||||
@@ -648,11 +664,12 @@ func _on_leaderboard_pressed() -> void:
|
|||||||
if leaderboard_panel_scene:
|
if leaderboard_panel_scene:
|
||||||
leaderboard_panel_instance = leaderboard_panel_scene.instantiate()
|
leaderboard_panel_instance = leaderboard_panel_scene.instantiate()
|
||||||
leaderboard_panel_instance.closed.connect(func(): leaderboard_panel_instance.hide())
|
leaderboard_panel_instance.closed.connect(func(): leaderboard_panel_instance.hide())
|
||||||
|
# Full-screen overlay
|
||||||
|
leaderboard_panel_instance.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||||
add_child(leaderboard_panel_instance)
|
add_child(leaderboard_panel_instance)
|
||||||
|
|
||||||
if leaderboard_panel_instance:
|
if leaderboard_panel_instance:
|
||||||
leaderboard_panel_instance.show_panel()
|
leaderboard_panel_instance.show_panel()
|
||||||
# Center it and apply some offset if needed
|
|
||||||
|
|
||||||
func _go_to_login() -> void:
|
func _go_to_login() -> void:
|
||||||
if get_tree():
|
if get_tree():
|
||||||
@@ -716,6 +733,10 @@ func _on_room_joined(room_data: Dictionary) -> void:
|
|||||||
func _on_room_left() -> void:
|
func _on_room_left() -> void:
|
||||||
_show_panel("main_menu")
|
_show_panel("main_menu")
|
||||||
connection_status.text = "Left room"
|
connection_status.text = "Left room"
|
||||||
|
# Release bot names for reuse
|
||||||
|
for key in _bot_names.keys():
|
||||||
|
NameGenerator.release_bot_name(_bot_names[key])
|
||||||
|
_bot_names.clear()
|
||||||
|
|
||||||
func _on_host_disconnected() -> void:
|
func _on_host_disconnected() -> void:
|
||||||
# Keep the connection status updated in the UI
|
# Keep the connection status updated in the UI
|
||||||
@@ -854,10 +875,15 @@ func _update_player_slots() -> void:
|
|||||||
# Empty slot - show as bot placeholder
|
# Empty slot - show as bot placeholder
|
||||||
slot.visible = true
|
slot.visible = true
|
||||||
|
|
||||||
# Update name to show as bot
|
# Assign stable bot name for this slot (generate once, reuse)
|
||||||
|
if not _bot_names.has(i):
|
||||||
|
_bot_names[i] = NameGenerator.generate_bot_name()
|
||||||
|
var bot_display_name: String = _bot_names[i]
|
||||||
|
|
||||||
|
# Update name to show bot with an icon prefix
|
||||||
var name_label = slot.get_node_or_null("PlayerName%d" % slot_num)
|
var name_label = slot.get_node_or_null("PlayerName%d" % slot_num)
|
||||||
if name_label:
|
if name_label:
|
||||||
name_label.text = "🤖 Bot %d" % slot_num
|
name_label.text = "🤖 " + bot_display_name
|
||||||
|
|
||||||
# Use a character for bot preview
|
# Use a character for bot preview
|
||||||
var char_preview = slot.get_node_or_null("CharacterPreview%d" % slot_num)
|
var char_preview = slot.get_node_or_null("CharacterPreview%d" % slot_num)
|
||||||
@@ -916,3 +942,13 @@ func _truncate_id(id: String) -> String:
|
|||||||
if id.length() > 16:
|
if id.length() > 16:
|
||||||
return id.substr(0, 8) + "..." + id.substr(-4)
|
return id.substr(0, 8) + "..." + id.substr(-4)
|
||||||
return id
|
return id
|
||||||
|
|
||||||
|
func _apply_loadout_character() -> void:
|
||||||
|
"""Apply the player's saved loadout default character to LobbyManager before entering a room."""
|
||||||
|
var saved_char: String = UserProfileManager.profile.get("loadout_character", "")
|
||||||
|
if saved_char.is_empty():
|
||||||
|
return
|
||||||
|
var idx := LobbyManager.available_characters.find(saved_char)
|
||||||
|
if idx != -1:
|
||||||
|
LobbyManager.local_character_index = idx
|
||||||
|
print("[Lobby] Loadout character applied: ", saved_char)
|
||||||
|
|||||||
@@ -2,83 +2,202 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://d1e2f3g4h5i6j" path="res://scripts/ui/leaderboard_panel.gd" id="1"]
|
[ext_resource type="Script" uid="uid://d1e2f3g4h5i6j" path="res://scripts/ui/leaderboard_panel.gd" id="1"]
|
||||||
[ext_resource type="Theme" uid="uid://da337sh5qxi0s" path="res://assets/themes/ui_theme.tres" id="2"]
|
[ext_resource type="Theme" uid="uid://da337sh5qxi0s" path="res://assets/themes/ui_theme.tres" id="2"]
|
||||||
|
[ext_resource type="FontFile" uid="uid://xnjx058n4tsw" path="res://assets/fonts/Nougat-ExtraBlack.ttf" id="3_font"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://1vk0mjnwkngi" path="res://assets/characters/Masbro.glb" id="4_masbro"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://d4cul3w3wem5w" path="res://assets/characters/Gatot.glb" id="4_gatot"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bmln7v6v5kvxg" path="res://assets/characters/Oldpop.glb" id="4_oldpop"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ejeamn0pyey4" path="res://assets/characters/Bob.glb" id="4_bob"]
|
||||||
|
[ext_resource type="AnimationLibrary" uid="uid://c3pyopnwibckj" path="res://assets/characters/animations/animation-pack.res" id="5_animlib"]
|
||||||
|
|
||||||
[node name="LeaderboardPanel" type="PanelContainer"]
|
[sub_resource type="Environment" id="Environment_lb"]
|
||||||
custom_minimum_size = Vector2(500, 400)
|
background_mode = 1
|
||||||
anchors_preset = 8
|
background_color = Color(0.06, 0.07, 0.10, 1)
|
||||||
anchor_left = 0.5
|
ambient_light_source = 2
|
||||||
anchor_top = 0.5
|
ambient_light_color = Color(0.5, 0.55, 0.75, 1)
|
||||||
anchor_right = 0.5
|
ambient_light_energy = 0.7
|
||||||
anchor_bottom = 0.5
|
|
||||||
offset_left = -250.0
|
[node name="LeaderboardPanel" type="Control"]
|
||||||
offset_top = -200.0
|
layout_mode = 3
|
||||||
offset_right = 250.0
|
anchors_preset = 15
|
||||||
offset_bottom = 200.0
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme = ExtResource("2")
|
theme = ExtResource("2")
|
||||||
script = ExtResource("1")
|
script = ExtResource("1")
|
||||||
|
|
||||||
[node name="VBox" type="VBoxContainer" parent="."]
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(0.05, 0.06, 0.09, 0.97)
|
||||||
|
|
||||||
|
[node name="MainLayout" type="HBoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme_override_constants/separation = 0
|
||||||
|
|
||||||
|
[node name="LeftPanel" type="PanelContainer" parent="MainLayout"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_stretch_ratio = 1.0
|
||||||
|
custom_minimum_size = Vector2(500, 0)
|
||||||
|
|
||||||
|
[node name="LeftVBox" type="VBoxContainer" parent="MainLayout/LeftPanel"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_constants/separation = 12
|
theme_override_constants/separation = 12
|
||||||
|
|
||||||
[node name="Header" type="HBoxContainer" parent="VBox"]
|
[node name="Header" type="HBoxContainer" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="Title" type="Label" parent="VBox/Header"]
|
[node name="BackBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/Header"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(44, 44)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_fonts/font = ExtResource("3_font")
|
||||||
|
text = "← BACK"
|
||||||
|
|
||||||
|
[node name="Title" type="Label" parent="MainLayout/LeftPanel/LeftVBox/Header"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
theme_override_colors/font_color = Color(0.647, 0.996, 0.224, 1)
|
theme_override_colors/font_color = Color(0.647, 0.996, 0.224, 1)
|
||||||
theme_override_font_sizes/font_size = 24
|
theme_override_fonts/font = ExtResource("3_font")
|
||||||
|
theme_override_font_sizes/font_size = 26
|
||||||
text = "LEADERBOARD"
|
text = "LEADERBOARD"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="CloseBtn" type="Button" parent="VBox/Header"]
|
[node name="SortTabs" type="HBoxContainer" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
unique_name_in_owner = true
|
|
||||||
custom_minimum_size = Vector2(32, 32)
|
|
||||||
layout_mode = 2
|
|
||||||
text = "X"
|
|
||||||
|
|
||||||
[node name="SortTabs" type="HBoxContainer" parent="VBox"]
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_constants/separation = 8
|
theme_override_constants/separation = 8
|
||||||
alignment = 1
|
alignment = 1
|
||||||
|
|
||||||
[node name="SortScoreBtn" type="Button" parent="VBox/SortTabs"]
|
[node name="SortScoreBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/SortTabs"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(120, 36)
|
custom_minimum_size = Vector2(120, 36)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
theme_override_fonts/font = ExtResource("3_font")
|
||||||
text = "High Score"
|
text = "High Score"
|
||||||
|
|
||||||
[node name="SortWinRateBtn" type="Button" parent="VBox/SortTabs"]
|
[node name="SortWinRateBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/SortTabs"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(120, 36)
|
custom_minimum_size = Vector2(120, 36)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
theme_override_fonts/font = ExtResource("3_font")
|
||||||
text = "Win Rate"
|
text = "Win Rate"
|
||||||
|
|
||||||
[node name="SortGamesBtn" type="Button" parent="VBox/SortTabs"]
|
[node name="SortGamesBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/SortTabs"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(120, 36)
|
custom_minimum_size = Vector2(120, 36)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
theme_override_fonts/font = ExtResource("3_font")
|
||||||
text = "Games Played"
|
text = "Games Played"
|
||||||
|
|
||||||
[node name="HSeparator" type="HSeparator" parent="VBox"]
|
[node name="HSeparator" type="HSeparator" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBox"]
|
[node name="ScrollContainer" type="ScrollContainer" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="LeaderboardList" type="VBoxContainer" parent="VBox/ScrollContainer"]
|
[node name="LeaderboardList" type="VBoxContainer" parent="MainLayout/LeftPanel/LeftVBox/ScrollContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
theme_override_constants/separation = 8
|
theme_override_constants/separation = 8
|
||||||
|
|
||||||
[node name="StatusLabel" type="Label" parent="VBox"]
|
[node name="StatusLabel" type="Label" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_colors/font_color = Color(0.69, 0.529, 0.357, 1)
|
theme_override_colors/font_color = Color(0.69, 0.529, 0.357, 1)
|
||||||
|
theme_override_fonts/font = ExtResource("3_font")
|
||||||
text = "Loading data..."
|
text = "Loading data..."
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="RightPanel" type="SubViewportContainer" parent="MainLayout"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_stretch_ratio = 0.8
|
||||||
|
custom_minimum_size = Vector2(340, 0)
|
||||||
|
stretch = true
|
||||||
|
|
||||||
|
[node name="PreviewViewport" type="SubViewport" parent="MainLayout/RightPanel"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
transparent_bg = true
|
||||||
|
size = Vector2i(500, 720)
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="MainLayout/RightPanel/PreviewViewport"]
|
||||||
|
environment = SubResource("Environment_lb")
|
||||||
|
|
||||||
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="MainLayout/RightPanel/PreviewViewport"]
|
||||||
|
transform = Transform3D(0.866025, -0.25, 0.433013, 0, 0.866025, 0.5, -0.5, -0.433013, 0.75, 0, 4, 0)
|
||||||
|
light_energy = 1.4
|
||||||
|
|
||||||
|
[node name="FillLight" type="OmniLight3D" parent="MainLayout/RightPanel/PreviewViewport"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 2, 2)
|
||||||
|
light_color = Color(0.4, 0.5, 1.0, 1)
|
||||||
|
light_energy = 0.5
|
||||||
|
omni_range = 8.0
|
||||||
|
|
||||||
|
[node name="Camera3D" type="Camera3D" parent="MainLayout/RightPanel/PreviewViewport"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 0.965926, 0.258819, 0, -0.258819, 0.965926, 0, 1.6, 3.2)
|
||||||
|
current = true
|
||||||
|
fov = 40.0
|
||||||
|
|
||||||
|
[node name="CharacterRoot" type="Node3D" parent="MainLayout/RightPanel/PreviewViewport"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
|
||||||
|
[node name="Masbro" parent="MainLayout/RightPanel/PreviewViewport/CharacterRoot" instance=ExtResource("4_masbro")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.485, 0)
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Bob" parent="MainLayout/RightPanel/PreviewViewport/CharacterRoot" instance=ExtResource("4_bob")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.484627, 0)
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Gatot" parent="MainLayout/RightPanel/PreviewViewport/CharacterRoot" instance=ExtResource("4_gatot")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.485, 0)
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Oldpop" parent="MainLayout/RightPanel/PreviewViewport/CharacterRoot" instance=ExtResource("4_oldpop")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.485, 0)
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="MainLayout/RightPanel/PreviewViewport/CharacterRoot"]
|
||||||
|
root_node = NodePath("../Oldpop")
|
||||||
|
libraries/animation-pack = ExtResource("5_animlib")
|
||||||
|
current_animation = "animation-pack/idle"
|
||||||
|
autoplay = "animation-pack/idle"
|
||||||
|
|
||||||
|
[node name="SelectedPlayerInfo" type="VBoxContainer" parent="MainLayout/RightPanel"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 2
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_top = -120.0
|
||||||
|
offset_right = 340.0
|
||||||
|
grow_vertical = 0
|
||||||
|
theme_override_constants/separation = 4
|
||||||
|
|
||||||
|
[node name="SelectedNameLabel" type="Label" parent="MainLayout/RightPanel/SelectedPlayerInfo"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||||
|
theme_override_fonts/font = ExtResource("3_font")
|
||||||
|
theme_override_font_sizes/font_size = 20
|
||||||
|
text = ""
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="SelectedRankLabel" type="Label" parent="MainLayout/RightPanel/SelectedPlayerInfo"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0.647, 0.996, 0.224, 1)
|
||||||
|
theme_override_fonts/font = ExtResource("3_font")
|
||||||
|
theme_override_font_sizes/font_size = 14
|
||||||
|
text = ""
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|||||||
+204
-49
@@ -3,72 +3,124 @@
|
|||||||
[ext_resource type="Script" uid="uid://y6wswtalyiho" path="res://scripts/ui/profile_panel.gd" id="1"]
|
[ext_resource type="Script" uid="uid://y6wswtalyiho" path="res://scripts/ui/profile_panel.gd" id="1"]
|
||||||
[ext_resource type="Theme" uid="uid://da337sh5qxi0s" path="res://assets/themes/ui_theme.tres" id="2"]
|
[ext_resource type="Theme" uid="uid://da337sh5qxi0s" path="res://assets/themes/ui_theme.tres" id="2"]
|
||||||
[ext_resource type="FontFile" uid="uid://xnjx058n4tsw" path="res://assets/fonts/Nougat-ExtraBlack.ttf" id="3_e13i6"]
|
[ext_resource type="FontFile" uid="uid://xnjx058n4tsw" path="res://assets/fonts/Nougat-ExtraBlack.ttf" id="3_e13i6"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://1vk0mjnwkngi" path="res://assets/characters/Masbro.glb" id="4_masbro"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://d4cul3w3wem5w" path="res://assets/characters/Gatot.glb" id="4_gatot"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bmln7v6v5kvxg" path="res://assets/characters/Oldpop.glb" id="4_oldpop"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ejeamn0pyey4" path="res://assets/characters/Bob.glb" id="4_bob"]
|
||||||
|
[ext_resource type="AnimationLibrary" uid="uid://c3pyopnwibckj" path="res://assets/characters/animations/animation-pack.res" id="5_animlib"]
|
||||||
|
|
||||||
[node name="ProfilePanel" type="PanelContainer" unique_id=229091481]
|
[sub_resource type="Environment" id="Environment_preview"]
|
||||||
offset_right = 380.0
|
background_mode = 1
|
||||||
offset_bottom = 480.0
|
background_color = Color(0.08, 0.09, 0.12, 1)
|
||||||
|
ambient_light_source = 2
|
||||||
|
ambient_light_color = Color(0.6, 0.65, 0.8, 1)
|
||||||
|
ambient_light_energy = 0.6
|
||||||
|
|
||||||
|
[node name="ProfilePanel" type="Control" unique_id=229091481]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
theme = ExtResource("2")
|
theme = ExtResource("2")
|
||||||
script = ExtResource("1")
|
script = ExtResource("1")
|
||||||
|
|
||||||
[node name="VBox" type="VBoxContainer" parent="." unique_id=953819957]
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 1
|
||||||
theme_override_constants/separation = 14
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(0.05, 0.06, 0.09, 0.97)
|
||||||
|
|
||||||
[node name="Header" type="HBoxContainer" parent="VBox" unique_id=485959454]
|
[node name="MainLayout" type="HBoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme_override_constants/separation = 0
|
||||||
|
|
||||||
|
[node name="LeftPanel" type="PanelContainer" parent="MainLayout"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_stretch_ratio = 1.0
|
||||||
|
custom_minimum_size = Vector2(420, 0)
|
||||||
|
|
||||||
|
[node name="LeftVBox" type="VBoxContainer" parent="MainLayout/LeftPanel"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 16
|
||||||
|
|
||||||
|
[node name="Header" type="HBoxContainer" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="Title" type="Label" parent="VBox/Header" unique_id=19242315]
|
[node name="BackBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/Header"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(44, 44)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
|
text = "← BACK"
|
||||||
|
|
||||||
|
[node name="Title" type="Label" parent="MainLayout/LeftPanel/LeftVBox/Header"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
theme_override_colors/font_color = Color(0.41568628, 0.6392157, 0.14117648, 1)
|
theme_override_colors/font_color = Color(0.41568628, 0.6392157, 0.14117648, 1)
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
theme_override_font_sizes/font_size = 22
|
theme_override_font_sizes/font_size = 26
|
||||||
text = "Profile"
|
text = "PROFILE & LOADOUT"
|
||||||
|
|
||||||
[node name="CloseButton" type="Button" parent="VBox/Header" unique_id=448699205]
|
[node name="Separator0" type="HSeparator" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
unique_name_in_owner = true
|
|
||||||
custom_minimum_size = Vector2(36, 36)
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "✕"
|
|
||||||
|
|
||||||
[node name="AvatarSection" type="HBoxContainer" parent="VBox" unique_id=501593330]
|
[node name="AvatarSection" type="HBoxContainer" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_constants/separation = 16
|
theme_override_constants/separation = 16
|
||||||
alignment = 1
|
alignment = 0
|
||||||
|
|
||||||
[node name="AvatarDisplay" type="TextureRect" parent="VBox/AvatarSection" unique_id=173716070]
|
[node name="AvatarDisplay" type="TextureRect" parent="MainLayout/LeftPanel/LeftVBox/AvatarSection"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(88, 88)
|
custom_minimum_size = Vector2(80, 80)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
expand_mode = 1
|
expand_mode = 1
|
||||||
stretch_mode = 5
|
stretch_mode = 5
|
||||||
|
|
||||||
[node name="AvatarButtons" type="VBoxContainer" parent="VBox/AvatarSection" unique_id=1408685281]
|
[node name="AvatarButtons" type="VBoxContainer" parent="MainLayout/LeftPanel/LeftVBox/AvatarSection"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
theme_override_constants/separation = 8
|
theme_override_constants/separation = 8
|
||||||
|
|
||||||
[node name="ChangeAvatarBtn" type="Button" parent="VBox/AvatarSection/AvatarButtons" unique_id=1502182238]
|
[node name="AccountType" type="Label" parent="MainLayout/LeftPanel/LeftVBox/AvatarSection/AvatarButtons"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(0, 44)
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0.69, 0.529, 0.357, 1)
|
||||||
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
|
text = "Account: Guest"
|
||||||
|
|
||||||
|
[node name="ChangeAvatarBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/AvatarSection/AvatarButtons"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(0, 40)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
text = "Change Avatar"
|
text = "Change Avatar"
|
||||||
|
|
||||||
[node name="DisplayNameSection" type="VBoxContainer" parent="VBox" unique_id=545753874]
|
[node name="DisplayNameSection" type="VBoxContainer" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_constants/separation = 8
|
theme_override_constants/separation = 8
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="VBox/DisplayNameSection" unique_id=1868331382]
|
[node name="Label" type="Label" parent="MainLayout/LeftPanel/LeftVBox/DisplayNameSection"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_colors/font_color = Color(0.69, 0.529, 0.357, 1)
|
theme_override_colors/font_color = Color(0.69, 0.529, 0.357, 1)
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
text = "Display Name"
|
text = "Display Name"
|
||||||
|
|
||||||
[node name="HBox" type="HBoxContainer" parent="VBox/DisplayNameSection" unique_id=1124739186]
|
[node name="HBox" type="HBoxContainer" parent="MainLayout/LeftPanel/LeftVBox/DisplayNameSection"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_constants/separation = 8
|
theme_override_constants/separation = 8
|
||||||
|
|
||||||
[node name="DisplayNameInput" type="LineEdit" parent="VBox/DisplayNameSection/HBox" unique_id=527983746]
|
[node name="DisplayNameInput" type="LineEdit" parent="MainLayout/LeftPanel/LeftVBox/DisplayNameSection/HBox"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(0, 44)
|
custom_minimum_size = Vector2(0, 44)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
@@ -76,88 +128,191 @@ size_flags_horizontal = 3
|
|||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
max_length = 50
|
max_length = 50
|
||||||
|
|
||||||
[node name="SaveNameBtn" type="Button" parent="VBox/DisplayNameSection/HBox" unique_id=843919725]
|
[node name="SaveNameBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/DisplayNameSection/HBox"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(80, 44)
|
custom_minimum_size = Vector2(80, 44)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
text = "Save"
|
text = "Save"
|
||||||
|
|
||||||
[node name="Separator1" type="HSeparator" parent="VBox" unique_id=1702408710]
|
[node name="Separator1" type="HSeparator" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="StatsSection" type="VBoxContainer" parent="VBox" unique_id=1972383442]
|
[node name="LoadoutSection" type="VBoxContainer" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 10
|
||||||
|
|
||||||
|
[node name="LoadoutTitle" type="Label" parent="MainLayout/LeftPanel/LeftVBox/LoadoutSection"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0.41568628, 0.6392157, 0.14117648, 1)
|
||||||
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
|
theme_override_font_sizes/font_size = 18
|
||||||
|
text = "DEFAULT CHARACTER (LOADOUT)"
|
||||||
|
|
||||||
|
[node name="LoadoutHint" type="Label" parent="MainLayout/LeftPanel/LeftVBox/LoadoutSection"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0.6, 0.6, 0.6, 1)
|
||||||
|
theme_override_font_sizes/font_size = 11
|
||||||
|
text = "This character will be auto-selected when you join or create a room."
|
||||||
|
autowrap_mode = 2
|
||||||
|
|
||||||
|
[node name="CharacterSelector" type="HBoxContainer" parent="MainLayout/LeftPanel/LeftVBox/LoadoutSection"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 8
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="CharLeftBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/LoadoutSection/CharacterSelector"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(44, 44)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
|
text = "◀"
|
||||||
|
|
||||||
|
[node name="LoadoutCharName" type="Label" parent="MainLayout/LeftPanel/LeftVBox/LoadoutSection/CharacterSelector"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(120, 44)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||||
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
|
theme_override_font_sizes/font_size = 18
|
||||||
|
text = "Copper"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="CharRightBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/LoadoutSection/CharacterSelector"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(44, 44)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
|
text = "▶"
|
||||||
|
|
||||||
|
[node name="SetDefaultBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/LoadoutSection"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(0, 44)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
|
text = "✓ SET AS DEFAULT"
|
||||||
|
|
||||||
|
[node name="Separator2" type="HSeparator" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="StatsSection" type="VBoxContainer" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_constants/separation = 6
|
theme_override_constants/separation = 6
|
||||||
|
|
||||||
[node name="StatsTitle" type="Label" parent="VBox/StatsSection" unique_id=1851168520]
|
[node name="StatsTitle" type="Label" parent="MainLayout/LeftPanel/LeftVBox/StatsSection"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_colors/font_color = Color(0.41536003, 0.64, 0.14080001, 1)
|
theme_override_colors/font_color = Color(0.41568628, 0.6392157, 0.14117648, 1)
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
theme_override_font_sizes/font_size = 16
|
theme_override_font_sizes/font_size = 16
|
||||||
text = "Statistics"
|
text = "Statistics"
|
||||||
|
|
||||||
[node name="GamesPlayed" type="Label" parent="VBox/StatsSection" unique_id=1727349753]
|
[node name="GamesPlayed" type="Label" parent="MainLayout/LeftPanel/LeftVBox/StatsSection"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_colors/font_color = Color(0.57, 0.32090998, 0.1767, 1)
|
theme_override_colors/font_color = Color(0.57, 0.32090998, 0.1767, 1)
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
text = "Games Played: 0"
|
text = "Games Played: 0"
|
||||||
|
|
||||||
[node name="WinRate" type="Label" parent="VBox/StatsSection" unique_id=1229711691]
|
[node name="WinRate" type="Label" parent="MainLayout/LeftPanel/LeftVBox/StatsSection"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_colors/font_color = Color(0.57, 0.32090998, 0.1767, 1)
|
theme_override_colors/font_color = Color(0.57, 0.32090998, 0.1767, 1)
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
text = "Win Rate: 0%"
|
text = "Win Rate: 0%"
|
||||||
|
|
||||||
[node name="HighScore" type="Label" parent="VBox/StatsSection" unique_id=443769119]
|
[node name="HighScore" type="Label" parent="MainLayout/LeftPanel/LeftVBox/StatsSection"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_colors/font_color = Color(0.57, 0.32090998, 0.1767, 1)
|
theme_override_colors/font_color = Color(0.57, 0.32090998, 0.1767, 1)
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
text = "High Score: 0"
|
text = "High Score: 0"
|
||||||
|
|
||||||
[node name="Separator2" type="HSeparator" parent="VBox" unique_id=307036203]
|
[node name="AccountSection" type="VBoxContainer" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
layout_mode = 2
|
|
||||||
|
|
||||||
[node name="AccountSection" type="VBoxContainer" parent="VBox" unique_id=1297099357]
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_constants/separation = 8
|
theme_override_constants/separation = 8
|
||||||
|
|
||||||
[node name="AccountType" type="Label" parent="VBox/AccountSection" unique_id=332392487]
|
[node name="LinkAccountBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/AccountSection"]
|
||||||
unique_name_in_owner = true
|
|
||||||
layout_mode = 2
|
|
||||||
theme_override_colors/font_color = Color(0.69, 0.529, 0.357, 1)
|
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
|
||||||
text = "Account: Guest"
|
|
||||||
|
|
||||||
[node name="LinkAccountBtn" type="Button" parent="VBox/AccountSection" unique_id=1719857784]
|
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(0, 44)
|
custom_minimum_size = Vector2(0, 44)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
text = "Link Email (Keep Progress)"
|
text = "Link Email (Keep Progress)"
|
||||||
|
|
||||||
[node name="LogoutBtn" type="Button" parent="VBox/AccountSection" unique_id=1335420017]
|
[node name="LogoutBtn" type="Button" parent="MainLayout/LeftPanel/LeftVBox/AccountSection"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(0, 44)
|
custom_minimum_size = Vector2(0, 44)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_fonts/font = ExtResource("3_e13i6")
|
theme_override_fonts/font = ExtResource("3_e13i6")
|
||||||
text = "Logout"
|
text = "Logout"
|
||||||
|
|
||||||
[node name="StatusLabel" type="Label" parent="VBox" unique_id=2080837765]
|
[node name="StatusLabel" type="Label" parent="MainLayout/LeftPanel/LeftVBox"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_font_sizes/font_size = 12
|
theme_override_font_sizes/font_size = 12
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="AvatarSelectionPopup" type="PopupPanel" parent="." unique_id=14363298]
|
[node name="RightPanel" type="SubViewportContainer" parent="MainLayout"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_stretch_ratio = 1.2
|
||||||
|
custom_minimum_size = Vector2(400, 0)
|
||||||
|
stretch = true
|
||||||
|
|
||||||
|
[node name="PreviewViewport" type="SubViewport" parent="MainLayout/RightPanel"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
transparent_bg = true
|
||||||
|
size = Vector2i(600, 720)
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="MainLayout/RightPanel/PreviewViewport"]
|
||||||
|
environment = SubResource("Environment_preview")
|
||||||
|
|
||||||
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="MainLayout/RightPanel/PreviewViewport"]
|
||||||
|
transform = Transform3D(0.866025, -0.25, 0.433013, 0, 0.866025, 0.5, -0.5, -0.433013, 0.75, 0, 4, 0)
|
||||||
|
light_energy = 1.4
|
||||||
|
|
||||||
|
[node name="FillLight" type="OmniLight3D" parent="MainLayout/RightPanel/PreviewViewport"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 2, 2)
|
||||||
|
light_color = Color(0.5, 0.6, 1.0, 1)
|
||||||
|
light_energy = 0.5
|
||||||
|
omni_range = 8.0
|
||||||
|
|
||||||
|
[node name="Camera3D" type="Camera3D" parent="MainLayout/RightPanel/PreviewViewport"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 0.965926, 0.258819, 0, -0.258819, 0.965926, 0, 1.6, 3.2)
|
||||||
|
current = true
|
||||||
|
fov = 40.0
|
||||||
|
|
||||||
|
[node name="CharacterRoot" type="Node3D" parent="MainLayout/RightPanel/PreviewViewport"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
|
||||||
|
[node name="Masbro" parent="MainLayout/RightPanel/PreviewViewport/CharacterRoot" instance=ExtResource("4_masbro")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.485, 0)
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Bob" parent="MainLayout/RightPanel/PreviewViewport/CharacterRoot" instance=ExtResource("4_bob")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.484627, 0)
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Gatot" parent="MainLayout/RightPanel/PreviewViewport/CharacterRoot" instance=ExtResource("4_gatot")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.485, 0)
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Oldpop" parent="MainLayout/RightPanel/PreviewViewport/CharacterRoot" instance=ExtResource("4_oldpop")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.485, 0)
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="MainLayout/RightPanel/PreviewViewport/CharacterRoot"]
|
||||||
|
root_node = NodePath("../Oldpop")
|
||||||
|
libraries/animation-pack = ExtResource("5_animlib")
|
||||||
|
current_animation = "animation-pack/idle"
|
||||||
|
autoplay = "animation-pack/idle"
|
||||||
|
|
||||||
|
[node name="AvatarSelectionPopup" type="PopupPanel" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
title = "Select Avatar"
|
title = "Select Avatar"
|
||||||
size = Vector2i(320, 220)
|
size = Vector2i(320, 220)
|
||||||
|
|
||||||
[node name="GridContainer" type="GridContainer" parent="AvatarSelectionPopup" unique_id=183560389]
|
[node name="GridContainer" type="GridContainer" parent="AvatarSelectionPopup"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
offset_left = 4.0
|
offset_left = 4.0
|
||||||
offset_top = 4.0
|
offset_top = 4.0
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
extends Node
|
||||||
|
## NameGenerator - Generates unique names for guest players and bots.
|
||||||
|
## Guest names: Capitalized adjective+noun combos (e.g. "SwiftFox")
|
||||||
|
## Bot names: Simple first names only, no numbers (e.g. "Jack")
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# Guest name pools — adjective + noun combos
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
const ADJECTIVES: Array[String] = [
|
||||||
|
"Swift", "Silent", "Bold", "Iron", "Dark", "Wild", "Frost", "Storm",
|
||||||
|
"Keen", "Jade", "Blaze", "Rift", "Neon", "Onyx", "Azure", "Grim",
|
||||||
|
"Sage", "Nova", "Apex", "Luna", "Solar", "Lunar", "Tech", "Vero",
|
||||||
|
"Echo", "Zeal", "Volt", "Brisk", "Dusk", "Dawn", "Sable", "Civic",
|
||||||
|
"Pixel", "Brave", "Sharp", "Amber", "Vivid", "Rapid", "Sleek", "Null",
|
||||||
|
"Prime", "Zero", "Hyper", "Turbo", "Sigma", "Omega", "Alpha", "Delta",
|
||||||
|
"Hex", "Red", "Blue", "Gold", "Aqua", "Teal", "Lime", "Ruby"
|
||||||
|
]
|
||||||
|
|
||||||
|
const NOUNS: Array[String] = [
|
||||||
|
"Fox", "Wolf", "Hawk", "Bear", "Lynx", "Crow", "Dirk", "Rook",
|
||||||
|
"Fang", "Bolt", "Node", "Byte", "Flux", "Spark", "Drift", "Tide",
|
||||||
|
"Claw", "Wing", "Shade", "Arrow", "Spike", "Globe", "Beam", "Core",
|
||||||
|
"Path", "Edge", "Root", "Link", "Code", "Beam", "Grid", "Chip",
|
||||||
|
"Dust", "Blade", "Stone", "Coin", "Rock", "Peak", "Wick", "Ray",
|
||||||
|
"Kite", "Mist", "Gale", "Reef", "Veil", "Gate", "Ash", "Dune"
|
||||||
|
]
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# Bot name pools — simple first names, lowercase-first style (Title Case)
|
||||||
|
# No numbers. These are distinct from guest names.
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
const BOT_NAMES: Array[String] = [
|
||||||
|
"Jack", "Max", "Sam", "Alex", "Leo", "Mia", "Zoe", "Kai",
|
||||||
|
"Ray", "Jay", "Kim", "Rex", "Ace", "Finn", "Ada", "Eli",
|
||||||
|
"Nia", "Ben", "Tao", "Vex", "Rue", "Dax", "Ora", "Pip",
|
||||||
|
"Cal", "Bex", "Jax", "Ren", "Ash", "Sky", "Nova", "Cruz",
|
||||||
|
"Remi", "Theo", "Cora", "Axel", "Nora", "Ivan", "Luna", "Dani",
|
||||||
|
"Luca", "Roxy", "Seth", "Tara", "Kale", "Vera", "Omar", "Jade"
|
||||||
|
]
|
||||||
|
|
||||||
|
# Track in-use names to prevent duplicates per session
|
||||||
|
var _used_guest_names: Array[String] = []
|
||||||
|
var _used_bot_names: Array[String] = []
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
randomize()
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# Guest name generation
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
func generate_guest_name() -> String:
|
||||||
|
"""Generate a unique guest name like 'SwiftFox'. Falls back if pool exhausted."""
|
||||||
|
var attempts := 0
|
||||||
|
var max_attempts := 100
|
||||||
|
|
||||||
|
while attempts < max_attempts:
|
||||||
|
var adj := ADJECTIVES[randi() % ADJECTIVES.size()]
|
||||||
|
var noun := NOUNS[randi() % NOUNS.size()]
|
||||||
|
var name_candidate := adj + noun
|
||||||
|
|
||||||
|
if name_candidate not in _used_guest_names:
|
||||||
|
_used_guest_names.append(name_candidate)
|
||||||
|
return name_candidate
|
||||||
|
attempts += 1
|
||||||
|
|
||||||
|
# Fallback: numbered guest if pool exhausted
|
||||||
|
var fallback := "Guest%d" % (_used_guest_names.size() + 1)
|
||||||
|
_used_guest_names.append(fallback)
|
||||||
|
return fallback
|
||||||
|
|
||||||
|
func release_guest_name(name: String) -> void:
|
||||||
|
"""Call when a guest disconnects to free up their name for reuse."""
|
||||||
|
_used_guest_names.erase(name)
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# Bot name generation
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
func generate_bot_name() -> String:
|
||||||
|
"""Generate a unique bot name like 'Jack'. Falls back with suffix if pool exhausted."""
|
||||||
|
# Build shuffled list of bot names not yet in use
|
||||||
|
var available: Array[String] = []
|
||||||
|
for n in BOT_NAMES:
|
||||||
|
if n not in _used_bot_names:
|
||||||
|
available.append(n)
|
||||||
|
|
||||||
|
if available.size() > 0:
|
||||||
|
available.shuffle()
|
||||||
|
var chosen := available[0]
|
||||||
|
_used_bot_names.append(chosen)
|
||||||
|
return chosen
|
||||||
|
|
||||||
|
# Pool exhausted — pick a random base name with a letter suffix
|
||||||
|
var base := BOT_NAMES[randi() % BOT_NAMES.size()]
|
||||||
|
var suffix_chars := "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
var candidate := base + suffix_chars[randi() % suffix_chars.length()]
|
||||||
|
_used_bot_names.append(candidate)
|
||||||
|
return candidate
|
||||||
|
|
||||||
|
func release_bot_name(name: String) -> void:
|
||||||
|
"""Call when a bot slot is removed to free up its name."""
|
||||||
|
_used_bot_names.erase(name)
|
||||||
|
|
||||||
|
func reset_all() -> void:
|
||||||
|
"""Reset both pools — useful on returning to main menu."""
|
||||||
|
_used_guest_names.clear()
|
||||||
|
_used_bot_names.clear()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://fni17a60y38p
|
||||||
+120
-51
@@ -1,25 +1,54 @@
|
|||||||
extends PanelContainer
|
extends Control
|
||||||
|
## Leaderboard panel — full-scene layout.
|
||||||
|
## Left: sortable leaderboard list.
|
||||||
|
## Right: 3D SubViewport character preview of the selected/top-ranked player.
|
||||||
|
|
||||||
signal closed
|
signal closed
|
||||||
|
|
||||||
@onready var close_btn := %CloseBtn as Button
|
# -------------------------------------------------------------------------
|
||||||
|
# UI References
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
@onready var back_btn := %BackBtn as Button
|
||||||
@onready var sort_score_btn := %SortScoreBtn as Button
|
@onready var sort_score_btn := %SortScoreBtn as Button
|
||||||
@onready var sort_win_rate_btn := %SortWinRateBtn as Button
|
@onready var sort_win_rate_btn := %SortWinRateBtn as Button
|
||||||
@onready var sort_games_btn := %SortGamesBtn as Button
|
@onready var sort_games_btn := %SortGamesBtn as Button
|
||||||
@onready var leaderboard_list := %LeaderboardList as VBoxContainer
|
@onready var leaderboard_list := %LeaderboardList as VBoxContainer
|
||||||
@onready var status_label := %StatusLabel as Label
|
@onready var status_label := %StatusLabel as Label
|
||||||
|
|
||||||
|
# 3D Preview
|
||||||
|
@onready var character_root := %CharacterRoot as Node3D
|
||||||
|
@onready var selected_name_label := %SelectedNameLabel as Label
|
||||||
|
@onready var selected_rank_label := %SelectedRankLabel as Label
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# State
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
var leaderboard_data: Array = []
|
var leaderboard_data: Array = []
|
||||||
var current_sort_key: String = "high_score"
|
var current_sort_key: String = "high_score"
|
||||||
|
var _anim_player: AnimationPlayer
|
||||||
|
|
||||||
|
# Maps game character name -> GLB node name in the SubViewport
|
||||||
|
# Must match the mapping in player.gd's set_character()
|
||||||
|
const CHAR_NODE_MAP: Dictionary = {
|
||||||
|
"Copper": "Oldpop",
|
||||||
|
"Dabro": "Masbro",
|
||||||
|
"Gatot": "Gatot",
|
||||||
|
"Pip": "Bob"
|
||||||
|
}
|
||||||
|
# Avatar index -> character name (same order as UserProfileManager.AVATARS)
|
||||||
|
const AVATAR_TO_CHAR: Array[String] = ["Pip", "Gatot", "Dabro", "Copper"]
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
close_btn.pressed.connect(_on_close_pressed)
|
back_btn.pressed.connect(_on_close_pressed)
|
||||||
sort_score_btn.pressed.connect(func(): _sort_by("high_score"))
|
sort_score_btn.pressed.connect(func(): _sort_by("high_score"))
|
||||||
sort_win_rate_btn.pressed.connect(func(): _sort_by("win_rate"))
|
sort_win_rate_btn.pressed.connect(func(): _sort_by("win_rate"))
|
||||||
sort_games_btn.pressed.connect(func(): _sort_by("games_played"))
|
sort_games_btn.pressed.connect(func(): _sort_by("games_played"))
|
||||||
|
|
||||||
_update_tab_visuals()
|
_update_tab_visuals()
|
||||||
|
_setup_3d_preview()
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Show / Close
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
func show_panel() -> void:
|
func show_panel() -> void:
|
||||||
show()
|
show()
|
||||||
_fetch_leaderboard_data()
|
_fetch_leaderboard_data()
|
||||||
@@ -28,29 +57,28 @@ func _on_close_pressed() -> void:
|
|||||||
hide()
|
hide()
|
||||||
emit_signal("closed")
|
emit_signal("closed")
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Data
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
func _fetch_leaderboard_data() -> void:
|
func _fetch_leaderboard_data() -> void:
|
||||||
if not NakamaManager.session:
|
if not NakamaManager.session:
|
||||||
status_label.text = "Not connected to Nakama"
|
status_label.text = "Not connected to Nakama"
|
||||||
return
|
return
|
||||||
|
|
||||||
status_label.text = "Loading data..."
|
status_label.text = "Loading data..."
|
||||||
|
|
||||||
# Clear existing items
|
|
||||||
for child in leaderboard_list.get_children():
|
for child in leaderboard_list.get_children():
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
|
|
||||||
var payload = JSON.stringify({})
|
var payload = JSON.stringify({})
|
||||||
var result = await NakamaManager.client.rpc_async(NakamaManager.session, "get_leaderboard_stats", payload)
|
var result = await NakamaManager.client.rpc_async(NakamaManager.session, "get_leaderboard_stats", payload)
|
||||||
|
|
||||||
if result.is_exception():
|
if result.is_exception():
|
||||||
status_label.text = "Failed to load leaderboard"
|
status_label.text = "Failed to load leaderboard"
|
||||||
push_error("[Leaderboard] RPC failed: ", result.get_exception().message)
|
push_error("[Leaderboard] RPC failed: ", result.get_exception().message)
|
||||||
return
|
return
|
||||||
|
|
||||||
var response_text = result.payload
|
|
||||||
var json = JSON.new()
|
var json = JSON.new()
|
||||||
var error = json.parse(response_text)
|
var error = json.parse(result.payload)
|
||||||
|
|
||||||
if error == OK:
|
if error == OK:
|
||||||
var data = json.get_data()
|
var data = json.get_data()
|
||||||
if data.has("leaderboard"):
|
if data.has("leaderboard"):
|
||||||
@@ -58,6 +86,9 @@ func _fetch_leaderboard_data() -> void:
|
|||||||
_calculate_win_rates()
|
_calculate_win_rates()
|
||||||
status_label.text = ""
|
status_label.text = ""
|
||||||
_sort_by(current_sort_key)
|
_sort_by(current_sort_key)
|
||||||
|
# Show top player's character in 3D preview
|
||||||
|
if leaderboard_data.size() > 0:
|
||||||
|
_show_entry_preview(0)
|
||||||
else:
|
else:
|
||||||
status_label.text = "No data found"
|
status_label.text = "No data found"
|
||||||
else:
|
else:
|
||||||
@@ -67,23 +98,20 @@ func _calculate_win_rates() -> void:
|
|||||||
for entry in leaderboard_data:
|
for entry in leaderboard_data:
|
||||||
var played = entry.get("games_played", 0)
|
var played = entry.get("games_played", 0)
|
||||||
var won = entry.get("games_won", 0)
|
var won = entry.get("games_won", 0)
|
||||||
if played > 0:
|
entry["win_rate"] = float(won) / float(played) * 100.0 if played > 0 else 0.0
|
||||||
entry["win_rate"] = float(won) / float(played) * 100.0
|
|
||||||
else:
|
|
||||||
entry["win_rate"] = 0.0
|
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Sorting / Display
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
func _sort_by(key: String) -> void:
|
func _sort_by(key: String) -> void:
|
||||||
current_sort_key = key
|
current_sort_key = key
|
||||||
_update_tab_visuals()
|
_update_tab_visuals()
|
||||||
|
|
||||||
leaderboard_data.sort_custom(func(a, b): return a.get(key, 0) > b.get(key, 0))
|
leaderboard_data.sort_custom(func(a, b): return a.get(key, 0) > b.get(key, 0))
|
||||||
|
|
||||||
_populate_list()
|
_populate_list()
|
||||||
|
|
||||||
func _update_tab_visuals() -> void:
|
func _update_tab_visuals() -> void:
|
||||||
var color_active = Color(0.647, 0.996, 0.224, 1)
|
var color_active = Color(0.647, 0.996, 0.224, 1)
|
||||||
var color_inactive = Color(0.69, 0.529, 0.357, 1)
|
var color_inactive = Color(0.69, 0.529, 0.357, 1)
|
||||||
|
|
||||||
sort_score_btn.add_theme_color_override("font_color", color_active if current_sort_key == "high_score" else color_inactive)
|
sort_score_btn.add_theme_color_override("font_color", color_active if current_sort_key == "high_score" else color_inactive)
|
||||||
sort_win_rate_btn.add_theme_color_override("font_color", color_active if current_sort_key == "win_rate" else color_inactive)
|
sort_win_rate_btn.add_theme_color_override("font_color", color_active if current_sort_key == "win_rate" else color_inactive)
|
||||||
sort_games_btn.add_theme_color_override("font_color", color_active if current_sort_key == "games_played" else color_inactive)
|
sort_games_btn.add_theme_color_override("font_color", color_active if current_sort_key == "games_played" else color_inactive)
|
||||||
@@ -91,48 +119,43 @@ func _update_tab_visuals() -> void:
|
|||||||
func _populate_list() -> void:
|
func _populate_list() -> void:
|
||||||
for child in leaderboard_list.get_children():
|
for child in leaderboard_list.get_children():
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
|
|
||||||
if leaderboard_data.size() == 0:
|
if leaderboard_data.size() == 0:
|
||||||
status_label.text = "No players found"
|
status_label.text = "No players found"
|
||||||
return
|
return
|
||||||
|
|
||||||
for i in range(leaderboard_data.size()):
|
for i in range(leaderboard_data.size()):
|
||||||
var entry = leaderboard_data[i]
|
var entry = leaderboard_data[i]
|
||||||
_create_leaderboard_item(i + 1, entry)
|
_create_leaderboard_item(i + 1, entry, i)
|
||||||
|
|
||||||
func _create_leaderboard_item(rank: int, entry: Dictionary) -> void:
|
func _create_leaderboard_item(rank: int, entry: Dictionary, index: int) -> void:
|
||||||
var item = PanelContainer.new()
|
var item = PanelContainer.new()
|
||||||
var style = StyleBoxFlat.new()
|
var style = StyleBoxFlat.new()
|
||||||
style.bg_color = Color(0.15, 0.15, 0.15, 1.0)
|
style.bg_color = Color(0.15, 0.15, 0.15, 1.0)
|
||||||
if rank <= 3:
|
if rank <= 3:
|
||||||
style.bg_color = Color(0.2, 0.2, 0.15, 1.0) # Slightly highlight top 3
|
style.bg_color = Color(0.2, 0.2, 0.15, 1.0)
|
||||||
style.set_corner_radius_all(4)
|
style.set_corner_radius_all(4)
|
||||||
style.content_margin_left = 10
|
style.content_margin_left = 10
|
||||||
style.content_margin_right = 10
|
style.content_margin_right = 10
|
||||||
style.content_margin_top = 8
|
style.content_margin_top = 8
|
||||||
style.content_margin_bottom = 8
|
style.content_margin_bottom = 8
|
||||||
item.add_theme_stylebox_override("panel", style)
|
item.add_theme_stylebox_override("panel", style)
|
||||||
|
|
||||||
var hbox = HBoxContainer.new()
|
var hbox = HBoxContainer.new()
|
||||||
hbox.theme_override_constants.separation = 16
|
hbox.theme_override_constants.separation = 16
|
||||||
item.add_child(hbox)
|
item.add_child(hbox)
|
||||||
|
|
||||||
# Rank
|
# Rank
|
||||||
var rank_label = Label.new()
|
var rank_label = Label.new()
|
||||||
rank_label.text = "#" + str(rank)
|
rank_label.text = "#" + str(rank)
|
||||||
rank_label.custom_minimum_size = Vector2(40, 0)
|
rank_label.custom_minimum_size = Vector2(40, 0)
|
||||||
|
match rank:
|
||||||
if rank == 1:
|
1: rank_label.add_theme_color_override("font_color", Color.GOLD)
|
||||||
rank_label.add_theme_color_override("font_color", Color.GOLD)
|
2: rank_label.add_theme_color_override("font_color", Color.SILVER)
|
||||||
elif rank == 2:
|
3: rank_label.add_theme_color_override("font_color", Color.DARK_ORANGE)
|
||||||
rank_label.add_theme_color_override("font_color", Color.SILVER)
|
_: rank_label.add_theme_color_override("font_color", Color.LIGHT_GRAY)
|
||||||
elif rank == 3:
|
|
||||||
rank_label.add_theme_color_override("font_color", Color.DARK_ORANGE)
|
|
||||||
else:
|
|
||||||
rank_label.add_theme_color_override("font_color", Color.LIGHT_GRAY)
|
|
||||||
|
|
||||||
hbox.add_child(rank_label)
|
hbox.add_child(rank_label)
|
||||||
|
|
||||||
# Avatar
|
# Avatar
|
||||||
var avatar_rect = TextureRect.new()
|
var avatar_rect = TextureRect.new()
|
||||||
avatar_rect.custom_minimum_size = Vector2(32, 32)
|
avatar_rect.custom_minimum_size = Vector2(32, 32)
|
||||||
@@ -142,29 +165,75 @@ func _create_leaderboard_item(rank: int, entry: Dictionary) -> void:
|
|||||||
avatar_url = UserProfileManager.AVATARS[0]
|
avatar_url = UserProfileManager.AVATARS[0]
|
||||||
avatar_rect.texture = load(avatar_url)
|
avatar_rect.texture = load(avatar_url)
|
||||||
hbox.add_child(avatar_rect)
|
hbox.add_child(avatar_rect)
|
||||||
|
|
||||||
# Name
|
# Name
|
||||||
var name_label = Label.new()
|
var name_label = Label.new()
|
||||||
name_label.text = entry.get("display_name", "Unknown")
|
name_label.text = entry.get("display_name", "Unknown")
|
||||||
name_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
name_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
name_label.add_theme_color_override("font_color", Color.WHITE)
|
name_label.add_theme_color_override("font_color", Color.WHITE)
|
||||||
hbox.add_child(name_label)
|
hbox.add_child(name_label)
|
||||||
|
|
||||||
# Value based on current sort
|
# Value
|
||||||
var value_label = Label.new()
|
var value_label = Label.new()
|
||||||
var color = Color(0.647, 0.996, 0.224, 1) # TEKTON green
|
var color = Color(0.647, 0.996, 0.224, 1)
|
||||||
|
|
||||||
match current_sort_key:
|
match current_sort_key:
|
||||||
"high_score":
|
"high_score": value_label.text = str(entry.get("high_score", 0))
|
||||||
value_label.text = str(entry.get("high_score", 0))
|
"win_rate": value_label.text = "%.1f%%" % entry.get("win_rate", 0.0)
|
||||||
"win_rate":
|
"games_played": value_label.text = str(entry.get("games_played", 0))
|
||||||
value_label.text = "%.1f%%" % entry.get("win_rate", 0.0)
|
|
||||||
"games_played":
|
|
||||||
value_label.text = str(entry.get("games_played", 0))
|
|
||||||
|
|
||||||
value_label.add_theme_color_override("font_color", color)
|
value_label.add_theme_color_override("font_color", color)
|
||||||
value_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
value_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||||
value_label.custom_minimum_size = Vector2(80, 0)
|
value_label.custom_minimum_size = Vector2(80, 0)
|
||||||
hbox.add_child(value_label)
|
hbox.add_child(value_label)
|
||||||
|
|
||||||
leaderboard_list.add_child(item)
|
leaderboard_list.add_child(item)
|
||||||
|
|
||||||
|
# Make row clickable to update 3D preview
|
||||||
|
item.gui_input.connect(func(event: InputEvent):
|
||||||
|
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
|
_show_entry_preview(index)
|
||||||
|
)
|
||||||
|
item.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# 3D Preview
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
func _setup_3d_preview() -> void:
|
||||||
|
if not character_root:
|
||||||
|
return
|
||||||
|
_anim_player = character_root.get_node_or_null("AnimationPlayer")
|
||||||
|
|
||||||
|
func _show_entry_preview(index: int) -> void:
|
||||||
|
if index >= leaderboard_data.size():
|
||||||
|
return
|
||||||
|
var entry = leaderboard_data[index]
|
||||||
|
|
||||||
|
# Determine character from avatar_url index
|
||||||
|
var avatar_url: String = entry.get("avatar_url", "")
|
||||||
|
var char_name := "Copper"
|
||||||
|
for i in range(UserProfileManager.AVATARS.size()):
|
||||||
|
if UserProfileManager.AVATARS[i] == avatar_url:
|
||||||
|
char_name = AVATAR_TO_CHAR[i] if i < AVATAR_TO_CHAR.size() else "Copper"
|
||||||
|
break
|
||||||
|
|
||||||
|
_update_3d_preview(char_name)
|
||||||
|
|
||||||
|
var display_name: String = entry.get("display_name", "Unknown")
|
||||||
|
var rank := index + 1
|
||||||
|
selected_name_label.text = display_name
|
||||||
|
selected_rank_label.text = "#%d" % rank
|
||||||
|
|
||||||
|
func _update_3d_preview(character_name: String) -> void:
|
||||||
|
if not character_root:
|
||||||
|
return
|
||||||
|
var node_name: String = CHAR_NODE_MAP.get(character_name, "Masbro")
|
||||||
|
for child in character_root.get_children():
|
||||||
|
if child is Node3D:
|
||||||
|
child.visible = (child.name == node_name)
|
||||||
|
if _anim_player:
|
||||||
|
var new_root := character_root.get_node_or_null(node_name)
|
||||||
|
if new_root:
|
||||||
|
_anim_player.root_node = new_root.get_path()
|
||||||
|
if _anim_player.has_animation("animation-pack/idle"):
|
||||||
|
_anim_player.play("animation-pack/idle")
|
||||||
|
elif _anim_player.get_animation_list().size() > 0:
|
||||||
|
_anim_player.play(_anim_player.get_animation_list()[0])
|
||||||
|
|||||||
+150
-43
@@ -1,10 +1,15 @@
|
|||||||
extends PanelContainer
|
extends Control
|
||||||
## Profile panel controller - displays and edits user profile
|
## Profile panel controller — full-scene loadout screen.
|
||||||
|
## Left: profile info + default character selector.
|
||||||
|
## Right: 3D SubViewport character preview.
|
||||||
|
|
||||||
signal closed
|
signal closed
|
||||||
signal profile_updated
|
signal profile_updated
|
||||||
|
|
||||||
@onready var close_button := %CloseButton as Button
|
# -------------------------------------------------------------------------
|
||||||
|
# UI References
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
@onready var back_btn := %BackBtn as Button
|
||||||
@onready var avatar_display := %AvatarDisplay as TextureRect
|
@onready var avatar_display := %AvatarDisplay as TextureRect
|
||||||
@onready var change_avatar_btn := %ChangeAvatarBtn as Button
|
@onready var change_avatar_btn := %ChangeAvatarBtn as Button
|
||||||
@onready var display_name_input := %DisplayNameInput as LineEdit
|
@onready var display_name_input := %DisplayNameInput as LineEdit
|
||||||
@@ -19,40 +24,70 @@ signal profile_updated
|
|||||||
@onready var avatar_popup := %AvatarSelectionPopup as PopupPanel
|
@onready var avatar_popup := %AvatarSelectionPopup as PopupPanel
|
||||||
@onready var avatar_grid := %GridContainer as GridContainer
|
@onready var avatar_grid := %GridContainer as GridContainer
|
||||||
|
|
||||||
|
# Loadout refs
|
||||||
|
@onready var char_left_btn := %CharLeftBtn as Button
|
||||||
|
@onready var char_right_btn := %CharRightBtn as Button
|
||||||
|
@onready var loadout_char_name := %LoadoutCharName as Label
|
||||||
|
@onready var set_default_btn := %SetDefaultBtn as Button
|
||||||
|
|
||||||
|
# 3D Preview refs
|
||||||
|
@onready var character_root := %CharacterRoot as Node3D
|
||||||
|
@onready var anim_player: AnimationPlayer
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# State
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
const CHARACTERS: Array[String] = ["Copper", "Dabro", "Gatot", "Pip"]
|
||||||
|
# Maps game character name -> GLB node name in the SubViewport
|
||||||
|
# Must match the mapping in player.gd's set_character()
|
||||||
|
const CHAR_NODE_MAP: Dictionary = {
|
||||||
|
"Copper": "Oldpop",
|
||||||
|
"Dabro": "Masbro",
|
||||||
|
"Gatot": "Gatot",
|
||||||
|
"Pip": "Bob"
|
||||||
|
}
|
||||||
|
|
||||||
|
var _loadout_index: int = 0 # Index into CHARACTERS
|
||||||
|
var _default_character: String = "Copper"
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
_connect_signals()
|
_connect_signals()
|
||||||
_load_profile_data()
|
_load_profile_data()
|
||||||
_setup_avatar_grid()
|
_setup_avatar_grid()
|
||||||
|
_load_loadout()
|
||||||
|
_setup_3d_preview()
|
||||||
|
|
||||||
func _connect_signals() -> void:
|
func _connect_signals() -> void:
|
||||||
close_button.pressed.connect(_on_close_pressed)
|
back_btn.pressed.connect(_on_close_pressed)
|
||||||
change_avatar_btn.pressed.connect(_on_change_avatar_pressed)
|
change_avatar_btn.pressed.connect(_on_change_avatar_pressed)
|
||||||
save_name_btn.pressed.connect(_on_save_name_pressed)
|
save_name_btn.pressed.connect(_on_save_name_pressed)
|
||||||
link_account_btn.pressed.connect(_on_link_account_pressed)
|
link_account_btn.pressed.connect(_on_link_account_pressed)
|
||||||
logout_btn.pressed.connect(_on_logout_pressed)
|
logout_btn.pressed.connect(_on_logout_pressed)
|
||||||
|
char_left_btn.pressed.connect(func(): _cycle_loadout_char(-1))
|
||||||
|
char_right_btn.pressed.connect(func(): _cycle_loadout_char(1))
|
||||||
|
set_default_btn.pressed.connect(_on_set_default_pressed)
|
||||||
|
|
||||||
UserProfileManager.profile_updated.connect(_on_profile_updated)
|
UserProfileManager.profile_updated.connect(_on_profile_updated)
|
||||||
UserProfileManager.profile_update_failed.connect(_on_profile_update_failed)
|
UserProfileManager.profile_update_failed.connect(_on_profile_update_failed)
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Profile
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
func _load_profile_data() -> void:
|
func _load_profile_data() -> void:
|
||||||
var profile := UserProfileManager.profile
|
var profile := UserProfileManager.profile
|
||||||
var stats := UserProfileManager.stats
|
var stats := UserProfileManager.stats
|
||||||
|
|
||||||
# Display name
|
|
||||||
display_name_input.text = profile.get("display_name", "Guest")
|
display_name_input.text = profile.get("display_name", "Guest")
|
||||||
display_name_input.max_length = 6
|
display_name_input.max_length = 6
|
||||||
|
|
||||||
# Avatar
|
|
||||||
var avatar_url: String = UserProfileManager.get_avatar_url()
|
var avatar_url: String = UserProfileManager.get_avatar_url()
|
||||||
if ResourceLoader.exists(avatar_url):
|
if ResourceLoader.exists(avatar_url):
|
||||||
avatar_display.texture = load(avatar_url)
|
avatar_display.texture = load(avatar_url)
|
||||||
|
|
||||||
# Stats
|
|
||||||
games_played_label.text = "Games Played: %d" % stats.get("games_played", 0)
|
games_played_label.text = "Games Played: %d" % stats.get("games_played", 0)
|
||||||
win_rate_label.text = "Win Rate: %.1f%%" % UserProfileManager.get_win_rate()
|
win_rate_label.text = "Win Rate: %.1f%%" % UserProfileManager.get_win_rate()
|
||||||
high_score_label.text = "High Score: %d" % stats.get("high_score", 0)
|
high_score_label.text = "High Score: %d" % stats.get("high_score", 0)
|
||||||
|
|
||||||
# Account type
|
|
||||||
if AuthManager.is_guest:
|
if AuthManager.is_guest:
|
||||||
account_type_label.text = "Account: Guest"
|
account_type_label.text = "Account: Guest"
|
||||||
link_account_btn.visible = true
|
link_account_btn.visible = true
|
||||||
@@ -61,7 +96,7 @@ func _load_profile_data() -> void:
|
|||||||
var mode_name := _get_auth_mode_name(AuthManager.auth_mode)
|
var mode_name := _get_auth_mode_name(AuthManager.auth_mode)
|
||||||
account_type_label.text = "Account: %s" % mode_name
|
account_type_label.text = "Account: %s" % mode_name
|
||||||
link_account_btn.visible = false
|
link_account_btn.visible = false
|
||||||
|
|
||||||
status_label.text = ""
|
status_label.text = ""
|
||||||
|
|
||||||
func _get_auth_mode_name(mode: int) -> String:
|
func _get_auth_mode_name(mode: int) -> String:
|
||||||
@@ -77,38 +112,108 @@ func _get_auth_mode_name(mode: int) -> String:
|
|||||||
_:
|
_:
|
||||||
return "Guest"
|
return "Guest"
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Loadout
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
func _load_loadout() -> void:
|
||||||
|
"""Load the saved default character from profile storage."""
|
||||||
|
var saved = UserProfileManager.profile.get("loadout_character", "Copper")
|
||||||
|
var idx = CHARACTERS.find(saved)
|
||||||
|
_loadout_index = max(idx, 0)
|
||||||
|
_default_character = CHARACTERS[_loadout_index]
|
||||||
|
_refresh_loadout_ui()
|
||||||
|
|
||||||
|
func _cycle_loadout_char(direction: int) -> void:
|
||||||
|
_loadout_index = wrapi(_loadout_index + direction, 0, CHARACTERS.size())
|
||||||
|
_refresh_loadout_ui()
|
||||||
|
_update_3d_preview(CHARACTERS[_loadout_index])
|
||||||
|
|
||||||
|
func _refresh_loadout_ui() -> void:
|
||||||
|
var char_name := CHARACTERS[_loadout_index]
|
||||||
|
loadout_char_name.text = char_name
|
||||||
|
var is_default := char_name == _default_character
|
||||||
|
set_default_btn.text = "✓ DEFAULT" if is_default else "Set as Default"
|
||||||
|
set_default_btn.disabled = is_default
|
||||||
|
_update_3d_preview(char_name)
|
||||||
|
|
||||||
|
func _on_set_default_pressed() -> void:
|
||||||
|
var char_name := CHARACTERS[_loadout_index]
|
||||||
|
_default_character = char_name
|
||||||
|
UserProfileManager.profile["loadout_character"] = char_name
|
||||||
|
# Also apply immediately to LobbyManager
|
||||||
|
if LobbyManager.available_characters.has(char_name):
|
||||||
|
LobbyManager.local_character_index = LobbyManager.available_characters.find(char_name)
|
||||||
|
status_label.text = "Loadout set to: " + char_name
|
||||||
|
status_label.add_theme_color_override("font_color", Color(0.4, 0.8, 0.4))
|
||||||
|
_refresh_loadout_ui()
|
||||||
|
# Persist to storage
|
||||||
|
_save_loadout_to_profile()
|
||||||
|
|
||||||
|
func _save_loadout_to_profile() -> void:
|
||||||
|
"""Save loadout_character field to Nakama profile storage."""
|
||||||
|
if not NakamaManager.session:
|
||||||
|
return
|
||||||
|
var data := {
|
||||||
|
"avatar_index": UserProfileManager.profile.get("avatar_index", 0),
|
||||||
|
"bio": UserProfileManager.profile.get("bio", ""),
|
||||||
|
"country": UserProfileManager.profile.get("country", ""),
|
||||||
|
"language": UserProfileManager.profile.get("language", "en"),
|
||||||
|
"loadout_character": _default_character
|
||||||
|
}
|
||||||
|
var write_obj := NakamaWriteStorageObject.new(
|
||||||
|
"profiles", "profile", 2, 1, JSON.stringify(data), ""
|
||||||
|
)
|
||||||
|
await NakamaManager.client.write_storage_objects_async(NakamaManager.session, [write_obj])
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# 3D Preview
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
func _setup_3d_preview() -> void:
|
||||||
|
anim_player = character_root.get_node_or_null("AnimationPlayer")
|
||||||
|
_update_3d_preview(_default_character)
|
||||||
|
|
||||||
|
func _update_3d_preview(character_name: String) -> void:
|
||||||
|
if not character_root:
|
||||||
|
return
|
||||||
|
var node_name: String = CHAR_NODE_MAP.get(character_name, "Masbro")
|
||||||
|
for child in character_root.get_children():
|
||||||
|
if child is Node3D:
|
||||||
|
child.visible = (child.name == node_name)
|
||||||
|
# Update AnimationPlayer root
|
||||||
|
if anim_player:
|
||||||
|
var new_root := character_root.get_node_or_null(node_name)
|
||||||
|
if new_root:
|
||||||
|
anim_player.root_node = new_root.get_path()
|
||||||
|
if anim_player.has_animation("animation-pack/idle"):
|
||||||
|
anim_player.play("animation-pack/idle")
|
||||||
|
elif anim_player.get_animation_list().size() > 0:
|
||||||
|
anim_player.play(anim_player.get_animation_list()[0])
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Avatar
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
func _setup_avatar_grid() -> void:
|
func _setup_avatar_grid() -> void:
|
||||||
# Clear existing
|
|
||||||
for child in avatar_grid.get_children():
|
for child in avatar_grid.get_children():
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
|
|
||||||
# Add avatar buttons
|
|
||||||
for i in range(UserProfileManager.AVATARS.size()):
|
for i in range(UserProfileManager.AVATARS.size()):
|
||||||
var avatar_path: String = UserProfileManager.AVATARS[i]
|
var avatar_path: String = UserProfileManager.AVATARS[i]
|
||||||
var btn := Button.new()
|
var btn := Button.new()
|
||||||
btn.custom_minimum_size = Vector2(64, 64)
|
btn.custom_minimum_size = Vector2(64, 64)
|
||||||
|
|
||||||
if ResourceLoader.exists(avatar_path):
|
if ResourceLoader.exists(avatar_path):
|
||||||
var tex := load(avatar_path) as Texture2D
|
var tex := load(avatar_path) as Texture2D
|
||||||
btn.icon = tex
|
btn.icon = tex
|
||||||
btn.expand_icon = true
|
btn.expand_icon = true
|
||||||
else:
|
else:
|
||||||
btn.text = str(i + 1)
|
btn.text = str(i + 1)
|
||||||
|
|
||||||
btn.pressed.connect(_on_avatar_selected.bind(i))
|
btn.pressed.connect(_on_avatar_selected.bind(i))
|
||||||
avatar_grid.add_child(btn)
|
avatar_grid.add_child(btn)
|
||||||
|
|
||||||
func _on_close_pressed() -> void:
|
|
||||||
hide()
|
|
||||||
emit_signal("closed")
|
|
||||||
|
|
||||||
func _on_change_avatar_pressed() -> void:
|
func _on_change_avatar_pressed() -> void:
|
||||||
avatar_popup.popup_centered()
|
avatar_popup.popup_centered()
|
||||||
|
|
||||||
func _on_avatar_selected(index: int) -> void:
|
func _on_avatar_selected(index: int) -> void:
|
||||||
avatar_popup.hide()
|
avatar_popup.hide()
|
||||||
status_label.text = "Saving avatar..."
|
status_label.text = "Saving avatar..."
|
||||||
|
|
||||||
var success := await UserProfileManager.update_avatar(index)
|
var success := await UserProfileManager.update_avatar(index)
|
||||||
if success:
|
if success:
|
||||||
var avatar_url: String = UserProfileManager.get_avatar_url()
|
var avatar_url: String = UserProfileManager.get_avatar_url()
|
||||||
@@ -118,20 +223,18 @@ func _on_avatar_selected(index: int) -> void:
|
|||||||
else:
|
else:
|
||||||
status_label.text = "Failed to update avatar"
|
status_label.text = "Failed to update avatar"
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Name
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
func _on_save_name_pressed() -> void:
|
func _on_save_name_pressed() -> void:
|
||||||
var new_name := display_name_input.text.strip_edges()
|
var new_name := display_name_input.text.strip_edges()
|
||||||
|
|
||||||
if new_name.is_empty():
|
if new_name.is_empty():
|
||||||
status_label.text = "Name cannot be empty"
|
status_label.text = "Name cannot be empty"
|
||||||
return
|
return
|
||||||
|
|
||||||
status_label.text = "Saving..."
|
status_label.text = "Saving..."
|
||||||
save_name_btn.disabled = true
|
save_name_btn.disabled = true
|
||||||
|
|
||||||
var success := await UserProfileManager.update_display_name(new_name)
|
var success := await UserProfileManager.update_display_name(new_name)
|
||||||
|
|
||||||
save_name_btn.disabled = false
|
save_name_btn.disabled = false
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
status_label.add_theme_color_override("font_color", Color.GREEN)
|
status_label.add_theme_color_override("font_color", Color.GREEN)
|
||||||
status_label.text = "Name updated!"
|
status_label.text = "Name updated!"
|
||||||
@@ -142,45 +245,38 @@ func _on_save_name_pressed() -> void:
|
|||||||
status_label.add_theme_color_override("font_color", Color.RED)
|
status_label.add_theme_color_override("font_color", Color.RED)
|
||||||
status_label.text = "Failed to update name"
|
status_label.text = "Failed to update name"
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Account
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
func _on_link_account_pressed() -> void:
|
func _on_link_account_pressed() -> void:
|
||||||
# Show link account dialog
|
|
||||||
# For now, just show a simple popup
|
|
||||||
var dialog := AcceptDialog.new()
|
var dialog := AcceptDialog.new()
|
||||||
dialog.title = "Link Email"
|
dialog.title = "Link Email"
|
||||||
dialog.dialog_text = "Enter your email and password to link this guest account.\nYour progress will be preserved!"
|
dialog.dialog_text = "Enter your email and password to link this guest account.\nYour progress will be preserved!"
|
||||||
|
|
||||||
var vbox := VBoxContainer.new()
|
var vbox := VBoxContainer.new()
|
||||||
var email_input := LineEdit.new()
|
var email_input := LineEdit.new()
|
||||||
email_input.placeholder_text = "Email"
|
email_input.placeholder_text = "Email"
|
||||||
var password_input := LineEdit.new()
|
var password_input := LineEdit.new()
|
||||||
password_input.placeholder_text = "Password"
|
password_input.placeholder_text = "Password"
|
||||||
password_input.secret = true
|
password_input.secret = true
|
||||||
|
|
||||||
vbox.add_child(email_input)
|
vbox.add_child(email_input)
|
||||||
vbox.add_child(password_input)
|
vbox.add_child(password_input)
|
||||||
dialog.add_child(vbox)
|
dialog.add_child(vbox)
|
||||||
|
|
||||||
add_child(dialog)
|
add_child(dialog)
|
||||||
dialog.popup_centered()
|
dialog.popup_centered()
|
||||||
|
|
||||||
dialog.confirmed.connect(func():
|
dialog.confirmed.connect(func():
|
||||||
var email := email_input.text.strip_edges()
|
var email := email_input.text.strip_edges()
|
||||||
var password := password_input.text
|
var password := password_input.text
|
||||||
|
|
||||||
if email.is_empty() or password.is_empty():
|
if email.is_empty() or password.is_empty():
|
||||||
status_label.text = "Please fill in all fields"
|
status_label.text = "Please fill in all fields"
|
||||||
return
|
return
|
||||||
|
|
||||||
status_label.text = "Linking account..."
|
status_label.text = "Linking account..."
|
||||||
var success := await AuthManager.link_email(email, password)
|
var success := await AuthManager.link_email(email, password)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
status_label.text = "Account linked successfully!"
|
status_label.text = "Account linked successfully!"
|
||||||
link_account_btn.visible = false
|
link_account_btn.visible = false
|
||||||
account_type_label.text = "Account: Email"
|
account_type_label.text = "Account: Email"
|
||||||
else:
|
else:
|
||||||
status_label.text = "Failed to link account"
|
status_label.text = "Failed to link account"
|
||||||
|
|
||||||
dialog.queue_free()
|
dialog.queue_free()
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -188,6 +284,21 @@ func _on_logout_pressed() -> void:
|
|||||||
AuthManager.logout()
|
AuthManager.logout()
|
||||||
get_tree().change_scene_to_file("res://scenes/ui/login_screen.tscn")
|
get_tree().change_scene_to_file("res://scenes/ui/login_screen.tscn")
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Close / Show
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
func _on_close_pressed() -> void:
|
||||||
|
hide()
|
||||||
|
emit_signal("closed")
|
||||||
|
|
||||||
|
func show_panel() -> void:
|
||||||
|
_load_profile_data()
|
||||||
|
_load_loadout()
|
||||||
|
show()
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Signal handlers
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
func _on_profile_updated() -> void:
|
func _on_profile_updated() -> void:
|
||||||
_load_profile_data()
|
_load_profile_data()
|
||||||
|
|
||||||
@@ -196,7 +307,3 @@ func _on_profile_update_failed(error: String) -> void:
|
|||||||
status_label.text = error
|
status_label.text = error
|
||||||
await get_tree().create_timer(3.0).timeout
|
await get_tree().create_timer(3.0).timeout
|
||||||
status_label.text = ""
|
status_label.text = ""
|
||||||
|
|
||||||
func show_panel() -> void:
|
|
||||||
_load_profile_data()
|
|
||||||
show()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user