43 lines
1.2 KiB
GDScript3
43 lines
1.2 KiB
GDScript3
|
|
class_name Lobby extends LobbyBase
|
||
|
|
|
||
|
|
|
||
|
|
@onready var rpc_signals: Node = $rpc_signals
|
||
|
|
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
Globals.lobby_data.lobby_ui = self
|
||
|
|
setup_signals()
|
||
|
|
|
||
|
|
func _exit_tree() -> void:
|
||
|
|
if server.peer:
|
||
|
|
server.close_connection()
|
||
|
|
|
||
|
|
func setup_signals() -> void:
|
||
|
|
rpc_signals.server_host_started.connect(_server_host_started)
|
||
|
|
rpc_signals.match_list_entry_added.connect(_on_match_list_entry_added)
|
||
|
|
rpc_signals.match_list_entry_removed.connect(_on_match_list_entry_removed)
|
||
|
|
|
||
|
|
func _server_host_started() -> void:
|
||
|
|
host_start_bttn.visible = false
|
||
|
|
host_stop_bttn.visible = true
|
||
|
|
|
||
|
|
func _on_match_list_entry_added(match_entry: Dictionary) -> void:
|
||
|
|
push_warning("Client: Added Match List Entry... ", match_entry)
|
||
|
|
|
||
|
|
_create_match_entry(match_entry)
|
||
|
|
|
||
|
|
func _on_match_list_entry_removed(match_id: String) -> void:
|
||
|
|
push_warning("Client: Removed Match List Entry... ", match_id)
|
||
|
|
|
||
|
|
for match_entry in match_list.get_children():
|
||
|
|
if not match_id == match_entry.match_id: continue
|
||
|
|
match_entry.queue_free()
|
||
|
|
|
||
|
|
func _create_match_entry(match_entry: Dictionary) -> void:
|
||
|
|
var container = MATCH_ENTRY.instantiate()
|
||
|
|
match_list.add_child(container)
|
||
|
|
|
||
|
|
container.name_lbl.text = match_entry.name
|
||
|
|
container.type_lbl.text = match_entry.type
|
||
|
|
container.match_id = match_entry.match_id
|