diff options
-rw-r--r-- | client/game.gd | 6 | ||||
-rw-r--r-- | client/menu/lobby.gd | 25 | ||||
-rw-r--r-- | client/menu/lobby.tscn | 51 | ||||
-rw-r--r-- | client/multiplayer.gd | 4 |
4 files changed, 62 insertions, 24 deletions
diff --git a/client/game.gd b/client/game.gd index 9f140327..2006d4c8 100644 --- a/client/game.gd +++ b/client/game.gd @@ -31,7 +31,7 @@ var tile_names: Array = [] var tile_index_by_name: Dictionary = {} var tile_collide: Array = [] var tile_interact: Array = [] -var map_names: Array = [] +var maps: Dictionary = {} var in_lobby := false var is_replay := false var is_joined := false @@ -65,13 +65,13 @@ func _ready(): tile_names_: Array, tile_collide_: Array, tile_interact_: Array, - map_names_: Array + maps_: Dictionary ): item_names = item_names_ tile_names = tile_names_ tile_collide = tile_collide_ tile_interact = tile_interact_ - map_names = map_names_ + maps = maps_ tile_index_by_name = {} for id in tile_names.size(): tile_index_by_name[tile_names[id]] = id diff --git a/client/menu/lobby.gd b/client/menu/lobby.gd index a31b38e9..ae7548b7 100644 --- a/client/menu/lobby.gd +++ b/client/menu/lobby.gd @@ -18,17 +18,21 @@ extends Control const PLAYER = preload("res://menu/lobby/player.tscn") +var map_count var selected_map := 0 var selected_map_name: String +var difficulty_names = [tr("Easy"), tr("Moderate"), tr("Hard"), tr("Very hard"), tr("Unplayable")] @onready var game: Game = $"../Game" -@onready var map_count = game.map_names.size() @onready var player_container = $VBoxContainer/Top/MarginContainer/VBoxContainer/Players -@onready var map_name_label = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/MapSelection + +@onready var map_name_label = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map/Name +@onready var map_player_label = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map/Players +@onready var map_difficulty_label = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map/Difficulty @onready var map_selector = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer -@onready var prev_map = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Left -@onready var next_map = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Right +@onready var prev_map = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/Left +@onready var next_map = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Right @onready var start_button = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/CenterContainer/ControllerButton func _ready(): @@ -39,16 +43,19 @@ func _ready(): game.left.connect(_on_game_left) func initialize(): - map_count = game.map_names.size() + map_count = game.maps.size() select_map(0) func select_map(i: int): - if i >= game.map_names.size(): + if i >= map_count: return selected_map = i - var map_name: String = game.map_names[i] - map_name_label.text = map_name - selected_map_name = map_name + var k = game.maps.keys()[i] + var map_data: Dictionary = game.maps[k] + map_name_label.text = map_data["name"] + map_player_label.text = tr("%d players recommended") % map_data["players"] + map_difficulty_label.text = difficulty_names[map_data["difficulty"] - 1] + selected_map_name = k func update_players(player_list: Dictionary): for i in player_container.get_children(): diff --git a/client/menu/lobby.tscn b/client/menu/lobby.tscn index 8510b995..06b050d0 100644 --- a/client/menu/lobby.tscn +++ b/client/menu/lobby.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://bc50la65ntifb"] +[gd_scene load_steps=12 format=3 uid="uid://bc50la65ntifb"] [ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_u18ke"] [ext_resource type="Script" path="res://menu/lobby.gd" id="2_7657i"] @@ -8,8 +8,13 @@ [ext_resource type="Texture2D" uid="uid://b33qmctbpf48g" path="res://menu/arrow_hover.svg" id="5_odwav"] [ext_resource type="Texture2D" uid="uid://by3qsrpxnfq4w" path="res://menu/arrow_focus.svg" id="6_tulu3"] [ext_resource type="PackedScene" uid="uid://b1f7bgn65j7b5" path="res://menu/controller_buttons/controller_button.tscn" id="7_t6mox"] +[ext_resource type="FontFile" uid="uid://5ixo6b3bd3km" path="res://menu/theme/font-josefin-sans.woff2" id="8_cwbpa"] [ext_resource type="Texture2D" uid="uid://bsx6fo7mv2u6a" path="res://menu/controller_buttons/x.svg" id="9_q14bw"] +[sub_resource type="FontVariation" id="FontVariation_5xxr2"] +base_font = ExtResource("8_cwbpa") +variation_embolden = 1.5 + [node name="Lobby" type="Control" groups=["no_auto_focus"]] layout_mode = 3 anchors_preset = 15 @@ -60,12 +65,15 @@ layout_mode = 2 theme_override_constants/separation = 24 [node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer"] -visible = false layout_mode = 2 alignment = 1 -[node name="Left" type="TextureButton" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer"] -custom_minimum_size = Vector2(19, 0) +[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +alignment = 1 + +[node name="Left" type="TextureButton" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer"] +custom_minimum_size = Vector2(19, 28) layout_mode = 2 focus_mode = 0 texture_normal = ExtResource("3_jxleg") @@ -76,15 +84,38 @@ ignore_texture_size = true stretch_mode = 4 flip_h = true -[node name="MapSelection" type="Label" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer"] +[node name="Map" type="VBoxContainer" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 + +[node name="Name" type="Label" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map"] custom_minimum_size = Vector2(264, 0) layout_mode = 2 -text = "Map" +theme_override_fonts/font = SubResource("FontVariation_5xxr2") +theme_override_font_sizes/font_size = 24 +text = "Map name" horizontal_alignment = 1 vertical_alignment = 1 -[node name="Right" type="TextureButton" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer"] -custom_minimum_size = Vector2(19, 0) +[node name="Players" type="Label" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map"] +custom_minimum_size = Vector2(264, 0) +layout_mode = 2 +text = "Players" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Difficulty" type="Label" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map"] +custom_minimum_size = Vector2(264, 0) +layout_mode = 2 +text = "Difficulty" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +alignment = 1 + +[node name="Right" type="TextureButton" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer2"] +custom_minimum_size = Vector2(19, 28) layout_mode = 2 focus_mode = 0 texture_normal = ExtResource("3_jxleg") @@ -105,6 +136,6 @@ expand_icon = true controller_texture = ExtResource("9_q14bw") press_action = "start_game" -[connection signal="pressed" from="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Left" to="." method="_on_left_pressed"] -[connection signal="pressed" from="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Right" to="." method="_on_right_pressed"] +[connection signal="pressed" from="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/Left" to="." method="_on_left_pressed"] +[connection signal="pressed" from="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Right" to="." method="_on_right_pressed"] [connection signal="pressed" from="VBoxContainer/Bottom/MarginContainer/VBoxContainer/CenterContainer/ControllerButton" to="." method="_on_controller_button_pressed"] diff --git a/client/multiplayer.gd b/client/multiplayer.gd index 19cb5e8c..4c334700 100644 --- a/client/multiplayer.gd +++ b/client/multiplayer.gd @@ -101,8 +101,8 @@ func handle_packet(bytes: PackedByteArray): var tile_names = decoded["data"]["tile_names"] var tile_collide = decoded["data"]["tile_collide"] var tile_interact = decoded["data"]["tile_interact"] - var map_names = decoded["data"]["map_names"] - data.emit(item_names, tile_names, tile_collide, tile_interact, map_names) + var maps = decoded["data"]["maps"] + data.emit(item_names, tile_names, tile_collide, tile_interact, maps) "add_player": var id = decoded["id"] var player_name = decoded["name"] |