summaryrefslogtreecommitdiff
path: root/UI
diff options
context:
space:
mode:
Diffstat (limited to 'UI')
-rw-r--r--UI/GamesLobby/games_lobby.gd (renamed from UI/GameLobby/game_lobby.gd)2
-rw-r--r--UI/GamesLobby/games_lobby.tscn (renamed from UI/GameLobby/game_lobby.tscn)18
-rw-r--r--UI/GamesLobby/lobby_game.gd (renamed from UI/GameLobby/lobby_game.gd)0
-rw-r--r--UI/GamesLobby/lobby_game.tscn (renamed from UI/GameLobby/lobby_game.tscn)2
-rw-r--r--UI/PlayerLobby/lobby.gd69
-rw-r--r--UI/Start.gd2
6 files changed, 55 insertions, 38 deletions
diff --git a/UI/GameLobby/game_lobby.gd b/UI/GamesLobby/games_lobby.gd
index f80015b..b829337 100644
--- a/UI/GameLobby/game_lobby.gd
+++ b/UI/GamesLobby/games_lobby.gd
@@ -5,7 +5,7 @@ var games := []
var refresh_interval := 15.0
-@onready var lobby_game_scene := preload("res://UI/GameLobby/lobby_game.tscn")
+@onready var lobby_game_scene := preload("res://UI/GamesLobby/lobby_game.tscn")
func _ready() -> void:
diff --git a/UI/GameLobby/game_lobby.tscn b/UI/GamesLobby/games_lobby.tscn
index 8c632d6..cfba68c 100644
--- a/UI/GameLobby/game_lobby.tscn
+++ b/UI/GamesLobby/games_lobby.tscn
@@ -1,18 +1,18 @@
[gd_scene load_steps=5 format=3 uid="uid://b0uqf5h2j7fvk"]
-[ext_resource type="Script" path="res://UI/GameLobby/game_lobby.gd" id="1_1vvm7"]
-[ext_resource type="Texture2D" uid="uid://kwgx33awj4y2" path="res://UI/Assets/Enjl-Starry Space Background/background_1.png" id="2_tyk1u"]
-[ext_resource type="Theme" uid="uid://bt84t61hrvoyn" path="res://UI/PlayerLobby/lobby_theme.tres" id="3_3iumi"]
-[ext_resource type="PackedScene" uid="uid://cs2a7wfrj4wn0" path="res://UI/GameLobby/lobby_game.tscn" id="3_83gpr"]
+[ext_resource type="Script" 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="GameLobby" type="Control"]
+[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_1vvm7")
+script = ExtResource("1_4dbpy")
[node name="Background" type="Control" parent="."]
layout_mode = 1
@@ -38,7 +38,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
-texture = ExtResource("2_tyk1u")
+texture = ExtResource("2_up3jk")
stretch_mode = 1
[node name="MarginContainer" type="MarginContainer" parent="."]
@@ -60,7 +60,7 @@ layout_mode = 2
unique_name_in_owner = true
layout_mode = 2
-[node name="LobbyGame" parent="MarginContainer/CenterContainer/GamesList" instance=ExtResource("3_83gpr")]
+[node name="LobbyGame" parent="MarginContainer/CenterContainer/GamesList" instance=ExtResource("3_wofvj")]
visible = false
layout_mode = 2
@@ -80,7 +80,7 @@ text = "No Games Found"
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 8
-theme = ExtResource("3_3iumi")
+theme = ExtResource("4_k7oqv")
[node name="Refresh" type="Button" parent="MarginContainer/VBoxContainer"]
unique_name_in_owner = true
diff --git a/UI/GameLobby/lobby_game.gd b/UI/GamesLobby/lobby_game.gd
index 39f9076..39f9076 100644
--- a/UI/GameLobby/lobby_game.gd
+++ b/UI/GamesLobby/lobby_game.gd
diff --git a/UI/GameLobby/lobby_game.tscn b/UI/GamesLobby/lobby_game.tscn
index a6809ac..1517416 100644
--- a/UI/GameLobby/lobby_game.tscn
+++ b/UI/GamesLobby/lobby_game.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cs2a7wfrj4wn0"]
-[ext_resource type="Script" path="res://UI/GameLobby/lobby_game.gd" id="1_cvsql"]
+[ext_resource type="Script" path="res://UI/GamesLobby/lobby_game.gd" id="1_cvsql"]
[node name="LobbyGame" type="HBoxContainer"]
script = ExtResource("1_cvsql")
diff --git a/UI/PlayerLobby/lobby.gd b/UI/PlayerLobby/lobby.gd
index 8c1c4a9..a278a33 100644
--- a/UI/PlayerLobby/lobby.gd
+++ b/UI/PlayerLobby/lobby.gd
@@ -19,7 +19,11 @@ func _ready() -> void:
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:
@@ -72,22 +76,22 @@ func update_list(current_list: Control, player_ids: Array):
label.add_theme_constant_override("outline_size", 10)
control.add_child(label)
current_list.add_child(control)
- #joined.emit()
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):
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()
+ start.rpc(settings)
func _on_cancel_button_pressed() -> void:
@@ -98,14 +102,14 @@ func _on_cancel_button_pressed() -> void:
@rpc("authority", "call_local")
-func start():
+func start(host_settings: Dictionary):
var packed_scene = %Maps.get_child(current_map_idx).get_meta("map_scene")
var scene = packed_scene.instantiate()
- for setting in settings:
- scene[setting] = settings[setting]
+ for setting in host_settings:
+ scene[setting] = host_settings[setting]
- if settings.get("use_premade_teams"):
+ if host_settings.get("use_premade_teams"):
var premade_teams = {}
for team_name in teams:
premade_teams[team_name] = teams[team_name]["players"]
@@ -130,12 +134,15 @@ func set_map(index: int):
# settings
for child in %Settings.get_children():
- child.queue_free()
+ child.free()
+
if map_button.has_meta("settings"):
current_map_scene = map_button.get_meta("map_scene").instantiate()
var map_settings = map_button.get_meta("settings", [])
for setting in map_settings:
- settings[setting] = current_map_scene[setting]
+ 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]
@@ -158,26 +165,36 @@ func set_setting(key: String, value: Variant):
%Settings.get_node(key).value = value
# generate PlayersLists per team with clickable labels to switch team
- if settings.get("use_premade_teams"):
- %PlayersListContainer.visible = false
- var team_names = current_map_scene.teams.names()
- var players_per_team = Network.get_ordered_player_ids().size() / 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)
+ 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())
)
- %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
+ 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(teams[team_name]["list"], teams[team_name]["players"])
+ update_list(list, Network.get_ordered_player_ids())
+ %PlayersListContainer.visible = true
@rpc("any_peer", "call_local")
diff --git a/UI/Start.gd b/UI/Start.gd
index 85a7946..8724cee 100644
--- a/UI/Start.gd
+++ b/UI/Start.gd
@@ -57,4 +57,4 @@ func _on_join_pressed() -> void:
func _on_search_pressed() -> void:
Client.player.username = %Username.text
- get_tree().change_scene_to_file("res://UI/GameLobby/game_lobby.tscn")
+ get_tree().change_scene_to_file("res://UI/GamesLobby/games_lobby.tscn")