Added ability to adjust mouse settings in game
This commit is contained in:
11
Assets/scripts/Component Scripts/Settings_Option.gd
Normal file
11
Assets/scripts/Component Scripts/Settings_Option.gd
Normal file
@ -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)
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user