-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsettings.gd
66 lines (48 loc) · 2.67 KB
/
settings.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
extends Node
const SETTINGS_FILE_PATH := "user://settings.cfg"
enum LocomotionDirectionSource { HEAD, LEFT_CONTROLLER, RIGHT_CONTROLLER }
enum LocomotionUpdateMode { ONCE, CONTINUOUS }
var msaa: int
var fxaa: bool
var teleporting_enabled: bool
var continuous_locomotion_enabled: bool
var locomotion_direction_source: int
var locomotion_update_mode: int
var hand_offset_position: Vector3
var hand_offset_rotation: Vector3
func load_settings(from_path: String = SETTINGS_FILE_PATH) -> int:
var config_file := ConfigFile.new()
var error_code := config_file.load(from_path)
Utility.set_framerate(config_file.get_value("performance", "framerate", 90))
msaa = config_file.get_value("performance", "msaa", Viewport.MSAA_2X)
fxaa = config_file.get_value("performance", "fxaa", false)
teleporting_enabled = config_file.get_value("teleporting", "enabled", true)
continuous_locomotion_enabled = config_file.get_value("continuous_locomotion", "enabled", false)
locomotion_direction_source = config_file.get_value("continuous_locomotion", "direction_source", \
LocomotionDirectionSource.HEAD)
locomotion_update_mode = config_file.get_value("continuous_locomotion", "update_mode", \
LocomotionUpdateMode.ONCE)
hand_offset_position = config_file.get_value("hand_offset", "position", Vector3.ZERO)
hand_offset_rotation = config_file.get_value("hand_offset", "rotation", Vector3.ZERO)
return error_code
func save_settings(to_path: String = SETTINGS_FILE_PATH) -> int:
var config_file := ConfigFile.new()
config_file.set_value("performance", "framerate", Engine.iterations_per_second)
config_file.set_value("performance", "msaa", msaa)
config_file.set_value("performance", "fxaa", fxaa)
config_file.set_value("teleporting", "enabled", teleporting_enabled)
config_file.set_value("continuous_locomotion", "enabled", continuous_locomotion_enabled)
config_file.set_value("continuous_locomotion", "direction_source", locomotion_direction_source)
config_file.set_value("continuous_locomotion", "update_mode", locomotion_update_mode)
config_file.set_value("hand_offset", "position", hand_offset_position)
config_file.set_value("hand_offset", "rotation", hand_offset_rotation)
return config_file.save(to_path)
func apply_to_viewport(viewport: Viewport) -> void:
viewport.msaa = self.msaa
viewport.fxaa = self.fxaa
func apply_to_player(player: VRPlayer) -> void:
player.teleporting_enabled = self.teleporting_enabled
player.continuous_locomotion_enabled = self.continuous_locomotion_enabled
player.locomotion_direction_source = self.locomotion_direction_source
player.locomotion_update_mode = self.locomotion_update_mode
player.set_hand_offset(self.hand_offset_position, self.hand_offset_rotation)