2026-08-07 02:50:54 -05:00
|
|
|
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
|
2026-08-09 18:41:18 -05:00
|
|
|
@onready var client: LobbyClient = $client
|
2026-08-07 02:50:54 -05:00
|
|
|
|
|
|
|
|
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:
|
2026-08-10 00:40:45 -05:00
|
|
|
Globals.game_data.game_address = host_address_input.text
|
|
|
|
|
Globals.game_data.game_port = int(host_port_range.value)
|
|
|
|
|
client.start_client(
|
|
|
|
|
Globals.game_data.game_address, Globals.game_data.game_port
|
|
|
|
|
)
|
2026-08-07 02:50:54 -05:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-09 18:41:18 -05:00
|
|
|
#MessageBus.emit_request.rpc_id(1, "match_list_add_entry", match_entry)
|
|
|
|
|
MessageBus.emit_request.rpc("match_list_add_entry", match_entry)
|
2026-08-07 02:50:54 -05:00
|
|
|
|
|
|
|
|
func _on_mode_bttn_pressed(button: Button) -> void:
|
|
|
|
|
active_mode = button.text.remove_chars("-").to_lower()
|