summaryrefslogtreecommitdiff
path: root/UI
diff options
context:
space:
mode:
Diffstat (limited to 'UI')
-rw-r--r--UI/Assets/Enjl-Starry Space Background/background_1.pngbin0 -> 1360 bytes
-rw-r--r--UI/Assets/Enjl-Starry Space Background/background_1.png.import34
-rw-r--r--UI/Assets/Enjl-Starry Space Background/background_2.pngbin0 -> 1031 bytes
-rw-r--r--UI/Assets/Enjl-Starry Space Background/background_2.png.import34
-rw-r--r--UI/Assets/Enjl-Starry Space Background/background_3.pngbin0 -> 1069 bytes
-rw-r--r--UI/Assets/Enjl-Starry Space Background/background_3.png.import34
-rw-r--r--UI/Assets/Enjl-Starry Space Background/background_4.pngbin0 -> 1357 bytes
-rw-r--r--UI/Assets/Enjl-Starry Space Background/background_4.png.import34
-rw-r--r--UI/Camera.gd3
-rw-r--r--UI/Camera.gd.uid1
-rw-r--r--UI/Camera.tscn2
-rw-r--r--UI/CollisionVisibilityArea.tscn2
-rw-r--r--UI/ContainContainer.tscn2
-rw-r--r--UI/GameMenu.tscn2
-rw-r--r--UI/GamesLobby/games_lobby.gd76
-rw-r--r--UI/GamesLobby/games_lobby.gd.uid1
-rw-r--r--UI/GamesLobby/games_lobby.tscn117
-rw-r--r--UI/GamesLobby/lobby_game.gd23
-rw-r--r--UI/GamesLobby/lobby_game.gd.uid1
-rw-r--r--UI/GamesLobby/lobby_game.tscn19
-rw-r--r--UI/HPBar.tscn2
-rw-r--r--UI/PlayerLobby/Lobby.tscn (renamed from UI/Lobby.tscn)110
-rw-r--r--UI/PlayerLobby/lobby.gd213
-rw-r--r--UI/PlayerLobby/lobby.gd.uid1
-rw-r--r--UI/PlayerLobby/lobby_setting.gd42
-rw-r--r--UI/PlayerLobby/lobby_setting.gd.uid1
-rw-r--r--UI/PlayerLobby/lobby_setting.tscn21
-rw-r--r--UI/PlayerLobby/lobby_theme.tres (renamed from UI/lobby_theme.tres)0
-rw-r--r--UI/PlayerLobby/map_button.gd6
-rw-r--r--UI/PlayerLobby/map_button.gd.uid1
-rw-r--r--UI/PlayerLobby/map_button.tscn9
-rw-r--r--UI/PlayersList.tscn2
-rw-r--r--UI/SpawnButton.tscn2
-rw-r--r--UI/Start.gd46
-rw-r--r--UI/Start.gd.uid1
-rw-r--r--UI/Start.tscn63
-rw-r--r--UI/TowerConfiguration.tscn2
-rw-r--r--UI/collision_visibility_area.gd.uid1
-rw-r--r--UI/contain_container.gd.uid1
-rw-r--r--UI/game_menu.gd.uid1
-rw-r--r--UI/hp_bar.gd19
-rw-r--r--UI/hp_bar.gd.uid1
-rw-r--r--UI/lobby.gd95
-rw-r--r--UI/players_list.gd.uid1
-rw-r--r--UI/players_list_container.gd24
-rw-r--r--UI/players_list_container.gd.uid1
-rw-r--r--UI/players_list_container.tscn54
-rw-r--r--UI/sliding_background.gdshader.uid1
-rw-r--r--UI/spawn_button.gd16
-rw-r--r--UI/spawn_button.gd.uid1
-rw-r--r--UI/tower_configuration.gd.uid1
51 files changed, 936 insertions, 188 deletions
diff --git a/UI/Assets/Enjl-Starry Space Background/background_1.png b/UI/Assets/Enjl-Starry Space Background/background_1.png
new file mode 100644
index 0000000..0c5f4db
--- /dev/null
+++ b/UI/Assets/Enjl-Starry Space Background/background_1.png
Binary files differ
diff --git a/UI/Assets/Enjl-Starry Space Background/background_1.png.import b/UI/Assets/Enjl-Starry Space Background/background_1.png.import
new file mode 100644
index 0000000..2f8173b
--- /dev/null
+++ b/UI/Assets/Enjl-Starry Space Background/background_1.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://kwgx33awj4y2"
+path="res://.godot/imported/background_1.png-7e438384413b8871a8afa17dff70ac05.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://UI/Assets/Enjl-Starry Space Background/background_1.png"
+dest_files=["res://.godot/imported/background_1.png-7e438384413b8871a8afa17dff70ac05.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/UI/Assets/Enjl-Starry Space Background/background_2.png b/UI/Assets/Enjl-Starry Space Background/background_2.png
new file mode 100644
index 0000000..a235905
--- /dev/null
+++ b/UI/Assets/Enjl-Starry Space Background/background_2.png
Binary files differ
diff --git a/UI/Assets/Enjl-Starry Space Background/background_2.png.import b/UI/Assets/Enjl-Starry Space Background/background_2.png.import
new file mode 100644
index 0000000..00385eb
--- /dev/null
+++ b/UI/Assets/Enjl-Starry Space Background/background_2.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://cp5mtdbyy8omw"
+path="res://.godot/imported/background_2.png-cb39a76cad6a4a776cf02a04592ad83f.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://UI/Assets/Enjl-Starry Space Background/background_2.png"
+dest_files=["res://.godot/imported/background_2.png-cb39a76cad6a4a776cf02a04592ad83f.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/UI/Assets/Enjl-Starry Space Background/background_3.png b/UI/Assets/Enjl-Starry Space Background/background_3.png
new file mode 100644
index 0000000..4b27ae0
--- /dev/null
+++ b/UI/Assets/Enjl-Starry Space Background/background_3.png
Binary files differ
diff --git a/UI/Assets/Enjl-Starry Space Background/background_3.png.import b/UI/Assets/Enjl-Starry Space Background/background_3.png.import
new file mode 100644
index 0000000..09c2e7f
--- /dev/null
+++ b/UI/Assets/Enjl-Starry Space Background/background_3.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://br8j56w0tahv3"
+path="res://.godot/imported/background_3.png-f4ce54baeff343ebed337e7f45439d89.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://UI/Assets/Enjl-Starry Space Background/background_3.png"
+dest_files=["res://.godot/imported/background_3.png-f4ce54baeff343ebed337e7f45439d89.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/UI/Assets/Enjl-Starry Space Background/background_4.png b/UI/Assets/Enjl-Starry Space Background/background_4.png
new file mode 100644
index 0000000..b40730a
--- /dev/null
+++ b/UI/Assets/Enjl-Starry Space Background/background_4.png
Binary files differ
diff --git a/UI/Assets/Enjl-Starry Space Background/background_4.png.import b/UI/Assets/Enjl-Starry Space Background/background_4.png.import
new file mode 100644
index 0000000..353d5cd
--- /dev/null
+++ b/UI/Assets/Enjl-Starry Space Background/background_4.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://iu0tc1luyuhv"
+path="res://.godot/imported/background_4.png-d90a2b266e3c1dbc29f3ad6c557346d3.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://UI/Assets/Enjl-Starry Space Background/background_4.png"
+dest_files=["res://.godot/imported/background_4.png-d90a2b266e3c1dbc29f3ad6c557346d3.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
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/Camera.gd.uid b/UI/Camera.gd.uid
new file mode 100644
index 0000000..9482336
--- /dev/null
+++ b/UI/Camera.gd.uid
@@ -0,0 +1 @@
+uid://cdtjyj7ivtru1
diff --git a/UI/Camera.tscn b/UI/Camera.tscn
index 869cd53..061332b 100644
--- a/UI/Camera.tscn
+++ b/UI/Camera.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://t8feyd2giabm"]
-[ext_resource type="Script" path="res://UI/Camera.gd" id="1_yiia3"]
+[ext_resource type="Script" uid="uid://cdtjyj7ivtru1" path="res://UI/Camera.gd" id="1_yiia3"]
[node name="Camera" type="Camera2D" groups=["camera"]]
anchor_mode = 0
diff --git a/UI/CollisionVisibilityArea.tscn b/UI/CollisionVisibilityArea.tscn
index 8ddcb01..aa02f7c 100644
--- a/UI/CollisionVisibilityArea.tscn
+++ b/UI/CollisionVisibilityArea.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cddsncmdb8g2j"]
-[ext_resource type="Script" path="res://UI/collision_visibility_area.gd" id="1_8fa5c"]
+[ext_resource type="Script" uid="uid://d1hu2usw8lyu2" path="res://UI/collision_visibility_area.gd" id="1_8fa5c"]
[node name="CollisionVisibilityArea" type="Area2D"]
script = ExtResource("1_8fa5c")
diff --git a/UI/ContainContainer.tscn b/UI/ContainContainer.tscn
index d9120ed..2bac30a 100644
--- a/UI/ContainContainer.tscn
+++ b/UI/ContainContainer.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://pchnqnutfth7"]
-[ext_resource type="Script" path="res://UI/contain_container.gd" id="1_oswre"]
+[ext_resource type="Script" uid="uid://bcx8c2kwehj4m" path="res://UI/contain_container.gd" id="1_oswre"]
[node name="ContainContainer" type="Container"]
script = ExtResource("1_oswre")
diff --git a/UI/GameMenu.tscn b/UI/GameMenu.tscn
index cf6646e..381b024 100644
--- a/UI/GameMenu.tscn
+++ b/UI/GameMenu.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://c13v4wmjm4sev"]
-[ext_resource type="Script" path="res://UI/game_menu.gd" id="1_frq7d"]
+[ext_resource type="Script" uid="uid://doa661nvsiwtb" path="res://UI/game_menu.gd" id="1_frq7d"]
[node name="GameMenu" type="Control"]
layout_mode = 3
diff --git a/UI/GamesLobby/games_lobby.gd b/UI/GamesLobby/games_lobby.gd
new file mode 100644
index 0000000..b829337
--- /dev/null
+++ b/UI/GamesLobby/games_lobby.gd
@@ -0,0 +1,76 @@
+extends Control
+
+
+var games := []
+
+var refresh_interval := 15.0
+
+@onready var lobby_game_scene := preload("res://UI/GamesLobby/lobby_game.tscn")
+
+
+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
+ $RefreshTimer.start()
+ else:
+ %ServerNotReachable.text = %ServerNotReachable.text.replace("%SERVER%", GameLobby.server_base_url)
+
+
+func check_game_lobby_available():
+ var is_available = await GameLobby.check_available()
+
+ %ServerNotReachable.visible = !is_available
+
+ return is_available
+
+
+func get_server_list():
+ var response = await GameLobby.request_get("/get-list")
+ var result = response.parse_json()
+ print(result)
+
+ if result["success"]:
+ for node in %GamesList.get_children():
+ node.queue_free()
+
+ 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:
+ get_tree().change_scene_to_file("res://UI/Start.tscn")
+
+
+func _on_refresh_pressed() -> void:
+ if await check_game_lobby_available():
+ get_server_list()
+ $RefreshTimer.start(refresh_interval)
+
+
+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/GamesLobby/games_lobby.gd.uid b/UI/GamesLobby/games_lobby.gd.uid
new file mode 100644
index 0000000..f884ee2
--- /dev/null
+++ b/UI/GamesLobby/games_lobby.gd.uid
@@ -0,0 +1 @@
+uid://ch3yprxw8y15i
diff --git a/UI/GamesLobby/games_lobby.tscn b/UI/GamesLobby/games_lobby.tscn
new file mode 100644
index 0000000..bbcde3b
--- /dev/null
+++ b/UI/GamesLobby/games_lobby.tscn
@@ -0,0 +1,117 @@
+[gd_scene load_steps=5 format=3 uid="uid://b0uqf5h2j7fvk"]
+
+[ext_resource type="Script" uid="uid://ch3yprxw8y15i" path="res://UI/GamesLobby/games_lobby.gd" id="1_4dbpy"]
+[ext_resource type="Texture2D" uid="uid://kwgx33awj4y2" path="res://UI/Assets/Enjl-Starry Space Background/background_1.png" id="2_up3jk"]
+[ext_resource type="PackedScene" uid="uid://cs2a7wfrj4wn0" path="res://UI/GamesLobby/lobby_game.tscn" id="3_wofvj"]
+[ext_resource type="Theme" uid="uid://bt84t61hrvoyn" path="res://UI/PlayerLobby/lobby_theme.tres" id="4_k7oqv"]
+
+[node name="GamesLobby" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+script = ExtResource("1_4dbpy")
+
+[node name="Background" type="Control" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="ColorRect" type="ColorRect" parent="Background"]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+color = Color(0, 0, 0, 1)
+
+[node name="TextureRect" type="TextureRect" parent="Background"]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+texture = ExtResource("2_up3jk")
+stretch_mode = 1
+
+[node name="MarginContainer" type="MarginContainer" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme_override_constants/margin_left = 4
+theme_override_constants/margin_top = 4
+theme_override_constants/margin_right = 4
+theme_override_constants/margin_bottom = 4
+
+[node name="CenterContainer" type="CenterContainer" parent="MarginContainer"]
+layout_mode = 2
+
+[node name="GamesList" type="VBoxContainer" parent="MarginContainer/CenterContainer"]
+unique_name_in_owner = true
+layout_mode = 2
+
+[node name="LobbyGame" parent="MarginContainer/CenterContainer/GamesList" instance=ExtResource("3_wofvj")]
+visible = false
+layout_mode = 2
+
+[node name="ServerNotReachable" type="Label" parent="MarginContainer/CenterContainer"]
+unique_name_in_owner = true
+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
+size_flags_vertical = 8
+theme = ExtResource("4_k7oqv")
+
+[node name="Refresh" type="Button" parent="MarginContainer/VBoxContainer"]
+unique_name_in_owner = true
+layout_mode = 2
+mouse_default_cursor_shape = 2
+text = "Refresh"
+
+[node name="BackButton" type="Button" parent="MarginContainer/VBoxContainer"]
+unique_name_in_owner = true
+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/GamesLobby/lobby_game.gd b/UI/GamesLobby/lobby_game.gd
new file mode 100644
index 0000000..39f9076
--- /dev/null
+++ b/UI/GamesLobby/lobby_game.gd
@@ -0,0 +1,23 @@
+extends HBoxContainer
+
+@export var game_id := ""
+@export var game_name := "":
+ set = set_game_name
+
+
+func set_game_name(value):
+ game_name = value
+ %Name.text = value
+
+
+func _on_join_pressed() -> void:
+ var response = await GameLobby.request_get("/join?id=%s" % [game_id])
+ if response.response_code == 200:
+ 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:
+ print(response.response_code)
diff --git a/UI/GamesLobby/lobby_game.gd.uid b/UI/GamesLobby/lobby_game.gd.uid
new file mode 100644
index 0000000..5ea3c00
--- /dev/null
+++ b/UI/GamesLobby/lobby_game.gd.uid
@@ -0,0 +1 @@
+uid://ipkke6duqoi6
diff --git a/UI/GamesLobby/lobby_game.tscn b/UI/GamesLobby/lobby_game.tscn
new file mode 100644
index 0000000..22f5525
--- /dev/null
+++ b/UI/GamesLobby/lobby_game.tscn
@@ -0,0 +1,19 @@
+[gd_scene load_steps=2 format=3 uid="uid://cs2a7wfrj4wn0"]
+
+[ext_resource type="Script" uid="uid://ipkke6duqoi6" path="res://UI/GamesLobby/lobby_game.gd" id="1_cvsql"]
+
+[node name="LobbyGame" type="HBoxContainer"]
+script = ExtResource("1_cvsql")
+
+[node name="Name" type="Label" parent="."]
+unique_name_in_owner = true
+layout_mode = 2
+text = "Game Name"
+
+[node name="Join" type="Button" parent="."]
+unique_name_in_owner = true
+layout_mode = 2
+mouse_default_cursor_shape = 2
+text = "Join"
+
+[connection signal="pressed" from="Join" to="." method="_on_join_pressed"]
diff --git a/UI/HPBar.tscn b/UI/HPBar.tscn
index fdd0542..7d03e1f 100644
--- a/UI/HPBar.tscn
+++ b/UI/HPBar.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=8 format=3 uid="uid://bjcrf4o4a80iv"]
-[ext_resource type="Script" path="res://UI/hp_bar.gd" id="1_63fia"]
+[ext_resource type="Script" uid="uid://cndetkp0v8w8y" path="res://UI/hp_bar.gd" id="1_63fia"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_c6ayl"]
diff --git a/UI/Lobby.tscn b/UI/PlayerLobby/Lobby.tscn
index 6c7f1f7..05eaea1 100644
--- a/UI/Lobby.tscn
+++ b/UI/PlayerLobby/Lobby.tscn
@@ -1,13 +1,16 @@
-[gd_scene load_steps=9 format=3 uid="uid://r45j806p4a74"]
+[gd_scene load_steps=12 format=3 uid="uid://r45j806p4a74"]
-[ext_resource type="Script" path="res://UI/lobby.gd" id="1_mm4gt"]
-[ext_resource type="Theme" uid="uid://bt84t61hrvoyn" path="res://UI/lobby_theme.tres" id="2_syjfh"]
-[ext_resource type="PackedScene" uid="uid://bl65jllb3e2py" path="res://Stages/Wintermaul/Wintermaul.tscn" id="3_3hc3h"]
+[ext_resource type="Script" uid="uid://87etsgjm04nb" path="res://UI/PlayerLobby/lobby.gd" id="1_mm4gt"]
+[ext_resource type="Texture2D" uid="uid://kwgx33awj4y2" path="res://UI/Assets/Enjl-Starry Space Background/background_1.png" id="2_0pdjl"]
+[ext_resource type="Theme" uid="uid://bt84t61hrvoyn" path="res://UI/PlayerLobby/lobby_theme.tres" id="2_syjfh"]
+[ext_resource type="PackedScene" uid="uid://cq6p055yuac0o" path="res://UI/players_list_container.tscn" id="3_2r7nj"]
[ext_resource type="Texture2D" uid="uid://ci7qydmwbanbp" path="res://Stages/Wintermaul/Assets/thumbnail.png" id="3_8r1n2"]
[ext_resource type="PackedScene" uid="uid://dwscklgkbhq28" path="res://Stages/Wintermaul2/Wintermaul2.tscn" id="4_v1caa"]
+[ext_resource type="PackedScene" uid="uid://uwfmfa3c0gqk" path="res://UI/PlayerLobby/map_button.tscn" id="5_3omml"]
[ext_resource type="Texture2D" uid="uid://cfiu7ah67vdpg" path="res://Stages/Square/Assets/thumbnail.png" id="5_5ewsi"]
-[ext_resource type="PackedScene" uid="uid://jxy7fj7yymfl" path="res://Stages/TinySwords/WintermaulTinySwords.tscn" id="5_hnsfx"]
[ext_resource type="Texture2D" uid="uid://cujvoqsqfrl4a" path="res://Stages/Wintermaul2/Assets/thumbnail.png" id="5_j23oc"]
+[ext_resource type="PackedScene" uid="uid://bl65jllb3e2py" path="res://Stages/Wintermaul/Wintermaul.tscn" id="6_qk8ma"]
+[ext_resource type="PackedScene" uid="uid://cw0hxxa1m1qm7" path="res://Stages/Square/square.tscn" id="8_qk8ma"]
[node name="Lobby" type="Control"]
layout_mode = 3
@@ -18,6 +21,33 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_mm4gt")
+[node name="Background" type="Control" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="ColorRect" type="ColorRect" parent="Background"]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+color = Color(0, 0, 0, 1)
+
+[node name="TextureRect" type="TextureRect" parent="Background"]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+texture = ExtResource("2_0pdjl")
+stretch_mode = 1
+
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
@@ -42,35 +72,13 @@ layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 32
-[node name="PanelContainer" type="PanelContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer"]
-layout_mode = 2
-size_flags_horizontal = 3
-
-[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/PanelContainer"]
-layout_mode = 2
-theme_override_constants/margin_left = 16
-theme_override_constants/margin_top = 16
-theme_override_constants/margin_right = 16
-theme_override_constants/margin_bottom = 16
-
-[node name="PlayersList" type="VBoxContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/PanelContainer/MarginContainer"]
+[node name="Teams" type="VBoxContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer"]
unique_name_in_owner = true
-custom_minimum_size = Vector2(0, 100)
-layout_mode = 2
-
-[node name="Control" type="MarginContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/PanelContainer/MarginContainer/PlayersList"]
layout_mode = 2
-[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/PanelContainer/MarginContainer/PlayersList/Control"]
-layout_mode = 2
-text = "A"
-
-[node name="Control2" type="MarginContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/PanelContainer/MarginContainer/PlayersList"]
-layout_mode = 2
-
-[node name="Label2" type="Label" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/PanelContainer/MarginContainer/PlayersList/Control2"]
+[node name="PlayersListContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Teams" instance=ExtResource("3_2r7nj")]
+unique_name_in_owner = true
layout_mode = 2
-text = "B"
[node name="Maps" type="VBoxContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer"]
unique_name_in_owner = true
@@ -78,36 +86,23 @@ layout_mode = 2
size_flags_horizontal = 3
theme = ExtResource("2_syjfh")
-[node name="MapButton" type="Button" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Maps"]
+[node name="MapButton" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Maps" instance=ExtResource("5_3omml")]
layout_mode = 2
-mouse_default_cursor_shape = 2
-toggle_mode = true
-text = "Wintermaul"
-metadata/map_scene = ExtResource("3_3hc3h")
-metadata/thumbnail = ExtResource("3_8r1n2")
+map_scene = ExtResource("6_qk8ma")
+thumbnail = ExtResource("3_8r1n2")
+settings = Array[String](["starting_lives", "starting_money", "starting_income", "use_premade_teams"])
-[node name="MapButton2" type="Button" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Maps"]
+[node name="MapButton2" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Maps" instance=ExtResource("5_3omml")]
layout_mode = 2
-mouse_default_cursor_shape = 2
-toggle_mode = true
text = "Squares"
-metadata/thumbnail = ExtResource("5_5ewsi")
+map_scene = ExtResource("8_qk8ma")
+thumbnail = ExtResource("5_5ewsi")
-[node name="MapButton3" type="Button" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Maps"]
+[node name="MapButton3" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Maps" instance=ExtResource("5_3omml")]
layout_mode = 2
-mouse_default_cursor_shape = 2
-toggle_mode = true
text = "Wintermaul 2"
-metadata/map_scene = ExtResource("4_v1caa")
-metadata/thumbnail = ExtResource("5_j23oc")
-
-[node name="MapButton4" type="Button" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Maps"]
-visible = false
-layout_mode = 2
-mouse_default_cursor_shape = 2
-toggle_mode = true
-text = "Wintermaul Tiny Swords"
-metadata/map_scene = ExtResource("5_hnsfx")
+map_scene = ExtResource("4_v1caa")
+thumbnail = ExtResource("5_j23oc")
[node name="Thumbnail" type="TextureRect" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer"]
unique_name_in_owner = true
@@ -117,6 +112,12 @@ texture = ExtResource("3_8r1n2")
expand_mode = 1
stretch_mode = 4
+[node name="Settings" type="VBoxContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer"]
+unique_name_in_owner = true
+layout_mode = 2
+size_flags_vertical = 0
+theme_override_constants/separation = 0
+
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 8
@@ -134,5 +135,8 @@ layout_mode = 2
mouse_default_cursor_shape = 2
text = "Cancel"
+[node name="KeepAliveTimer" type="Timer" parent="."]
+wait_time = 30.0
+
[connection signal="pressed" from="MarginContainer/VBoxContainer/VBoxContainer/StartButton" to="." method="_on_start_button_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/VBoxContainer/CancelButton" to="." method="_on_cancel_button_pressed"]
diff --git a/UI/PlayerLobby/lobby.gd b/UI/PlayerLobby/lobby.gd
new file mode 100644
index 0000000..c391a11
--- /dev/null
+++ b/UI/PlayerLobby/lobby.gd
@@ -0,0 +1,213 @@
+extends Control
+
+
+signal joined
+
+var current_map_idx := 0
+var current_map_scene: Node
+
+var settings := {}
+var teams := {}
+
+@onready var list: Control = %PlayersListContainer.list
+
+
+func _ready() -> void:
+ if not multiplayer.is_server():
+ %StartButton.disabled = true
+
+ if multiplayer.is_server():
+ joined.connect(func():
+ set_map.rpc(current_map_idx)
+ for setting in settings:
+ set_setting.rpc(setting, settings[setting])
+ # TODO: check that use_premade_teams behaves correctly on join
+ )
+
+ for idx in %Maps.get_child_count():
+ %Maps.get_child(idx).pressed.connect(func():
+ if current_map_idx != idx:
+ set_map.rpc(idx)
+ )
+
+ if not multiplayer.is_server():
+ for node: Control in %Maps.get_children():
+ node.mouse_filter = Control.MOUSE_FILTER_IGNORE
+
+ Network.players_changed.connect(update_players)
+ update_players()
+
+ multiplayer.peer_disconnected.connect(remove_player)
+ multiplayer.peer_connected.connect(_on_peer_connected)
+ multiplayer.peer_disconnected.connect(_on_peer_disconnected)
+
+ # reset map texture for clean load
+ %Thumbnail.texture = null
+ set_map(current_map_idx)
+
+ # send keep-alive to game-lobby-server
+ if multiplayer.is_server():
+ $KeepAliveTimer.start()
+ $KeepAliveTimer.timeout.connect(func():
+ await GameLobby.request_post("/keep-alive")
+ )
+
+
+func update_players():
+ update_list(list, Network.get_ordered_player_ids())
+
+
+func remove_player(id):
+ list.remove_child(list.get_node(str(id)))
+
+
+func update_list(current_list: Control, player_ids: Array):
+ for id in player_ids:
+ var player: Player = Network.get_player(id)
+
+ var control: Control = current_list.get_node_or_null(str(id))
+ if not control:
+ control = MarginContainer.new()
+ control.name = str(id)
+ var label = Label.new()
+ label.add_theme_color_override("font_color", player.get_color())
+ if id == multiplayer.get_unique_id():
+ label.add_theme_color_override("font_outline_color", Color(0.75, 0.75, 0.75, 0.75))
+ label.add_theme_constant_override("outline_size", 10)
+ control.add_child(label)
+ current_list.add_child(control)
+
+ 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)
+
+
+func _on_peer_connected(id):
+ Network._on_peer_connected(id)
+ joined.emit()
+
+func _on_peer_disconnected(id):
+ Network._on_peer_disconnected(id)
+
+
+func _on_start_button_pressed() -> void:
+ start.rpc(settings)
+
+
+func _on_cancel_button_pressed() -> void:
+ multiplayer.multiplayer_peer.close()
+
+ # TODO: if was host => Start. if was joined and connected from list => List
+ get_tree().change_scene_to_file("res://UI/Start.tscn")
+
+
+@rpc("authority", "call_local")
+func start(host_settings: Dictionary):
+ var packed_scene = %Maps.get_child(current_map_idx).map_scene
+ var scene = packed_scene.instantiate()
+
+ for setting in host_settings:
+ scene[setting] = host_settings[setting]
+
+ if host_settings.get("use_premade_teams"):
+ var premade_teams = {}
+ for team_name in teams:
+ premade_teams[team_name] = teams[team_name]["players"]
+ scene.premade_teams = premade_teams
+
+ multiplayer.multiplayer_peer.refuse_new_connections = true
+
+ Client.change_scene_to_instance(scene)
+
+
+@rpc("authority", "call_local")
+func set_map(index: int):
+ current_map_idx = index
+
+ for node: Control in %Teams.get_children().slice(1):
+ node.queue_free()
+ %PlayersListContainer.visible = true
+
+ for node: Button in %Maps.get_children():
+ node.add_theme_color_override("font_color", Color(1.0, 1.0, 1.0, 0.5))
+
+ var map_button = %Maps.get_child(index)
+ var thumbnail = map_button.thumbnail
+
+ # settings
+ for child in %Settings.get_children():
+ child.free()
+
+ if map_button.settings.size() > 0:
+ current_map_scene = map_button.map_scene.instantiate()
+ for setting in map_button.settings:
+ if not settings.has(setting):
+ settings[setting] = current_map_scene[setting]
+
+ var control = preload("res://UI/PlayerLobby/lobby_setting.tscn").instantiate()
+ control.label = setting
+ control.value = settings[setting]
+ control.disabled = !multiplayer.is_server()
+ if multiplayer.is_server():
+ control.value_changed.connect(func(value):
+ set_setting.rpc(setting, value)
+ )
+ %Settings.add_child(control)
+
+ map_button.add_theme_color_override("font_color", Color(1.0, 1.0, 1.0, 1.0))
+ %Thumbnail.texture = thumbnail
+
+
+@rpc("authority", "call_local")
+func set_setting(key: String, value: Variant):
+ settings[key] = value
+
+ if not multiplayer.is_server():
+ %Settings.get_node(key).value = value
+
+ # generate PlayersLists per team with clickable labels to switch team
+ if key == "use_premade_teams":
+ if value:
+ %PlayersListContainer.visible = false
+ var team_names = current_map_scene.teams.names()
+ var players_per_team = ceil(
+ float(Network.get_ordered_player_ids().size()) / float(team_names.size())
+ )
+
+ for idx in team_names.size():
+ var team_name = team_names[idx]
+
+ var new_list_container = preload("res://UI/players_list_container.tscn").instantiate()
+ new_list_container.label = team_name.to_upper()
+ new_list_container.clicked.connect(func():
+ switch_team.rpc(team_name)
+ )
+ %Teams.add_child(new_list_container)
+
+ var offset = players_per_team * idx
+ teams[team_name] = {}
+ teams[team_name]["players"] = Network.get_ordered_player_ids().slice(offset, offset + players_per_team)
+ teams[team_name]["list"] = new_list_container.list
+
+ update_list(teams[team_name]["list"], teams[team_name]["players"])
+ else:
+ for node in %Teams.get_children().slice(1): # get all but the main list
+ node.queue_free()
+
+ update_list(list, Network.get_ordered_player_ids())
+ %PlayersListContainer.visible = true
+
+
+@rpc("any_peer", "call_local")
+func switch_team(team_name: String):
+#func switch_team(previous_team_name: String, new_team_name: String):
+ var player_id = multiplayer.get_remote_sender_id()
+
+ for key in teams:
+ var team = teams[key]
+ team["players"].erase(player_id)
+ var node = team["list"].get_node_or_null(str(player_id))
+ if node: team["list"].remove_child(node)
+
+ teams[team_name]["players"].append(player_id)
+ update_list(teams[team_name]["list"], teams[team_name]["players"])
diff --git a/UI/PlayerLobby/lobby.gd.uid b/UI/PlayerLobby/lobby.gd.uid
new file mode 100644
index 0000000..f3af632
--- /dev/null
+++ b/UI/PlayerLobby/lobby.gd.uid
@@ -0,0 +1 @@
+uid://87etsgjm04nb
diff --git a/UI/PlayerLobby/lobby_setting.gd b/UI/PlayerLobby/lobby_setting.gd
new file mode 100644
index 0000000..8f0efe3
--- /dev/null
+++ b/UI/PlayerLobby/lobby_setting.gd
@@ -0,0 +1,42 @@
+extends HBoxContainer
+
+
+signal value_changed(value: Variant)
+
+var label := "":
+ set(value):
+ $Label.text = str(value)
+ name = str(value)
+ get():
+ return $Label.text
+
+var value: Variant = "":
+ set(new_value):
+ value = new_value
+ if typeof(new_value) == TYPE_BOOL:
+ $TextEdit.visible = false
+ $CheckBox.visible = true
+
+ $CheckBox.set_pressed_no_signal(new_value)
+ else:
+ $TextEdit.visible = true
+ $CheckBox.visible = false
+ $TextEdit.text = str(new_value)
+ get():
+ if typeof(value) == TYPE_BOOL:
+ return $CheckBox.button_pressed
+ else:
+ return $TextEdit.text
+
+var disabled := false:
+ set(value):
+ disabled = value
+ $TextEdit.editable = !value
+ $CheckBox.disabled = value
+
+
+func _on_text_edit_text_changed(new_text: String) -> void:
+ value_changed.emit(new_text)
+
+func _on_check_box_toggled(_toggled_on: bool) -> void:
+ value_changed.emit($CheckBox.button_pressed)
diff --git a/UI/PlayerLobby/lobby_setting.gd.uid b/UI/PlayerLobby/lobby_setting.gd.uid
new file mode 100644
index 0000000..b2bfbef
--- /dev/null
+++ b/UI/PlayerLobby/lobby_setting.gd.uid
@@ -0,0 +1 @@
+uid://b47vm2uggdqxn
diff --git a/UI/PlayerLobby/lobby_setting.tscn b/UI/PlayerLobby/lobby_setting.tscn
new file mode 100644
index 0000000..d4baded
--- /dev/null
+++ b/UI/PlayerLobby/lobby_setting.tscn
@@ -0,0 +1,21 @@
+[gd_scene load_steps=2 format=3 uid="uid://fgqkxat8pwjk"]
+
+[ext_resource type="Script" uid="uid://b47vm2uggdqxn" path="res://UI/PlayerLobby/lobby_setting.gd" id="1_ntovh"]
+
+[node name="LobbySetting" type="HBoxContainer"]
+size_flags_vertical = 2
+script = ExtResource("1_ntovh")
+
+[node name="Label" type="Label" parent="."]
+layout_mode = 2
+text = "Setting"
+
+[node name="TextEdit" type="LineEdit" parent="."]
+layout_mode = 2
+text = "5"
+
+[node name="CheckBox" type="CheckBox" parent="."]
+layout_mode = 2
+
+[connection signal="text_changed" from="TextEdit" to="." method="_on_text_edit_text_changed"]
+[connection signal="toggled" from="CheckBox" to="." method="_on_check_box_toggled"]
diff --git a/UI/lobby_theme.tres b/UI/PlayerLobby/lobby_theme.tres
index 0307ae1..0307ae1 100644
--- a/UI/lobby_theme.tres
+++ b/UI/PlayerLobby/lobby_theme.tres
diff --git a/UI/PlayerLobby/map_button.gd b/UI/PlayerLobby/map_button.gd
new file mode 100644
index 0000000..a52c2f7
--- /dev/null
+++ b/UI/PlayerLobby/map_button.gd
@@ -0,0 +1,6 @@
+extends Button
+
+
+@export var map_scene: PackedScene
+@export var thumbnail: Texture2D
+@export var settings: Array[String]
diff --git a/UI/PlayerLobby/map_button.gd.uid b/UI/PlayerLobby/map_button.gd.uid
new file mode 100644
index 0000000..6c7009f
--- /dev/null
+++ b/UI/PlayerLobby/map_button.gd.uid
@@ -0,0 +1 @@
+uid://c118jfgnuae7q
diff --git a/UI/PlayerLobby/map_button.tscn b/UI/PlayerLobby/map_button.tscn
new file mode 100644
index 0000000..c947db1
--- /dev/null
+++ b/UI/PlayerLobby/map_button.tscn
@@ -0,0 +1,9 @@
+[gd_scene load_steps=2 format=3 uid="uid://uwfmfa3c0gqk"]
+
+[ext_resource type="Script" uid="uid://c118jfgnuae7q" path="res://UI/PlayerLobby/map_button.gd" id="1_ks6re"]
+
+[node name="MapButton" type="Button"]
+mouse_default_cursor_shape = 2
+toggle_mode = true
+text = "Wintermaul"
+script = ExtResource("1_ks6re")
diff --git a/UI/PlayersList.tscn b/UI/PlayersList.tscn
index fabc008..a0ff21c 100644
--- a/UI/PlayersList.tscn
+++ b/UI/PlayersList.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=5 format=3 uid="uid://cxd6c4kbnk04c"]
-[ext_resource type="Script" path="res://UI/players_list.gd" id="1_67rpy"]
+[ext_resource type="Script" uid="uid://b8kj5jawk4ye6" path="res://UI/players_list.gd" id="1_67rpy"]
[ext_resource type="Theme" uid="uid://c7f1ftrx53ag1" path="res://theme.tres" id="1_igafg"]
[ext_resource type="PackedScene" uid="uid://dslebs7aarkoa" path="res://UI/panel_background_blue.tscn" id="2_3bkxi"]
[ext_resource type="PackedScene" uid="uid://wxe1hpn013y8" path="res://UI/PlayersListItem.tscn" id="2_ug8m7"]
diff --git a/UI/SpawnButton.tscn b/UI/SpawnButton.tscn
index a5954a0..78ab2d7 100644
--- a/UI/SpawnButton.tscn
+++ b/UI/SpawnButton.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://x6kohecnw7f5"]
-[ext_resource type="Script" path="res://UI/spawn_button.gd" id="1_ayei4"]
+[ext_resource type="Script" uid="uid://pm435vpllta1" path="res://UI/spawn_button.gd" id="1_ayei4"]
[node name="SpawnButton" type="TextureButton"]
texture_filter = 1
diff --git a/UI/Start.gd b/UI/Start.gd
index c9a0342..53b18fb 100644
--- a/UI/Start.gd
+++ b/UI/Start.gd
@@ -2,13 +2,18 @@ extends Control
func _ready():
+ multiplayer.peer_connected.connect(_on_peer_connected)
+ multiplayer.peer_disconnected.connect(_on_peer_disconnected)
+
if OS.has_environment("USER"):
- %Name.text = OS.get_environment("USER")
+ %Username.text = OS.get_environment("USER")
elif OS.has_environment("USERNAME"):
- %Name.text = OS.get_environment("USERNAME")
+ %Username.text = OS.get_environment("USERNAME")
+
+ %GameName.text = "%s's Game" % [%Username.text]
-func get_ip():
+func get_ip() -> String:
var ip := "127.0.0.1"
if %IP.text:
ip = %IP.text
@@ -16,20 +21,41 @@ func get_ip():
return ip
-func get_port():
- var port := 1234
+func get_port() -> int:
+ var port: int = Client.get_config().get_value("general", "host_default_port")
if %Port.text:
- port = %Port.text
+ port = int(%Port.text)
return port
+
+func _on_peer_connected(id):
+ Network._on_peer_connected(id)
+
+func _on_peer_disconnected(id):
+ Network._on_peer_disconnected(id)
+
+
func _on_host_pressed() -> void:
- Client.player.username = %Name.text
+ Client.player.username = %Username.text
+
+ var response = await GameLobby.request_post("/host", {"port": get_port(), "name" : %GameName.text})
+ if response.result_code == HTTPRequest.RESULT_SUCCESS:
+ var result = response.parse_json()
+ if result["success"]:
+ GameLobby.current_game_id = result["data"]["id"]
+ GameLobby.current_secret = result["data"]["secret"]
+
Network.host_game(get_port())
- get_tree().change_scene_to_file("res://UI/Lobby.tscn")
+ get_tree().change_scene_to_file("res://UI/PlayerLobby/Lobby.tscn")
func _on_join_pressed() -> void:
- Client.player.username = %Name.text
+ Client.player.username = %Username.text
Network.join_game(get_ip(), get_port())
- get_tree().change_scene_to_file("res://UI/Lobby.tscn")
+ get_tree().change_scene_to_file("res://UI/PlayerLobby/Lobby.tscn")
+
+
+func _on_search_pressed() -> void:
+ Client.player.username = %Username.text
+ get_tree().change_scene_to_file("res://UI/GamesLobby/games_lobby.tscn")
diff --git a/UI/Start.gd.uid b/UI/Start.gd.uid
new file mode 100644
index 0000000..4353185
--- /dev/null
+++ b/UI/Start.gd.uid
@@ -0,0 +1 @@
+uid://d2s0wofufuo05
diff --git a/UI/Start.tscn b/UI/Start.tscn
index b85d869..aa7d8b1 100644
--- a/UI/Start.tscn
+++ b/UI/Start.tscn
@@ -1,6 +1,8 @@
-[gd_scene load_steps=2 format=3 uid="uid://bcbxer883ygg7"]
+[gd_scene load_steps=4 format=3 uid="uid://bcbxer883ygg7"]
-[ext_resource type="Script" path="res://UI/Start.gd" id="1_h1h6c"]
+[ext_resource type="Script" uid="uid://d2s0wofufuo05" path="res://UI/Start.gd" id="1_h1h6c"]
+[ext_resource type="Theme" uid="uid://c7f1ftrx53ag1" path="res://theme.tres" id="1_uriow"]
+[ext_resource type="Texture2D" uid="uid://kwgx33awj4y2" path="res://UI/Assets/Enjl-Starry Space Background/background_1.png" id="2_fxy5w"]
[node name="Start" type="Control"]
layout_mode = 3
@@ -9,8 +11,36 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
+theme = ExtResource("1_uriow")
script = ExtResource("1_h1h6c")
+[node name="Background" type="Control" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="ColorRect" type="ColorRect" parent="Background"]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+color = Color(0, 0, 0, 1)
+
+[node name="TextureRect" type="TextureRect" parent="Background"]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+texture = ExtResource("2_fxy5w")
+stretch_mode = 1
+
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1
anchors_preset = 15
@@ -22,29 +52,35 @@ grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
layout_mode = 2
-[node name="Name" type="TextEdit" parent="CenterContainer/VBoxContainer"]
+[node name="GameName" type="LineEdit" parent="CenterContainer/VBoxContainer"]
+unique_name_in_owner = true
+custom_minimum_size = Vector2(175, 0)
+layout_mode = 2
+theme_override_font_sizes/font_size = 18
+placeholder_text = "Game Name"
+
+[node name="Username" type="LineEdit" parent="CenterContainer/VBoxContainer"]
unique_name_in_owner = true
-custom_minimum_size = Vector2(0, 50)
+custom_minimum_size = Vector2(150, 0)
layout_mode = 2
-placeholder_text = "Name"
+placeholder_text = "Username"
[node name="Host" type="Button" parent="CenterContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
+mouse_default_cursor_shape = 2
theme_override_font_sizes/font_size = 24
text = "Host"
-[node name="IP" type="TextEdit" parent="CenterContainer/VBoxContainer"]
+[node name="IP" type="LineEdit" parent="CenterContainer/VBoxContainer"]
unique_name_in_owner = true
-custom_minimum_size = Vector2(150, 50)
layout_mode = 2
size_flags_vertical = 3
theme_override_font_sizes/font_size = 18
placeholder_text = "Join IP"
-[node name="Port" type="TextEdit" parent="CenterContainer/VBoxContainer"]
+[node name="Port" type="LineEdit" parent="CenterContainer/VBoxContainer"]
unique_name_in_owner = true
-custom_minimum_size = Vector2(150, 50)
layout_mode = 2
size_flags_vertical = 3
theme_override_font_sizes/font_size = 18
@@ -53,8 +89,17 @@ placeholder_text = "Host&Join Port"
[node name="Join" type="Button" parent="CenterContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
+mouse_default_cursor_shape = 2
theme_override_font_sizes/font_size = 24
text = "Join"
+[node name="Search" type="Button" parent="CenterContainer/VBoxContainer"]
+unique_name_in_owner = true
+layout_mode = 2
+mouse_default_cursor_shape = 2
+theme_override_font_sizes/font_size = 24
+text = "Search"
+
[connection signal="pressed" from="CenterContainer/VBoxContainer/Host" to="." method="_on_host_pressed"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/Join" to="." method="_on_join_pressed"]
+[connection signal="pressed" from="CenterContainer/VBoxContainer/Search" to="." method="_on_search_pressed"]
diff --git a/UI/TowerConfiguration.tscn b/UI/TowerConfiguration.tscn
index ba8c2a9..38587be 100644
--- a/UI/TowerConfiguration.tscn
+++ b/UI/TowerConfiguration.tscn
@@ -1,7 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://c05aq7xd4kx1p"]
[ext_resource type="Texture2D" uid="uid://dujcs2ls3u6tj" path="res://Towers/Assets/spritesheet.png" id="2_m6q2y"]
-[ext_resource type="Script" path="res://UI/tower_configuration.gd" id="2_vvfd0"]
+[ext_resource type="Script" uid="uid://be0wi1458bdae" path="res://UI/tower_configuration.gd" id="2_vvfd0"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_k0400"]
diff --git a/UI/collision_visibility_area.gd.uid b/UI/collision_visibility_area.gd.uid
new file mode 100644
index 0000000..17f6e49
--- /dev/null
+++ b/UI/collision_visibility_area.gd.uid
@@ -0,0 +1 @@
+uid://d1hu2usw8lyu2
diff --git a/UI/contain_container.gd.uid b/UI/contain_container.gd.uid
new file mode 100644
index 0000000..d701bfb
--- /dev/null
+++ b/UI/contain_container.gd.uid
@@ -0,0 +1 @@
+uid://bcx8c2kwehj4m
diff --git a/UI/game_menu.gd.uid b/UI/game_menu.gd.uid
new file mode 100644
index 0000000..beec871
--- /dev/null
+++ b/UI/game_menu.gd.uid
@@ -0,0 +1 @@
+uid://doa661nvsiwtb
diff --git a/UI/hp_bar.gd b/UI/hp_bar.gd
index 9df85e8..bb18bf2 100644
--- a/UI/hp_bar.gd
+++ b/UI/hp_bar.gd
@@ -25,11 +25,30 @@ func set_value(value):
visible = true
+func show_numbers(value: float):
+ # TODO: factor out to scene
+
+ var label = Label.new()
+ label.text = str(value)
+ label.position.x = randf_range(0.0, size.x)
+ label.position.y = -size.y*5
+ label.add_theme_font_size_override("font_size", 8)
+ add_child(label)
+
+ var tween = create_tween()
+ tween.tween_property(label, "position", Vector2(label.position.x, label.position.y - size.y), 0.25)
+ tween.tween_property(label, "self_modulate", Color(1, 1, 1, 0), 0.25)
+ await tween.finished
+ label.queue_free()
+
+
func _on_health_bar_value_changed(value: float) -> void:
if not $ImmediateDamageTimer.is_stopped():
$ImmediateDamageBar.value = $HealthBar.value + value_difference
$ImmediateDamageTimer.start()
+
+ show_numbers(value_difference)
func _on_immediate_damage_timer_timeout() -> void:
diff --git a/UI/hp_bar.gd.uid b/UI/hp_bar.gd.uid
new file mode 100644
index 0000000..4971b3e
--- /dev/null
+++ b/UI/hp_bar.gd.uid
@@ -0,0 +1 @@
+uid://cndetkp0v8w8y
diff --git a/UI/lobby.gd b/UI/lobby.gd
deleted file mode 100644
index 26a7b97..0000000
--- a/UI/lobby.gd
+++ /dev/null
@@ -1,95 +0,0 @@
-extends Control
-
-
-signal joined
-
-var current_map_idx := 0
-
-@onready var list: VBoxContainer = %PlayersList
-
-
-func _ready() -> void:
- if not multiplayer.is_server():
- %StartButton.disabled = true
- #%StartButton.queue_free()
-
- %PlayersList.remove_child(%PlayersList.get_child(0))
- %PlayersList.remove_child(%PlayersList.get_child(0))
-
- if multiplayer.is_server():
- set_map.rpc(current_map_idx)
- joined.connect(func():
- set_map.rpc(current_map_idx)
- )
- for idx in %Maps.get_child_count():
- %Maps.get_child(idx).pressed.connect(func():
- set_map.rpc(idx)
- )
- if not multiplayer.is_server():
- set_map(0)
- for node: Control in %Maps.get_children():
- node.mouse_filter = Control.MOUSE_FILTER_IGNORE
-
- Network.players_changed.connect(update_players)
- update_players()
-
- multiplayer.peer_disconnected.connect(remove_player)
-
- # reset map texture for clean load
- %Thumbnail.texture = null
- set_map(current_map_idx)
-
-
-func update_players():
- for id in Network.get_ordered_player_ids():
- var player: Player = Network.get_player(id)
-
- var control: Control = list.get_node_or_null(str(id))
- if not control:
- control = MarginContainer.new()
- control.name = str(id)
- var label = Label.new()
- label.add_theme_color_override("font_color", player.get_color())
- if id == multiplayer.get_unique_id():
- label.add_theme_color_override("font_outline_color", Color(0.75, 0.75, 0.75, 0.75))
- label.add_theme_constant_override("outline_size", 10)
- control.add_child(label)
- list.add_child(control)
- joined.emit()
-
- control.get_child(0).text = str(player.username)
- control.get_child(0).tooltip_text = str(id)
- list.move_child(control, Network.get_ordered_player_ids().find(id) + 1)
-
-
-func remove_player(id):
- list.remove_child(list.get_node(str(id)))
-
-
-func _on_start_button_pressed() -> void:
- start.rpc()
-
-
-func _on_cancel_button_pressed() -> void:
- multiplayer.multiplayer_peer.close()
- get_tree().change_scene_to_file("res://UI/Start.tscn")
-
-
-@rpc("authority", "call_local")
-func start():
- var scene = %Maps.get_child(current_map_idx).get_meta("map_scene")
- get_tree().change_scene_to_packed(scene)
-
-
-@rpc("authority", "call_local")
-func set_map(index: int):
- current_map_idx = index
-
- for node: Button in %Maps.get_children():
- node.add_theme_color_override("font_color", Color(1.0, 1.0, 1.0, 0.5))
-
- var node = %Maps.get_child(index)
- var thumbnail = node.get_meta("thumbnail")
-
- node.add_theme_color_override("font_color", Color(1.0, 1.0, 1.0, 1.0))
- %Thumbnail.texture = thumbnail
diff --git a/UI/players_list.gd.uid b/UI/players_list.gd.uid
new file mode 100644
index 0000000..98a819f
--- /dev/null
+++ b/UI/players_list.gd.uid
@@ -0,0 +1 @@
+uid://b8kj5jawk4ye6
diff --git a/UI/players_list_container.gd b/UI/players_list_container.gd
new file mode 100644
index 0000000..238a703
--- /dev/null
+++ b/UI/players_list_container.gd
@@ -0,0 +1,24 @@
+extends VBoxContainer
+
+
+signal clicked
+
+@export var label: String:
+ set(value):
+ label = value
+ $Label.text = value
+ $Label.visible = !!value
+
+@onready var list := %PlayersList
+
+
+func _ready():
+ $Label.visible = !!label
+
+ list.remove_child(list.get_child(0))
+ list.remove_child(list.get_child(0))
+
+
+func _on_label_gui_input(event: InputEvent) -> void:
+ if event.is_action("select"):
+ clicked.emit()
diff --git a/UI/players_list_container.gd.uid b/UI/players_list_container.gd.uid
new file mode 100644
index 0000000..80e4ea0
--- /dev/null
+++ b/UI/players_list_container.gd.uid
@@ -0,0 +1 @@
+uid://daqhvycu4o8hx
diff --git a/UI/players_list_container.tscn b/UI/players_list_container.tscn
new file mode 100644
index 0000000..18dd9cc
--- /dev/null
+++ b/UI/players_list_container.tscn
@@ -0,0 +1,54 @@
+[gd_scene load_steps=4 format=3 uid="uid://cq6p055yuac0o"]
+
+[ext_resource type="Script" uid="uid://daqhvycu4o8hx" path="res://UI/players_list_container.gd" id="1_f2j1s"]
+[ext_resource type="PackedScene" uid="uid://dslebs7aarkoa" path="res://UI/panel_background_blue.tscn" id="1_y7ccy"]
+
+[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_fm6m2"]
+
+[node name="VBoxContainer" type="VBoxContainer"]
+offset_right = 64.0
+offset_bottom = 132.0
+script = ExtResource("1_f2j1s")
+
+[node name="Label" type="Label" parent="."]
+layout_mode = 2
+mouse_filter = 0
+mouse_default_cursor_shape = 2
+text = "Label"
+
+[node name="PlayersListContainer" type="PanelContainer" parent="."]
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+theme_override_styles/panel = SubResource("StyleBoxEmpty_fm6m2")
+
+[node name="PanelBackgroundBlue" parent="PlayersListContainer" instance=ExtResource("1_y7ccy")]
+layout_mode = 2
+
+[node name="MarginContainer" type="MarginContainer" parent="PlayersListContainer"]
+layout_mode = 2
+theme_override_constants/margin_left = 16
+theme_override_constants/margin_top = 16
+theme_override_constants/margin_right = 16
+theme_override_constants/margin_bottom = 16
+
+[node name="PlayersList" type="VBoxContainer" parent="PlayersListContainer/MarginContainer"]
+unique_name_in_owner = true
+custom_minimum_size = Vector2(0, 100)
+layout_mode = 2
+
+[node name="Control" type="MarginContainer" parent="PlayersListContainer/MarginContainer/PlayersList"]
+layout_mode = 2
+
+[node name="Label" type="Label" parent="PlayersListContainer/MarginContainer/PlayersList/Control"]
+layout_mode = 2
+text = "A"
+
+[node name="Control2" type="MarginContainer" parent="PlayersListContainer/MarginContainer/PlayersList"]
+layout_mode = 2
+
+[node name="Label2" type="Label" parent="PlayersListContainer/MarginContainer/PlayersList/Control2"]
+layout_mode = 2
+text = "B"
+
+[connection signal="gui_input" from="Label" to="." method="_on_label_gui_input"]
diff --git a/UI/sliding_background.gdshader.uid b/UI/sliding_background.gdshader.uid
new file mode 100644
index 0000000..55932ba
--- /dev/null
+++ b/UI/sliding_background.gdshader.uid
@@ -0,0 +1 @@
+uid://bvni6cdwtojtr
diff --git a/UI/spawn_button.gd b/UI/spawn_button.gd
index 3051dfb..a5a1947 100644
--- a/UI/spawn_button.gd
+++ b/UI/spawn_button.gd
@@ -1,24 +1,16 @@
extends TextureButton
-@export var texture: Texture2D
-@export var sprite_sheet: SpriteFrames
-
-@export var cost := 5
+@export var unit_resource: UnitResource
func _ready():
- tooltip_text = "Cost: " + str(cost)
+ tooltip_text = "Cost: " + str(unit_resource.cost) + "\n" + "Income: " + str(unit_resource.income)
func _on_pressed() -> void:
var unit = preload("res://Units/Unit.tscn").instantiate() as Unit
- if texture:
- unit.get_node("Sprite2D").texture = texture
- unit.get_node("Sprite2D").scale = Vector2(32,32) / texture.get_size()
-
- if sprite_sheet:
- unit.get_node("AnimatedSprite2D").sprite_frames = sprite_sheet
+ unit.unit_resource = unit_resource
- Client.spawn_unit(unit, Client.current_stage.get_spawn(), Client.current_stage.get_overwrite_target())
+ Client.spawn_unit(unit, Client.current_stage.get_spawn(), Client.current_stage.get_spawn_target())
diff --git a/UI/spawn_button.gd.uid b/UI/spawn_button.gd.uid
new file mode 100644
index 0000000..d3cfa3d
--- /dev/null
+++ b/UI/spawn_button.gd.uid
@@ -0,0 +1 @@
+uid://pm435vpllta1
diff --git a/UI/tower_configuration.gd.uid b/UI/tower_configuration.gd.uid
new file mode 100644
index 0000000..6f18ad6
--- /dev/null
+++ b/UI/tower_configuration.gd.uid
@@ -0,0 +1 @@
+uid://be0wi1458bdae