Make settings look a lot better
This commit is contained in:
parent
0527567350
commit
58a3b74d2b
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cqiwdajl71ujv" path="res://scenes/ui/slider.tscn" id="1_8wfqe"]
|
[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")]
|
[node name="settings" type="SettingsPanel" unique_id=999912383 node_paths=PackedStringArray("general_grid", "volume_grid")]
|
||||||
settings_grid = NodePath("grid")
|
general_grid = NodePath("v_box_container/tab_container/general")
|
||||||
|
volume_grid = NodePath("v_box_container/tab_container/volume")
|
||||||
slider_scene = ExtResource("1_8wfqe")
|
slider_scene = ExtResource("1_8wfqe")
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
@ -17,20 +18,37 @@ offset_bottom = 112.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
[node name="grid" type="GridContainer" parent="." unique_id=833231169]
|
[node name="v_box_container" type="VBoxContainer" parent="." unique_id=1384128810]
|
||||||
custom_minimum_size = Vector2(400, 0)
|
|
||||||
custom_maximum_size = Vector2(400, -1)
|
|
||||||
layout_mode = 2
|
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
|
layout_mode = 2
|
||||||
text = "Settings"
|
text = "Settings"
|
||||||
horizontal_alignment = 1
|
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
|
layout_mode = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
text = "Close"
|
text = "Close"
|
||||||
|
|
||||||
[connection signal="pressed" from="grid/button" to="." method="close"]
|
[connection signal="pressed" from="v_box_container/button" to="." method="close"]
|
||||||
|
|||||||
@ -20,6 +20,11 @@ pub enum Setting {
|
|||||||
AnnouncerVolume,
|
AnnouncerVolume,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum SettingsTab {
|
||||||
|
General,
|
||||||
|
Volume,
|
||||||
|
}
|
||||||
|
|
||||||
impl ToString for Setting {
|
impl ToString for Setting {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
match self {
|
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)]
|
#[derive(Clone)]
|
||||||
pub enum SettingValue {
|
pub enum SettingValue {
|
||||||
SliderNumber(SliderValue),
|
SliderNumber(SliderValue),
|
||||||
@ -51,7 +69,9 @@ pub struct SliderValue {
|
|||||||
#[class(base=PanelContainer, init)]
|
#[class(base=PanelContainer, init)]
|
||||||
pub struct SettingsPanel {
|
pub struct SettingsPanel {
|
||||||
#[export]
|
#[export]
|
||||||
settings_grid: Option<Gd<GridContainer>>,
|
general_grid: Option<Gd<GridContainer>>,
|
||||||
|
#[export]
|
||||||
|
volume_grid: Option<Gd<GridContainer>>,
|
||||||
#[export]
|
#[export]
|
||||||
slider_scene: Option<Gd<PackedScene>>,
|
slider_scene: Option<Gd<PackedScene>>,
|
||||||
|
|
||||||
@ -110,13 +130,18 @@ impl IPanelContainer for SettingsPanel {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(mut grid) = self.settings_grid.clone() {
|
let mut keys = self.settings.keys().collect::<Vec<_>>();
|
||||||
let mut keys = self.settings.keys().collect::<Vec<_>>();
|
keys.sort();
|
||||||
keys.sort();
|
|
||||||
|
|
||||||
for setting in keys.into_iter() {
|
for setting in keys.into_iter() {
|
||||||
let value = self.settings.get(setting).unwrap().clone();
|
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();
|
let mut label = Label::new_alloc();
|
||||||
label.set_text(&setting.to_string());
|
label.set_text(&setting.to_string());
|
||||||
label.set_h_size_flags(SizeFlags::EXPAND | SizeFlags::SHRINK_BEGIN);
|
label.set_h_size_flags(SizeFlags::EXPAND | SizeFlags::SHRINK_BEGIN);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user