Global refactor

This commit is contained in:
Rendo 2025-12-09 11:53:52 +05:00
commit 0589ca4e23
180 changed files with 249 additions and 401 deletions

View file

@ -0,0 +1,15 @@
extends Button
@export var weapon: WeaponResource
func _ready() -> void:
icon = weapon.preview
text = str(weapon.cost)
func _pressed() -> void:
var player_data = Session.get_player_data()
if player_data["money"] >= weapon.cost:
var player: Player = Session.player_nodes[multiplayer.get_unique_id()]
player_data["money"] -= weapon.cost
player.get_node("WeaponSystem").add(weapon.weapon_system_scene.instantiate(),"ability_first")

View file

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

View file

@ -0,0 +1,17 @@
[gd_scene load_steps=3 format=3 uid="uid://b1ej6kmbjpm78"]
[ext_resource type="Texture2D" uid="uid://dnxw4x3cmu7io" path="res://icon.svg" id="1_apu4l"]
[ext_resource type="Script" uid="uid://bq32y7eee1f63" path="res://gui/buy_menu/buy_button/buy_button.gd" id="1_impj7"]
[node name="BuyButton" type="Button"]
anchors_preset = -1
anchor_right = 0.035
anchor_bottom = 0.075
offset_right = -4.799999
offset_bottom = -14.000004
text = "3600"
icon = ExtResource("1_apu4l")
icon_alignment = 1
vertical_icon_alignment = 0
expand_icon = true
script = ExtResource("1_impj7")

29
gui/buy_menu/buy_menu.gd Normal file
View file

@ -0,0 +1,29 @@
extends ColorRect
func _ready() -> void:
Session.round_state_changed.connect(on_round_state_changed)
func on_round_state_changed(state: int) -> void:
if state != Session.ROUND_STATES.BUY:
visible = false
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
if Session.session_started_flag:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _input(event: InputEvent) -> void:
if event.is_action_pressed("plr_buy"):
if Session.round_state == Session.ROUND_STATES.BUY:
visible = not visible
else:
visible = false
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
if Session.session_started_flag:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE

View file

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

View file

