diff --git a/godot/scenes/ui/settings.tscn b/godot/scenes/ui/settings.tscn index ebe0134..ade7db2 100644 --- a/godot/scenes/ui/settings.tscn +++ b/godot/scenes/ui/settings.tscn @@ -2,8 +2,9 @@ [ext_resource type="PackedScene" uid="uid://cqiwdajl71ujv" path="res://scenes/ui/slider.tscn" id="1_8wfqe"] -[node name="settings" type="SettingsPanel" unique_id=999912383 node_paths=PackedStringArray("settings_grid")] -settings_grid = NodePath("grid") +[node name="settings" type="SettingsPanel" unique_id=999912383 node_paths=PackedStringArray("general_grid", "volume_grid")] +general_grid = NodePath("v_box_container/tab_container/general") +volume_grid = NodePath("v_box_container/tab_container/volume") slider_scene = ExtResource("1_8wfqe") anchors_preset = 8 anchor_left = 0.5 @@ -17,20 +18,37 @@ offset_bottom = 112.0 grow_horizontal = 2 grow_vertical = 2 -[node name="grid" type="GridContainer" parent="." unique_id=833231169] -custom_minimum_size = Vector2(400, 0) -custom_maximum_size = Vector2(400, -1) +[node name="v_box_container" type="VBoxContainer" parent="." unique_id=1384128810] layout_mode = 2 -columns = 2 -[node name="label" type="Label" parent="grid" unique_id=2036746921] +[node name="label" type="Label" parent="v_box_container" unique_id=2036746921] layout_mode = 2 text = "Settings" horizontal_alignment = 1 -[node name="button" type="Button" parent="grid" unique_id=1301469030] +[node name="tab_container" type="TabContainer" parent="v_box_container" unique_id=66433174] +layout_mode = 2 +size_flags_vertical = 3 +current_tab = 0 + +[node name="general" type="GridContainer" parent="v_box_container/tab_container" unique_id=833231169] +custom_minimum_size = Vector2(400, 0) +custom_maximum_size = Vector2(400, -1) +layout_mode = 2 +columns = 2 +metadata/_tab_index = 0 + +[node name="volume" type="GridContainer" parent="v_box_container/tab_container" unique_id=1992916365] +visible = false +custom_minimum_size = Vector2(400, 0) +custom_maximum_size = Vector2(400, -1) +layout_mode = 2 +columns = 2 +metadata/_tab_index = 1 + +[node name="button" type="Button" parent="v_box_container" unique_id=1301469030] layout_mode = 2 size_flags_horizontal = 4 text = "Close" -[connection signal="pressed" from="grid/button" to="." method="close"] +[connection signal="pressed" from="v_box_container/button" to="." method="close"] diff --git a/rust/src/ui/settings.rs b/rust/src/ui/settings.rs index 7285c5e..fbf6723 100644 --- a/rust/src/ui/settings.rs +++ b/rust/src/ui/settings.rs @@ -20,6 +20,11 @@ pub enum Setting { AnnouncerVolume, } +pub enum SettingsTab { + General, + Volume, +} + impl ToString for Setting { fn to_string(&self) -> String { match self { @@ -34,6 +39,19 @@ impl ToString for Setting { } } +impl Setting { + pub fn tab(&self) -> SettingsTab { + match self { + Setting::FoV => SettingsTab::General, + Setting::DefaultName => SettingsTab::General, + Setting::MasterVolume => SettingsTab::Volume, + Setting::SfxVolume => SettingsTab::Volume, + Setting::MusicVolume => SettingsTab::Volume, + Setting::AnnouncerVolume => SettingsTab::Volume, + } + } +} + #[derive(Clone)] pub enum SettingValue { SliderNumber(SliderValue), @@ -51,7 +69,9 @@ pub struct SliderValue { #[class(base=PanelContainer, init)] pub struct SettingsPanel { #[export] - settings_grid: Option>, + general_grid: Option>, + #[export] + volume_grid: Option>, #[export] slider_scene: Option>, @@ -110,13 +130,18 @@ impl IPanelContainer for SettingsPanel { }), ); - if let Some(mut grid) = self.settings_grid.clone() { - let mut keys = self.settings.keys().collect::>(); - keys.sort(); + let mut keys = self.settings.keys().collect::>(); + keys.sort(); - for setting in keys.into_iter() { - let value = self.settings.get(setting).unwrap().clone(); + for setting in keys.into_iter() { + let value = self.settings.get(setting).unwrap().clone(); + let grid = match setting.tab() { + SettingsTab::General => self.general_grid.clone(), + SettingsTab::Volume => self.volume_grid.clone(), + }; + + if let Some(mut grid) = grid { let mut label = Label::new_alloc(); label.set_text(&setting.to_string()); label.set_h_size_flags(SizeFlags::EXPAND | SizeFlags::SHRINK_BEGIN);