forked from SaracenOne/sar1_mocap_manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsar1_mocap_manager.gd
64 lines (48 loc) · 2.31 KB
/
sar1_mocap_manager.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
@tool
extends Node
class_name MocapManager
const mocap_functions_const = preload("sar1_mocap_functions.gd")
const mocap_constants_const = preload("sar1_mocap_constants.gd")
const USER_PREFERENCES_SECTION_NAME = "mocap"
var set_settings_value_callback: Callable = Callable()
var get_settings_value_callback: Callable = Callable()
var save_settings_callback: Callable = Callable()
var recording_enabled = false
#
static func start_recording(p_fps: int) -> MocapRecording:
var mocap_recording: MocapRecording = null
var dict: Dictionary = mocap_functions_const._incremental_mocap_file_path({"mocap_directory":"user://" + mocap_constants_const.MOCAP_DIR})
if dict["error"] == OK:
mocap_recording = MocapRecording.new(dict["path"])
if mocap_recording.open_file_write() == OK:
mocap_recording.set_version(mocap_constants_const.MOCAP_VERSION)
mocap_recording.set_fps(p_fps)
mocap_recording.write_mocap_header()
else:
printerr("Could not open mocap file for writing")
return mocap_recording
func set_settings_value(p_key: String, p_value) -> void:
if set_settings_value_callback.is_valid():
set_settings_value_callback.call(USER_PREFERENCES_SECTION_NAME, p_key, p_value)
func set_settings_values():
set_settings_value("recording_enabled", recording_enabled)
func get_settings_value(p_key: String, p_type: int, p_default):
if get_settings_value_callback.is_valid():
return get_settings_value_callback.call(USER_PREFERENCES_SECTION_NAME, p_key, p_type, p_default)
else:
return p_default
func is_quitting() -> void:
set_settings_values()
func get_settings_values() -> void:
recording_enabled = get_settings_value("recording_enabled", TYPE_BOOL, recording_enabled)
func assign_set_settings_value_funcref(p_instance: Object, p_function: String) -> void:
set_settings_value_callback = Callable(p_instance, p_function)
func assign_get_settings_value_funcref(p_instance: Object, p_function: String) -> void:
get_settings_value_callback = Callable(p_instance, p_function)
func assign_save_settings_funcref(p_instance: Object, p_function: String) -> void:
save_settings_callback = Callable(p_instance, p_function)
func _ready():
var directory: Directory = Directory.new()
if !directory.dir_exists("user://mocap"):
if directory.make_dir_recursive("user://mocap") != OK:
printerr("Could not create mocap directory")