@ -0,0 +1,45 @@
[gd_scene load_steps=5 format=3 uid="uid://j5lgbg8c0pq"]
[ext_resource type="PackedScene" uid="uid://b1ej6kmbjpm78" path="res://gui/buy_menu/buy_button/buy_button.tscn" id="1_8guql"]
[ext_resource type="Script" uid="uid://dba17sgimp4j0" path="res://gui/buy_menu/buy_menu.gd" id="1_ko0fn"]
[ext_resource type="Resource" uid="uid://b081hg7uxx1wu" path="res://weapons/molikman_molotov.tres" id="2_0gws3"]
[ext_resource type="Script" uid="uid://dk4diwvruvkch" path="res://gui/buy_menu/player_money_label.gd" id="2_ll0n6"]
[node name="BuyMenu" type="ColorRect"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0.22745098)
script = ExtResource("1_ko0fn")
[node name="CenterContainer" type="CenterContainer" 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="PanelContainer" type="PanelContainer" parent="CenterContainer"]
layout_mode = 2
[node name="AbilitiesContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
layout_mode = 2
script = ExtResource("2_ll0n6")
[node name="WeaponsContainer" type="GridContainer" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
layout_mode = 2
columns = 5
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
layout_mode = 2
[node name="BuyButton" parent="CenterContainer/PanelContainer/AbilitiesContainer/HBoxContainer" instance=ExtResource("1_8guql")]
layout_mode = 2
weapon = ExtResource("2_0gws3")

View file

@ -0,0 +1,7 @@
extends Label
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
var data = Session.get_player_data()
if data.has("money"):
text = str(data["money"])

View file

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

View file

@ -0,0 +1,7 @@
extends Node
var SENSITIVITY: float = 0.004
var TOGGLE_CROUCH: bool = false
var TOGGLE_SCOPE: bool = false
var TOGGLE_WALK: bool = false

View file

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

View file

@ -0,0 +1,86 @@
[gd_scene load_steps=2 format=3 uid="uid://bv6ptrditssow"]
[ext_resource type="Script" uid="uid://ddi1alk8oyi1b" path="res://gui/client_settings/client_settings_menu.gd" id="1_xqyus"]
[node name="ClientSettingsMenu" type="CanvasLayer"]
layer = 3
[node name="CenterContainer" type="CenterContainer" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="PanelContainer" type="PanelContainer" parent="CenterContainer"]
layout_mode = 2
script = ExtResource("1_xqyus")
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer"]
layout_mode = 2
[node name="FullscreenButton" type="CheckButton" parent="CenterContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
text = "Полный экран"
[node name="Sensitivity" type="HBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer/Sensitivity"]
layout_mode = 2
text = "Чувствительность"
[node name="SensitivitySlider" type="HSlider" parent="CenterContainer/PanelContainer/VBoxContainer/Sensitivity"]
unique_name_in_owner = true
custom_minimum_size = Vector2(256, 0)
layout_mode = 2
size_flags_horizontal = 3
min_value = 0.001
max_value = 0.02
step = 0.001
value = 0.001
[node name="SensitivityBox" type="SpinBox" parent="CenterContainer/PanelContainer/VBoxContainer/Sensitivity"]
unique_name_in_owner = true
layout_mode = 2
max_value = 0.1
step = 0.001
value = 0.02
allow_greater = true
allow_lesser = true
[node name="GameplayMainAudio" type="HBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer/GameplayMainAudio"]
layout_mode = 2
text = "Геймплейные звуки"
[node name="GameplayMainSlider" type="HSlider" parent="CenterContainer/PanelContainer/VBoxContainer/GameplayMainAudio"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
max_value = 1.0
step = 0.01
value = 1.0
[node name="LeaveButton" type="Button" parent="CenterContainer/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "Покинуть сессию"
[node name="StopSession" type="Button" parent="CenterContainer/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "Окончить сессию"
[connection signal="pressed" from="CenterContainer/PanelContainer/VBoxContainer/FullscreenButton" to="CenterContainer/PanelContainer" method="_on_fullscreen_button_pressed"]
[connection signal="toggled" from="CenterContainer/PanelContainer/VBoxContainer/FullscreenButton" to="CenterContainer/PanelContainer" method="_on_fullscreen_button_toggled"]
[connection signal="value_changed" from="CenterContainer/PanelContainer/VBoxContainer/Sensitivity/SensitivitySlider" to="CenterContainer/PanelContainer" method="_on_sensitivity_slider_value_changed"]
[connection signal="value_changed" from="CenterContainer/PanelContainer/VBoxContainer/Sensitivity/SensitivityBox" to="CenterContainer/PanelContainer" method="_on_sensitivity_box_value_changed"]
[connection signal="value_changed" from="CenterContainer/PanelContainer/VBoxContainer/GameplayMainAudio/GameplayMainSlider" to="CenterContainer/PanelContainer" method="_on_gameplay_main_slider_value_changed"]
[connection signal="pressed" from="CenterContainer/PanelContainer/VBoxContainer/LeaveButton" to="CenterContainer/PanelContainer" method="_on_leave_button_pressed"]
[connection signal="pressed" from="CenterContainer/PanelContainer/VBoxContainer/StopSession" to="CenterContainer/PanelContainer" method="_on_stop_session_pressed"]

View file

@ -0,0 +1,43 @@
extends Control
func _ready() -> void:
hide()
Session.session_started.connect(%LeaveButton.show)
Session.session_ended.connect(%LeaveButton.hide)
Lobby.lobby_created.connect(%StopSession.show)
Lobby.lobby_closed.connect(%StopSession.hide)
%SensitivitySlider.set_value_no_signal(ClientSettings.SENSITIVITY)
%SensitivityBox.set_value_no_signal(ClientSettings.SENSITIVITY)
func _input(event: InputEvent) -> void:
if event.is_action_pressed("menu_settings"):
visible = not visible
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
if Session.session_started_flag:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _on_gameplay_main_slider_value_changed(value: float) -> void:
AudioServer.set_bus_volume_linear(1,value)
func _on_fullscreen_button_toggled(toggled_on: bool) -> void:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN if toggled_on else DisplayServer.WINDOW_MODE_WINDOWED)
func _on_sensitivity_slider_value_changed(value: float) -> void:
%SensitivityBox.set_value_no_signal(value)
ClientSettings.SENSITIVITY = value
func _on_sensitivity_box_value_changed(value: float) -> void:
%SensitivitySlider.set_value_no_signal(value)
ClientSettings.SENSITIVITY = value
func _on_leave_button_pressed() -> void:
Session.quit_session()
func _on_stop_session_pressed() -> void:
if multiplayer.is_server():
Session.end_session()

View file

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

22
gui/crosshair.gd Normal file
View file

@ -0,0 +1,22 @@
extends Control
@export var outline: bool = true
@export var outline_color: Color = Color.BLACK
@export var outline_width: float = 0.1
@export var dot_radius: float = 1.0
@export var dot_color: Color = Color.WHITE
@export var crosses_width: float = 1.0
@export var crosses_length: float = 2.0
@export var crosses_offset: float = 0.2
@export var crosses_color: Color = Color.WHITE
func _draw() -> void:
var origin = size/2.0
draw_circle(origin,dot_radius,dot_color,false,outline_width)
for i in range(0,4):
var direction: Vector2 = Vector2.RIGHT.rotated(i*PI/2)
var offset_position: Vector2 = direction * crosses_offset
draw_line(origin+offset_position,origin+direction*crosses_length+offset_position,crosses_color,crosses_width)

1
gui/crosshair.gd.uid Normal file
View file

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

View file

@ -0,0 +1,5 @@
extends Label
func on_ammo_updated(ammo: int, remaining_ammo: int):
text = str(ammo)+"/"+str(remaining_ammo)

View file

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

View file

@ -0,0 +1,5 @@
extends ProgressBar
func on_hp_changed(to: int):
value = to

View file

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

View file

@ -0,0 +1,22 @@
extends Label
@export var our_side: bool
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
Session.round_started.connect(update)
Session.session_started.connect(update)
func update():
if our_side:
match Lobby.get_team():
Session.TEAMS.DEFENCE:
text = str(Session.defender_score)
Session.TEAMS.ATTACK, Session.TEAMS.SPECTATE, Session.TEAMS.UNASSIGNED:
text = str(Session.attacker_score)
else:
match Lobby.get_team():
Session.TEAMS.DEFENCE:
text = str(Session.attacker_score)
Session.TEAMS.ATTACK, Session.TEAMS.SPECTATE, Session.TEAMS.UNASSIGNED:
text = str(Session.defender_score)

View file

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

View file

@ -0,0 +1,8 @@
extends Label
func _process(_delta: float) -> void:
var seconds_u = int(round(Session.reference_round_time))
var seconds = seconds_u % 60
@warning_ignore("integer_division")
var minutes = seconds_u / 60
text = str(minutes)+":"+str(seconds).pad_zeros(2)

View file

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

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

View 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"]

View 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()

View file

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

View file

@ -0,0 +1,37 @@
extends Control
func _on_spectator_button_pressed() -> void:
if Lobby.get_team() != Session.TEAMS.SPECTATE:
Lobby.switch_team(Session.TEAMS.SPECTATE)
visible = false
update_mouse()
func _on_attack_button_pressed() -> void:
if Lobby.get_team() != Session.TEAMS.ATTACK:
Lobby.switch_team(Session.TEAMS.ATTACK)
visible = false
update_mouse()
func _on_defence_button_pressed() -> void:
if Lobby.get_team() != Session.TEAMS.DEFENCE:
Lobby.switch_team(Session.TEAMS.DEFENCE)
visible = false
update_mouse()
func _on_cancel_button_pressed() -> void:
visible = false
update_mouse()
func _input(event: InputEvent) -> void:
if event.is_action_pressed("menu_team_choice"):
visible = not visible
update_mouse()
func update_mouse() -> void:
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
if Session.session_started_flag:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE

View file

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

View file

@ -0,0 +1,47 @@
[gd_scene load_steps=2 format=3 uid="uid://cmon3g1lsm3q"]
[ext_resource type="Script" uid="uid://m8qq2eynls6n" path="res://gui/team_choice/team_choice_menu.gd" id="1_kch1g"]
[node name="TeamChoiceMenu" type="CenterContainer"]
visible = false
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_kch1g")
[node name="Panel" type="PanelContainer" parent="."]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Panel"]
layout_mode = 2
[node name="Label" type="Label" parent="Panel/VBoxContainer"]
layout_mode = 2
text = "Choose your team"
horizontal_alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer"]
layout_mode = 2
[node name="SpectatorButton" type="Button" parent="Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Spectators"
[node name="AttackButton" type="Button" parent="Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Attackers"
[node name="DefenceButton" type="Button" parent="Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Defenders"
[node name="CancelButton" type="Button" parent="Panel/VBoxContainer"]
layout_mode = 2
text = "Cancel"
[connection signal="pressed" from="Panel/VBoxContainer/HBoxContainer/SpectatorButton" to="." method="_on_spectator_button_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/HBoxContainer/AttackButton" to="." method="_on_attack_button_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/HBoxContainer/DefenceButton" to="." method="_on_defence_button_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/CancelButton" to="." method="_on_cancel_button_pressed"]