summaryrefslogtreecommitdiff
path: root/UI
diff options
context:
space:
mode:
Diffstat (limited to 'UI')
-rw-r--r--UI/Camera.gd3
-rw-r--r--UI/GameLobby/game_lobby.gd29
-rw-r--r--UI/GameLobby/game_lobby.tscn23
-rw-r--r--UI/GameLobby/lobby_game.gd1
-rw-r--r--UI/PlayerLobby/lobby.gd3
5 files changed, 52 insertions, 7 deletions
diff --git a/UI/Camera.gd b/UI/Camera.gd
index 1fd9361..34e194c 100644
--- a/UI/Camera.gd
+++ b/UI/Camera.gd
@@ -63,7 +63,8 @@ func _input(event):
Input.set_default_cursor_shape(Input.CURSOR_MOVE)
elif event.is_action_released("camera_drag"):
is_in_drag_mode = false
- Input.set_default_cursor_shape(Input.CURSOR_ARROW)
+ if Input.get_current_cursor_shape() == Input.CURSOR_MOVE:
+ Input.set_default_cursor_shape(Input.CURSOR_ARROW)
if event is InputEventMouseMotion:
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:
diff --git a/UI/PlayerLobby/lobby.gd b/UI/PlayerLobby/lobby.gd
index 4169478..8c1c4a9 100644
--- a/UI/PlayerLobby/lobby.gd
+++ b/UI/PlayerLobby/lobby.gd
@@ -45,7 +45,7 @@ func _ready() -> void:
if multiplayer.is_server():
$KeepAliveTimer.start()
$KeepAliveTimer.timeout.connect(func():
- GameLobby.request_post("/keep-alive")
+ await GameLobby.request_post("/keep-alive")
)
@@ -77,6 +77,7 @@ func update_list(current_list: Control, player_ids: Array):
control.get_child(0).text = str(player.username)
control.get_child(0).tooltip_text = str(id)
current_list.move_child(control, player_ids.find(id) + 1)
+ # TODO: test with 3 players
func _on_peer_connected(id):