Host settings 👍

This commit is contained in:
Rendo 2025-12-12 14:55:53 +05:00
commit 54b99eb20f
13 changed files with 203 additions and 148 deletions

View file

@ -0,0 +1,33 @@
extends VBoxContainer
func _ready() -> void:
%RoundTimeBox.set_value_no_signal(LobbySettings.round_time)
%BombTimeBox.set_value_no_signal(LobbySettings.bomb_time)
%BuyTimeBox.set_value_no_signal(LobbySettings.buy_time)
%TeamSwitchBox.set_value_no_signal(LobbySettings.half_rounds)
%RoundBox.set_value_no_signal(LobbySettings.win_score)
%AllowMultipleAbilityButton.set_pressed_no_signal(LobbySettings.allow_multiple_abilities)
func _on_round_time_box_value_changed(value: float) -> void:
LobbySettings.round_time = value
func _on_bomb_time_box_value_changed(value: float) -> void:
LobbySettings.bomb_time = value
func _on_buy_time_box_value_changed(value: float) -> void:
LobbySettings.buy_time = value
func _on_round_box_value_changed(value: float) -> void:
LobbySettings.win_score = int(value)
%TeamSwitchBox.value = value-1
func _on_team_switch_box_value_changed(value: float) -> void:
LobbySettings.half_rounds = int(value)
func _on_allow_multiple_ability_button_toggled(toggled_on: bool) -> void:
LobbySettings.allow_multiple_abilities = toggled_on

View file

