Files
Billiards/scenes/screens/lobby_screen/lobby_base.gd
itdominator 93a2be399c refactor: decouple game networking from lobby client
* Replace direct client/server networking references with GameClient/GameServer scenes
* Refactor message bus to support local emission and argument expansion
* Move lobby connection lifecycle handling to message bus events
* Remove multiplayer connection wait helpers and direct lobby client coupling
* Rename Server to ServerNetworking and update lobby client references
* Update scene resources and export configuration
2026-08-09 18:41:18 -05:00

60 lines
2.2 KiB
GDScript

class_name LobbyBase extends Node
const MATCH_ENTRY = preload("res://scenes/screens/lobby_screen/match_entry.tscn")
@onready var host_address_input: LineEdit = $ui/body/left_body/server_host_hbox/host_address_input
@onready var host_port_range: SpinBox = $ui/body/left_body/server_host_hbox/host_port_range
@onready var host_connect_bttn: Button = $ui/body/left_body/server_host_hbox/host_connect_bttn
@onready var host_disconnect_bttn: Button = $ui/body/left_body/server_host_hbox/host_disconnect_bttn
@onready var search_vbox: VBoxContainer = $ui/body/left_body/search_vbox
@onready var match_search_input: LineEdit = $ui/body/left_body/search_vbox/search_hbox/match_search_input
@onready var match_list: VBoxContainer = $ui/body/left_body/search_vbox/scroll_container/match_list
@onready var match_create_vbox: VBoxContainer = $ui/body/right_body
@onready var new_match_name_input: LineEdit = $ui/body/right_body/create_match_hbox/new_match_name_input
@onready var rpc_signals: Node = $rpc_signals
@onready var client: LobbyClient = $client
var active_mode: String = "snooker"
var active_match: HBoxContainer = null
func _on_home_bttn_pressed() -> void:
Globals.game_state.set_game_scene(
"res://scenes/screens/start_screen/start.tscn"
)
func _on_host_connect_bttn_pressed() -> void:
client.start_client(host_address_input.text, int(host_port_range.value))
func _on_host_disconnect_bttn_pressed() -> void:
match_create_vbox.visible = false
search_vbox.visible = false
host_disconnect_bttn.visible = false
host_connect_bttn.visible = true
for match_block in match_list.get_children():
match_block.queue_free()
client.close_connection()
func _on_match_search_bttn_pressed() -> void:
pass
func _on_match_create_bttn_pressed() -> void:
if active_match: return
var match_entry: Dictionary = {
"name": new_match_name_input.text,
"type": active_mode
}
#MessageBus.emit_request.rpc_id(1, "match_list_add_entry", match_entry)
MessageBus.emit_request.rpc("match_list_add_entry", match_entry)
func _on_mode_bttn_pressed(button: Button) -> void:
active_mode = button.text.remove_chars("-").to_lower()