Main menu host settings

This commit is contained in:
Rendo 2025-12-08 14:39:20 +05:00
commit 2705959bfd
4 changed files with 146 additions and 21 deletions

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://cbtp4rvg66ba1"] [gd_scene load_steps=3 format=3 uid="uid://cbtp4rvg66ba1"]
[ext_resource type="Script" uid="uid://bsyuos803g7qf" path="res://scripts/gui/main_menu_gui.gd" id="1_l6cm7"] [ext_resource type="Script" uid="uid://bsyuos803g7qf" path="res://scripts/gui/main_menu_gui.gd" id="1_l6cm7"]
[ext_resource type="Script" uid="uid://dh64rv15w8ecl" path="res://scripts/multiplayer/host_menu.gd" id="2_ekxnf"]
[node name="MainMenu" type="CenterContainer"] [node name="MainMenu" type="CenterContainer"]
anchors_preset = 15 anchors_preset = 15
@ -12,6 +13,7 @@ script = ExtResource("1_l6cm7")
metadata/_edit_lock_ = true metadata/_edit_lock_ = true
[node name="MainMenu" type="PanelContainer" parent="."] [node name="MainMenu" type="PanelContainer" parent="."]
visible = false
custom_minimum_size = Vector2(256, 0) custom_minimum_size = Vector2(256, 0)
layout_mode = 2 layout_mode = 2
@ -31,82 +33,171 @@ layout_mode = 2
placeholder_text = "ip" placeholder_text = "ip"
[node name="Lobby" type="PanelContainer" parent="."] [node name="Lobby" type="PanelContainer" parent="."]
visible = false
custom_minimum_size = Vector2(256, 256) custom_minimum_size = Vector2(256, 256)
layout_mode = 2 layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Lobby"] [node name="HBoxContainer" type="HBoxContainer" parent="Lobby"]
layout_mode = 2 layout_mode = 2
[node name="Players" type="HBoxContainer" parent="Lobby/VBoxContainer"] [node name="ClientMenu" type="VBoxContainer" parent="Lobby/HBoxContainer"]
layout_mode = 2
[node name="Players" type="HBoxContainer" parent="Lobby/HBoxContainer/ClientMenu"]
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
alignment = 1 alignment = 1
[node name="AttackTeam" type="VBoxContainer" parent="Lobby/VBoxContainer/Players"] [node name="AttackTeam" type="VBoxContainer" parent="Lobby/HBoxContainer/ClientMenu/Players"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="TeamName" type="Label" parent="Lobby/VBoxContainer/Players/AttackTeam"] [node name="TeamName" type="Label" parent="Lobby/HBoxContainer/ClientMenu/Players/AttackTeam"]
layout_mode = 2 layout_mode = 2
text = "Attack" text = "Attack"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="DefenceTeam" type="VBoxContainer" parent="Lobby/VBoxContainer/Players"] [node name="DefenceTeam" type="VBoxContainer" parent="Lobby/HBoxContainer/ClientMenu/Players"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="TeamName" type="Label" parent="Lobby/VBoxContainer/Players/DefenceTeam"] [node name="TeamName" type="Label" parent="Lobby/HBoxContainer/ClientMenu/Players/DefenceTeam"]
layout_mode = 2 layout_mode = 2
text = "Defence" text = "Defence"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="SpectatorsTeam" type="VBoxContainer" parent="Lobby/VBoxContainer/Players"] [node name="SpectatorsTeam" type="VBoxContainer" parent="Lobby/HBoxContainer/ClientMenu/Players"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="TeamName" type="Label" parent="Lobby/VBoxContainer/Players/SpectatorsTeam"] [node name="TeamName" type="Label" parent="Lobby/HBoxContainer/ClientMenu/Players/SpectatorsTeam"]
layout_mode = 2 layout_mode = 2
text = "Spectators" text = "Spectators"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="Buttons" type="HBoxContainer" parent="Lobby/VBoxContainer"] [node name="Buttons" type="HBoxContainer" parent="Lobby/HBoxContainer/ClientMenu"]
layout_mode = 2 layout_mode = 2
alignment = 1 alignment = 1
[node name="LeaveButton" type="Button" parent="Lobby/VBoxContainer/Buttons"] [node name="LeaveButton" type="Button" parent="Lobby/HBoxContainer/ClientMenu/Buttons"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
text = "Leave" text = "Leave"
[node name="StartButton" type="Button" parent="Lobby/VBoxContainer/Buttons"] [node name="StartButton" type="Button" parent="Lobby/HBoxContainer/ClientMenu/Buttons"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
text = "Start" text = "Start"
[node name="JoinAttackButton" type="Button" parent="Lobby/VBoxContainer/Buttons"] [node name="JoinAttackButton" type="Button" parent="Lobby/HBoxContainer/ClientMenu/Buttons"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
text = "Join Attack" text = "Join Attack"
[node name="JoinDefenceButton" type="Button" parent="Lobby/VBoxContainer/Buttons"] [node name="JoinDefenceButton" type="Button" parent="Lobby/HBoxContainer/ClientMenu/Buttons"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
text = "Join Defence" text = "Join Defence"
[node name="JoinSpectatorsButton" type="Button" parent="Lobby/VBoxContainer/Buttons"] [node name="JoinSpectatorsButton" type="Button" parent="Lobby/HBoxContainer/ClientMenu/Buttons"]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Join Spectators" text = "Join Spectators"
[node name="HostMenu" type="VBoxContainer" parent="Lobby/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
script = ExtResource("2_ekxnf")
[node name="RoundTime" type="HBoxContainer" parent="Lobby/HBoxContainer/HostMenu"]
layout_mode = 2
[node name="Label" type="Label" parent="Lobby/HBoxContainer/HostMenu/RoundTime"]
layout_mode = 2
text = "Время раунда"
[node name="RoundTimeBox" type="SpinBox" parent="Lobby/HBoxContainer/HostMenu/RoundTime"]
unique_name_in_owner = true
layout_mode = 2
min_value = 1.0
step = 0.01
value = 1.0
allow_greater = true
[node name="BombTime" type="HBoxContainer" parent="Lobby/HBoxContainer/HostMenu"]
layout_mode = 2
[node name="Label" type="Label" parent="Lobby/HBoxContainer/HostMenu/BombTime"]
layout_mode = 2
text = "Отсчёт бомбы"
[node name="BombTimeBox" type="SpinBox" parent="Lobby/HBoxContainer/HostMenu/BombTime"]
unique_name_in_owner = true
layout_mode = 2
min_value = 1.0
step = 0.01
value = 1.0
allow_greater = true
[node name="BuyTime" type="HBoxContainer" parent="Lobby/HBoxContainer/HostMenu"]
layout_mode = 2
[node name="Label" type="Label" parent="Lobby/HBoxContainer/HostMenu/BuyTime"]
layout_mode = 2
text = "Время закупок"
[node name="BuyTimeBox" type="SpinBox" parent="Lobby/HBoxContainer/HostMenu/BuyTime"]
unique_name_in_owner = true
layout_mode = 2
min_value = 1.0
step = 0.01
value = 1.0
allow_greater = true
[node name="RoundAmount" type="HBoxContainer" parent="Lobby/HBoxContainer/HostMenu"]
layout_mode = 2
[node name="Label" type="Label" parent="Lobby/HBoxContainer/HostMenu/RoundAmount"]
layout_mode = 2
text = "Раундов для победы"
[node name="RoundBox" type="SpinBox" parent="Lobby/HBoxContainer/HostMenu/RoundAmount"]
unique_name_in_owner = true
layout_mode = 2
min_value = 2.0
max_value = 20.0
value = 2.0
rounded = true
allow_greater = true
[node name="TeamSwitchAmount" type="HBoxContainer" parent="Lobby/HBoxContainer/HostMenu"]
layout_mode = 2
[node name="Label" type="Label" parent="Lobby/HBoxContainer/HostMenu/TeamSwitchAmount"]
layout_mode = 2
text = "Раунд смены сторон"
[node name="TeamSwitchBox" type="SpinBox" parent="Lobby/HBoxContainer/HostMenu/TeamSwitchAmount"]
unique_name_in_owner = true
layout_mode = 2
min_value = 1.0
max_value = 20.0
value = 2.0
rounded = true
allow_greater = true
[connection signal="pressed" from="MainMenu/VBoxContainer/HostButton" to="." method="_on_host_button_pressed"] [connection signal="pressed" from="MainMenu/VBoxContainer/HostButton" to="." method="_on_host_button_pressed"]
[connection signal="pressed" from="MainMenu/VBoxContainer/ConnectButton" to="." method="_on_connect_button_pressed"] [connection signal="pressed" from="MainMenu/VBoxContainer/ConnectButton" to="." method="_on_connect_button_pressed"]
[connection signal="pressed" from="Lobby/VBoxContainer/Buttons/LeaveButton" to="." method="_on_leave_button_pressed"] [connection signal="pressed" from="Lobby/HBoxContainer/ClientMenu/Buttons/LeaveButton" to="." method="_on_leave_button_pressed"]
[connection signal="pressed" from="Lobby/VBoxContainer/Buttons/StartButton" to="." method="_on_start_button_pressed"] [connection signal="pressed" from="Lobby/HBoxContainer/ClientMenu/Buttons/StartButton" to="." method="_on_start_button_pressed"]
[connection signal="pressed" from="Lobby/VBoxContainer/Buttons/JoinAttackButton" to="." method="_on_join_attack_button_pressed"] [connection signal="pressed" from="Lobby/HBoxContainer/ClientMenu/Buttons/JoinAttackButton" to="." method="_on_join_attack_button_pressed"]
[connection signal="pressed" from="Lobby/VBoxContainer/Buttons/JoinDefenceButton" to="." method="_on_join_defence_button_pressed"] [connection signal="pressed" from="Lobby/HBoxContainer/ClientMenu/Buttons/JoinDefenceButton" to="." method="_on_join_defence_button_pressed"]
[connection signal="pressed" from="Lobby/VBoxContainer/Buttons/JoinSpectatorsButton" to="." method="_on_join_spectators_button_pressed"] [connection signal="pressed" from="Lobby/HBoxContainer/ClientMenu/Buttons/JoinSpectatorsButton" to="." method="_on_join_spectators_button_pressed"]
[connection signal="value_changed" from="Lobby/HBoxContainer/HostMenu/RoundTime/RoundTimeBox" to="Lobby/HBoxContainer/HostMenu" method="_on_round_time_box_value_changed"]
[connection signal="value_changed" from="Lobby/HBoxContainer/HostMenu/BombTime/BombTimeBox" to="Lobby/HBoxContainer/HostMenu" method="_on_bomb_time_box_value_changed"]
[connection signal="value_changed" from="Lobby/HBoxContainer/HostMenu/BuyTime/BuyTimeBox" to="Lobby/HBoxContainer/HostMenu" method="_on_buy_time_box_value_changed"]
[connection signal="value_changed" from="Lobby/HBoxContainer/HostMenu/RoundAmount/RoundBox" to="Lobby/HBoxContainer/HostMenu" method="_on_round_box_value_changed"]
[connection signal="value_changed" from="Lobby/HBoxContainer/HostMenu/TeamSwitchAmount/TeamSwitchBox" to="Lobby/HBoxContainer/HostMenu" method="_on_team_switch_box_value_changed"]

View file

@ -7,6 +7,9 @@ func _ready() -> void:
Lobby.lobby_created.connect(show_host_buttons) Lobby.lobby_created.connect(show_host_buttons)
Lobby.lobby_closed.connect(cleanup_lobby) Lobby.lobby_closed.connect(cleanup_lobby)
Lobby.update_teams_state.connect(on_player_switched_team) Lobby.update_teams_state.connect(on_player_switched_team)
$Lobby.hide()
$MainMenu.show()
func _on_leave_button_pressed() -> void: func _on_leave_button_pressed() -> void:
Lobby.leave() Lobby.leave()
@ -25,9 +28,11 @@ func _on_start_button_pressed() -> void:
func hide_host_buttons() -> void: func hide_host_buttons() -> void:
%StartButton.hide() %StartButton.hide()
%HostMenu.hide()
func show_host_buttons() -> void: func show_host_buttons() -> void:
%StartButton.show() %StartButton.show()
%HostMenu.show()
func _on_host_button_pressed() -> void: func _on_host_button_pressed() -> void:
Lobby.host() Lobby.host()

View file

@ -0,0 +1,28 @@
extends VBoxContainer
func _ready() -> void:
%RoundTimeBox.set_value_no_signal(Lobby.round_time)
%BombTimeBox.set_value_no_signal(Lobby.bomb_time)
%BuyTimeBox.set_value_no_signal(Lobby.buy_time)
%TeamSwitchBox.set_value_no_signal(Lobby.half_rounds)
%RoundBox.set_value_no_signal(Lobby.win_score)
func _on_round_time_box_value_changed(value: float) -> void:
Lobby.round_time = value
func _on_bomb_time_box_value_changed(value: float) -> void:
Lobby.bomb_time = value
func _on_buy_time_box_value_changed(value: float) -> void:
Lobby.buy_time = value
func _on_round_box_value_changed(value: float) -> void:
Lobby.win_score = int(value)
%TeamSwitchBox.value = value-1
func _on_team_switch_box_value_changed(value: float) -> void:
Lobby.half_rounds = int(value)

View file

@ -0,0 +1 @@
uid://dh64rv15w8ecl