update network

This commit is contained in:
2026-02-04 16:31:18 +08:00
parent 4ccf789421
commit 08b0493c06
10 changed files with 203 additions and 22 deletions
+37 -5
View File
@@ -7,6 +7,10 @@ extends Control
@onready var browse_rooms_btn = $MainMenuPanel/VBoxContainer/ButtonSection/BrowseRoomsBtn
@onready var main_menu_profile_btn = $MainMenuPanel/VBoxContainer/ButtonSection/ProfileBtn
# UI References - Server Selection
@onready var server_option = $MainMenuPanel/VBoxContainer/ServerSelectionSection/ServerOption
@onready var server_ip_input = $MainMenuPanel/VBoxContainer/ServerSelectionSection/ServerIPInput
# UI References - Room List
@onready var room_list_panel = $RoomListPanel
@onready var room_list = $RoomListPanel/VBoxContainer/RoomList
@@ -68,18 +72,23 @@ var current_match_id: String = ""
var scarcity_option: OptionButton
var scarcity_label: Label
# Server Selection Controls (Now in tscn)
# var server_option: OptionButton
# var server_ip_input: LineEdit
func _ready():
# Check if user is authenticated
if not AuthManager.is_logged_in():
call_deferred("_go_to_login")
return
# Check if user is authenticated (Commented out to allow server config on main menu)
# if not AuthManager.is_logged_in():
# call_deferred("_go_to_login")
# return
# Load character textures
_load_character_textures()
# Inject Scarcity UI
call_deferred("_setup_scarcity_ui")
# Server config UI is now in tscn
# Get player slot references
_setup_player_slots()
@@ -108,6 +117,15 @@ func _ready():
if main_menu_profile_btn:
main_menu_profile_btn.pressed.connect(_on_profile_btn_pressed)
# Connect Server Selection signals
if server_option:
server_option.item_selected.connect(_on_server_option_selected)
# Initialize state
_on_server_option_selected(server_option.selected)
if server_ip_input:
server_ip_input.text_submitted.connect(_on_server_ip_submitted)
server_ip_input.focus_exited.connect(func(): _on_server_ip_submitted(server_ip_input.text))
# Connect button signals - Room List
refresh_btn.pressed.connect(_on_refresh_pressed)
join_btn.pressed.connect(_on_join_pressed)
@@ -166,6 +184,20 @@ func _load_character_textures() -> void:
else:
print("[Lobby] Character texture not found: ", tex_path)
func _on_server_option_selected(index: int) -> void:
if index == 0:
# Localhost
if server_ip_input: server_ip_input.visible = false
NakamaManager.set_server("localhost")
else:
# Remote
if server_ip_input: server_ip_input.visible = true
if server_ip_input: NakamaManager.set_server(server_ip_input.text)
func _on_server_ip_submitted(new_text: String) -> void:
if server_option and server_option.selected == 1:
NakamaManager.set_server(new_text.strip_edges())
func _setup_scarcity_ui() -> void:
"""Inject scarcity controls into SettingsSection."""
if not duration_option: return