2024-12-08 23:21:05 +00:00
|
|
|
class_name GameSettingsType extends Node
|
|
|
|
## Container for project settings, for quick runtime access.
|
|
|
|
|
2024-12-09 04:51:04 +00:00
|
|
|
var settings_file: String
|
2024-12-09 09:57:08 +00:00
|
|
|
var audio_bus_file: String
|
2024-12-09 04:51:04 +00:00
|
|
|
|
2024-12-08 23:21:05 +00:00
|
|
|
var free_camera_speed: float
|
|
|
|
var x_sensitivity: float
|
|
|
|
var y_sensitivity: float
|
|
|
|
var x_acceleration: float
|
|
|
|
var y_acceleration: float
|
|
|
|
var invert_pitch: bool
|
|
|
|
var enable_screen_shake: bool
|
|
|
|
var enable_hit_lag: bool
|
|
|
|
|
2024-12-09 22:05:31 +00:00
|
|
|
var projection_collisions: bool
|
|
|
|
var projection_gravity: bool
|
|
|
|
|
2024-12-08 23:21:05 +00:00
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
ProjectSettings.settings_changed.connect(_read_settings)
|
2024-12-09 09:57:08 +00:00
|
|
|
_read_settings()
|
|
|
|
_load_audio_bus_override()
|
2024-12-08 23:21:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _read_settings() -> void:
|
2024-12-09 04:51:04 +00:00
|
|
|
settings_file = ProjectSettings.get_setting("application/config/project_settings_override")
|
2024-12-09 09:57:08 +00:00
|
|
|
audio_bus_file = ProjectSettings.get_setting("game/audio/buses/override_bus_layout")
|
2024-12-09 04:51:04 +00:00
|
|
|
|
2024-12-08 23:21:05 +00:00
|
|
|
free_camera_speed = ProjectSettings.get_setting("game/config/controls/camera/free_camera_speed")
|
|
|
|
x_sensitivity = ProjectSettings.get_setting("game/config/controls/camera/x_axis_sensitivity")
|
|
|
|
y_sensitivity = ProjectSettings.get_setting("game/config/controls/camera/y_axis_sensitivity")
|
|
|
|
x_acceleration = ProjectSettings.get_setting("game/config/controls/camera/x_axis_acceleration")
|
|
|
|
y_acceleration = ProjectSettings.get_setting("game/config/controls/camera/y_axis_acceleration")
|
|
|
|
invert_pitch = ProjectSettings.get_setting("game/config/controls/camera/invert_pitch")
|
|
|
|
|
|
|
|
enable_screen_shake = ProjectSettings.get_setting(
|
|
|
|
"game/config/accessibility/enable_screen_shake"
|
|
|
|
)
|
|
|
|
enable_hit_lag = ProjectSettings.get_setting("game/config/accessibility/enable_hit_lag")
|
2024-12-09 09:57:08 +00:00
|
|
|
|
2024-12-09 22:05:31 +00:00
|
|
|
projection_collisions = ProjectSettings.get_setting(
|
|
|
|
"game/config/gameplay/projection/detect_collision"
|
|
|
|
)
|
|
|
|
projection_gravity = ProjectSettings.get_setting(
|
|
|
|
"game/config/gameplay/projection/use_local_gravity"
|
|
|
|
)
|
|
|
|
|
2024-12-09 09:57:08 +00:00
|
|
|
|
|
|
|
func _load_audio_bus_override() -> void:
|
|
|
|
# Load override audio bus file
|
|
|
|
if FileAccess.file_exists(audio_bus_file):
|
|
|
|
print_debug("Loading audio bus override from ", audio_bus_file)
|
|
|
|
var bus_layout: AudioBusLayout = load(audio_bus_file)
|
|
|
|
AudioServer.set_bus_layout(bus_layout)
|
|
|
|
|
|
|
|
|
|
|
|
func write() -> void:
|
|
|
|
print_debug("Writing settings to ", settings_file)
|
|
|
|
ProjectSettings.save_custom(settings_file)
|
|
|
|
print_debug("Writing audio bus levels to ", audio_bus_file)
|
|
|
|
ResourceSaver.save(AudioServer.generate_bus_layout(), audio_bus_file)
|