From 59bf07b076b33b7693d1adf4f72a9ef66d28f7f8 Mon Sep 17 00:00:00 2001 From: Rendo Date: Sun, 7 Dec 2025 17:21:01 +0500 Subject: [PATCH] Team switch --- levels/prototype_scene.tscn | 47 ++++++++++++++++++++++++++++- project.godot | 5 +++ scripts/gui/client_settings_menu.gd | 1 - scripts/gui/team_choice_menu.gd | 37 +++++++++++++++++++++++ scripts/gui/team_choice_menu.gd.uid | 1 + 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 scripts/gui/team_choice_menu.gd create mode 100644 scripts/gui/team_choice_menu.gd.uid diff --git a/levels/prototype_scene.tscn b/levels/prototype_scene.tscn index 2a8deb4..0d6f3af 100644 --- a/levels/prototype_scene.tscn +++ b/levels/prototype_scene.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=23 format=3 uid="uid://cqrh2cc7m2i7f"] +[gd_scene load_steps=24 format=3 uid="uid://cqrh2cc7m2i7f"] [ext_resource type="Environment" uid="uid://d0cfgtx2yxw13" path="res://environments/prototype_environment.tres" id="1_i6jab"] [ext_resource type="Material" uid="uid://bx3f5vx71ynh5" path="res://materials/Graymat.tres" id="4_y6i55"] @@ -18,6 +18,7 @@ [ext_resource type="Script" uid="uid://3i00rp8urth7" path="res://scripts/object_container.gd" id="11_02ic3"] [ext_resource type="Script" uid="uid://bala54fa32e35" path="res://scripts/gui/hud/player_round_display.gd" id="17_wsuwo"] [ext_resource type="Script" uid="uid://bos7nftlx8tv3" path="res://scripts/gui/hud/player_round_time.gd" id="18_0hcup"] +[ext_resource type="Script" uid="uid://m8qq2eynls6n" path="res://scripts/gui/team_choice_menu.gd" id="19_0hcup"] [sub_resource type="BoxShape3D" id="BoxShape3D_ysk2e"] size = Vector3(15.324341, 0.96273804, 21.381592) @@ -339,3 +340,47 @@ script = ExtResource("18_0hcup") [node name="RoundDisplayTheir" type="Label" parent="CanvasLayer/RoundData"] layout_mode = 2 script = ExtResource("17_wsuwo") + +[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer"] +visible = false +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("19_0hcup") + +[node name="Panel" type="PanelContainer" parent="CanvasLayer/CenterContainer"] +layout_mode = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/CenterContainer/Panel"] +layout_mode = 2 + +[node name="Label" type="Label" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer"] +layout_mode = 2 +text = "Choose your team" +horizontal_alignment = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer"] +layout_mode = 2 + +[node name="SpectatorButton" type="Button" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "Spectators" + +[node name="AttackButton" type="Button" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "Attackers" + +[node name="DefenceButton" type="Button" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "Defenders" + +[node name="CancelButton" type="Button" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer"] +layout_mode = 2 +text = "Cancel" + +[connection signal="pressed" from="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer/SpectatorButton" to="CanvasLayer/CenterContainer" method="_on_spectator_button_pressed"] +[connection signal="pressed" from="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer/AttackButton" to="CanvasLayer/CenterContainer" method="_on_attack_button_pressed"] +[connection signal="pressed" from="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer/DefenceButton" to="CanvasLayer/CenterContainer" method="_on_defence_button_pressed"] +[connection signal="pressed" from="CanvasLayer/CenterContainer/Panel/VBoxContainer/CancelButton" to="CanvasLayer/CenterContainer" method="_on_cancel_button_pressed"] diff --git a/project.godot b/project.godot index 41109f9..62e91e6 100644 --- a/project.godot +++ b/project.godot @@ -156,6 +156,11 @@ menu_settings={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } +menu_team_choice={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":77,"key_label":0,"unicode":109,"location":0,"echo":false,"script":null) +] +} [layer_names] diff --git a/scripts/gui/client_settings_menu.gd b/scripts/gui/client_settings_menu.gd index cc19bfd..da89a96 100644 --- a/scripts/gui/client_settings_menu.gd +++ b/scripts/gui/client_settings_menu.gd @@ -5,7 +5,6 @@ var cached_mouse_state: Input.MouseMode func _on_check_button_toggled(toggled_on: bool) -> void: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN if toggled_on else DisplayServer.WINDOW_MODE_WINDOWED) - func _on_h_slider_value_changed(value: float) -> void: $VBoxContainer/Sensitivity/SpinBox.set_value_no_signal(value) ClientSettings.SENSITIVITY = value diff --git a/scripts/gui/team_choice_menu.gd b/scripts/gui/team_choice_menu.gd new file mode 100644 index 0000000..ed314a2 --- /dev/null +++ b/scripts/gui/team_choice_menu.gd @@ -0,0 +1,37 @@ +extends Control + +var cached_mouse_state: Input.MouseMode + +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: + cached_mouse_state = Input.mouse_mode + Input.mouse_mode = Input.MOUSE_MODE_VISIBLE + else: + Input.mouse_mode = cached_mouse_state diff --git a/scripts/gui/team_choice_menu.gd.uid b/scripts/gui/team_choice_menu.gd.uid new file mode 100644 index 0000000..75ed8fb --- /dev/null +++ b/scripts/gui/team_choice_menu.gd.uid @@ -0,0 +1 @@ +uid://m8qq2eynls6n