diff --git a/Assets/components/Pause Screen.tscn b/Assets/components/Pause Screen.tscn index 7015c95..7a126b6 100644 --- a/Assets/components/Pause Screen.tscn +++ b/Assets/components/Pause Screen.tscn @@ -63,6 +63,7 @@ text = "Quit " [node name="Settings" type="Control" parent="."] +visible = false layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -112,39 +113,29 @@ offset_bottom = -16.0 grow_horizontal = 2 grow_vertical = 2 -[node name="HBoxContainer" parent="Settings/ColorRect/VBoxContainer" instance=ExtResource("4_6nahw")] +[node name="Setting Option" parent="Settings/ColorRect/VBoxContainer" instance=ExtResource("4_6nahw")] layout_mode = 2 +Setting = 0 -[node name="HBoxContainer4" parent="Settings/ColorRect/VBoxContainer" instance=ExtResource("4_6nahw")] +[node name="Setting Option2" parent="Settings/ColorRect/VBoxContainer" instance=ExtResource("4_6nahw")] layout_mode = 2 -SettingName = "Joystick Settings" -SettingLabel = "Joystick_Settings" +Setting = 1 -[node name="HBoxContainer2" type="HBoxContainer" parent="Settings/ColorRect/VBoxContainer"] +[node name="Setting Option3" parent="Settings/ColorRect/VBoxContainer" instance=ExtResource("4_6nahw")] layout_mode = 2 -alignment = 1 +Setting = 2 -[node name="Label" type="Label" parent="Settings/ColorRect/VBoxContainer/HBoxContainer2"] -custom_minimum_size = Vector2(400, 0) +[node name="Setting Option4" parent="Settings/ColorRect/VBoxContainer" instance=ExtResource("4_6nahw")] layout_mode = 2 -text = "Joystick Sensativity" -horizontal_alignment = 1 -vertical_alignment = 1 +Setting = 3 -[node name="HSlider" type="HSlider" parent="Settings/ColorRect/VBoxContainer/HBoxContainer2"] -custom_minimum_size = Vector2(200, 0) +[node name="Setting Option5" parent="Settings/ColorRect/VBoxContainer" instance=ExtResource("4_6nahw")] layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 4 +Setting = 4 -[node name="HBoxContainer3" type="HBoxContainer" parent="Settings/ColorRect/VBoxContainer"] -layout_mode = 2 - -[node name="Label" type="Label" parent="Settings/ColorRect/VBoxContainer/HBoxContainer3"] -layout_mode = 2 - -[node name="HSlider" type="HSlider" parent="Settings/ColorRect/VBoxContainer/HBoxContainer3"] +[node name="Setting Option6" parent="Settings/ColorRect/VBoxContainer" instance=ExtResource("4_6nahw")] layout_mode = 2 +Setting = 5 [connection signal="pressed" from="Pause Menu/Menu/Resume" to="." method="_on_resume_pressed"] [connection signal="pressed" from="Pause Menu/Menu/Settings" to="." method="_on_settings_pressed"] diff --git a/Assets/components/Settings_Option.tscn b/Assets/components/Settings_Option.tscn index 1471417..46a03dc 100644 --- a/Assets/components/Settings_Option.tscn +++ b/Assets/components/Settings_Option.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://Assets/scripts/Component Scripts/Settings_Option.gd" id="1_aieqa"] -[node name="HBoxContainer" type="HBoxContainer"] +[node name="Setting Option" type="HBoxContainer"] custom_minimum_size = Vector2(0, 40) alignment = 1 script = ExtResource("1_aieqa") @@ -10,7 +10,7 @@ script = ExtResource("1_aieqa") [node name="Label" type="Label" parent="."] custom_minimum_size = Vector2(400, 0) layout_mode = 2 -text = "Mouse Sensitity" +text = "Temp String" horizontal_alignment = 1 vertical_alignment = 1 diff --git a/Assets/scripts/Component Scripts/Settings_Option.gd b/Assets/scripts/Component Scripts/Settings_Option.gd new file mode 100644 index 0000000..0235690 --- /dev/null +++ b/Assets/scripts/Component Scripts/Settings_Option.gd @@ -0,0 +1,11 @@ +extends HBoxContainer + +@export var Setting:GlobalSettings.Setting = GlobalSettings.Setting.Test_Value + +# Called when the node enters the scene tree for the first time. +func _ready(): + $Label.text = GlobalSettings.GetSettingName(Setting) + $HSlider.value = GlobalSettings.GetSetting(Setting) + +func _on_setting_slider_value_changed(value:float): + GlobalSettings.SetSetting(Setting, value) diff --git a/Assets/scripts/Head.gd b/Assets/scripts/Head.gd index 62c50ab..fb2312f 100644 --- a/Assets/scripts/Head.gd +++ b/Assets/scripts/Head.gd @@ -7,14 +7,14 @@ var max_angle_radians = 1.5 func _process(delta): var look_velocity = Input.get_vector("look_left", "look_right", "look_up", "look_down") - var rotate_degree = -look_velocity.y * GlobalSettings.Joystick_Sensitivity + var rotate_degree = -look_velocity.y * GlobalSettings.GetSetting(GlobalSettings.Setting.Joystick_Speed) rotate_x(rotate_degree) func _unhandled_input(event): if event is InputEventMouseMotion: var mouse_movement = -event.relative.y - var rotate_amount = mouse_movement * GlobalSettings.Mouse_Sensitivity + var rotate_amount = mouse_movement * GlobalSettings.GetSetting(GlobalSettings.Setting.Mouse_Speed) var rotation_after = rotate_amount + rotation.x if rotation_after <= max_angle_radians and rotate_amount > 0: rotate_x(rotate_amount) diff --git a/Assets/scripts/global_settings.gd b/Assets/scripts/global_settings.gd index c9ad88e..bebb910 100644 --- a/Assets/scripts/global_settings.gd +++ b/Assets/scripts/global_settings.gd @@ -1,17 +1,78 @@ extends Node +enum Setting{Mouse_Speed, Joystick_Speed, SFX_Volume, Music_Volume, Voice_Volume, FOV, Test_Value} + var DEVMODE = true var is_paused = false -var Joystick_Sensitivity = 2 -var Mouse_Sensitivity = 0.02 - var current_map = "" var SpawnPoint:Vector3 var Player_Last_Location = Vector3(0,0,0) var HasGeneratorKey = false +var Settings:Dictionary = { + Setting.Mouse_Speed: { + "value": 0.02, + "text": "Mouse Speed", + "range": Vector2(0.0001, 0.09) + }, + Setting.Joystick_Speed: { + "value": 2, + "text": "Mouse Speed", + "range": Vector2(0.5, 4) + }, + Setting.SFX_Volume: { + "value": 100, + "text": "SFX Volume", + "range": Vector2(0,100) + }, + Setting.Music_Volume: { + "value": 100, + "text": "Music Volume", + "range": Vector2(0,100) + }, + Setting.Voice_Volume: { + "value": 100, + "text": "Voice Volume", + "range": Vector2(0,100) + }, + Setting.FOV: { + "value": 95, + "text": "FOV", + "range": Vector2(75,115) + }, + Setting.Test_Value: { + "value": 69, + "text": "Test Value", + "range": Vector2(0,100) + } +} + +var GlobalData:Dictionary = { + "SpawnPoint": Vector3(), + "Player_Last_Location": Vector3() +} + +func GetSetting(SettingName): + return Settings.get(SettingName).get("value") + +func GetSettingName(SettingName): + return Settings.get(SettingName).get("text") + +func GetSettingRange(SettingName): + return Settings.get(SettingName).get("range") + + + +func SetSetting(SettingName, value): + Settings[SettingName]["value"] = value + +func PrintSettings(): + for setting in Settings.keys(): + print(setting, ":", Settings.get(setting)) + + func SetCurrentMap(selected_map): current_map = selected_map diff --git a/Assets/scripts/player.gd b/Assets/scripts/player.gd index 7c7d1ab..e10d7b0 100644 --- a/Assets/scripts/player.gd +++ b/Assets/scripts/player.gd @@ -50,7 +50,7 @@ func _physics_process(delta): move_and_slide() var look_velocity = Input.get_vector("look_left", "look_right", "look_up", "look_down") - rotate_y(-look_velocity.x * GlobalSettings.Joystick_Sensitivity * delta) + rotate_y(-look_velocity.x * GlobalSettings.GetSetting(GlobalSettings.Setting.Joystick_Speed) * delta) func _process(delta): #Calculations for seeing if you vaped too many times within a short span @@ -72,7 +72,7 @@ func _input(event): respawn() if not is_paused: if event is InputEventMouseMotion: - rotate_y(-event.relative.x * GlobalSettings.Mouse_Sensitivity) + rotate_y(-event.relative.x * GlobalSettings.GetSetting(GlobalSettings.Setting.Mouse_Speed)) if event.is_action_pressed("vape"): if current_condition == CONDITION.NORMAL: