From c51d4aa91d127fdaff2b4b4d60e0efb0cc8af9c7 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Mon, 24 May 2021 12:39:37 +0200 Subject: [PATCH] upgrade settings manager, add default overlay in settings definition --- ovr-utils/addons/settings-manager/settings.gd | 54 +------------ .../settings-manager/settings_definition.gd | 78 +++++++++++++++++++ 2 files changed, 80 insertions(+), 52 deletions(-) create mode 100644 ovr-utils/addons/settings-manager/settings_definition.gd diff --git a/ovr-utils/addons/settings-manager/settings.gd b/ovr-utils/addons/settings-manager/settings.gd index 3dd5447..0ba03e8 100644 --- a/ovr-utils/addons/settings-manager/settings.gd +++ b/ovr-utils/addons/settings-manager/settings.gd @@ -5,57 +5,7 @@ signal settings_loaded # emitted when settings are loaded from file, needs to be var DEBUG_SETTINGS = true var SETTINGS_PATH = "user://settings.json" -const SETTINGS_DEF = { - "grab_mode": { - "name": "Grab mode", - "description": "Grab and drag around any overlay", - "flags": ["no_save"], - "type": "bool", - "default": false - }, - "overlays": { - "name": "Settings for all overlays", - "type": "dict", - "flags": ["resize"], - "definition": { - "type": "dict", - "definition": { - "width": { - "name": "Width (m)", - "type": "number", - "default": 0.4 - }, - "target": { - "name": "Tracking target", - "type": "string", - "default": "world" - }, - "fallback": { - "name": "Target fallback priority order", - "type": "array", - "default": ["world"] - }, - "offsets": { - "name": "Offsets", - "flags": ["resize"], - "type": "dict", - "definition": { - "pos": { - "name": "Offset position", - "type": "vector3", - "default": Vector3() - }, - "rot": { - "name": "Offset rotation", - "type": "quat", - "default": Quat() - } - } - } - } - } - } -} +const SETTINGS_DEF = preload("res://addons/settings-manager/settings_definition.gd").DEF var s: Dictionary = {} @@ -77,7 +27,7 @@ func _init_sub_setting(def): match def.type: "dict": if has_flag(def, "resize"): - return {} + return def.default var _s = {} for key in def.definition: _s[key] = _init_sub_setting(def.definition[key]) diff --git a/ovr-utils/addons/settings-manager/settings_definition.gd b/ovr-utils/addons/settings-manager/settings_definition.gd new file mode 100644 index 0000000..fc37833 --- /dev/null +++ b/ovr-utils/addons/settings-manager/settings_definition.gd @@ -0,0 +1,78 @@ +extends Node + +const DEF = { + "grab_mode": { + "name": "Grab mode", + "description": "Grab and drag around any overlay", + "flags": ["no_save"], + "type": "bool", + "default": false + }, + "overlays": { + "name": "Settings for all overlays", + "type": "dict", + "flags": ["resize"], + "definition": { + "type": "dict", + "definition": { + "width": { + "name": "Width (m)", + "type": "number", + "default": 0.4 + }, + "target": { + "name": "Tracking target", + "type": "string", + "default": "world" + }, + "fallback": { + "name": "Target fallback priority order", + "type": "array", + "default": ["world"] + }, + "offsets": { + "name": "Offsets", + "flags": ["resize"], + "type": "dict", + "definition": { + "type": "dict", + "definition":{ + "pos": { + "name": "Offset position", + "type": "vector3", + "default": Vector3() + }, + "rot": { + "name": "Offset rotation", + "type": "quat", + "default": Quat() + } + } + }, + "default": {} + } + } + }, + "default": { + "main": { + "width": 0.4, + "target": "left", + "fallback": ["left", "right", "head"], + "offsets": { + "left": { + "pos": Vector3(), + "rot": Quat(), + }, + "right": { + "pos": Vector3(), + "rot": Quat(), + }, + "head": { + "pos": Vector3(0,0,-0.5), + "rot": Quat(), + }, + } + } + } + } +}