summaryrefslogtreecommitdiff
path: root/UI/GameLobby
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-21 14:15:11 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-21 14:15:11 +0100
commit5b35174ffab42f0331f1a6527ef6bbab7a3dbdcb (patch)
tree071530353b02f45fffc26aa4b0f43f7b901b3046 /UI/GameLobby
parenta854a1862a30632e49520f6e1e11333d5c8ff241 (diff)
next commitHEADmain
Diffstat (limited to 'UI/GameLobby')
-rw-r--r--UI/GameLobby/game_lobby.gd29
-rw-r--r--UI/GameLobby/game_lobby.tscn23
-rw-r--r--UI/GameLobby/lobby_game.gd1
3 files changed, 48 insertions, 5 deletions
diff --git a/UI/GameLobby/game_lobby.gd b/UI/GameLobby/game_lobby.gd
index 85a8a91..f80015b 100644
--- a/UI/GameLobby/game_lobby.gd
+++ b/UI/GameLobby/game_lobby.gd
@@ -11,6 +11,8 @@ var refresh_interval := 15.0
func _ready() -> void:
%GamesList.get_child(0).queue_free()
+ %ServerUrl.text = GameLobby.server_base_url
+
if await check_game_lobby_available():
get_server_list()
$RefreshTimer.wait_time = refresh_interval
@@ -36,11 +38,16 @@ func get_server_list():
for node in %GamesList.get_children():
node.queue_free()
- for game in result["data"]:
- var lobby_game = lobby_game_scene.instantiate()
- lobby_game.game_id = game["id"]
- lobby_game.game_name = game["name"]
- %GamesList.add_child(lobby_game)
+ if result["data"].size() > 0:
+ %NoGamesFound.visible = false
+
+ for game in result["data"]:
+ var lobby_game = lobby_game_scene.instantiate()
+ lobby_game.game_id = game["id"]
+ lobby_game.game_name = game["name"]
+ %GamesList.add_child(lobby_game)
+ else:
+ %NoGamesFound.visible = true
func _on_back_button_pressed() -> void:
@@ -55,3 +62,15 @@ func _on_refresh_pressed() -> void:
func _on_refresh_timer_timeout() -> void:
get_server_list()
+
+
+func _on_set_server_pressed() -> void:
+ var config = Client.get_config()
+ config.set_value(
+ "general",
+ "game_lobby_server_base_url",
+ %ServerUrl.text
+ )
+ config.save("user://config")
+
+ GameLobby.server_base_url = %ServerUrl.text
diff --git a/UI/GameLobby/game_lobby.tscn b/UI/GameLobby/game_lobby.tscn
index 241dbe5..8c632d6 100644
--- a/UI/GameLobby/game_lobby.tscn
+++ b/UI/GameLobby/game_lobby.tscn
@@ -61,6 +61,7 @@ unique_name_in_owner = true
layout_mode = 2
[node name="LobbyGame" parent="MarginContainer/CenterContainer/GamesList" instance=ExtResource("3_83gpr")]
+visible = false
layout_mode = 2
[node name="ServerNotReachable" type="Label" parent="MarginContainer/CenterContainer"]
@@ -69,6 +70,12 @@ visible = false
layout_mode = 2
text = "Game Lobby Server at %SERVER% not reachable"
+[node name="NoGamesFound" type="Label" parent="MarginContainer/CenterContainer"]
+unique_name_in_owner = true
+visible = false
+layout_mode = 2
+text = "No Games Found"
+
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
size_flags_horizontal = 8
@@ -87,8 +94,24 @@ layout_mode = 2
mouse_default_cursor_shape = 2
text = "Back"
+[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
+layout_mode = 2
+size_flags_horizontal = 8
+size_flags_vertical = 0
+
+[node name="ServerUrl" type="LineEdit" parent="MarginContainer/HBoxContainer"]
+unique_name_in_owner = true
+layout_mode = 2
+expand_to_text_length = true
+
+[node name="SetServer" type="Button" parent="MarginContainer/HBoxContainer"]
+unique_name_in_owner = true
+layout_mode = 2
+text = "Set Server"
+
[node name="RefreshTimer" type="Timer" parent="."]
[connection signal="pressed" from="MarginContainer/VBoxContainer/Refresh" to="." method="_on_refresh_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/BackButton" to="." method="_on_back_button_pressed"]
+[connection signal="pressed" from="MarginContainer/HBoxContainer/SetServer" to="." method="_on_set_server_pressed"]
[connection signal="timeout" from="RefreshTimer" to="." method="_on_refresh_timer_timeout"]
diff --git a/UI/GameLobby/lobby_game.gd b/UI/GameLobby/lobby_game.gd
index 2433dfd..39f9076 100644
--- a/UI/GameLobby/lobby_game.gd
+++ b/UI/GameLobby/lobby_game.gd
@@ -16,6 +16,7 @@ func _on_join_pressed() -> void:
var result = response.parse_json()
var game_data = result["data"]
+ print(game_data)
Network.join_game(game_data["ip"], game_data["port"])
get_tree().change_scene_to_file("res://UI/PlayerLobby/Lobby.tscn")
else: