Global refactor
This commit is contained in:
parent
3868af29e3
commit
0589ca4e23
180 changed files with 249 additions and 401 deletions
28
gui/main_menu/host_menu.gd
Normal file
28
gui/main_menu/host_menu.gd
Normal 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)
|
||||
1
gui/main_menu/host_menu.gd.uid
Normal file
1
gui/main_menu/host_menu.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dh64rv15w8ecl
|
||||
203
gui/main_menu/main_menu.tscn
Normal file
203
gui/main_menu/main_menu.tscn
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
[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://dh64rv15w8ecl" path="res://gui/main_menu/host_menu.gd" id="2_ekxnf"]
|
||||
|
||||
[node name="MainMenu" type="CenterContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_l6cm7")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="MainMenu" type="PanelContainer" parent="."]
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(256, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MainMenu"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HostButton" type="Button" parent="MainMenu/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "HOST"
|
||||
|
||||
[node name="ConnectButton" type="Button" parent="MainMenu/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "CONNECT"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="MainMenu/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
placeholder_text = "ip"
|
||||
|
||||
[node name="Lobby" type="PanelContainer" parent="."]
|
||||
custom_minimum_size = Vector2(256, 256)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Lobby"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ClientMenu" type="VBoxContainer" parent="Lobby/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Players" type="HBoxContainer" parent="Lobby/HBoxContainer/ClientMenu"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
|
||||
[node name="AttackTeam" type="VBoxContainer" parent="Lobby/HBoxContainer/ClientMenu/Players"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="TeamName" type="Label" parent="Lobby/HBoxContainer/ClientMenu/Players/AttackTeam"]
|
||||
layout_mode = 2
|
||||
text = "Attack"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="DefenceTeam" type="VBoxContainer" parent="Lobby/HBoxContainer/ClientMenu/Players"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="TeamName" type="Label" parent="Lobby/HBoxContainer/ClientMenu/Players/DefenceTeam"]
|
||||
layout_mode = 2
|
||||
text = "Defence"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="SpectatorsTeam" type="VBoxContainer" parent="Lobby/HBoxContainer/ClientMenu/Players"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="TeamName" type="Label" parent="Lobby/HBoxContainer/ClientMenu/Players/SpectatorsTeam"]
|
||||
layout_mode = 2
|
||||
text = "Spectators"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Buttons" type="HBoxContainer" parent="Lobby/HBoxContainer/ClientMenu"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="LeaveButton" type="Button" parent="Lobby/HBoxContainer/ClientMenu/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Leave"
|
||||
|
||||
[node name="StartButton" type="Button" parent="Lobby/HBoxContainer/ClientMenu/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Start"
|
||||
|
||||
[node name="JoinAttackButton" type="Button" parent="Lobby/HBoxContainer/ClientMenu/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Join Attack"
|
||||
|
||||
[node name="JoinDefenceButton" type="Button" parent="Lobby/HBoxContainer/ClientMenu/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Join Defence"
|
||||
|
||||
[node name="JoinSpectatorsButton" type="Button" parent="Lobby/HBoxContainer/ClientMenu/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
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/ConnectButton" to="." method="_on_connect_button_pressed"]
|
||||
[connection signal="pressed" from="Lobby/HBoxContainer/ClientMenu/Buttons/LeaveButton" to="." method="_on_leave_button_pressed"]
|
||||
[connection signal="pressed" from="Lobby/HBoxContainer/ClientMenu/Buttons/StartButton" to="." method="_on_start_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/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"]
|
||||
110
gui/main_menu/main_menu_gui.gd
Normal file
110
gui/main_menu/main_menu_gui.gd
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
extends Control
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Lobby.lobby_joined.connect(hide_host_buttons)
|
||||
Session.session_started.connect(hide)
|
||||
Lobby.lobby_created.connect(show_host_buttons)
|
||||
Lobby.lobby_closed.connect(cleanup_lobby)
|
||||
Lobby.update_teams_state.connect(on_player_switched_team)
|
||||
Session.session_ended.connect(on_session_ended)
|
||||
|
||||
$Lobby.hide()
|
||||
$MainMenu.show()
|
||||
|
||||
func _on_leave_button_pressed() -> void:
|
||||
Lobby.leave()
|
||||
cleanup_lobby()
|
||||
|
||||
func cleanup_lobby() -> void:
|
||||
$Lobby.hide()
|
||||
$MainMenu.show()
|
||||
%JoinAttackButton.show()
|
||||
%JoinDefenceButton.show()
|
||||
%JoinSpectatorsButton.hide()
|
||||
|
||||
|
||||
func _on_start_button_pressed() -> void:
|
||||
Lobby.start_game()
|
||||
|
||||
func hide_host_buttons() -> void:
|
||||
%StartButton.hide()
|
||||
%HostMenu.hide()
|
||||
|
||||
func show_host_buttons() -> void:
|
||||
%StartButton.show()
|
||||
%HostMenu.show()
|
||||
|
||||
func _on_host_button_pressed() -> void:
|
||||
Lobby.host()
|
||||
$MainMenu.hide()
|
||||
$Lobby.show()
|
||||
|
||||
func _on_connect_button_pressed() -> void:
|
||||
var ip = $MainMenu/VBoxContainer/LineEdit.text
|
||||
if ip == "":
|
||||
ip = "localhost"
|
||||
var joined = Lobby.join(ip)
|
||||
if joined != Error.OK:
|
||||
return
|
||||
$MainMenu.hide()
|
||||
$Lobby.show()
|
||||
|
||||
func on_player_switched_team():
|
||||
%JoinAttackButton.hide()
|
||||
%JoinDefenceButton.hide()
|
||||
%JoinSpectatorsButton.visible = Lobby.specators_team.has(multiplayer.get_unique_id()) == false
|
||||
if Lobby.attack_team.size() < 5 and not Lobby.attack_team.has(multiplayer.get_unique_id()):
|
||||
%JoinAttackButton.show()
|
||||
if Lobby.defence_team.size() < 5 and not Lobby.defence_team.has(multiplayer.get_unique_id()):
|
||||
%JoinDefenceButton.show()
|
||||
|
||||
for child in %AttackTeam.get_children():
|
||||
if child.name == "TeamName":
|
||||
continue
|
||||
child.queue_free()
|
||||
|
||||
for child in %DefenceTeam.get_children():
|
||||
if child.name == "TeamName":
|
||||
continue
|
||||
child.queue_free()
|
||||
|
||||
for child in %SpectatorsTeam.get_children():
|
||||
if child.name == "TeamName":
|
||||
continue
|
||||
child.queue_free()
|
||||
|
||||
for attacker in Lobby.attack_team:
|
||||
var label = Label.new()
|
||||
label.text = str(attacker)
|
||||
%AttackTeam.add_child(label)
|
||||
|
||||
for defender in Lobby.defence_team:
|
||||
var label = Label.new()
|
||||
label.text = str(defender)
|
||||
%DefenceTeam.add_child(label)
|
||||
|
||||
for spectator in Lobby.specators_team:
|
||||
var label = Label.new()
|
||||
label.text = str(spectator)
|
||||
%SpectatorsTeam.add_child(label)
|
||||
|
||||
func _on_join_attack_button_pressed() -> void:
|
||||
Lobby.switch_team(Session.TEAMS.ATTACK)
|
||||
|
||||
|
||||
func _on_join_defence_button_pressed() -> void:
|
||||
Lobby.switch_team(Session.TEAMS.DEFENCE)
|
||||
|
||||
|
||||
func _on_join_spectators_button_pressed() -> void:
|
||||
Lobby.switch_team(Session.TEAMS.SPECTATE)
|
||||
|
||||
func on_session_ended() -> void:
|
||||
show()
|
||||
if Lobby.in_lobby:
|
||||
$MainMenu.hide()
|
||||
$Lobby.show()
|
||||
else:
|
||||
$MainMenu.show()
|
||||
$Lobby.hide()
|
||||
1
gui/main_menu/main_menu_gui.gd.uid
Normal file
1
gui/main_menu/main_menu_gui.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bsyuos803g7qf
|
||||
Loading…
Add table
Add a link
Reference in a new issue