From 92b7090e9c9942c1bf9a5b5f40b852a2988580d2 Mon Sep 17 00:00:00 2001 From: no_name_user_7718 Date: Fri, 17 May 2024 15:29:11 +0300 Subject: [PATCH] fix: search game --- data/scenes/lobbies/GamesSinhronizer.gd | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/data/scenes/lobbies/GamesSinhronizer.gd b/data/scenes/lobbies/GamesSinhronizer.gd index 94b969d..f7cec36 100644 --- a/data/scenes/lobbies/GamesSinhronizer.gd +++ b/data/scenes/lobbies/GamesSinhronizer.gd @@ -2,6 +2,7 @@ extends Node @export var GameBox : VBoxContainer +@export var SearchLine : LineEdit func _ready(): @@ -12,14 +13,22 @@ func create_game(_gameData:Dictionary): 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("authority", "call_local", "unreliable", 2) func rpc_set_games_list(_games:Array): - for game in _games: - var gameLabel = preload("res://data/scenes/lobbies/GameLabel.tscn").instantiate() - gameLabel.set_game_data(game) - GameBox.add_child(gameLabel) + if _games.size() > 0: + for game in _games: + var gameLabel = preload("res://data/scenes/lobbies/GameLabel.tscn").instantiate() + gameLabel.set_game_data(game) + GameBox.add_child(gameLabel) if GATEWAY.debug: print("Get games list")