fix: search game

pull/10/head
Евгений Сугоняко 2024-05-17 15:29:11 +03:00
parent e05ded74a9
commit 92b7090e9c
1 changed files with 13 additions and 4 deletions

View File

@ -2,6 +2,7 @@ extends Node
@export var GameBox : VBoxContainer @export var GameBox : VBoxContainer
@export var SearchLine : LineEdit
func _ready(): func _ready():
@ -12,14 +13,22 @@ func create_game(_gameData:Dictionary):
rpc_id(1, "rpc_create_game", _gameData) rpc_id(1, "rpc_create_game", _gameData)
func _on_search_button_button_up():
if SearchLine.text == "":
rpc_id(1, "rpc_get_games_list")
else:
rpc_id(1, "rpc_get_game", SearchLine.text)
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
# RPC Client # RPC Client
@rpc("authority", "call_local", "unreliable", 2) @rpc("authority", "call_local", "unreliable", 2)
func rpc_set_games_list(_games:Array): func rpc_set_games_list(_games:Array):
for game in _games: if _games.size() > 0:
var gameLabel = preload("res://data/scenes/lobbies/GameLabel.tscn").instantiate() for game in _games:
gameLabel.set_game_data(game) var gameLabel = preload("res://data/scenes/lobbies/GameLabel.tscn").instantiate()
GameBox.add_child(gameLabel) gameLabel.set_game_data(game)
GameBox.add_child(gameLabel)
if GATEWAY.debug: if GATEWAY.debug:
print("Get games list") print("Get games list")