diff --git a/ui/ControlsMenu.cs b/ui/ControlsMenu.cs new file mode 100644 index 0000000..9526d48 --- /dev/null +++ b/ui/ControlsMenu.cs @@ -0,0 +1,27 @@ +public partial class ControlsMenu : MarginContainer +{ + [Export] public Label DisplayX { get; set; } + [Export] public Label DisplayY { get; set; } + [Export] public HSlider SliderX { get; set; } + [Export] public HSlider SliderY { get; set; } + [Export] public CheckButton InvertX { get; set; } + [Export] public CheckButton InvertY { get; set; } + + public override void _Ready() + { + SliderX.ValueChanged += _ => OnValueChanged(); + SliderY.ValueChanged += _ => OnValueChanged(); + InvertX.Toggled += _ => OnValueChanged(); + InvertY.Toggled += _ => OnValueChanged(); + } + + void OnValueChanged() + { + DisplayX.Text = $"{SliderX.Value:0.00}"; + DisplayY.Text = $"{SliderY.Value:0.00}"; + Game.Instance.LocalPlayer.Camera.MouseSensitivity = new( + (float)SliderX.Value * (InvertX.ButtonPressed ? -1 : 1), + (float)SliderY.Value * (InvertY.ButtonPressed ? -1 : 1)); + // TODO: Do a saving. + } +} diff --git a/ui/menu.tscn b/ui/menu.tscn index 070fb83..db36533 100644 --- a/ui/menu.tscn +++ b/ui/menu.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=8 format=3 uid="uid://c5ooi36ibspfo"] +[gd_scene load_steps=11 format=3 uid="uid://c5ooi36ibspfo"] [ext_resource type="Script" path="res://ui/Menu.cs" id="1_5qxrt"] [ext_resource type="Script" path="res://ui/MultiplayerMenu.cs" id="2_3ulcb"] +[ext_resource type="Script" path="res://ui/ControlsMenu.cs" id="3_jnj0g"] [sub_resource type="LabelSettings" id="LabelSettings_u8eqm"] font_size = 22 @@ -15,6 +16,12 @@ font_color = Color(0.75, 0.75, 0.75, 1) [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_2rjy4"] +[sub_resource type="SystemFont" id="SystemFont_y3lqx"] +font_names = PackedStringArray("Monospace") + +[sub_resource type="LabelSettings" id="LabelSettings_b1gi8"] +font = SubResource("SystemFont_y3lqx") + [node name="Menu" type="CenterContainer" node_paths=PackedStringArray("SideButtons", "Tabs")] offset_right = 586.0 offset_bottom = 386.0 @@ -236,15 +243,87 @@ layout_mode = 2 size_flags_horizontal = 3 text = "Disconnect" -[node name="Controls" type="CenterContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer"] +[node name="Controls" type="MarginContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer" node_paths=PackedStringArray("DisplayX", "DisplayY", "SliderX", "SliderY", "InvertX", "InvertY")] visible = false layout_mode = 2 +theme_override_constants/margin_left = 8 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 8 +theme_override_constants/margin_bottom = 8 +script = ExtResource("3_jnj0g") +DisplayX = NodePath("ScrollContainer/VBoxContainer/GridContainer/DisplayX") +DisplayY = NodePath("ScrollContainer/VBoxContainer/GridContainer/DisplayY") +SliderX = NodePath("ScrollContainer/VBoxContainer/GridContainer/SliderX") +SliderY = NodePath("ScrollContainer/VBoxContainer/GridContainer/SliderY") +InvertX = NodePath("ScrollContainer/VBoxContainer/GridContainer/InvertX") +InvertY = NodePath("ScrollContainer/VBoxContainer/GridContainer/InvertY") + +[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls"] +layout_mode = 2 +horizontal_scroll_mode = 0 -[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls"] +[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer"] layout_mode = 2 -text = "Controls -(nothing here yet)" -horizontal_alignment = 1 +size_flags_horizontal = 3 + +[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer/VBoxContainer"] +layout_mode = 2 +text = "Mouse Sensitivity" + +[node name="GridContainer" type="GridContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/h_separation = 12 +columns = 4 + +[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer/VBoxContainer/GridContainer"] +custom_minimum_size = Vector2(32, 0) +layout_mode = 2 +text = "X:" +horizontal_alignment = 2 + +[node name="DisplayX" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer/VBoxContainer/GridContainer"] +layout_mode = 2 +text = "0.20 +" +label_settings = SubResource("LabelSettings_b1gi8") + +[node name="SliderX" type="HSlider" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer/VBoxContainer/GridContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 1 +min_value = 0.02 +max_value = 2.0 +step = 0.02 +value = 0.2 + +[node name="InvertX" type="CheckButton" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer/VBoxContainer/GridContainer"] +layout_mode = 2 +text = "Invert" + +[node name="Label2" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer/VBoxContainer/GridContainer"] +custom_minimum_size = Vector2(32, 0) +layout_mode = 2 +text = "Y:" +horizontal_alignment = 2 + +[node name="DisplayY" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer/VBoxContainer/GridContainer"] +layout_mode = 2 +text = "0.20 +" +label_settings = SubResource("LabelSettings_b1gi8") + +[node name="SliderY" type="HSlider" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer/VBoxContainer/GridContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 1 +min_value = 0.02 +max_value = 2.0 +step = 0.02 +value = 0.2 + +[node name="InvertY" type="CheckButton" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer/Controls/ScrollContainer/VBoxContainer/GridContainer"] +layout_mode = 2 +text = "Invert" [node name="Graphics" type="CenterContainer" parent="PanelContainer/MarginContainer/VBoxContainer/GridContainer/TabContainer"] visible = false