Add tabs for settings, make orbit speed separately configurable

This commit is contained in:
Jens Pitkänen 2024-08-20 16:10:15 +03:00
parent a40f4afbbb
commit 814a7c3c3c
4 changed files with 213 additions and 19 deletions

View File

@ -8,7 +8,7 @@ bg_color = Color(0.2, 0.2, 0.2, 0.921569)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_q40bd"]
bg_color = Color(0.25, 0.25, 0.25, 0.909804)
[node name="PauseMenu" type="Control" node_paths=PackedStringArray("InitialFocusTarget", "VolumeSlider", "CameraSensitivityX", "CameraSensitivityY", "CameraInvertX", "CameraInvertY")]
[node name="PauseMenu" type="Control" node_paths=PackedStringArray("InitialFocusTarget", "VolumeSlider", "CameraSensitivityX", "CameraSensitivityY", "CameraInvertX", "CameraInvertY", "TableOrbitSpeedX", "TableOrbitSpeedY", "TableOrbitInvertX", "TableOrbitInvertY")]
process_mode = 3
layout_mode = 3
anchors_preset = 15
@ -18,11 +18,15 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_p5jo3")
InitialFocusTarget = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/ContinueButton")
VolumeSlider = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options/VolumeSlider")
CameraSensitivityX = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options/CameraXSlider")
CameraSensitivityY = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options/CameraYSlider")
CameraInvertX = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options/CameraXInvCheck")
CameraInvertY = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options/CameraYInvCheck")
VolumeSlider = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/General settings/Grid/VolumeSlider")
CameraSensitivityX = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid/CameraXSlider")
CameraSensitivityY = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid/CameraYSlider")
CameraInvertX = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid/CameraXInvCheck")
CameraInvertY = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid/CameraYInvCheck")
TableOrbitSpeedX = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid/RotateSpeedSlider")
TableOrbitSpeedY = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid/TiltSpeedSlider")
TableOrbitInvertX = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid/InvertRotateCheck")
TableOrbitInvertY = NodePath("CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid/InvertTiltCheck")
[node name="CenterContainer" type="CenterContainer" parent="."]
process_mode = 2
@ -61,17 +65,32 @@ layout_mode = 2
focus_neighbor_top = NodePath("../QuitButton")
text = "Continue"
[node name="Options" type="GridContainer" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons"]
[node name="TabContainer" type="TabContainer" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons"]
custom_minimum_size = Vector2(340, 200)
layout_mode = 2
theme_override_font_sizes/font_size = 11
current_tab = 2
[node name="General settings" type="MarginContainer" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer"]
visible = false
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
metadata/_tab_index = 0
[node name="Grid" type="GridContainer" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/General settings"]
layout_mode = 2
theme_override_constants/h_separation = 14
theme_override_constants/v_separation = 9
columns = 2
[node name="VolumeLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options"]
[node name="VolumeLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/General settings/Grid"]
layout_mode = 2
text = "Volume"
[node name="VolumeSlider" type="HSlider" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options"]
[node name="VolumeSlider" type="HSlider" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/General settings/Grid"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
size_flags_horizontal = 3
@ -79,42 +98,185 @@ size_flags_vertical = 1
max_value = 1.0
step = 0.05
[node name="CameraXLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options"]
[node name="Camera" type="MarginContainer" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer"]
visible = false
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
metadata/_tab_index = 1
[node name="Grid" type="GridContainer" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera"]
layout_mode = 2
theme_override_constants/h_separation = 14
theme_override_constants/v_separation = 9
columns = 2
[node name="CameraXLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid"]
layout_mode = 2
text = "Camera yaw speed"
[node name="CameraXSlider" type="HSlider" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options"]
[node name="CameraXSlider" type="HSlider" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
max_value = 10.0
step = 0.25
[node name="CameraXInvLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options"]
[node name="CameraXInvLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid"]
layout_mode = 2
text = "Camera invert yaw"
[node name="CameraXInvCheck" type="CheckButton" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options"]
[node name="CameraXInvCheck" type="CheckButton" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid"]
layout_mode = 2
size_flags_horizontal = 3
action_mode = 0
[node name="CameraYLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options"]
[node name="CameraYLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid"]
layout_mode = 2
text = "Camera pitch speed"
[node name="CameraYSlider" type="HSlider" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options"]
[node name="CameraYSlider" type="HSlider" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
max_value = 10.0
step = 0.25
[node name="CameraYInvLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options"]
[node name="CameraYInvLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid"]
layout_mode = 2
text = "Camera invert pitch"
[node name="CameraYInvCheck" type="CheckButton" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/Options"]
[node name="CameraYInvCheck" type="CheckButton" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Camera/Grid"]
layout_mode = 2
size_flags_horizontal = 3
action_mode = 0
[node name="Building" type="MarginContainer" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer"]
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
metadata/_tab_index = 2
[node name="Grid" type="GridContainer" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building"]
layout_mode = 2
theme_override_constants/h_separation = 14
theme_override_constants/v_separation = 9
columns = 2
[node name="RotateSpeedLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid"]
layout_mode = 2
text = "Rotation speed"
[node name="RotateSpeedSlider" type="HSlider" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
max_value = 6.0
step = 0.25
[node name="InvertRotateLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid"]
layout_mode = 2
text = "Invert rotation"
[node name="InvertRotateCheck" type="CheckButton" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid"]
layout_mode = 2
size_flags_horizontal = 3
action_mode = 0
[node name="TiltSpeedLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid"]
layout_mode = 2
text = "Tilt speed"
[node name="TiltSpeedSlider" type="HSlider" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
max_value = 6.0
step = 0.25
[node name="InvertTiltLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid"]
layout_mode = 2
text = "Invert tilt"
[node name="InvertTiltCheck" type="CheckButton" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Building/Grid"]
layout_mode = 2
size_flags_horizontal = 3
action_mode = 0
[node name="Graphics" type="MarginContainer" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer"]
visible = false
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
metadata/_tab_index = 3
[node name="Grid" type="GridContainer" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Graphics"]
layout_mode = 2
theme_override_constants/h_separation = 14
theme_override_constants/v_separation = 9
columns = 2
[node name="MsaaLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Graphics/Grid"]
layout_mode = 2
text = "MSAA"
[node name="MsaaOptions" type="OptionButton" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Graphics/Grid"]
layout_mode = 2
disabled = true
selected = 2
item_count = 4
popup/item_0/text = "Disabled"
popup/item_1/text = "2 samples"
popup/item_1/id = 1
popup/item_2/text = "4 samples"
popup/item_2/id = 2
popup/item_3/text = "8 samples"
popup/item_3/id = 3
[node name="RenderScaleLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Graphics/Grid"]
layout_mode = 2
text = "Render scale
"
[node name="RenderScaleOptions" type="OptionButton" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Graphics/Grid"]
layout_mode = 2
disabled = true
selected = 3
item_count = 6
popup/item_0/text = "25%"
popup/item_0/id = 25
popup/item_1/text = "50%"
popup/item_1/id = 50
popup/item_2/text = "75%"
popup/item_2/id = 75
popup/item_3/text = "100%"
popup/item_3/id = 100
popup/item_4/text = "150%"
popup/item_4/id = 150
popup/item_5/text = "200%"
popup/item_5/id = 200
[node name="UpscaleLabel" type="Label" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Graphics/Grid"]
layout_mode = 2
text = "Upscaling"
[node name="UpscaleOption" type="OptionButton" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons/TabContainer/Graphics/Grid"]
layout_mode = 2
disabled = true
selected = 0
item_count = 3
popup/item_0/text = "Linear"
popup/item_1/text = "FSR 1.0"
popup/item_1/id = 1
popup/item_2/text = "FSR 2.2"
popup/item_2/id = 2
[node name="QuitButton" type="Button" parent="CenterContainer/HBoxContainer/OptionsAndButtonsContainer/MarginContainer/Options and buttons"]
layout_mode = 2
focus_neighbor_bottom = NodePath("../ContinueButton")

View File

@ -104,7 +104,7 @@ namespace Gmtk24 {
Input.MouseMode = Input.MouseModeEnum.Visible;
if (Input.IsActionPressed("drag_orbit") && @event is InputEventMouseMotion mouseMotion) {
var cameraSensitivity = UserSettings.Singleton.GetCameraSpeedMultipliers();
var cameraSensitivity = UserSettings.Singleton.GetOrbitSpeedMultipliers();
var mouseMultiplier = 0.0003f;
CurrentYaw -= mouseMotion.ScreenRelative.X * mouseMultiplier * cameraSensitivity.X;
CurrentPitch -= mouseMotion.ScreenRelative.Y * mouseMultiplier * cameraSensitivity.Y;

View File

@ -4,9 +4,10 @@ namespace Gmtk24 {
public partial class PauseMenu : Control {
[Export]
public Control InitialFocusTarget;
[ExportCategory("Setting controls")]
[ExportCategory("Setting controls (general)")]
[Export]
public Range VolumeSlider;
[ExportCategory("Setting controls (camera)")]
[Export]
public Range CameraSensitivityX;
[Export]
@ -15,6 +16,15 @@ namespace Gmtk24 {
public BaseButton CameraInvertX;
[Export]
public BaseButton CameraInvertY;
[ExportCategory("Setting controls (building)")]
[Export]
public Range TableOrbitSpeedX;
[Export]
public Range TableOrbitSpeedY;
[Export]
public BaseButton TableOrbitInvertX;
[Export]
public BaseButton TableOrbitInvertY;
[Export]
public Table Table;
@ -24,6 +34,7 @@ namespace Gmtk24 {
public override void _Ready() {
VolumeSlider.Value = UserSettings.Singleton.Volume;
VolumeSlider.ValueChanged += (value) => UserSettings.Singleton.SetVolume((float)value);
CameraSensitivityX.Value = UserSettings.Singleton.CameraSensitivityX;
CameraSensitivityX.ValueChanged += (value) => UserSettings.Singleton.CameraSensitivityX = (float)value;
CameraSensitivityY.Value = UserSettings.Singleton.CameraSensitivityY;
@ -33,6 +44,15 @@ namespace Gmtk24 {
CameraInvertY.ButtonPressed = UserSettings.Singleton.CameraInvertY;
CameraInvertY.Toggled += (on) => UserSettings.Singleton.CameraInvertY = on;
TableOrbitSpeedX.Value = UserSettings.Singleton.TableOrbitSpeedX;
TableOrbitSpeedX.ValueChanged += (value) => UserSettings.Singleton.TableOrbitSpeedX = (float)value;
TableOrbitSpeedY.Value = UserSettings.Singleton.TableOrbitSpeedY;
TableOrbitSpeedY.ValueChanged += (value) => UserSettings.Singleton.TableOrbitSpeedY = (float)value;
TableOrbitInvertX.ButtonPressed = UserSettings.Singleton.TableOrbitInvertX;
TableOrbitInvertX.Toggled += (on) => UserSettings.Singleton.TableOrbitInvertX = on;
TableOrbitInvertY.ButtonPressed = UserSettings.Singleton.TableOrbitInvertY;
TableOrbitInvertY.Toggled += (on) => UserSettings.Singleton.TableOrbitInvertY = on;
Open();
}

View File

@ -7,11 +7,17 @@ namespace Gmtk24 {
public static UserSettings Singleton { get; private set; }
public float Volume { get; private set; }
public float CameraSensitivityX = 2f;
public float CameraSensitivityY = 2f;
public bool CameraInvertX = false;
public bool CameraInvertY = false;
public float TableOrbitSpeedX = 1f;
public float TableOrbitSpeedY = 1f;
public bool TableOrbitInvertX = false;
public bool TableOrbitInvertY = false;
public override void _Ready() {
SetVolume(0.2f);
Singleton = this;
@ -23,6 +29,12 @@ namespace Gmtk24 {
return new Vector2(x, y);
}
public Vector2 GetOrbitSpeedMultipliers() {
var x = TableOrbitSpeedX * (TableOrbitInvertX ? -1 : 1);
var y = TableOrbitSpeedY * (TableOrbitInvertY ? -1 : 1);
return new Vector2(x, y);
}
public void SetVolume(float volume) {
AudioServer.SetBusVolumeDb(0, volume == 0 ? -80 : Mathf.LinearToDb(volume));
Volume = volume;