feat: Implement core multiplayer lobby system with room management, player profiles, and game settings.
This commit is contained in:
@@ -221,6 +221,7 @@ layout_mode = 2
|
|||||||
text = "PROFILE"
|
text = "PROFILE"
|
||||||
|
|
||||||
[node name="LobbyPanel" type="Control" parent="." unique_id=1745714811]
|
[node name="LobbyPanel" type="Control" parent="." unique_id=1745714811]
|
||||||
|
visible = false
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ func set_player_name(new_name: String) -> void:
|
|||||||
break
|
break
|
||||||
|
|
||||||
# Sync to all peers if connected
|
# Sync to all peers if connected
|
||||||
if multiplayer.has_multiplayer_peer():
|
if multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
|
||||||
rpc("sync_player_name", my_id, new_name)
|
rpc("sync_player_name", my_id, new_name)
|
||||||
|
|
||||||
emit_signal("player_list_changed")
|
emit_signal("player_list_changed")
|
||||||
|
|||||||
@@ -120,17 +120,25 @@ func load_stats() -> Dictionary:
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
func update_display_name(new_name: String) -> bool:
|
func update_display_name(new_name: String) -> bool:
|
||||||
if not NakamaManager.session:
|
|
||||||
emit_signal("profile_update_failed", "Not authenticated")
|
|
||||||
return false
|
|
||||||
|
|
||||||
if new_name.strip_edges().is_empty():
|
if new_name.strip_edges().is_empty():
|
||||||
emit_signal("profile_update_failed", "Display name cannot be empty")
|
emit_signal("profile_update_failed", "Display name cannot be empty")
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if new_name.length() > 50:
|
if new_name.length() > 6:
|
||||||
emit_signal("profile_update_failed", "Display name too long (max 50 characters)")
|
emit_signal("profile_update_failed", "Display name too long (max 6 characters)")
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
var regex = RegEx.new()
|
||||||
|
regex.compile("^[A-Za-z]+$")
|
||||||
|
if not regex.search(new_name):
|
||||||
|
emit_signal("profile_update_failed", "Name must contain only letters")
|
||||||
|
return false
|
||||||
|
|
||||||
|
# Allow guest name updates locally
|
||||||
|
if not NakamaManager.session or AuthManager.is_guest:
|
||||||
|
profile["display_name"] = new_name
|
||||||
|
emit_signal("profile_updated")
|
||||||
|
return true
|
||||||
|
|
||||||
var result: NakamaAsyncResult = await NakamaManager.client.update_account_async(
|
var result: NakamaAsyncResult = await NakamaManager.client.update_account_async(
|
||||||
NakamaManager.session,
|
NakamaManager.session,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ func _load_profile_data() -> void:
|
|||||||
|
|
||||||
# Display name
|
# 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
|
||||||
|
|
||||||
# Avatar
|
# Avatar
|
||||||
var avatar_url: String = UserProfileManager.get_avatar_url()
|
var avatar_url: String = UserProfileManager.get_avatar_url()
|
||||||
@@ -132,9 +133,13 @@ func _on_save_name_pressed() -> void:
|
|||||||
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.text = "Name updated!"
|
status_label.text = "Name updated!"
|
||||||
emit_signal("profile_updated")
|
emit_signal("profile_updated")
|
||||||
|
await get_tree().create_timer(3.0).timeout
|
||||||
|
status_label.text = ""
|
||||||
else:
|
else:
|
||||||
|
status_label.add_theme_color_override("font_color", Color.RED)
|
||||||
status_label.text = "Failed to update name"
|
status_label.text = "Failed to update name"
|
||||||
|
|
||||||
func _on_link_account_pressed() -> void:
|
func _on_link_account_pressed() -> void:
|
||||||
@@ -187,7 +192,10 @@ func _on_profile_updated() -> void:
|
|||||||
_load_profile_data()
|
_load_profile_data()
|
||||||
|
|
||||||
func _on_profile_update_failed(error: String) -> void:
|
func _on_profile_update_failed(error: String) -> void:
|
||||||
|
status_label.add_theme_color_override("font_color", Color.RED)
|
||||||
status_label.text = error
|
status_label.text = error
|
||||||
|
await get_tree().create_timer(3.0).timeout
|
||||||
|
status_label.text = ""
|
||||||
|
|
||||||
func show_panel() -> void:
|
func show_panel() -> void:
|
||||||
_load_profile_data()
|
_load_profile_data()
|
||||||
|
|||||||
Reference in New Issue
Block a user