Compare commits
No commits in common. "69e609e501f8de7a3d8b4b41a14ae1e2b6c48e78" and "2547707eb9da2876d351f3320b34ceaec17d38c4" have entirely different histories.
69e609e501
...
2547707eb9
@ -160,15 +160,5 @@ grow_horizontal = 0
|
|||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
text = "Options"
|
text = "Options"
|
||||||
|
|
||||||
[node name="exit_button" type="Button" parent="." unique_id=267703633]
|
|
||||||
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
|
|
||||||
text = "Exit"
|
|
||||||
|
|
||||||
[connection signal="pressed" from="options_panel/options_close" to="." method="close_options"]
|
[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="options_button" to="." method="open_options"]
|
||||||
[connection signal="pressed" from="exit_button" to="." method="exit"]
|
|
||||||
|
|||||||
@ -1,239 +1,24 @@
|
|||||||
[gd_scene format=3 uid="uid://lahirbqfppvw"]
|
[gd_scene format=3 uid="uid://lahirbqfppvw"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bbmc2gmy7g8ag" path="res://scenes/misc/menu_player.tscn" id="1_o5qli"]
|
[sub_resource type="BoxMesh" id="BoxMesh_m77kh"]
|
||||||
|
|
||||||
[node name="menu" type="MainMenu" unique_id=2036763876 node_paths=PackedStringArray("camera", "main_position", "host_position", "main_panel", "host_panel", "join_panel", "host_port", "join_addr", "popup_panel", "popup_title", "popup_text", "popup_button")]
|
[node name="node_3d" type="Node3D" unique_id=591926555]
|
||||||
camera = NodePath("camera_3d")
|
|
||||||
main_position = NodePath("main_pos")
|
|
||||||
host_position = NodePath("host_pos")
|
|
||||||
main_panel = NodePath("main_panel")
|
|
||||||
host_panel = NodePath("host_panel")
|
|
||||||
join_panel = NodePath("join_panel")
|
|
||||||
host_port = NodePath("host_panel/v_box_container/host_port")
|
|
||||||
join_addr = NodePath("join_panel/v_box_container/address_text")
|
|
||||||
popup_panel = NodePath("popup_panel")
|
|
||||||
popup_title = NodePath("popup_panel/v_box_container/title")
|
|
||||||
popup_text = NodePath("popup_panel/v_box_container/text")
|
|
||||||
popup_button = NodePath("popup_panel/v_box_container/ok")
|
|
||||||
|
|
||||||
[node name="camera_3d" type="Camera3D" parent="." unique_id=1513321931]
|
[node name="camera_3d" type="Camera3D" parent="." unique_id=1513321931]
|
||||||
transform = Transform3D(0.98629165, -0.031186381, 0.16203775, -1.4054481e-08, 0.981978, 0.1889952, -0.16501158, -0.18640438, 0.9685167, 1.0974052, 1.7166122, 1.4909106)
|
transform = Transform3D(0.85754585, -0.09722054, 0.50513697, 0, 0.98197806, 0.18899518, -0.5144076, -0.16207202, 0.8420912, 1.0974057, 0.86883736, 1.7596759)
|
||||||
current = true
|
|
||||||
|
[node name="mesh_instance_3d" type="MeshInstance3D" parent="." unique_id=1466304853]
|
||||||
|
mesh = SubResource("BoxMesh_m77kh")
|
||||||
|
|
||||||
[node name="directional_light_3d" type="DirectionalLight3D" parent="." unique_id=75522463]
|
[node name="directional_light_3d" type="DirectionalLight3D" parent="." unique_id=75522463]
|
||||||
transform = Transform3D(0.61237246, -0.5, 0.61237246, 0.3535534, 0.8660254, 0.3535534, -0.7071068, 0, 0.7071068, 0, 1, 2)
|
transform = Transform3D(0.61237246, -0.5, 0.61237246, 0.3535534, 0.8660254, 0.3535534, -0.7071068, 0, 0.7071068, 0, 1, 2)
|
||||||
|
|
||||||
[node name="menu_player" parent="." unique_id=928718358 instance=ExtResource("1_o5qli")]
|
[node name="netstats" type="NetStatsLabel" parent="." unique_id=1366169487]
|
||||||
transform = Transform3D(0.66809446, 0, -0.74407655, 0, 1, 0, 0.74407655, 0, 0.66809446, 2.270261, -2.3841858e-07, -1.3596804)
|
anchors_preset = 12
|
||||||
|
anchor_top = 1.0
|
||||||
[node name="menu_player2" parent="." unique_id=1735741962 instance=ExtResource("1_o5qli")]
|
anchor_right = 1.0
|
||||||
transform = Transform3D(0.9823497, 0, 0.18705386, 0, 1, 0, -0.18705386, 0, 0.9823497, -3.3954296, 1.1920929e-06, 0.47203088)
|
anchor_bottom = 1.0
|
||||||
|
offset_top = -144.0
|
||||||
[node name="menu_player3" parent="." unique_id=1638403481 instance=ExtResource("1_o5qli")]
|
|
||||||
transform = Transform3D(-0.26696783, 0, 0.9637054, 0, 1, 0, -0.9637054, 0, -0.26696783, -3.5550833, -2.3841858e-07, 2.7302406)
|
|
||||||
|
|
||||||
[node name="main_panel" type="Panel" parent="." unique_id=2078435804]
|
|
||||||
offset_left = 139.0
|
|
||||||
offset_top = 167.0
|
|
||||||
offset_right = 336.0
|
|
||||||
offset_bottom = 474.0
|
|
||||||
|
|
||||||
[node name="v_box_container" type="VBoxContainer" parent="main_panel" unique_id=287461844]
|
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 8
|
|
||||||
anchor_left = 0.5
|
|
||||||
anchor_top = 0.5
|
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
offset_left = -47.0
|
|
||||||
offset_top = -95.0
|
|
||||||
offset_right = 47.0
|
|
||||||
offset_bottom = 95.0
|
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 0
|
||||||
alignment = 1
|
vertical_alignment = 2
|
||||||
|
|
||||||
[node name="label" type="Label" parent="main_panel/v_box_container" unique_id=140542377]
|
|
||||||
custom_minimum_size = Vector2(0, 50)
|
|
||||||
layout_mode = 2
|
|
||||||
text = "QuakeBall"
|
|
||||||
horizontal_alignment = 1
|
|
||||||
metadata/_edit_lock_ = true
|
|
||||||
|
|
||||||
[node name="host" type="Button" parent="main_panel/v_box_container" unique_id=1962091117]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Host Game"
|
|
||||||
metadata/_edit_lock_ = true
|
|
||||||
|
|
||||||
[node name="join" type="Button" parent="main_panel/v_box_container" unique_id=1364459397]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Join Game"
|
|
||||||
metadata/_edit_lock_ = true
|
|
||||||
|
|
||||||
[node name="settings" type="Button" parent="main_panel/v_box_container" unique_id=1153899756]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Settings"
|
|
||||||
metadata/_edit_lock_ = true
|
|
||||||
|
|
||||||
[node name="quit" type="Button" parent="main_panel/v_box_container" unique_id=1508139096]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Quit"
|
|
||||||
metadata/_edit_lock_ = true
|
|
||||||
|
|
||||||
[node name="host_panel" type="Panel" parent="." unique_id=1633876079]
|
|
||||||
visible = false
|
|
||||||
offset_left = 139.0
|
|
||||||
offset_top = 167.0
|
|
||||||
offset_right = 336.0
|
|
||||||
offset_bottom = 474.0
|
|
||||||
|
|
||||||
[node name="v_box_container" type="VBoxContainer" parent="host_panel" unique_id=1651169053]
|
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 8
|
|
||||||
anchor_left = 0.5
|
|
||||||
anchor_top = 0.5
|
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
offset_left = -47.0
|
|
||||||
offset_top = -95.0
|
|
||||||
offset_right = 47.0
|
|
||||||
offset_bottom = 95.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
alignment = 1
|
|
||||||
|
|
||||||
[node name="title" type="Label" parent="host_panel/v_box_container" unique_id=1539421918]
|
|
||||||
custom_minimum_size = Vector2(0, 50)
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Host Game"
|
|
||||||
horizontal_alignment = 1
|
|
||||||
metadata/_edit_lock_ = true
|
|
||||||
|
|
||||||
[node name="port_label" type="Label" parent="host_panel/v_box_container" unique_id=1618746525]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Port"
|
|
||||||
horizontal_alignment = 1
|
|
||||||
|
|
||||||
[node name="host_port" type="SpinBox" parent="host_panel/v_box_container" unique_id=1116593197]
|
|
||||||
layout_mode = 2
|
|
||||||
max_value = 16000.0
|
|
||||||
value = 8080.0
|
|
||||||
alignment = 1
|
|
||||||
|
|
||||||
[node name="host" type="Button" parent="host_panel/v_box_container" unique_id=312403378]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Host"
|
|
||||||
|
|
||||||
[node name="back" type="Button" parent="host_panel/v_box_container" unique_id=1658922684]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Back"
|
|
||||||
|
|
||||||
[node name="join_panel" type="Panel" parent="." unique_id=1630672771]
|
|
||||||
visible = false
|
|
||||||
offset_left = 139.0
|
|
||||||
offset_top = 167.0
|
|
||||||
offset_right = 336.0
|
|
||||||
offset_bottom = 474.0
|
|
||||||
|
|
||||||
[node name="v_box_container" type="VBoxContainer" parent="join_panel" unique_id=2029384993]
|
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 8
|
|
||||||
anchor_left = 0.5
|
|
||||||
anchor_top = 0.5
|
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
offset_left = -47.0
|
|
||||||
offset_top = -95.0
|
|
||||||
offset_right = 47.0
|
|
||||||
offset_bottom = 95.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
alignment = 1
|
|
||||||
|
|
||||||
[node name="title" type="Label" parent="join_panel/v_box_container" unique_id=268455606]
|
|
||||||
custom_minimum_size = Vector2(0, 50)
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Join Game"
|
|
||||||
horizontal_alignment = 1
|
|
||||||
metadata/_edit_lock_ = true
|
|
||||||
|
|
||||||
[node name="address_label" type="Label" parent="join_panel/v_box_container" unique_id=425811384]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Address"
|
|
||||||
horizontal_alignment = 1
|
|
||||||
|
|
||||||
[node name="address_text" type="TextEdit" parent="join_panel/v_box_container" unique_id=584304528]
|
|
||||||
custom_minimum_size = Vector2(150, 30)
|
|
||||||
layout_mode = 2
|
|
||||||
|
|
||||||
[node name="join" type="Button" parent="join_panel/v_box_container" unique_id=1953386108]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Join"
|
|
||||||
|
|
||||||
[node name="back" type="Button" parent="join_panel/v_box_container" unique_id=759190425]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Back"
|
|
||||||
|
|
||||||
[node name="main_pos" type="Node3D" parent="." unique_id=98241074]
|
|
||||||
transform = Transform3D(0.98629165, -0.031186387, 0.16203767, -1.4054484e-08, 0.981978, 0.1889952, -0.16501155, -0.18640435, 0.9685167, 1.0974054, 1.7166122, 1.4909104)
|
|
||||||
|
|
||||||
[node name="host_pos" type="Node3D" parent="." unique_id=663794107]
|
|
||||||
transform = Transform3D(0.3960592, -0.17354009, 0.90167665, -1.9851193e-08, 0.981978, 0.18899521, -0.9182249, -0.0748533, 0.38892144, -1.0602233, 1.7166122, 3.759781)
|
|
||||||
|
|
||||||
[node name="popup_panel" type="Panel" parent="." unique_id=1792775604]
|
|
||||||
visible = false
|
|
||||||
anchors_preset = 8
|
|
||||||
anchor_left = 0.5
|
|
||||||
anchor_top = 0.5
|
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
offset_left = -153.0
|
|
||||||
offset_top = -71.0
|
|
||||||
offset_right = 153.0
|
|
||||||
offset_bottom = 71.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
|
|
||||||
[node name="v_box_container" type="VBoxContainer" parent="popup_panel" unique_id=465766643]
|
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 8
|
|
||||||
anchor_left = 0.5
|
|
||||||
anchor_top = 0.5
|
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
offset_left = -20.0
|
|
||||||
offset_top = -20.0
|
|
||||||
offset_right = 20.0
|
|
||||||
offset_bottom = 20.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
alignment = 1
|
|
||||||
|
|
||||||
[node name="title" type="Label" parent="popup_panel/v_box_container" unique_id=1944397487]
|
|
||||||
layout_mode = 2
|
|
||||||
size_flags_horizontal = 4
|
|
||||||
theme_override_font_sizes/font_size = 25
|
|
||||||
text = "Some Title"
|
|
||||||
horizontal_alignment = 1
|
|
||||||
|
|
||||||
[node name="text" type="Label" parent="popup_panel/v_box_container" unique_id=1988165424]
|
|
||||||
custom_minimum_size = Vector2(300, 0)
|
|
||||||
custom_maximum_size = Vector2(300, -1)
|
|
||||||
layout_mode = 2
|
|
||||||
size_flags_horizontal = 4
|
|
||||||
text = "Some text"
|
|
||||||
horizontal_alignment = 1
|
|
||||||
autowrap_mode = 3
|
|
||||||
|
|
||||||
[node name="ok" type="Button" parent="popup_panel/v_box_container" unique_id=488898874]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Ok"
|
|
||||||
|
|
||||||
[connection signal="pressed" from="main_panel/v_box_container/host" to="." method="go_to_host_game"]
|
|
||||||
[connection signal="pressed" from="main_panel/v_box_container/join" to="." method="go_to_join_game"]
|
|
||||||
[connection signal="pressed" from="main_panel/v_box_container/quit" to="." method="quit_game"]
|
|
||||||
[connection signal="pressed" from="host_panel/v_box_container/host" to="." method="host_game"]
|
|
||||||
[connection signal="pressed" from="host_panel/v_box_container/back" to="." method="go_to_main_menu"]
|
|
||||||
[connection signal="pressed" from="join_panel/v_box_container/join" to="." method="join_game"]
|
|
||||||
[connection signal="pressed" from="join_panel/v_box_container/back" to="." method="go_to_main_menu"]
|
|
||||||
[connection signal="pressed" from="popup_panel/v_box_container/ok" to="." method="hide_popup"]
|
|
||||||
|
|||||||
@ -4,12 +4,10 @@
|
|||||||
[ext_resource type="MapResource" uid="uid://c7n1tacc7a73t" path="res://maps/default_map.tres" id="1_glms7"]
|
[ext_resource type="MapResource" uid="uid://c7n1tacc7a73t" path="res://maps/default_map.tres" id="1_glms7"]
|
||||||
[ext_resource type="PackedScene" uid="uid://df84sctteh4kw" path="res://scenes/game_finished.tscn" id="1_qf2qp"]
|
[ext_resource type="PackedScene" uid="uid://df84sctteh4kw" path="res://scenes/game_finished.tscn" id="1_qf2qp"]
|
||||||
[ext_resource type="MapResource" uid="uid://sc3507f75002" path="res://maps/diner.tres" id="2_glms7"]
|
[ext_resource type="MapResource" uid="uid://sc3507f75002" path="res://maps/diner.tres" id="2_glms7"]
|
||||||
[ext_resource type="PackedScene" uid="uid://lahirbqfppvw" path="res://scenes/main.tscn" id="3_7ele1"]
|
|
||||||
[ext_resource type="MapResource" uid="uid://bsjoandgu476y" path="res://maps/two_towers.tres" id="5_rotn8"]
|
[ext_resource type="MapResource" uid="uid://bsjoandgu476y" path="res://maps/two_towers.tres" id="5_rotn8"]
|
||||||
|
|
||||||
[node name="game_manager" type="GameManager" unique_id=1442044769]
|
[node name="game_manager" type="GameManager" unique_id=1442044769]
|
||||||
respawn_timer = 10.0
|
respawn_timer = 10.0
|
||||||
lobby_screen = ExtResource("1_3ama4")
|
lobby_screen = ExtResource("1_3ama4")
|
||||||
game_finished_screen = ExtResource("1_qf2qp")
|
game_finished_screen = ExtResource("1_qf2qp")
|
||||||
main_menu = ExtResource("3_7ele1")
|
|
||||||
maps = Array[MapResource]([ExtResource("1_glms7"), ExtResource("2_glms7"), ExtResource("5_rotn8")])
|
maps = Array[MapResource]([ExtResource("1_glms7"), ExtResource("2_glms7"), ExtResource("5_rotn8")])
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
[gd_scene format=3 uid="uid://bbmc2gmy7g8ag"]
|
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bod6b3befmyt5" path="res://scenes/player/soldier_m.tscn" id="1_pgypt"]
|
|
||||||
|
|
||||||
[node name="menu_player" type="MenuPlayer" unique_id=928718358 node_paths=PackedStringArray("mesh")]
|
|
||||||
mesh = NodePath("soldier_m")
|
|
||||||
|
|
||||||
[node name="soldier_m" parent="." unique_id=281995630 instance=ExtResource("1_pgypt")]
|
|
||||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
|
|
||||||
@ -31,14 +31,10 @@ pub struct GameManager {
|
|||||||
pub lobby_screen: Option<Gd<PackedScene>>,
|
pub lobby_screen: Option<Gd<PackedScene>>,
|
||||||
#[export]
|
#[export]
|
||||||
pub game_finished_screen: Option<Gd<PackedScene>>,
|
pub game_finished_screen: Option<Gd<PackedScene>>,
|
||||||
#[export]
|
|
||||||
pub main_menu: Option<Gd<PackedScene>>,
|
|
||||||
|
|
||||||
pub game: Option<Gd<Game>>,
|
pub game: Option<Gd<Game>>,
|
||||||
base: Base<Node>,
|
base: Base<Node>,
|
||||||
|
|
||||||
exiting: bool,
|
|
||||||
|
|
||||||
#[export]
|
#[export]
|
||||||
pub maps: Array<Gd<MapResource>>,
|
pub maps: Array<Gd<MapResource>>,
|
||||||
}
|
}
|
||||||
@ -81,11 +77,9 @@ impl GameManager {
|
|||||||
game.signals()
|
game.signals()
|
||||||
.on_map_changed()
|
.on_map_changed()
|
||||||
.connect_other(s, |s, id| s.signals().on_map_changed().emit(id));
|
.connect_other(s, |s, id| s.signals().on_map_changed().emit(id));
|
||||||
game.signals().on_game_finished().connect_other(s, |s| {
|
game.signals()
|
||||||
if !s.exiting {
|
.on_game_finished()
|
||||||
s.go_to_finish_screen()
|
.connect_other(s, |s| s.go_to_finish_screen());
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -94,15 +88,6 @@ impl GameManager {
|
|||||||
self.game = Some(game);
|
self.game = Some(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exit_game(&mut self) {
|
|
||||||
self.exiting = true;
|
|
||||||
if let Some(mut game) = self.game.take() {
|
|
||||||
game.bind_mut().finish_game();
|
|
||||||
game.queue_free();
|
|
||||||
self.go_to_main_menu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn go_to_finish_screen(&self) {
|
pub fn go_to_finish_screen(&self) {
|
||||||
if let Some(scene) = &self.game_finished_screen {
|
if let Some(scene) = &self.game_finished_screen {
|
||||||
self.base().get_tree().change_scene_to_packed(scene);
|
self.base().get_tree().change_scene_to_packed(scene);
|
||||||
@ -114,12 +99,6 @@ impl GameManager {
|
|||||||
self.base().get_tree().change_scene_to_packed(lobby);
|
self.base().get_tree().change_scene_to_packed(lobby);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn go_to_main_menu(&self) {
|
|
||||||
if let Some(scene) = &self.main_menu {
|
|
||||||
self.base().get_tree().change_scene_to_packed(scene);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GameOptions {
|
pub struct GameOptions {
|
||||||
|
|||||||
@ -10,7 +10,6 @@ pub mod map_resource;
|
|||||||
pub mod net;
|
pub mod net;
|
||||||
pub mod player;
|
pub mod player;
|
||||||
pub mod player_hand_remover;
|
pub mod player_hand_remover;
|
||||||
pub mod popup_queue;
|
|
||||||
pub mod soldier_mesh;
|
pub mod soldier_mesh;
|
||||||
pub mod team_resource;
|
pub mod team_resource;
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
|
|||||||
@ -12,7 +12,6 @@ use crate::{
|
|||||||
game_manager::{Game, GameManager, GameOption, GameOptionValue, NetPlayer},
|
game_manager::{Game, GameManager, GameOption, GameOptionValue, NetPlayer},
|
||||||
net::{net_stats::Stats, util::NetVector3},
|
net::{net_stats::Stats, util::NetVector3},
|
||||||
player::{DamageSource, NetTransform},
|
player::{DamageSource, NetTransform},
|
||||||
popup_queue::{Popup, PopupQueue},
|
|
||||||
ui::cli::{CliColor, CommandLinePanel},
|
ui::cli::{CliColor, CommandLinePanel},
|
||||||
weapon::WeaponType,
|
weapon::WeaponType,
|
||||||
};
|
};
|
||||||
@ -107,20 +106,6 @@ impl INode for NetworkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while let Some(message) = self.poll() {
|
while let Some(message) = self.poll() {
|
||||||
match &message {
|
|
||||||
PeerMessage::Disconnected(_, connection_error) => {
|
|
||||||
if !self.is_host() {
|
|
||||||
let message = if let Some(err) = connection_error {
|
|
||||||
format!("{}", err)
|
|
||||||
} else {
|
|
||||||
String::new()
|
|
||||||
};
|
|
||||||
self.signals().on_client_disconnected().emit(&message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.handle_message(message);
|
self.handle_message(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,10 +116,6 @@ impl INode for NetworkManager {
|
|||||||
impl NetworkManager {
|
impl NetworkManager {
|
||||||
#[signal]
|
#[signal]
|
||||||
pub fn lobby_joined();
|
pub fn lobby_joined();
|
||||||
#[signal]
|
|
||||||
pub fn on_client_disconnected(error: GString);
|
|
||||||
#[signal]
|
|
||||||
pub fn on_error_hosting_server(error: GString);
|
|
||||||
|
|
||||||
fn poll(&mut self) -> Option<PeerMessage<Package>> {
|
fn poll(&mut self) -> Option<PeerMessage<Package>> {
|
||||||
let mut cli = CommandLinePanel::singleton();
|
let mut cli = CommandLinePanel::singleton();
|
||||||
@ -203,17 +184,6 @@ impl NetworkManager {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
cli.bind_mut()
|
cli.bind_mut()
|
||||||
.publish_message(format!("Error hosting server: {}", err), CliColor::Error);
|
.publish_message(format!("Error hosting server: {}", err), CliColor::Error);
|
||||||
self.run_deferred(move |s| {
|
|
||||||
s.signals()
|
|
||||||
.on_error_hosting_server()
|
|
||||||
.emit(&format!("{}", err));
|
|
||||||
|
|
||||||
PopupQueue::singleton().bind_mut().queue(Popup {
|
|
||||||
title: "Error hosting server".to_owned(),
|
|
||||||
message: err.to_string(),
|
|
||||||
ok: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use godot::obj::Singleton;
|
|
||||||
use teanet::PeerMessage;
|
use teanet::PeerMessage;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
game_manager::{Game, GameManager, GameOption},
|
game_manager::{Game, GameManager, GameOption},
|
||||||
net::network_manager::{NetworkManager, Package, PeerKind},
|
net::network_manager::{NetworkManager, Package, PeerKind},
|
||||||
popup_queue::{Popup, PopupQueue},
|
|
||||||
ui::cli::{CliColor, CommandLinePanel},
|
ui::cli::{CliColor, CommandLinePanel},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -34,24 +32,12 @@ impl NetworkManager {
|
|||||||
format!("Error with connection: {}", err),
|
format!("Error with connection: {}", err),
|
||||||
CliColor::Error,
|
CliColor::Error,
|
||||||
);
|
);
|
||||||
|
|
||||||
PopupQueue::singleton().bind_mut().queue(Popup {
|
|
||||||
title: "Error".to_owned(),
|
|
||||||
message: err.to_string(),
|
|
||||||
ok: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
PopupQueue::singleton().bind_mut().queue(Popup {
|
|
||||||
title: "Disconnected".to_owned(),
|
|
||||||
message: "disconnected".to_owned(),
|
|
||||||
ok: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
peer.close();
|
peer.close();
|
||||||
}
|
}
|
||||||
teanet::PeerMessage::Closed => {
|
teanet::PeerMessage::Closed => {
|
||||||
self.peer = None;
|
self.peer = None;
|
||||||
GameManager::singleton().bind_mut().exit_game();
|
GameManager::singleton().bind_mut().game = None;
|
||||||
}
|
}
|
||||||
teanet::PeerMessage::Message(_, msg) => match msg {
|
teanet::PeerMessage::Message(_, msg) => match msg {
|
||||||
Package::Hello => {
|
Package::Hello => {
|
||||||
@ -258,7 +244,7 @@ impl NetworkManager {
|
|||||||
cli.bind_mut()
|
cli.bind_mut()
|
||||||
.publish_message(format!("Server closed"), CliColor::Info);
|
.publish_message(format!("Server closed"), CliColor::Info);
|
||||||
self.peer = None;
|
self.peer = None;
|
||||||
GameManager::singleton().bind_mut().exit_game();
|
GameManager::singleton().bind_mut().game = None;
|
||||||
}
|
}
|
||||||
teanet::PeerMessage::Message(conn, msg) => match msg {
|
teanet::PeerMessage::Message(conn, msg) => match msg {
|
||||||
Package::SetSelfNick(nick) => {
|
Package::SetSelfNick(nick) => {
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
use std::collections::VecDeque;
|
|
||||||
|
|
||||||
use godot::prelude::*;
|
|
||||||
|
|
||||||
pub struct Popup {
|
|
||||||
pub title: String,
|
|
||||||
pub message: String,
|
|
||||||
pub ok: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
|
||||||
#[class(base=Node, init, singleton)]
|
|
||||||
pub struct PopupQueue {
|
|
||||||
popups: VecDeque<Popup>,
|
|
||||||
|
|
||||||
base: Base<Node>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PopupQueue {
|
|
||||||
pub fn queue(&mut self, popup: Popup) {
|
|
||||||
self.popups.push_back(popup);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn poll(&mut self) -> Option<Popup> {
|
|
||||||
self.popups.pop_front()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -209,12 +209,6 @@ impl LobbyPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[func]
|
|
||||||
pub fn exit(&mut self) {
|
|
||||||
GameManager::singleton().bind_mut().exit_game();
|
|
||||||
NetworkManager::singleton().bind_mut().disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn option_changed(&mut self, key: GameOption, value: GameOptionValue) {
|
fn option_changed(&mut self, key: GameOption, value: GameOptionValue) {
|
||||||
if let Some(game) = &mut Game::singleton() {
|
if let Some(game) = &mut Game::singleton() {
|
||||||
game.bind_mut().change_option(key, value);
|
game.bind_mut().change_option(key, value);
|
||||||
|
|||||||
@ -1,215 +0,0 @@
|
|||||||
use godot::{
|
|
||||||
classes::{Button, Camera3D, Label, Panel, SpinBox, TextEdit},
|
|
||||||
prelude::*,
|
|
||||||
register::property::SimpleVar,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
net::network_manager::NetworkManager,
|
|
||||||
popup_queue::{Popup, PopupQueue},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, GodotConvert, Default, Export)]
|
|
||||||
#[godot(via = u8)]
|
|
||||||
pub enum Menu {
|
|
||||||
#[default]
|
|
||||||
MainMenu,
|
|
||||||
HostMenu,
|
|
||||||
JoinMenu,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SimpleVar for Menu {}
|
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
|
||||||
#[class(base=Node3D, init, tool)]
|
|
||||||
pub struct MainMenu {
|
|
||||||
#[export]
|
|
||||||
camera: Option<Gd<Camera3D>>,
|
|
||||||
|
|
||||||
#[export]
|
|
||||||
main_position: Option<Gd<Node3D>>,
|
|
||||||
#[export]
|
|
||||||
host_position: Option<Gd<Node3D>>,
|
|
||||||
|
|
||||||
#[export]
|
|
||||||
main_panel: Option<Gd<Panel>>,
|
|
||||||
#[export]
|
|
||||||
host_panel: Option<Gd<Panel>>,
|
|
||||||
#[export]
|
|
||||||
join_panel: Option<Gd<Panel>>,
|
|
||||||
|
|
||||||
#[export]
|
|
||||||
host_port: Option<Gd<SpinBox>>,
|
|
||||||
#[export]
|
|
||||||
join_addr: Option<Gd<TextEdit>>,
|
|
||||||
|
|
||||||
#[export]
|
|
||||||
popup_panel: Option<Gd<Panel>>,
|
|
||||||
#[export]
|
|
||||||
popup_title: Option<Gd<Label>>,
|
|
||||||
#[export]
|
|
||||||
popup_text: Option<Gd<Label>>,
|
|
||||||
#[export]
|
|
||||||
popup_button: Option<Gd<Button>>,
|
|
||||||
|
|
||||||
#[export]
|
|
||||||
current_menu: Menu,
|
|
||||||
|
|
||||||
prev_panel: Option<Gd<Panel>>,
|
|
||||||
|
|
||||||
base: Base<Node3D>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[godot_api]
|
|
||||||
impl INode3D for MainMenu {
|
|
||||||
fn ready(&mut self) {
|
|
||||||
self.hide_popup();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process(&mut self, _delta: f64) {
|
|
||||||
if let Some(camera) = &mut self.camera {
|
|
||||||
let target = match self.current_menu {
|
|
||||||
Menu::MainMenu => {
|
|
||||||
if let Some(pos) = &self.main_position {
|
|
||||||
Some((
|
|
||||||
pos.get_global_position(),
|
|
||||||
pos.get_global_rotation(),
|
|
||||||
self.main_panel.clone(),
|
|
||||||
))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Menu::HostMenu => {
|
|
||||||
if let Some(pos) = &self.host_position {
|
|
||||||
Some((
|
|
||||||
pos.get_global_position(),
|
|
||||||
pos.get_global_rotation(),
|
|
||||||
self.host_panel.clone(),
|
|
||||||
))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Menu::JoinMenu => {
|
|
||||||
if let Some(pos) = &self.host_position {
|
|
||||||
Some((
|
|
||||||
pos.get_global_position(),
|
|
||||||
pos.get_global_rotation(),
|
|
||||||
self.join_panel.clone(),
|
|
||||||
))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some((target_pos, target_rot, target_panel)) = target {
|
|
||||||
let prev_pos = camera.get_global_position();
|
|
||||||
let prev_rot = camera.get_global_rotation();
|
|
||||||
let new_pos = prev_pos.lerp(target_pos, 0.2);
|
|
||||||
let new_rot = prev_rot.lerp(target_rot, 0.2);
|
|
||||||
camera.set_global_position(new_pos);
|
|
||||||
camera.set_global_rotation(new_rot);
|
|
||||||
|
|
||||||
if let Some(mut panel) = target_panel {
|
|
||||||
if let Some(prev_panel) = &mut self.prev_panel {
|
|
||||||
if prev_panel.instance_id() != panel.instance_id() {
|
|
||||||
prev_panel.set_visible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.prev_panel = Some(panel.clone());
|
|
||||||
panel.set_visible(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(popup_panel) = self.popup_panel.clone()
|
|
||||||
&& let Some(button) = self.popup_button.clone()
|
|
||||||
{
|
|
||||||
if !popup_panel.is_visible() || !button.is_visible() {
|
|
||||||
if let Some(popup) = PopupQueue::singleton().bind_mut().poll() {
|
|
||||||
self.show_popup(&popup.title, &popup.message, popup.ok);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[godot_api]
|
|
||||||
impl MainMenu {
|
|
||||||
#[func]
|
|
||||||
pub fn host_game(&mut self) {
|
|
||||||
if let Some(host_port) = &self.host_port {
|
|
||||||
NetworkManager::singleton()
|
|
||||||
.bind_mut()
|
|
||||||
.host(host_port.get_value() as u16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[func]
|
|
||||||
pub fn join_game(&mut self) {
|
|
||||||
if let Some(addr) = self.join_addr.clone() {
|
|
||||||
self.show_popup("Joining", "joining game", false);
|
|
||||||
PopupQueue::singleton().bind_mut().queue(Popup {
|
|
||||||
title: "Joining".to_owned(),
|
|
||||||
message: "joining game".to_owned(),
|
|
||||||
ok: false,
|
|
||||||
});
|
|
||||||
match addr.get_text().to_string().parse() {
|
|
||||||
Ok(addr) => {
|
|
||||||
NetworkManager::singleton().bind_mut().join(addr);
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
PopupQueue::singleton().bind_mut().queue(Popup {
|
|
||||||
title: "Error".to_owned(),
|
|
||||||
message: format!("Error joining: {}", err),
|
|
||||||
ok: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[func]
|
|
||||||
pub fn go_to_main_menu(&mut self) {
|
|
||||||
self.current_menu = Menu::MainMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[func]
|
|
||||||
pub fn go_to_host_game(&mut self) {
|
|
||||||
self.current_menu = Menu::HostMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[func]
|
|
||||||
pub fn go_to_join_game(&mut self) {
|
|
||||||
self.current_menu = Menu::JoinMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[func]
|
|
||||||
pub fn quit_game(&mut self) {
|
|
||||||
self.base().get_tree().quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn show_popup(&mut self, title: &str, text: &str, ok: bool) {
|
|
||||||
if let Some(panel) = &mut self.popup_panel {
|
|
||||||
panel.set_visible(true);
|
|
||||||
if let Some(title_label) = &mut self.popup_title {
|
|
||||||
title_label.set_text(title);
|
|
||||||
}
|
|
||||||
if let Some(text_label) = &mut self.popup_text {
|
|
||||||
text_label.set_text(text);
|
|
||||||
}
|
|
||||||
if let Some(button) = &mut self.popup_button {
|
|
||||||
button.set_visible(ok);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[func]
|
|
||||||
pub fn hide_popup(&mut self) {
|
|
||||||
if let Some(panel) = &mut self.popup_panel {
|
|
||||||
panel.set_visible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
use godot::prelude::*;
|
|
||||||
|
|
||||||
use crate::soldier_mesh::SoldierMesh;
|
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
|
||||||
#[class(base=Node3D, init)]
|
|
||||||
pub struct MenuPlayer {
|
|
||||||
#[export]
|
|
||||||
mesh: Option<Gd<SoldierMesh>>,
|
|
||||||
|
|
||||||
base: Base<Node3D>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[godot_api]
|
|
||||||
impl INode3D for MenuPlayer {
|
|
||||||
fn ready(&mut self) {
|
|
||||||
if let Some(mesh) = &mut self.mesh {
|
|
||||||
mesh.bind_mut().spawn_raygun();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,8 +2,6 @@ pub mod cli;
|
|||||||
pub mod game_finished_screen;
|
pub mod game_finished_screen;
|
||||||
pub mod lobby;
|
pub mod lobby;
|
||||||
pub mod lobby_player_listing;
|
pub mod lobby_player_listing;
|
||||||
pub mod main_menu;
|
|
||||||
pub mod menu_player;
|
|
||||||
pub mod net_stats;
|
pub mod net_stats;
|
||||||
pub mod player_listing;
|
pub mod player_listing;
|
||||||
pub mod simple_score_view;
|
pub mod simple_score_view;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user