diff options
author | Peter Kim <pk15950@gmail.com> | 2022-02-17 10:00:19 +0300 |
---|---|---|
committer | Peter Kim <pk15950@gmail.com> | 2022-02-17 10:00:19 +0300 |
commit | 4803bc04f3fc6b0cfcda638d9aa89dee40e6bfc5 (patch) | |
tree | 5c96747f36358656b417eabfa5ef656782198bc3 /viewport_vr_preview/action_map_io.py | |
parent | e56895f5e48c6cc3be45caad8058535186bd4809 (diff) |
VR: Update action paths based on API changes
XR actions API was changed in rB6a8709ba136e.
Diffstat (limited to 'viewport_vr_preview/action_map_io.py')
-rw-r--r-- | viewport_vr_preview/action_map_io.py | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/viewport_vr_preview/action_map_io.py b/viewport_vr_preview/action_map_io.py index b6e73ce7..c4e04581 100644 --- a/viewport_vr_preview/action_map_io.py +++ b/viewport_vr_preview/action_map_io.py @@ -36,13 +36,20 @@ def repr_f32(f): return "%.*f" % (i, f_test) return f_str + def ami_args_as_data(ami): s = [ f"\"type\": '{ami.type}'", - f"\"user_path0\": '{ami.user_path0}'", - f"\"user_path1\": '{ami.user_path1}'", ] + sup = f"\"user_paths\": [" + for user_path in ami.user_paths: + sup += f"'{user_path.path}', " + if len(ami.user_paths) > 0: + sup = sup[:-2] + sup += "]" + s.append(sup) + if ami.type == 'FLOAT' or ami.type == 'VECTOR2D': s.append(f"\"op\": '{ami.op}'") s.append(f"\"op_mode\": '{ami.op_mode}'") @@ -57,14 +64,14 @@ def ami_args_as_data(ami): s.append(f"\"pose_is_controller_grip\": '{ami.pose_is_controller_grip}'") s.append(f"\"pose_is_controller_aim\": '{ami.pose_is_controller_aim}'") - return "{" + ", ".join(s) + "}" def ami_data_from_args(ami, args): ami.type = args["type"] - ami.user_path0 = args["user_path0"] - ami.user_path1 = args["user_path1"] + + for path in args["user_paths"]: + ami.user_paths.new(path) if ami.type == 'FLOAT' or ami.type == 'VECTOR2D': ami.op = args["op"] @@ -134,10 +141,16 @@ def _ami_attrs_or_none(level, ami): def amb_args_as_data(amb, type): s = [ f"\"profile\": '{amb.profile}'", - f"\"component_path0\": '{amb.component_path0}'", - f"\"component_path1\": '{amb.component_path1}'", ] + scp = f"\"component_paths\": [" + for component_path in amb.component_paths: + scp += f"'{component_path.path}', " + if len(amb.component_paths) > 0: + scp = scp[:-2] + scp += "]" + s.append(scp) + if type == 'FLOAT' or type == 'VECTOR2D': s.append(f"\"threshold\": '{amb.threshold}'") if type == 'FLOAT': @@ -154,8 +167,9 @@ def amb_args_as_data(amb, type): def amb_data_from_args(amb, args, type): amb.profile = args["profile"] - amb.component_path0 = args["component_path0"] - amb.component_path1 = args["component_path1"] + + for path in args["component_paths"]: + amb.component_paths.new(path) if type == 'FLOAT' or type == 'VECTOR2D': amb.threshold = float(args["threshold"]) |