@ -0,0 +1,148 @@
[gd_scene load_steps=4 format=3 uid="uid://dswn8a8anj2hu"]
[ext_resource type="Script" uid="uid://dh64rv15w8ecl" path="res://gui/host_menu/host_menu.gd" id="1_83e8q"]
[ext_resource type="Script" uid="uid://r1uwav8lrw6c" path="res://multiplayer/port_forward_button.gd" id="2_lgwxd"]
[ext_resource type="Script" uid="uid://dq2pv2wy8uojd" path="res://multiplayer/ip_display.gd" id="3_f5ibf"]
[node name="HostMenu" type="VBoxContainer"]
script = ExtResource("1_83e8q")
[node name="Time" type="FoldableContainer" parent="."]
layout_mode = 2
folded = true
title = "Время раунда"
[node name="VBoxContainer" type="VBoxContainer" parent="Time"]
visible = false
layout_mode = 2
[node name="RoundTime" type="HBoxContainer" parent="Time/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Time/VBoxContainer/RoundTime"]
layout_mode = 2
text = "Время раунда"
[node name="RoundTimeBox" type="SpinBox" parent="Time/VBoxContainer/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="Time/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Time/VBoxContainer/BombTime"]
layout_mode = 2
text = "Отсчёт бомбы"
[node name="BombTimeBox" type="SpinBox" parent="Time/VBoxContainer/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="Time/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Time/VBoxContainer/BuyTime"]
layout_mode = 2
text = "Время закупок"
[node name="BuyTimeBox" type="SpinBox" parent="Time/VBoxContainer/BuyTime"]
unique_name_in_owner = true
layout_mode = 2
min_value = 1.0
step = 0.01
value = 1.0
allow_greater = true
[node name="Round" type="FoldableContainer" parent="."]
layout_mode = 2
folded = true
title = "Раунд"
[node name="VBoxContainer" type="VBoxContainer" parent="Round"]
visible = false
layout_mode = 2
[node name="RoundAmount" type="HBoxContainer" parent="Round/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Round/VBoxContainer/RoundAmount"]
layout_mode = 2
text = "Раундов для победы"
[node name="RoundBox" type="SpinBox" parent="Round/VBoxContainer/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="Round/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Round/VBoxContainer/TeamSwitchAmount"]
layout_mode = 2
text = "Раунд смены сторон"
[node name="TeamSwitchBox" type="SpinBox" parent="Round/VBoxContainer/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
[node name="FoldableContainer" type="FoldableContainer" parent="."]
layout_mode = 2
folded = true
title = "Геймплей"
[node name="AllowMultipleAbilityButton" type="CheckButton" parent="FoldableContainer"]
unique_name_in_owner = true
visible = false
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
text = "Неограниченная закупка абилок"
autowrap_mode = 2
[node name="PortForward" type="FoldableContainer" parent="."]
layout_mode = 2
folded = true
title = "Проброс портов"
[node name="PortForwardContainer" type="VBoxContainer" parent="PortForward"]
visible = false
layout_mode = 2
[node name="ForwardPortButton" type="Button" parent="PortForward/PortForwardContainer"]
layout_mode = 2
text = "Попробовать пробросить порты"
script = ExtResource("2_lgwxd")
[node name="Label" type="Label" parent="PortForward/PortForwardContainer"]
layout_mode = 2
text = "Статус публичного IP:"
[node name="PublicIP" type="LineEdit" parent="PortForward/PortForwardContainer"]
unique_name_in_owner = true
layout_mode = 2
editable = false
script = ExtResource("3_f5ibf")
[connection signal="value_changed" from="Time/VBoxContainer/RoundTime/RoundTimeBox" to="." method="_on_round_time_box_value_changed"]
[connection signal="value_changed" from="Time/VBoxContainer/BombTime/BombTimeBox" to="." method="_on_bomb_time_box_value_changed"]
[connection signal="value_changed" from="Time/VBoxContainer/BuyTime/BuyTimeBox" to="." method="_on_buy_time_box_value_changed"]
[connection signal="value_changed" from="Round/VBoxContainer/RoundAmount/RoundBox" to="." method="_on_round_box_value_changed"]
[connection signal="value_changed" from="Round/VBoxContainer/TeamSwitchAmount/TeamSwitchBox" to="." method="_on_team_switch_box_value_changed"]
[connection signal="toggled" from="FoldableContainer/AllowMultipleAbilityButton" to="." method="_on_allow_multiple_ability_button_toggled"]
[connection signal="update_ip" from="PortForward/PortForwardContainer/ForwardPortButton" to="PortForward/PortForwardContainer/PublicIP" method="on_update_ip"]

View file

@ -1,28 +0,0 @@
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

@ -1,9 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://cbtp4rvg66ba1"] [gd_scene load_steps=3 format=3 uid="uid://cbtp4rvg66ba1"]
[ext_resource type="Script" uid="uid://bsyuos803g7qf" path="res://gui/main_menu/main_menu_gui.gd" id="1_l6cm7"] [ext_resource type="Script" uid="uid://bsyuos803g7qf" path="res://gui/main_menu/main_menu_gui.gd" id="1_l6cm7"]
[ext_resource type="Script" uid="uid://dh64rv15w8ecl" path="res://gui/main_menu/host_menu.gd" id="2_ekxnf"] [ext_resource type="PackedScene" uid="uid://dswn8a8anj2hu" path="res://gui/host_menu/host_menu.tscn" id="2_85nol"]
[ext_resource type="Script" uid="uid://r1uwav8lrw6c" path="res://multiplayer/port_forward_button.gd" id="3_6wy0j"]
[ext_resource type="Script" uid="uid://dq2pv2wy8uojd" path="res://multiplayer/ip_display.gd" id="3_qy2xc"]
[node name="MainMenu" type="CenterContainer"] [node name="MainMenu" type="CenterContainer"]
anchors_preset = 15 anchors_preset = 15
@ -109,102 +107,13 @@ visible = false
layout_mode = 2 layout_mode = 2
text = "Join Spectators" text = "Join Spectators"
[node name="HostMenu" type="VBoxContainer" parent="Lobby/HBoxContainer"] [node name="HostConainer" type="ScrollContainer" parent="Lobby/HBoxContainer"]
layout_mode = 2
horizontal_scroll_mode = 0
[node name="HostMenu" parent="Lobby/HBoxContainer/HostConainer" instance=ExtResource("2_85nol")]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 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
[node name="ForwardPortButton" type="Button" parent="Lobby/HBoxContainer/HostMenu"]
layout_mode = 2
text = "Попробовать пробросить порты"
script = ExtResource("3_6wy0j")
[node name="Label" type="Label" parent="Lobby/HBoxContainer/HostMenu"]
layout_mode = 2
text = "Статус публичного IP:"
[node name="PublicIP" type="LineEdit" parent="Lobby/HBoxContainer/HostMenu"]
unique_name_in_owner = true
layout_mode = 2
editable = false
script = ExtResource("3_qy2xc")
[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"]
@ -213,9 +122,3 @@ script = ExtResource("3_qy2xc")
[connection signal="pressed" from="Lobby/HBoxContainer/ClientMenu/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/HBoxContainer/ClientMenu/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/HBoxContainer/ClientMenu/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"]
[connection signal="update_ip" from="Lobby/HBoxContainer/HostMenu/ForwardPortButton" to="Lobby/HBoxContainer/HostMenu/PublicIP" method="on_update_ip"]

View file

@ -15,13 +15,6 @@ var attack_team: Array[int] = []
var defence_team: Array[int] = [] var defence_team: Array[int] = []
var specators_team: Array[int] = [] var specators_team: Array[int] = []
# Host defined variables
var win_score: int = 13
var half_rounds :int = 12
var bomb_time: float = 45.0
var buy_time: float = 15.0
var round_time: float = 150.0
func _ready() -> void: func _ready() -> void:
multiplayer.peer_disconnected.connect(player_left) multiplayer.peer_disconnected.connect(player_left)
multiplayer.server_disconnected.connect(server_disconnected) multiplayer.server_disconnected.connect(server_disconnected)

View file

@ -0,0 +1,8 @@
extends Node
var win_score: int = 13
var half_rounds :int = 12
var bomb_time: float = 45.0
var buy_time: float = 15.0
var round_time: float = 150.0
var allow_multiple_abilities: bool = false

View file

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

View file

@ -167,9 +167,9 @@ func start_session() -> void:
session_started_flag = true session_started_flag = true
session_started.emit() session_started.emit()
bomb_timer.wait_time = Lobby.bomb_time bomb_timer.wait_time = LobbySettings.bomb_time
round_timer.wait_time = Lobby.round_time round_timer.wait_time = LobbySettings.round_time
buy_timer.wait_time = Lobby.buy_time buy_timer.wait_time = LobbySettings.buy_time
var all_players: PackedInt32Array = multiplayer.get_peers() var all_players: PackedInt32Array = multiplayer.get_peers()
all_players.append(multiplayer.get_unique_id()) all_players.append(multiplayer.get_unique_id())

View file

@ -1,4 +0,0 @@
extends Node
var player: CharacterBody3D

View file

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

View file

@ -20,8 +20,8 @@ config/icon="res://icon.svg"
[autoload] [autoload]
PlayerGlobal="*res://players/player/player_global.gd"
Lobby="*res://multiplayer/lobby.gd" Lobby="*res://multiplayer/lobby.gd"
LobbySettings="*res://multiplayer/lobby_settings.gd"
Session="*res://multiplayer/session.gd" Session="*res://multiplayer/session.gd"
ClientSettings="*res://gui/client_settings/client_settings.gd" ClientSettings="*res://gui/client_settings/client_settings.gd"
Registry="*res://systems/registry.gd" Registry="*res://systems/registry.gd"

View file

@ -80,6 +80,8 @@ func get_empty_ability_slot() -> StringName:
return "ability_first" return "ability_first"
func can_add_ability(ability: StringName, slot: StringName) -> bool: func can_add_ability(ability: StringName, slot: StringName) -> bool:
if LobbySettings.allow_multiple_abilities:
return can_add(slot)
for ability_slot in ["ability_first","ability_second","ability_third"]: for ability_slot in ["ability_first","ability_second","ability_third"]:
if slots[ability_slot] != null and slots[ability_slot].weapon_gid == ability: if slots[ability_slot] != null and slots[ability_slot].weapon_gid == ability:
return false return false