Compare commits

...

8 Commits

Author SHA1 Message Date
45a3cbb163 Add max length to name 2026-07-24 04:27:09 +03:00
2cc78905c3 Change a bunch of TextEdits into LineEdits 2026-07-24 04:25:55 +03:00
0a61d805a0 Improve chat 2026-07-24 04:18:44 +03:00
f9593454ce Make sure chat messages always remain 2026-07-24 04:14:55 +03:00
c44b419f9f Add sending chat messages as well 2026-07-24 04:11:18 +03:00
1664ee7973 Add chat & chat box 2026-07-24 03:58:44 +03:00
f9e6c5727e Add some preliminary chat messages 2026-07-24 02:49:46 +03:00
ebc9a93b5f Add announcements 2026-07-24 02:13:21 +03:00
46 changed files with 892 additions and 115 deletions

View File

@ -2,5 +2,6 @@
- [LaserFast and LaserWithRecovery](godot/raw_assets/sfx/)
- [Hit](godot/raw_assets/sfx/Hit.mp3)
- [Footstep sounds on Tree Trunk](godot/raw_assets/sfx/footsteps/) via [zapsplat](https://www.zapsplat.com/sound-effect-packs/footsteps-on-fallen-tree-trunk)
- [Announcer sounds](godot/raw_assets/sfx/announcer/) by [TripleSnail](https://opengameart.org/content/announcer-kill-sounds)
- [Soldier model and rig](godot/raw_assets/Soldier/) by [Casti_131](https://opengameart.org/content/low-poly-soldier-with-weapons)
- [Torment Textures](godot/maps/textures) (`str_*` files) by [Bradley D. (strideh.itch.io)](https://strideh.itch.io)

View File

@ -26,15 +26,6 @@ local_player = ExtResource("1_yjvui")
remote_player = ExtResource("2_kcncr")
ball = ExtResource("3_e0nj3")
[node name="net_stats_label" type="NetStatsLabel" parent="." unique_id=1821474986]
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -152.0
offset_right = 369.0
grow_vertical = 0
vertical_alignment = 2
[node name="terrain" type="MeshInstance3D" parent="." unique_id=1474127252]
material_override = SubResource("StandardMaterial3D_u8vuu")
mesh = SubResource("PlaneMesh_1cgct")

View File

@ -22,6 +22,7 @@ CommandLinePanelGlobal="*uid://bsb6asp5o35w3"
GameManagerGlobal="*uid://bii6018k3ip3t"
CliParserGlobal="*uid://c52o7xa0fnr53"
GameSettingsGlobal="*uid://bjr15hjiojecw"
AnnouncerGlobal="*uid://5gey4i80mmsa"
[display]
@ -98,6 +99,11 @@ scoreboard={
"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":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
open_chat={
"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":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
[physics]

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cmx868xfm5tr"
path="res://.godot/imported/Carnage.wav-0aa25ce2dbaf67c412d878ecccaa2a43.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/Carnage.wav"
dest_files=["res://.godot/imported/Carnage.wav-0aa25ce2dbaf67c412d878ecccaa2a43.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bwv7hydyynxo3"
path="res://.godot/imported/Dominating.wav-9094379de14f4d99f4362076b03e9be9.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/Dominating.wav"
dest_files=["res://.godot/imported/Dominating.wav-9094379de14f4d99f4362076b03e9be9.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://b5816xcsj2ueh"
path="res://.godot/imported/DoubleKill.wav-1dae3420408145da22058102a5b9489c.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/DoubleKill.wav"
dest_files=["res://.godot/imported/DoubleKill.wav-1dae3420408145da22058102a5b9489c.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bg8wugv6ij0pj"
path="res://.godot/imported/FirstBlood.wav-3a1ab2cafcafce472d28811db364622d.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/FirstBlood.wav"
dest_files=["res://.godot/imported/FirstBlood.wav-3a1ab2cafcafce472d28811db364622d.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://celsg1h2xc85k"
path="res://.godot/imported/Godlike.wav-5ec4df26a22987b555e4f010565e2276.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/Godlike.wav"
dest_files=["res://.godot/imported/Godlike.wav-5ec4df26a22987b555e4f010565e2276.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cc5t6p6w468hi"
path="res://.godot/imported/KillingSpree.wav-448dff3e279f17fef54b67c2bf084908.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/KillingSpree.wav"
dest_files=["res://.godot/imported/KillingSpree.wav-448dff3e279f17fef54b67c2bf084908.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://baml6py7t1ycd"
path="res://.godot/imported/Massacre.wav-26fd0dde29cf79df78d170f36281a8b1.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/Massacre.wav"
dest_files=["res://.godot/imported/Massacre.wav-26fd0dde29cf79df78d170f36281a8b1.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bjewmgxjuwsqo"
path="res://.godot/imported/Mayhem.wav-ea221444f4057bff04fd5e46ce2da957.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/Mayhem.wav"
dest_files=["res://.godot/imported/Mayhem.wav-ea221444f4057bff04fd5e46ce2da957.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dfxrsl808f6o0"
path="res://.godot/imported/MegaKill.wav-809778ac21e83a3da5eb84b1403e21a2.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/MegaKill.wav"
dest_files=["res://.godot/imported/MegaKill.wav-809778ac21e83a3da5eb84b1403e21a2.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://4i6t6yh2j45t"
path="res://.godot/imported/Ownage.wav-7853435740c868c6707b6c2ef354df86.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/Ownage.wav"
dest_files=["res://.godot/imported/Ownage.wav-7853435740c868c6707b6c2ef354df86.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://ccg5hd454nqpe"
path="res://.godot/imported/Rampage.wav-328d28840941970a1c0afd53cf5a6790.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/Rampage.wav"
dest_files=["res://.godot/imported/Rampage.wav-328d28840941970a1c0afd53cf5a6790.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://co82glo13i8at"
path="res://.godot/imported/TripleKill.wav-5cd8a2f25db2a8430eba6089c5c04d0e.sample"
[deps]
source_file="res://raw_assets/sfx/announcer/TripleKill.wav"
dest_files=["res://.godot/imported/TripleKill.wav-5cd8a2f25db2a8430eba6089c5c04d0e.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

View File

@ -1,6 +1,7 @@
[gd_scene format=3 uid="uid://bwd6bj21x310s"]
[ext_resource type="PackedScene" uid="uid://ccd0wj2usx5os" path="res://scenes/ui/lobby_player_listing.tscn" id="1_o1atq"]
[ext_resource type="PackedScene" uid="uid://ffh5txda3j1" path="res://scenes/ui/chat_box.tscn" id="2_5gu6x"]
[sub_resource type="LabelSettings" id="LabelSettings_1cgct"]
font_size = 32
@ -10,9 +11,9 @@ bg_color = Color(0.30692267, 0.3069227, 0.30692264, 1)
[node name="lobby" type="LobbyPanel" unique_id=915192272 node_paths=PackedStringArray("players_list", "name_field", "ready_button", "map_selection", "options_panel", "options_grid")]
players_list = NodePath("v_box_container/players_list")
name_field = NodePath("v_box_container/h_box_container/text_edit")
name_field = NodePath("")
player_listing_prefab = ExtResource("1_o1atq")
ready_button = NodePath("ready_button")
ready_button = NodePath("v_box_container3/ready_button")
map_selection = NodePath("v_box_container2/option_button")
options_panel = NodePath("options_panel")
options_grid = NodePath("options_panel/h_box_container/options_grid")
@ -26,8 +27,8 @@ grow_vertical = 2
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_top = 69.0
offset_bottom = 92.0
offset_top = 8.0
offset_bottom = 53.0
grow_horizontal = 2
text = "Lobby"
label_settings = SubResource("LabelSettings_1cgct")
@ -35,14 +36,13 @@ horizontal_alignment = 1
[node name="v_box_container" type="VBoxContainer" parent="." unique_id=336946640]
layout_mode = 0
offset_left = 129.0
offset_top = 146.0
offset_right = 334.0
offset_bottom = 200.0
offset_left = 85.0
offset_top = 111.0
offset_right = 290.0
offset_bottom = 165.0
[node name="h_box_container" type="HBoxContainer" parent="v_box_container" unique_id=1789302658]
layout_mode = 2
offset_transform_enabled = true
offset_transform_position = Vector2(100, 0)
metadata/_edit_lock_ = true
@ -50,9 +50,10 @@ metadata/_edit_lock_ = true
layout_mode = 2
text = "Name:"
[node name="text_edit" type="TextEdit" parent="v_box_container/h_box_container" unique_id=683714912]
[node name="text_edit" type="LineEdit" parent="v_box_container/h_box_container" unique_id=284528736]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
max_length = 20
[node name="players_label" type="Label" parent="v_box_container" unique_id=1537542117]
layout_mode = 2
@ -63,38 +64,15 @@ metadata/_edit_lock_ = true
layout_mode = 2
metadata/_edit_lock_ = true
[node name="netstats" type="NetStatsLabel" parent="." unique_id=1335814511]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -144.0
grow_horizontal = 2
grow_vertical = 0
vertical_alignment = 2
[node name="ready_button" type="Button" parent="." unique_id=311553419]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 129.0
offset_top = -177.0
offset_right = 278.0
offset_bottom = -126.0
grow_vertical = 0
text = "Not Ready"
[node name="v_box_container2" type="VBoxContainer" parent="." unique_id=653902328]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -329.0
offset_top = 146.0
offset_right = -221.0
offset_bottom = 204.0
offset_left = -835.0
offset_top = 111.0
offset_right = -727.0
offset_bottom = 169.0
grow_horizontal = 0
[node name="option_button" type="OptionButton" parent="v_box_container2" unique_id=426342653]
@ -145,30 +123,50 @@ layout_mode = 2
layout_mode = 2
columns = 2
[node name="options_button" type="Button" parent="." unique_id=2109111628]
[node name="chat_box" parent="." unique_id=1125601400 instance=ExtResource("2_5gu6x")]
custom_minimum_size = Vector2(400, 300)
custom_maximum_size = Vector2(400, 300)
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -309.0
offset_top = -166.0
offset_right = -239.0
offset_bottom = -135.0
offset_left = -535.0
offset_top = -352.0
offset_right = -35.0
offset_bottom = -52.0
grow_horizontal = 0
grow_vertical = 0
text = "Options"
[node name="exit_button" type="Button" parent="." unique_id=267703633]
[node name="v_box_container3" type="VBoxContainer" parent="." unique_id=1320505732]
layout_mode = 0
offset_left = 43.0
offset_top = 33.0
offset_right = 108.0
offset_bottom = 86.0
theme_override_font_sizes/font_size = 32
offset_left = 87.0
offset_top = 538.0
offset_right = 198.0
offset_bottom = 604.0
[node name="ready_button" type="Button" parent="v_box_container3" unique_id=311553419]
custom_minimum_size = Vector2(100, 0)
custom_maximum_size = Vector2(100, -1)
layout_mode = 2
text = "Not Ready"
metadata/_edit_lock_ = true
[node name="h_box_container" type="HBoxContainer" parent="v_box_container3" unique_id=1165099293]
layout_mode = 2
metadata/_edit_lock_ = true
[node name="exit_button" type="Button" parent="v_box_container3/h_box_container" unique_id=267703633]
layout_mode = 2
text = "Exit"
metadata/_edit_lock_ = true
[node name="options_button" type="Button" parent="v_box_container3/h_box_container" unique_id=2109111628]
layout_mode = 2
text = "Options"
metadata/_edit_lock_ = true
[connection signal="pressed" from="options_panel/options_close" to="." method="close_options"]
[connection signal="pressed" from="options_button" to="." method="open_options"]
[connection signal="pressed" from="exit_button" to="." method="exit"]
[connection signal="pressed" from="v_box_container3/h_box_container/exit_button" to="." method="exit"]
[connection signal="pressed" from="v_box_container3/h_box_container/options_button" to="." method="open_options"]

View File

@ -163,7 +163,7 @@ layout_mode = 2
text = "Address"
horizontal_alignment = 1
[node name="address_text" type="TextEdit" parent="join_panel/v_box_container" unique_id=584304528]
[node name="address_text" type="LineEdit" parent="join_panel/v_box_container" unique_id=672176728]
custom_minimum_size = Vector2(150, 30)
layout_mode = 2
text = "127.0.0.1:8080"

View File

@ -0,0 +1,15 @@
[gd_scene format=3 uid="uid://5gey4i80mmsa"]
[ext_resource type="AudioStream" uid="uid://bg8wugv6ij0pj" path="res://raw_assets/sfx/announcer/FirstBlood.wav" id="1_h17tq"]
[ext_resource type="AudioStream" uid="uid://b5816xcsj2ueh" path="res://raw_assets/sfx/announcer/DoubleKill.wav" id="2_6jrtu"]
[ext_resource type="AudioStream" uid="uid://co82glo13i8at" path="res://raw_assets/sfx/announcer/TripleKill.wav" id="3_6ob50"]
[ext_resource type="AudioStream" uid="uid://dfxrsl808f6o0" path="res://raw_assets/sfx/announcer/MegaKill.wav" id="4_0lbme"]
[node name="announcer" type="Announcer" unique_id=1062756235 node_paths=PackedStringArray("player")]
player = NodePath("audio_stream_player")
first_blood = ExtResource("1_h17tq")
double_kill = ExtResource("2_6jrtu")
triple_kill = ExtResource("3_6ob50")
mega_kill = ExtResource("4_0lbme")
[node name="audio_stream_player" type="AudioStreamPlayer" parent="." unique_id=1168314007]

View File

@ -4,13 +4,14 @@
[ext_resource type="PackedScene" uid="uid://cl66unms2gim0" path="res://scenes/player/effects.tscn" id="2_ywmwa"]
[ext_resource type="PackedScene" uid="uid://n3u0jr4wiib1" path="res://scenes/ui/settings.tscn" id="3_beej8"]
[ext_resource type="PackedScene" uid="uid://2sfy0vq0fqt3" path="res://scenes/ui/player_listing.tscn" id="4_okac2"]
[ext_resource type="PackedScene" uid="uid://ffh5txda3j1" path="res://scenes/ui/chat_box.tscn" id="5_cv68x"]
[sub_resource type="Environment" id="Environment_3nx84"]
glow_enabled = true
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_oh8vq"]
[node name="player" type="LocalPlayer" unique_id=863055906 node_paths=PackedStringArray("camera", "soldier_mesh", "collider", "effects", "dead_cam_target", "respawn_label", "ball_origin", "weapon_node", "pause_panel", "exit_to_lobby", "settings_panel", "scoreboard")]
[node name="player" type="LocalPlayer" unique_id=863055906 node_paths=PackedStringArray("camera", "soldier_mesh", "collider", "effects", "dead_cam_target", "respawn_label", "ball_origin", "weapon_node", "pause_panel", "exit_to_lobby", "settings_panel", "scoreboard", "chatbox")]
look_sensitivity = 1.5
camera = NodePath("camera_3d")
move_speed = 5.0
@ -25,6 +26,7 @@ pause_panel = NodePath("pause_menu")
exit_to_lobby = NodePath("pause_menu/v_box_container/exit_to_lobby")
settings_panel = NodePath("settings")
scoreboard = NodePath("scoreboard")
chatbox = NodePath("chat_box")
health = 100
collision_mask = 4
@ -137,6 +139,15 @@ layout_mode = 2
alignment = 1
metadata/_edit_lock_ = true
[node name="chat_box" parent="." unique_id=1125601400 instance=ExtResource("5_cv68x")]
in_game = true
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -300.0
offset_bottom = 0.0
grow_vertical = 0
[connection signal="pressed" from="pause_menu/v_box_container/settings" to="settings" method="open"]
[connection signal="pressed" from="pause_menu/v_box_container/exit_to_lobby" to="." method="exit_to_lobby"]
[connection signal="pressed" from="pause_menu/v_box_container/exit" to="." method="exit"]

View File

@ -0,0 +1,35 @@
[gd_scene format=3 uid="uid://ffh5txda3j1"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_61vwu"]
bg_color = Color(0.6, 0.6, 0.6, 0)
[node name="chat_box" type="ChatBox" unique_id=1125601400 node_paths=PackedStringArray("scroll", "messages", "line_edit")]
scroll = NodePath("panel/scroll_container")
messages = NodePath("panel/scroll_container/v_box_container")
line_edit = NodePath("line_edit")
custom_minimum_size = Vector2(500, 300)
custom_maximum_size = Vector2(500, 300)
offset_right = 500.0
offset_bottom = 300.0
[node name="panel" type="Panel" parent="." unique_id=674673935]
layout_mode = 2
size_flags_vertical = 3
theme_override_styles/panel = SubResource("StyleBoxFlat_61vwu")
metadata/_edit_lock_ = true
[node name="scroll_container" type="ScrollContainer" parent="panel" unique_id=810829343]
layout_mode = 0
offset_right = 500.0
offset_bottom = 270.0
horizontal_scroll_mode = 3
vertical_scroll_mode = 3
[node name="v_box_container" type="VBoxContainer" parent="panel/scroll_container" unique_id=406354045]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
alignment = 2
[node name="line_edit" type="LineEdit" parent="." unique_id=785348302]
layout_mode = 2

View File

@ -10,12 +10,12 @@ scroll_container = NodePath("scroll_container")
anchors_preset = 10
anchor_right = 1.0
offset_left = 1.0
offset_top = -344.0
offset_top = -540.0
offset_right = 1.0
offset_bottom = -37.0
offset_bottom = -233.0
grow_horizontal = 2
[node name="input_field" type="TextEdit" parent="command_line_panel" unique_id=2095748573]
[node name="input_field" type="LineEdit" parent="command_line_panel" unique_id=33075135]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
@ -45,3 +45,10 @@ scroll_active = false
autowrap_mode = 0
shortcut_keys_enabled = false
metadata/_edit_lock_ = true
[node name="net_stats_label" type="NetStatsLabel" parent="command_line_panel" unique_id=860927733]
layout_mode = 0
offset_left = -1.0
offset_top = 344.0
offset_right = 341.0
offset_bottom = 499.0

62
rust/src/announcer.rs Normal file
View File

@ -0,0 +1,62 @@
use godot::{
classes::{AudioStream, AudioStreamPlayer},
prelude::*,
tools::get_autoload_by_name,
};
use serde::{Deserialize, Serialize};
pub const ANNOUCER_GLOBAL: &str = "AnnouncerGlobal";
#[derive(GodotClass)]
#[class(base=Node3D, init)]
pub struct Announcer {
#[export]
player: Option<Gd<AudioStreamPlayer>>,
#[export]
#[export_group(name = "Sounds")]
first_blood: Option<Gd<AudioStream>>,
#[export]
#[export_group(name = "Sounds")]
double_kill: Option<Gd<AudioStream>>,
#[export]
#[export_group(name = "Sounds")]
triple_kill: Option<Gd<AudioStream>>,
#[export]
#[export_group(name = "Sounds")]
mega_kill: Option<Gd<AudioStream>>,
base: Base<Node3D>,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum Announcement {
FirstBlood,
DoubleKill,
TripleKill,
MegaKill,
}
impl Announcer {
pub fn singleton() -> Gd<Announcer> {
get_autoload_by_name::<Announcer>(ANNOUCER_GLOBAL)
}
pub fn announce(&mut self, announcement: Announcement) {
let sound = match announcement {
Announcement::FirstBlood => &self.first_blood,
Announcement::DoubleKill => &self.double_kill,
Announcement::TripleKill => &self.triple_kill,
Announcement::MegaKill => &self.mega_kill,
};
if let Some(sound) = sound
&& let Some(player) = &mut self.player
{
player.set_stream(sound);
player.play();
}
}
}

101
rust/src/chat.rs Normal file
View File

@ -0,0 +1,101 @@
use godot::{classes::RichTextLabel, prelude::*};
use crate::{
announcer::Announcement,
game_manager::{Game, Player},
player::DamageSource,
};
#[derive(GodotClass)]
#[class(base=Node, init)]
pub struct Chat {
messages: Vec<ChatMessage>,
base: Base<Node>,
}
#[godot_api]
impl Chat {
#[signal]
pub fn on_new_message(idx: Gd<RichTextLabel>);
pub fn singleton() -> Option<Gd<Chat>> {
Game::singleton().and_then(|g| g.get_child(0).map(|c| c.cast()))
}
pub fn get_messages(&self) -> Vec<Gd<RichTextLabel>> {
self.messages.iter().map(|m| m.as_label()).collect()
}
pub fn new_message(&mut self, message: ChatMessage) {
self.messages.len() as i64;
self.messages.push(message.clone());
self.run_deferred(move |s| s.signals().on_new_message().emit(&message.as_label()));
}
}
#[derive(Debug, Clone)]
pub enum ChatMessage {
Death(DamageSource, u16),
Announcement(u16, Announcement),
ChatMessage(String, Color, String),
}
impl ChatMessage {
pub fn as_label(&self) -> Gd<RichTextLabel> {
let mut label = RichTextLabel::new_alloc();
label.set_fit_content(true);
match self {
ChatMessage::Death(source, player_id) => {
if let Some(game) = Game::singleton()
&& let Some(player) = game.bind().find_player(*player_id)
{
match source {
DamageSource::Player(source_id) => {
if let Some(source) = game.bind().find_player(*source_id) {
add_player(&mut label, source);
label.append_text(" fragged ");
add_player(&mut label, &player);
}
}
DamageSource::Killbox => {
add_player(&mut label, &player);
label.append_text(" fell into the void");
}
}
}
}
ChatMessage::Announcement(player_id, announcement) => {
if let Some(game) = Game::singleton()
&& let Some(player) = game.bind().find_player(*player_id)
{
add_player(&mut label, &player);
label.append_text(" got ");
let what = match announcement {
Announcement::FirstBlood => "First Blood",
Announcement::DoubleKill => "a Double Kill",
Announcement::TripleKill => "a Triple Kill",
Announcement::MegaKill => "a Mega Kill",
};
label.append_text(&format!("[color=red]{}[/color]", what));
}
}
ChatMessage::ChatMessage(name, color, message) => {
label.push_color(*color);
label.add_text(&format!("{}: ", name));
label.pop();
label.add_text(message);
}
}
label
}
}
fn add_player(label: &mut Gd<RichTextLabel>, player: &Player) {
if let Some(game) = Game::singleton()
&& let Some(team) = game.bind().get_team(player.data.team)
{
label.push_color(team.bind().color);
label.add_text(&player.data.name);
label.pop();
}
}

View File

@ -4,7 +4,12 @@ use godot::{classes::CharacterBody3D, prelude::*, tools::get_autoload_by_name};
use serde::{Deserialize, Serialize};
use crate::{
announcer::{
Announcement::{self, FirstBlood},
Announcer,
},
ball::Ball,
chat::{Chat, ChatMessage},
map::Map,
map_resource::MapResource,
net::{
@ -212,6 +217,11 @@ pub struct Game {
#[godot_api]
impl INode for Game {
fn ready(&mut self) {
let chat = Chat::new_alloc();
self.base_mut().add_child(&chat);
}
fn physics_process(&mut self, delta: f64) {
self.since_last_sync += delta;
if self.since_last_sync > (1. / 60.) {
@ -282,6 +292,13 @@ impl INode for Game {
}
}
}
for player in &mut self.players {
player.killing_spree_cd -= delta;
if player.killing_spree_cd <= 0. {
player.killing_spree = 0;
}
}
}
}
@ -483,6 +500,8 @@ impl Game {
kills: 0,
deaths: 0,
},
killing_spree: 0,
killing_spree_cd: 0.,
character: None,
});
self.run_deferred(move |s| s.signals().on_new_player().emit(id));
@ -839,15 +858,82 @@ impl Game {
// Handle for when a player is killed, run both on client and server
pub fn on_kill(&mut self, source: DamageSource, player_id: u16) {
if let DamageSource::Player(source_id) = source
let total_prev_kills: u16 = self.players.iter().map(|p| p.data.kills).sum();
if let Some(chat) = &mut Chat::singleton() {
chat.bind_mut()
.new_message(ChatMessage::Death(source, player_id));
}
let killing_spree = if let DamageSource::Player(source_id) = source
&& let Some(source_player) = self.find_player_mut(source_id)
{
source_player.data.kills += 1;
}
source_player.killing_spree += 1;
source_player.killing_spree_cd = 10.;
source_player.killing_spree
} else {
0
};
if let Some(player) = self.find_player_mut(player_id) {
player.data.deaths += 1;
}
self.run_deferred(move |s| s.signals().on_player_killed().emit(player_id));
self.run_deferred(move |s| {
s.signals().on_player_killed().emit(player_id);
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer
&& let PeerKind::Server(peer, _) = peer
{
if total_prev_kills == 0 {
if let DamageSource::Player(source_id) = source {
s.on_announcement(source_id, Announcement::FirstBlood);
peer.broadcast_reliable(Package::Announcement(source_id, FirstBlood));
}
}
let announcement = match killing_spree {
2 => Some(Announcement::DoubleKill),
3 => Some(Announcement::TripleKill),
4 => Some(Announcement::MegaKill),
_ => None,
};
if let Some(announcement) = announcement {
if let DamageSource::Player(source_id) = source {
s.on_announcement(source_id, announcement);
peer.broadcast_reliable(Package::Announcement(source_id, announcement));
}
}
}
});
}
pub fn on_chat_message(&mut self, player_id: u16, message: String) {
if let Some(chat) = &mut Chat::singleton() {
if let Some(player) = self.find_player(player_id)
&& let Some(team) = self.get_team(player.data.team)
{
chat.bind_mut().new_message(ChatMessage::ChatMessage(
player.data.name.clone(),
team.bind().color,
message.clone(),
));
}
}
self.run_deferred(move |_| {
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer
&& let PeerKind::Server(peer, _) = peer
{
peer.broadcast_reliable(Package::ChatMessage(player_id, message.clone()));
}
});
}
pub fn on_announcement(&mut self, player_id: u16, announcement: Announcement) {
if let Some(chat) = &mut Chat::singleton() {
chat.bind_mut()
.new_message(ChatMessage::Announcement(player_id, announcement));
}
Announcer::singleton().bind_mut().announce(announcement);
}
// Handle taking damage, from server to client
@ -894,6 +980,8 @@ pub struct Player {
pub connection_addr: SocketAddr,
pub data: NetPlayer,
pub character: Option<DynGd<CharacterBody3D, dyn IPlayer + 'static>>,
pub killing_spree: u16,
pub killing_spree_cd: f64,
}
impl Player {
@ -1009,6 +1097,8 @@ impl From<NetPlayer> for Player {
connection_addr: SocketAddr::from(([0, 0, 0, 0], 0)),
data: value,
character: None,
killing_spree: 0,
killing_spree_cd: 0.,
}
}
}

View File

@ -1,6 +1,8 @@
use godot::prelude::*;
pub mod announcer;
pub mod ball;
pub mod chat;
pub mod cli_parser;
pub mod game_manager;
pub mod game_settings;

View File

@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
use teanet::{Peer, PeerConfig, PeerMessage};
use crate::{
announcer::Announcement,
game_manager::{Game, GameManager, GameOption, GameOptionValue, NetPlayer},
game_settings::GameSettingsManager,
net::{net_stats::Stats, util::NetVector3},
@ -291,6 +292,7 @@ pub enum Package {
PlayerLeft(NetPlayer),
SetTeam(u16, u8),
GameOptionChanged(GameOption, GameOptionValue),
ChatMessage(u16, String),
// Lobby packages
SetReady(u16, bool),
@ -310,6 +312,7 @@ pub enum Package {
DespawnBall,
SwapWeapon(u16, WeaponType),
Goal(Vec<u8>),
Announcement(u16, Announcement),
// End-of-Game packages
FinishGame,

View File

@ -200,6 +200,16 @@ impl NetworkManager {
game.bind_mut().finish_game();
}
}
Package::Announcement(source_id, announcement) => {
if let Some(game) = &mut Game::singleton() {
game.bind_mut().on_announcement(source_id, announcement);
}
}
Package::ChatMessage(source_id, message) => {
if let Some(game) = &mut Game::singleton() {
game.bind_mut().on_chat_message(source_id, message);
}
}
_ => {}
},
},
@ -367,6 +377,15 @@ impl NetworkManager {
}
}
}
Package::ChatMessage(_, message) => {
if let Some(game) = &mut Game::singleton() {
let player =
game.bind().find_player_by_addr(&conn.address).cloned();
if let Some(player) = player {
game.bind_mut().on_chat_message(player.id(), message);
}
}
}
_ => {}
},
},

View File

@ -26,7 +26,7 @@ use crate::{
soldier_mesh::SoldierMesh,
weapon::{BallWeapon, Raygun, Weapon, WeaponType},
},
ui::{cli::CommandLinePanel, settings::SettingsPanel},
ui::{chatbox::ChatBox, cli::CommandLinePanel, settings::SettingsPanel},
};
pub mod effects;
@ -208,6 +208,8 @@ pub struct LocalPlayer {
#[export]
scoreboard: Option<Gd<PanelContainer>>,
#[export]
chatbox: Option<Gd<ChatBox>>,
#[export]
health: i32,
pub player_id: Option<u16>,
@ -408,6 +410,17 @@ impl ICharacterBody3D for LocalPlayer {
s.update_lock();
});
if let Some(chatbox) = self.chatbox.clone() {
chatbox
.signals()
.on_opened()
.connect_other(self, |s| s.update_lock());
chatbox
.signals()
.on_closed()
.connect_other(self, |s| s.update_lock());
}
self.swap_weapon(WeaponType::Raygun);
if let Some(camera) = &mut self.camera {
@ -628,7 +641,12 @@ impl LocalPlayer {
} else {
false
};
s.set_lock(!CommandLinePanel::singleton().bind().opened && !paused);
let chat_visible = if let Some(chat) = &s.chatbox {
chat.bind().is_editing()
} else {
false
};
s.set_lock(!CommandLinePanel::singleton().bind().opened && !paused && !chat_visible);
});
}
@ -897,7 +915,7 @@ impl RemotePlayer {
pub fn on_take_damage(source: DamageSourceSignal, source_player: u16, damage: i32);
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum DamageSource {
Player(u16),
Killbox,

140
rust/src/ui/chatbox.rs Normal file
View File

@ -0,0 +1,140 @@
use std::i32;
use godot::{
classes::{
Engine, IVBoxContainer, InputEvent, LineEdit, Panel, RichTextLabel, ScrollContainer,
VBoxContainer,
},
prelude::*,
};
use crate::{
chat::Chat,
game_manager::Game,
net::network_manager::{NetworkManager, Package, PeerKind},
};
#[derive(GodotClass)]
#[class(base=VBoxContainer, init, tool)]
pub struct ChatBox {
#[export]
scroll: Option<Gd<ScrollContainer>>,
#[export]
messages: Option<Gd<VBoxContainer>>,
#[export]
line_edit: Option<Gd<LineEdit>>,
#[export]
pub in_game: bool,
scroll_on_next_update: bool,
base: Base<VBoxContainer>,
}
#[godot_api]
impl IVBoxContainer for ChatBox {
fn ready(&mut self) {
if !Engine::singleton().is_editor_hint() {
self.run_deferred(|s| {
if let Some(chat) = Chat::singleton() {
for message in chat.bind().get_messages() {
s.on_new_message(message);
}
chat.signals()
.on_new_message()
.connect_other(s, |s, m| s.run_deferred(|s| s.on_new_message(m)));
}
});
if let Some(line_edit) = self.line_edit.clone() {
line_edit
.signals()
.text_submitted()
.connect_other(self, Self::on_submit);
}
}
if self.in_game
&& let Some(line_edit) = &mut self.line_edit
{
line_edit.set_visible(false);
}
}
fn process(&mut self, _: f64) {
if self.scroll_on_next_update
&& let Some(scroll) = &mut self.scroll
{
scroll.set_v_scroll(i32::MAX);
self.scroll_on_next_update = false;
}
}
fn input(&mut self, event: Gd<InputEvent>) {
if self.in_game && event.is_action_pressed("open_chat") {
if let Some(line_edit) = &mut self.line_edit {
let is_visible = line_edit.is_visible();
if !is_visible {
line_edit.set_visible(true);
let mut line_edit = line_edit.clone();
self.run_deferred(move |_| {
if line_edit.is_visible() {
line_edit.grab_focus();
}
});
self.signals().on_opened().emit();
}
}
}
}
}
#[godot_api]
impl ChatBox {
#[signal]
pub fn on_opened();
#[signal]
pub fn on_closed();
fn on_new_message(&mut self, message: Gd<RichTextLabel>) {
if let Some(messages) = &mut self.messages {
messages.add_child(&message);
}
self.scroll_on_next_update = true;
}
pub fn on_submit(&mut self, message: GString) {
if let Some(line_edit) = &mut self.line_edit {
line_edit.clear();
if self.in_game {
line_edit.set_visible(false);
}
}
self.signals().on_closed().emit();
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer {
match peer {
PeerKind::Client(peer, socket_addr) => {
peer.send_reliable(socket_addr, Package::ChatMessage(0, message.to_string()));
}
PeerKind::Server(..) => {
self.run_deferred(move |_| {
if let Some(game) = &mut Game::singleton() {
let self_id = game.bind().self_id;
game.bind_mut()
.on_chat_message(self_id.unwrap_or(0), message.to_string());
}
});
}
}
}
}
pub fn is_editing(&self) -> bool {
if let Some(line_edit) = &self.line_edit {
line_edit.is_visible()
} else {
false
}
}
}

View File

@ -3,7 +3,7 @@ use std::net::SocketAddr;
use std::rc::Rc;
use godot::classes::{
CanvasLayer, IPanel, InputEvent, Panel, RichTextLabel, ScrollContainer, TextEdit,
CanvasLayer, IPanel, InputEvent, LineEdit, Panel, RichTextLabel, ScrollContainer,
};
use godot::prelude::*;
use godot::tools::get_autoload_by_name;
@ -32,7 +32,7 @@ pub const CLI_GLOBAL_NAME: &str = "CommandLinePanelGlobal";
#[class(base=Panel)]
pub struct CommandLinePanel {
#[export]
pub input_field: Option<Gd<TextEdit>>,
pub input_field: Option<Gd<LineEdit>>,
#[export]
pub text_field: Option<Gd<RichTextLabel>>,
#[export]
@ -74,6 +74,13 @@ impl IPanel for CommandLinePanel {
}
fn ready(&mut self) {
if let Some(input_field) = self.input_field.clone() {
input_field
.signals()
.text_submitted()
.connect_other(self, |s, value| s.input_command(value.to_string()));
}
self.idle_y = self.base().get_position().y;
}
@ -85,15 +92,6 @@ impl IPanel for CommandLinePanel {
self.scroll_next_update = false;
}
if let Some(input) = self.input_field.clone() {
let text = input.get_text();
if text.contains("\n") {
let parts = text.split("\n");
let first = parts.get(0).unwrap();
self.input_command(first.to_string());
}
}
let old_pos = self.base().get_position();
let mut target_pos = self.base().get_position();
if self.opened {

View File

@ -2,8 +2,8 @@ use std::collections::HashMap;
use godot::{
classes::{
Button, CheckBox, Control, GridContainer, IPanel, Label, OptionButton, Panel, SpinBox,
TextEdit, VBoxContainer,
Button, CheckBox, Control, GridContainer, IPanel, Label, LineEdit, OptionButton, Panel,
SpinBox, VBoxContainer,
},
prelude::*,
};
@ -20,7 +20,7 @@ pub struct LobbyPanel {
#[export]
players_list: Option<Gd<VBoxContainer>>,
#[export]
name_field: Option<Gd<TextEdit>>,
name_field: Option<Gd<LineEdit>>,
#[export]
player_listing_prefab: Option<Gd<PackedScene>>,
#[export]
@ -108,22 +108,18 @@ impl IPanel for LobbyPanel {
name_field
.signals()
.text_changed()
.connect_other(self, |s| {
if let Some(name_field) = &s.name_field {
if let Some(game) = &mut Game::singleton() {
let player_id = game.bind().self_id;
if let Some(player_id) = player_id {
game.bind_mut().update_player_nick(
player_id,
name_field.get_text().to_string(),
);
}
.connect_other(self, |_, value| {
if let Some(game) = &mut Game::singleton() {
let player_id = game.bind().self_id;
if let Some(player_id) = player_id {
game.bind_mut()
.update_player_nick(player_id, value.to_string());
}
NetworkManager::singleton()
.bind_mut()
.update_nick(name_field.get_text().to_string());
}
NetworkManager::singleton()
.bind_mut()
.update_nick(value.to_string());
});
}

View File

@ -1,5 +1,5 @@
use godot::{
classes::{Button, Camera3D, Label, Panel, SpinBox, TextEdit},
classes::{Button, Camera3D, Label, LineEdit, Panel, SpinBox},
prelude::*,
register::property::SimpleVar,
};
@ -41,7 +41,7 @@ pub struct MainMenu {
#[export]
host_port: Option<Gd<SpinBox>>,
#[export]
join_addr: Option<Gd<TextEdit>>,
join_addr: Option<Gd<LineEdit>>,
#[export]
popup_panel: Option<Gd<Panel>>,

View File

@ -1,3 +1,4 @@
pub mod chatbox;
pub mod cli;
pub mod game_finished_screen;
pub mod lobby;

View File

@ -1,7 +1,7 @@
use std::collections::HashMap;
use godot::{
classes::{Control, GridContainer, IPanel, Label, Panel, TextEdit, control::SizeFlags},
classes::{Control, GridContainer, IPanel, Label, LineEdit, Panel, control::SizeFlags},
prelude::*,
};
@ -103,25 +103,20 @@ impl IPanel for SettingsPanel {
slider.upcast::<Control>()
}
SettingValue::String(value) => {
let mut text_edit = TextEdit::new_alloc();
text_edit.set_custom_minimum_size(Vector2::new(100., -1.));
text_edit.set_text(value);
let mut line_edit = LineEdit::new_alloc();
line_edit.set_custom_minimum_size(Vector2::new(100., -1.));
line_edit.set_text(value);
line_edit.set_max_length(20);
let setting_clone = setting.clone();
let text_edit_clone = text_edit.clone();
text_edit
line_edit
.signals()
.text_changed()
.connect_other(self, move |s| {
s.on_change(
setting_clone,
SettingValue::String(
text_edit_clone.get_text().to_string(),
),
);
.connect_other(self, move |s, v| {
s.on_change(setting_clone, SettingValue::String(v.to_string()));
});
text_edit.upcast()
line_edit.upcast()
}
};