diff --git a/godot/scenes/main.tscn b/godot/scenes/main.tscn index 3149064..1a7a83e 100644 --- a/godot/scenes/main.tscn +++ b/godot/scenes/main.tscn @@ -1,6 +1,7 @@ [gd_scene format=3 uid="uid://lahirbqfppvw"] [ext_resource type="PackedScene" uid="uid://bbmc2gmy7g8ag" path="res://scenes/misc/menu_player.tscn" id="1_o5qli"] +[ext_resource type="PackedScene" uid="uid://dsxu0y8pjbw3k" path="res://scenes/ui/credits.tscn" id="1_sugp2"] [ext_resource type="PackedScene" uid="uid://n3u0jr4wiib1" path="res://scenes/ui/settings.tscn" id="2_0wfyh"] [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", "recent_servers_button", "popup_panel", "popup_title", "popup_text", "popup_button")] @@ -17,6 +18,7 @@ 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") +credits = ExtResource("1_sugp2") [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) @@ -72,6 +74,11 @@ layout_mode = 2 text = "Join Game" metadata/_edit_lock_ = true +[node name="credits" type="Button" parent="main_panel/v_box_container" unique_id=953921422] +layout_mode = 2 +text = "Credits" +metadata/_edit_lock_ = true + [node name="settings" type="Button" parent="main_panel/v_box_container" unique_id=1153899756] layout_mode = 2 text = "Settings" @@ -240,6 +247,7 @@ 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/credits" to="." method="open_credits"] [connection signal="pressed" from="main_panel/v_box_container/settings" to="settings" method="open"] [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"] diff --git a/godot/scenes/credits.tscn b/godot/scenes/ui/credits.tscn similarity index 89% rename from godot/scenes/credits.tscn rename to godot/scenes/ui/credits.tscn index 204b325..cc03efc 100644 --- a/godot/scenes/credits.tscn +++ b/godot/scenes/ui/credits.tscn @@ -45,10 +45,12 @@ layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="back" type="Button" parent="panel" unique_id=676253720] +[node name="close" type="Button" parent="panel" unique_id=676253720] layout_mode = 0 offset_left = 46.0 offset_top = 575.0 offset_right = 91.0 offset_bottom = 606.0 -text = "Back to Main Menu" +text = "Close" + +[connection signal="pressed" from="panel/close" to="." method="close"] diff --git a/rust/src/ui/credits.rs b/rust/src/ui/credits.rs index 8c96e57..b5f197b 100644 --- a/rust/src/ui/credits.rs +++ b/rust/src/ui/credits.rs @@ -43,6 +43,7 @@ impl IControl for CreditsMenu { } } +#[godot_api] impl CreditsMenu { pub fn add_credit(&mut self, credit: CreditPerson) { if let Some(container) = &mut self.credits_container { @@ -87,4 +88,9 @@ impl CreditsMenu { container.add_child(&margin); } } + + #[func] + pub fn close(&mut self) { + self.base_mut().queue_free(); + } } diff --git a/rust/src/ui/main_menu.rs b/rust/src/ui/main_menu.rs index dd2eb85..b77878c 100644 --- a/rust/src/ui/main_menu.rs +++ b/rust/src/ui/main_menu.rs @@ -8,6 +8,7 @@ use crate::{ game_settings::{GameSettingsManager, RecentServer}, net::network_manager::NetworkManager, popup_queue::{Popup, PopupQueue}, + ui::credits::CreditsMenu, }; #[derive(Debug, Clone, GodotConvert, Default, Export)] @@ -57,6 +58,8 @@ pub struct MainMenu { #[export] current_menu: Menu, + #[export] + credits: Option>, prev_panel: Option>, @@ -212,6 +215,15 @@ impl MainMenu { self.base().get_tree().quit(); } + #[func] + pub fn open_credits(&mut self) { + if let Some(credits) = self.credits.clone() { + let credits = credits.instantiate_as::(); + godot_print!("{}", credits); + self.base_mut().add_child(&credits); + } + } + pub fn show_popup(&mut self, title: &str, text: &str, ok: bool) { if let Some(panel) = &mut self.popup_panel { panel.set_visible(true);