diff options
Diffstat (limited to 'client/menu')
-rw-r--r-- | client/menu/blur_setup.gd | 1 | ||||
-rw-r--r-- | client/menu/character.gd | 12 | ||||
-rw-r--r-- | client/menu/communicate/popup_message/popup_message.gd | 117 | ||||
-rw-r--r-- | client/menu/communicate/popup_message/popup_message.tscn | 86 | ||||
-rw-r--r-- | client/menu/communicate/popup_message/server_message.gd | 13 | ||||
-rw-r--r-- | client/menu/communicate/popup_message/server_message.tscn | 6 | ||||
-rw-r--r-- | client/menu/hairstyle_preview.gd | 2 | ||||
-rw-r--r-- | client/menu/ingame.gd | 39 | ||||
-rw-r--r-- | client/menu/lobby.gd | 42 | ||||
-rw-r--r-- | client/menu/menu_background.gd | 32 | ||||
-rw-r--r-- | client/menu/play.gd | 1 |
11 files changed, 195 insertions, 156 deletions
diff --git a/client/menu/blur_setup.gd b/client/menu/blur_setup.gd index 331d1f47..9d55a9d4 100644 --- a/client/menu/blur_setup.gd +++ b/client/menu/blur_setup.gd @@ -14,6 +14,7 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. # extends Control +class_name BlurSetup func _ready(): update(Global.get_setting("graphics.ui_blur")) diff --git a/client/menu/character.gd b/client/menu/character.gd index 6af30250..dd3bc5cd 100644 --- a/client/menu/character.gd +++ b/client/menu/character.gd @@ -18,7 +18,6 @@ extends Menu @onready var character: Character = $Node3D/Character -@onready var num_hairstyles := character.hairstyles.keys().size() @onready var back_button := $VBoxContainer/bottom_panel/back @onready var map: Map = $Node3D/Map @onready var username_edit = $VBoxContainer/top_panel/a/username @@ -26,7 +25,7 @@ extends Menu func _ready(): super() $VBoxContainer/top_panel/a/username.text = Global.get_profile("username") - character.select_hairstyle(Global.get_profile("character")) + character.set_style(Global.get_profile("character")) init_map() func init_map(): @@ -53,6 +52,7 @@ func init_map(): for y in tiles.size(): for x in tiles[y].size(): map.set_tile(Vector2i(x,y) - co, gt.call([x,y]), [[x,y-1],[x-1,y],[x,y+1],[x+1,y]].map(gt)) + map.flush() func _input(_event): if Input.is_action_just_pressed("ui_cancel"): @@ -68,9 +68,9 @@ func _on_back_pressed(): replace_menu("res://menu/main.tscn") func _on_character_back_pressed(): - Global.set_profile("character", (Global.get_profile("character") - 1) % num_hairstyles) - character.select_hairstyle(Global.get_profile("character")) + Global.set_profile("character", max(Global.get_profile("character") - 1, 0)) + character.set_style(Global.get_profile("character")) func _on_character_forward_pressed(): - Global.set_profile("character", (Global.get_profile("character") + 1) % num_hairstyles) - character.select_hairstyle(Global.get_profile("character")) + Global.set_profile("character", max(Global.get_profile("character") + 1, 0)) + character.set_style(Global.get_profile("character")) diff --git a/client/menu/communicate/popup_message/popup_message.gd b/client/menu/communicate/popup_message/popup_message.gd index 6c2c2c0e..98bd94e3 100644 --- a/client/menu/communicate/popup_message/popup_message.gd +++ b/client/menu/communicate/popup_message/popup_message.gd @@ -14,45 +14,34 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # -extends MarginContainer +extends Control class_name PopupMessage +const SERVER_MESSAGE_SCENE = preload("res://menu/communicate/popup_message/server_message.tscn") + var is_ingame := false var is_joined := false -@onready var server_msg = $VBox/ServerMessage -@onready var server_msg_positional = $ServerMessagePositional -@onready var hint_msg = $VBox/HintMessage - -@onready var server_msg_timer: Timer = $ServerTimer -@onready var hint_msg_timer: Timer = $HintTimer - -@onready var server_msg_label: Label = $VBox/ServerMessage/CenterContainer/Label -@onready var server_msg_positional_label: Label = $ServerMessagePositional/ServerMessage/CenterContainer/Label -@onready var hint_msg_label: Label = $VBox/HintMessage/CenterContainer/Label +var positional_messages = {} -@onready var server_msg_positional_panel: PanelContainer = $ServerMessagePositional/ServerMessage +@onready var positional_messages_node: Control = $Positional +@onready var server_msg = $Static/VBox/ServerMessage +@onready var hint_msg = $Static/VBox/HintMessage -@onready var auto_hint_timers: Node = $AutoHintTimers +@onready var server_msg_label: Label = $Static/VBox/ServerMessage/CenterContainer/Label +@onready var hint_msg_label: Label = $Static/VBox/HintMessage/CenterContainer/Label -@onready var reset_timer = $Reset -@onready var join_while_running_timer = $JoinWhileRunning +@onready var auto_hint_timers: Node = $Timers/AutoHints +@onready var server_msg_timer: Timer = $Timers/Server +@onready var hint_msg_timer: Timer = $Timers/Hint +@onready var reset_timer = $Timers/Reset +@onready var join_while_running_timer = $Timers/JoinWhileRunning @onready var game: Game = $"../Game" -var server_message_position := Vector2.ZERO -var last_server_message_panel_size := Vector2.ZERO - func _ready(): - game.joined.connect( - func player_joined(): - is_joined = true - update_state() - ) - game.left.connect( - func player_joined(): - is_joined = false - update_state() + game.join_state_updated.connect(func(state: Game.JoinState): + is_joined = state == Game.JoinState.JOINED ) game.update_tutorial_running.connect( func a(running: bool): @@ -61,25 +50,26 @@ func _ready(): else: update_state() ) + game.in_lobby_updated.connect( + func a(in_lobby): + is_ingame = not in_lobby + update_state() + ) func _process(_delta: float): - if server_msg_positional.visible: - var pos_3d = Vector3(server_message_position.x + 0.5, 1.5, server_message_position.y + 0.5) + for pos: Vector2 in positional_messages.keys(): + var msg: PositionalMessage = positional_messages[pos] + var pos_3d = Vector3(pos.x + 0.5, 1.5, pos.y + 0.5) var pos_2d = get_viewport().get_camera_3d().unproject_position(pos_3d) - var server_message_panel_size = server_msg_positional_panel.size - server_msg_positional.position = pos_2d.clamp(Vector2.ZERO + 0.5 * server_message_panel_size, Vector2(get_viewport_rect().size) - 0.5 * server_message_panel_size) - if server_message_panel_size != last_server_message_panel_size: - last_server_message_panel_size = server_message_panel_size - server_msg_positional_panel.position = -0.5 * last_server_message_panel_size - -func ingame(): - is_ingame = true - update_state() - -func lobby(): - is_ingame = false - update_state() + msg.node_2d.position = pos_2d.clamp( + Vector2.ZERO + 0.5 * msg.node.size, + Vector2(get_viewport_rect().size) - 0.5 * msg.node.size + ) + + if msg.node.size != msg.last_size: + msg.last_size = msg.node.size + msg.node.position = -0.5 * msg.last_size func update_state(): if is_ingame and is_joined: @@ -91,30 +81,35 @@ func update_state(): stop_game_hints() func display_server_msg(msg: String, auto_remove := true): - clear_server_msg() server_msg.show() server_msg_label.text = msg if auto_remove: server_msg_timer.start() -func display_server_msg_positional(msg: String, pos: Vector2, auto_remove := true): +func _on_server_timeout() -> void: clear_server_msg() - server_msg_positional.show() - server_message_position = pos - server_msg_positional_label.text = msg - server_msg_positional_panel.size = Vector2.ZERO - - if auto_remove: - server_msg_timer.start() -func clear_server_msg(): - server_msg_timer.stop() - server_msg.hide() - server_msg_positional.hide() +func display_server_msg_positional(text: String, pos: Vector2, use_monospace: bool): + var msg := PositionalMessage.new() + msg.node = SERVER_MESSAGE_SCENE.instantiate() + msg.node_2d = Node2D.new() + positional_messages_node.add_child(msg.node_2d) + msg.node_2d.add_child(msg.node) + msg.node.set_text(text, use_monospace) + msg.node.size = Vector2.ZERO + msg.position = pos + positional_messages[pos] = msg -func _on_server_timer_timeout(): - clear_server_msg() +func clear_server_msg(position_ = null): + if position_ == null: + server_msg_timer.stop() + server_msg.hide() + else: + if position_ in positional_messages: + var msg: PositionalMessage = positional_messages[position_] + msg.node_2d.queue_free() + positional_messages.erase(position_) func display_hint_msg(msg: String): hint_msg.show() @@ -220,7 +215,7 @@ func _on_rotate_camera_timeout(): )])) func _on_join_while_running_timeout(): - if not game.is_joined and not Global.get_hint("has_seen_join_while_running"): + if not game.join_state == Game.JoinState.JOINED and not Global.get_hint("has_seen_join_while_running"): Global.set_hint("has_seen_join_while_running", true) display_hint_msg(tr("c.hint.join_while_running").format([display_keybind("menu")])) @@ -228,3 +223,9 @@ func _on_performance_timeout() -> void: if not Global.get_hint("has_seen_performance") and Engine.get_frames_per_second() < DisplayServer.screen_get_refresh_rate() * 0.75: Global.set_hint("has_seen_performance", true) display_hint_msg(tr("c.hint.framerate_low")) + +class PositionalMessage: + var node: ServerMessage + var node_2d: Node2D + var position: Vector2 + var last_size: Vector2 diff --git a/client/menu/communicate/popup_message/popup_message.tscn b/client/menu/communicate/popup_message/popup_message.tscn index 799712e1..880e8670 100644 --- a/client/menu/communicate/popup_message/popup_message.tscn +++ b/client/menu/communicate/popup_message/popup_message.tscn @@ -33,25 +33,35 @@ content_margin_top = 8.0 content_margin_right = 32.0 content_margin_bottom = 8.0 -[node name="PopupMessage" type="MarginContainer"] +[node name="PopupMessage" type="Control"] +layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 -theme = ExtResource("1_a1566") script = ExtResource("2_sbew6") -[node name="VBox" type="VBoxContainer" parent="."] +[node name="Static" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +theme = ExtResource("1_a1566") + +[node name="VBox" type="VBoxContainer" parent="Static"] layout_mode = 2 mouse_filter = 2 -[node name="ServerMessage" parent="VBox" instance=ExtResource("3_m3rok")] +[node name="ServerMessage" parent="Static/VBox" instance=ExtResource("3_m3rok")] visible = false layout_mode = 2 -[node name="HintMessage" type="PanelContainer" parent="VBox"] +[node name="HintMessage" type="PanelContainer" parent="Static/VBox"] visible = false material = SubResource("ShaderMaterial_k0m35") layout_mode = 2 @@ -60,12 +70,12 @@ mouse_filter = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_vq4dg") script = ExtResource("4_pvwmw") -[node name="CenterContainer" type="HBoxContainer" parent="VBox/HintMessage"] +[node name="CenterContainer" type="HBoxContainer" parent="Static/VBox/HintMessage"] layout_mode = 2 mouse_filter = 2 alignment = 1 -[node name="MarginContainer" type="MarginContainer" parent="VBox/HintMessage/CenterContainer"] +[node name="MarginContainer" type="MarginContainer" parent="Static/VBox/HintMessage/CenterContainer"] layout_mode = 2 mouse_filter = 2 theme_override_constants/margin_left = 4 @@ -73,7 +83,7 @@ theme_override_constants/margin_top = 4 theme_override_constants/margin_right = 4 theme_override_constants/margin_bottom = 4 -[node name="TextureRect" type="TextureRect" parent="VBox/HintMessage/CenterContainer/MarginContainer"] +[node name="TextureRect" type="TextureRect" parent="Static/VBox/HintMessage/CenterContainer/MarginContainer"] custom_minimum_size = Vector2(28, 28) layout_mode = 2 mouse_filter = 2 @@ -81,7 +91,7 @@ texture = ExtResource("5_2dxsd") expand_mode = 1 stretch_mode = 4 -[node name="Label" type="Label" parent="VBox/HintMessage/CenterContainer"] +[node name="Label" type="Label" parent="Static/VBox/HintMessage/CenterContainer"] layout_mode = 2 size_flags_horizontal = 3 theme_override_fonts/font = SubResource("FontVariation_qfltj") @@ -89,60 +99,66 @@ theme_override_styles/normal = SubResource("StyleBoxEmpty_3rgop") text = "A hint is worth more than a thousand manuals" autowrap_mode = 3 -[node name="ServerTimer" type="Timer" parent="."] +[node name="Positional" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="Timers" type="Node" parent="."] + +[node name="Server" type="Timer" parent="Timers"] wait_time = 5.0 one_shot = true -[node name="HintTimer" type="Timer" parent="."] +[node name="Hint" type="Timer" parent="Timers"] wait_time = 10.0 one_shot = true -[node name="AutoHintTimers" type="Node" parent="."] +[node name="AutoHints" type="Node" parent="Timers"] -[node name="Move" type="Timer" parent="AutoHintTimers"] +[node name="Move" type="Timer" parent="Timers/AutoHints"] wait_time = 2.0 one_shot = true -[node name="Performance" type="Timer" parent="AutoHintTimers"] +[node name="Performance" type="Timer" parent="Timers/AutoHints"] wait_time = 20.0 one_shot = true -[node name="Boost" type="Timer" parent="AutoHintTimers"] +[node name="Boost" type="Timer" parent="Timers/AutoHints"] wait_time = 90.0 one_shot = true -[node name="Interact" type="Timer" parent="AutoHintTimers"] +[node name="Interact" type="Timer" parent="Timers/AutoHints"] wait_time = 15.0 one_shot = true -[node name="RotateCamera" type="Timer" parent="AutoHintTimers"] +[node name="RotateCamera" type="Timer" parent="Timers/AutoHints"] wait_time = 120.0 one_shot = true -[node name="Zoom" type="Timer" parent="AutoHintTimers"] +[node name="Zoom" type="Timer" parent="Timers/AutoHints"] wait_time = 135.0 one_shot = true -[node name="Reset" type="Timer" parent="."] +[node name="Reset" type="Timer" parent="Timers"] wait_time = 10.0 one_shot = true -[node name="JoinWhileRunning" type="Timer" parent="."] +[node name="JoinWhileRunning" type="Timer" parent="Timers"] wait_time = 5.0 one_shot = true -[node name="ServerMessagePositional" type="Node2D" parent="."] -visible = false - -[node name="ServerMessage" parent="ServerMessagePositional" instance=ExtResource("3_m3rok")] - -[connection signal="timeout" from="ServerTimer" to="." method="_on_server_timer_timeout"] -[connection signal="timeout" from="HintTimer" to="." method="_on_hint_timer_timeout"] -[connection signal="timeout" from="AutoHintTimers/Move" to="." method="_on_move_timeout"] -[connection signal="timeout" from="AutoHintTimers/Performance" to="." method="_on_performance_timeout"] -[connection signal="timeout" from="AutoHintTimers/Boost" to="." method="_on_boost_timeout"] -[connection signal="timeout" from="AutoHintTimers/Interact" to="." method="_on_interact_timeout"] -[connection signal="timeout" from="AutoHintTimers/RotateCamera" to="." method="_on_rotate_camera_timeout"] -[connection signal="timeout" from="AutoHintTimers/Zoom" to="." method="_on_zoom_timeout"] -[connection signal="timeout" from="Reset" to="." method="_on_reset_timeout"] -[connection signal="timeout" from="JoinWhileRunning" to="." method="_on_join_while_running_timeout"] +[connection signal="timeout" from="Timers/Server" to="." method="_on_server_timeout"] +[connection signal="timeout" from="Timers/Hint" to="Static" method="_on_hint_timer_timeout"] +[connection signal="timeout" from="Timers/AutoHints/Move" to="Static" method="_on_move_timeout"] +[connection signal="timeout" from="Timers/AutoHints/Performance" to="Static" method="_on_performance_timeout"] +[connection signal="timeout" from="Timers/AutoHints/Boost" to="Static" method="_on_boost_timeout"] +[connection signal="timeout" from="Timers/AutoHints/Interact" to="Static" method="_on_interact_timeout"] +[connection signal="timeout" from="Timers/AutoHints/RotateCamera" to="Static" method="_on_rotate_camera_timeout"] +[connection signal="timeout" from="Timers/AutoHints/Zoom" to="Static" method="_on_zoom_timeout"] +[connection signal="timeout" from="Timers/Reset" to="Static" method="_on_reset_timeout"] +[connection signal="timeout" from="Timers/JoinWhileRunning" to="Static" method="_on_join_while_running_timeout"] diff --git a/client/menu/communicate/popup_message/server_message.gd b/client/menu/communicate/popup_message/server_message.gd new file mode 100644 index 00000000..fc12ee76 --- /dev/null +++ b/client/menu/communicate/popup_message/server_message.gd @@ -0,0 +1,13 @@ +extends BlurSetup +class_name ServerMessage + +const DEFAULT_FONT = preload("res://menu/theme/font-josefin-sans.woff2") +const MONOSPACE_FONT = preload("res://menu/theme/font-azaret-mono.woff2") + +@onready var label: Label = $CenterContainer/Label + +func set_text(text: String, use_monospace := true): + label.text = text + var font: FontVariation = label.get_theme_font("font") + font.base_font = MONOSPACE_FONT if use_monospace else DEFAULT_FONT + label.add_theme_font_size_override("font_size", 16 if use_monospace else 20) diff --git a/client/menu/communicate/popup_message/server_message.tscn b/client/menu/communicate/popup_message/server_message.tscn index 63160942..2a848419 100644 --- a/client/menu/communicate/popup_message/server_message.tscn +++ b/client/menu/communicate/popup_message/server_message.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=8 format=3 uid="uid://dq61p3a8og2b6"] [ext_resource type="Shader" path="res://menu/blur_mix.gdshader" id="1_qv8ew"] -[ext_resource type="Script" path="res://menu/blur_setup.gd" id="2_80a6b"] +[ext_resource type="Script" path="res://menu/communicate/popup_message/server_message.gd" id="2_csqo8"] [ext_resource type="FontFile" uid="uid://bk704sc5gkrb3" path="res://menu/theme/font-azaret-mono.woff2" id="3_dw20j"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_q3bbd"] @@ -20,6 +20,7 @@ corner_radius_bottom_right = 16 corner_radius_bottom_left = 16 [sub_resource type="FontVariation" id="FontVariation_qfltj"] +resource_local_to_scene = true base_font = ExtResource("3_dw20j") variation_embolden = 0.75 @@ -35,7 +36,7 @@ size_flags_horizontal = 4 size_flags_vertical = 0 mouse_filter = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_vq4dg") -script = ExtResource("2_80a6b") +script = ExtResource("2_csqo8") [node name="CenterContainer" type="CenterContainer" parent="."] layout_mode = 2 @@ -45,5 +46,6 @@ mouse_filter = 2 layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_fonts/font = SubResource("FontVariation_qfltj") +theme_override_font_sizes/font_size = 16 theme_override_styles/normal = SubResource("StyleBoxEmpty_3rgop") text = "Server message" diff --git a/client/menu/hairstyle_preview.gd b/client/menu/hairstyle_preview.gd index 5a9cce68..08b6aab9 100644 --- a/client/menu/hairstyle_preview.gd +++ b/client/menu/hairstyle_preview.gd @@ -19,7 +19,7 @@ extends VBoxContainer signal selected(character: int) func setup(character: int, group: ButtonGroup): - $HairViewport/Node3D/Character.select_hairstyle(character) + $HairViewport/Node3D/Character.set_style(character) $Select.button_group = group $Select.text = tr("c.setup.uniform.value").format([character + 1]) $Select.pressed.connect(func(): selected.emit(character)) diff --git a/client/menu/ingame.gd b/client/menu/ingame.gd index 7052f237..ba365f8e 100644 --- a/client/menu/ingame.gd +++ b/client/menu/ingame.gd @@ -26,19 +26,16 @@ extends Menu var opened func _ready(): opened = Time.get_ticks_msec() - game.joined.connect(_on_game_joined) - game.left.connect(_on_game_left) - update_button_text() - game.joined.connect(update_lobby_button) - game.left.connect(update_lobby_button) + game.join_state_updated.connect(_on_game_join_state_changed) + _on_game_join_state_changed(game.join_state) update_lobby_button() super() func update_lobby_button(): - lobby_button.disabled = game.in_lobby or not game.is_joined + lobby_button.disabled = game.in_lobby or game.join_state == Game.JoinState.SPECTATING if game.in_lobby: lobby_button.tooltip_text = "Cannot cancel game since no game is running." - elif not game.is_joined: + elif not game.join_state == Game.JoinState.JOINED: lobby_button.tooltip_text = "You must join in order to be able to cancel the current game." else: lobby_button.tooltip_text = "" @@ -71,21 +68,15 @@ func _on_lobby_pressed(): exit() func _on_leave_pressed(): - if game.is_joined: - game.mp.send_leave(game.player_id) - elif not game.join_sent: - leave_button.disabled = true - game.join() + game.toggle_join() -func _on_game_joined(): - leave_button.disabled = false - update_button_text() - -func _on_game_left(): - update_button_text() - -func update_button_text(): - if game.is_joined: - leave_button.text = tr("c.menu.ingame.leave") - else: - leave_button.text = tr("c.menu.ingame.join") +func _on_game_join_state_changed(state: Game.JoinState): + match state: + Game.JoinState.JOINED: + leave_button.disabled = false + leave_button.text = tr("c.menu.ingame.leave") + Game.JoinState.SPECTATING: + leave_button.disabled = false + leave_button.text = tr("c.menu.ingame.join") + Game.JoinState.WAITING: + leave_button.disabled = true diff --git a/client/menu/lobby.gd b/client/menu/lobby.gd index 0dca6f4c..d595444e 100644 --- a/client/menu/lobby.gd +++ b/client/menu/lobby.gd @@ -52,8 +52,8 @@ func _ready(): game.update_players.connect(update_players) initialize() game.data_updated.connect(initialize) - game.joined.connect(_on_game_joined) - game.left.connect(_on_game_left) + game.join_state_updated.connect(_on_game_join_state_updated) + _on_game_join_state_updated(game.join_state) check_for_music() func initialize(): @@ -145,18 +145,6 @@ func _input(_event): elif Input.is_action_just_pressed("next") and not next_map.disabled: next_map.emit_signal("pressed") -func _on_game_joined(): - map_selector.show() - map_list.show() - bots_container.show() - start_button.disabled = false - -func _on_game_left(): - map_selector.hide() - map_list.hide() - bots_container.hide() - start_button.disabled = true - func _on_left_pressed(): selected_map = (selected_map - 1) % map_count select_map(selected_map) @@ -177,13 +165,27 @@ func _on_controller_button_pressed(): game.mp.send_chat(game.player_id, start_msg) Sound.play_music("stop") # TODO: Game music enter +func _on_game_join_state_updated(state: Game.JoinState): + match state: + Game.JoinState.JOINED: + map_selector.show() + map_list.show() + bots_container.show() + start_button.disabled = false + join_spectate.disabled = false + join_spectate.text = tr("c.menu.ingame.spectate") + Game.JoinState.SPECTATING: + map_selector.hide() + map_list.hide() + bots_container.hide() + start_button.disabled = true + join_spectate.disabled = false + join_spectate.text = tr("c.menu.ingame.join") + Game.JoinState.WAITING: + join_spectate.disabled = true + func _on_join_spectate_pressed(): - if game.is_joined: - game.leave() - join_spectate.text = tr("c.menu.ingame.join") - elif not game.join_sent: - game.join() - join_spectate.text = tr("c.menu.ingame.spectate") + game.toggle_join() func check_for_music(): if visible: diff --git a/client/menu/menu_background.gd b/client/menu/menu_background.gd index 33ec6e43..77fb123f 100644 --- a/client/menu/menu_background.gd +++ b/client/menu/menu_background.gd @@ -17,8 +17,8 @@ # extends Node3D -const NULLS = [null,null,null,null] -const BUCKETS = [[], ["floor","floor","floor","floor","tomato-crate", "steak-crate"], ["table", "chair", "counter"], ["sink", "stove"]] +const CRATES = ["tomato-crate", "steak-crate", "cheese-crate", "lettuce-crate", "flour-crate", "coconut-crate"] +const TOOLS = ["sink", "cuttingboard", "stove", "oven", "freezer"] @onready var environment: WorldEnvironment = $Environment @onready var map: Map = $Map @@ -27,12 +27,26 @@ func _ready(): if !Global.on_vulkan(): environment.environment.tonemap_exposure = 0.25 - for x in range(-10,11): - for y in range(-10,11): - var w = exp(-sqrt(x*x+y*y) * 0.15) + var tiles = {} + for x in range(-10, 11): + for y in range(-10, 11): + var w = exp(-sqrt(x * x + y * y) * 0.15) var k = randf() * w - var bucket = BUCKETS[int(floor(k * BUCKETS.size())) % BUCKETS.size()] - if bucket.size() == 0: continue - var tile_name = bucket[randi() % bucket.size()] - map.set_tile(Vector2i(x,y), tile_name) + var tn = null + if k > 0.25: tn = "floor" + if k > 0.4: tn = choose(CRATES) if randf() > 0.3 else "counter" + if k > 0.6: tn = choose(TOOLS) + if tn != null: tiles[str(Vector2i(x,y))] = [tn,[x,y]] + + var gt = func (cs): + var t = tiles.get(str(Vector2i(cs[0],cs[1]))) + return null if t == null else t[0] + for pk in tiles.keys(): + var x = tiles[pk][1][0] + var y = tiles[pk][1][1] + var t = gt.call([x,y]) + if t != null: map.set_tile(Vector2i(x,y), t, [[x,y-1],[x-1,y],[x,y+1],[x+1,y]].map(gt)) + map.flush() + +func choose(a): return a[floor(a.size() * randf())] diff --git a/client/menu/play.gd b/client/menu/play.gd index 1fe19224..b117d6a4 100644 --- a/client/menu/play.gd +++ b/client/menu/play.gd @@ -19,7 +19,6 @@ extends Menu var url_regex: RegEx = RegEx.new() -@onready var req: HTTPRequest = $HTTPRequest @onready var server_list: VBoxContainer = $side/margin/options/second/ScrollContainerCustom/ServerList @onready var server_list_loading: Label = $side/margin/options/second/Loading @onready var connect_uri = $side/margin/options/second/connect/uri |